public void startElement()

in src/main/java/org/apache/easyant/core/configuration/EasyAntConfigParser.java [158:239]


        public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {

            super.startElement(uri, localName, name, attributes);
            if ("easyant-config/ivysettings".equals(getContext())) {
                if (attributes.getValue("url") != null && !attributes.getValue("url").equals("")) {
                    easyAntConfiguration.setEasyantIvySettingsUrl(attributes.getValue("url"));
                }
                if (attributes.getValue("file") != null && !attributes.getValue("file").equals("")) {
                    easyAntConfiguration.setEasyantIvySettingsFile(attributes.getValue("file"));
                }
            }
            if ("easyant-config/system-plugins/plugin".equals(getContext())) {
                PluginDescriptor pluginDescriptor = new PluginDescriptor();
                String org = attributes.getValue("org") != null ? attributes.getValue("org") : attributes
                        .getValue("organisation");
                pluginDescriptor.setOrganisation(org);
                pluginDescriptor.setModule(attributes.getValue("module"));
                String rev = attributes.getValue("rev") != null ? attributes.getValue("rev") : attributes
                        .getValue("revision");
                pluginDescriptor.setRevision(rev);
                pluginDescriptor.setMrid(attributes.getValue("mrid"));
                pluginDescriptor.setAs(attributes.getValue("as"));
                boolean mandatory = false;
                if (attributes.getValue("mandatory") != null && "true".equals(attributes.getValue("mandatory"))) {
                    mandatory = true;
                }
                pluginDescriptor.setMandatory(mandatory);
                if (attributes.getValue("inherit-scope") != null) {
                    InheritableScope scope = InheritableScope.valueOf(attributes.getValue("inherit-scope")
                            .toUpperCase());
                    pluginDescriptor.setInheritScope(scope);
                }
                if (attributes.getValue("inheritable") != null && "true".equals(attributes.getValue("inheritable"))) {
                    pluginDescriptor.setInheritable(true);
                }
                pluginDescriptor.setMode(attributes.getValue("mode"));
                easyAntConfiguration.addSystemPlugin(pluginDescriptor);
            }
            if ("easyant-config/properties/property".equals(getContext())) {
                if (attributes.getValue("file") != null || attributes.getValue("url") != null) {
                    Properties properties = new Properties();
                    InputStream is = null;

                    try {
                        if (attributes.getValue("file") != null) {
                            File f = new File(attributes.getValue("file"));
                            is = new FileInputStream(f);
                            properties.load(is);
                        } else if (attributes.getValue("url") != null) {
                            URL url = new URL(attributes.getValue("url"));
                            is = url.openStream();
                            properties.load(is);
                        }

                        Enumeration<?> propertiesEnum = properties.propertyNames();
                        while (propertiesEnum.hasMoreElements()) {
                            String key = (String) propertiesEnum.nextElement();
                            easyAntConfiguration.getDefinedProps().put(key, properties.get(key));
                        }
                    } catch (IOException e) {
                        if (attributes.getValue("file") != null) {
                            throw new SAXException("can't read property file at : " + attributes.getValue("file"));
                        } else if (attributes.getValue("url") != null) {
                            throw new SAXException("can't read property file at : " + attributes.getValue("url"));
                        }
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                                // do nothing
                            }
                        }
                    }

                } else if (attributes.getValue("name") != null) {
                    easyAntConfiguration.getDefinedProps().put(attributes.getValue("name"),
                            attributes.getValue("value"));
                }

            }
        }