protected void parseRule()

in src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java [1170:1241]


        protected void parseRule(String tag, Attributes attributes) throws MalformedURLException {
            String name = settings.substitute(attributes.getValue("name"));
            if (name == null) {
                name = settings.substitute(attributes.getValue("artifact"));
                if (name == null) {
                    name = "artifact".equals(tag) ? dd.getDependencyId().getName()
                            : PatternMatcher.ANY_EXPRESSION;
                }
            }
            String type = settings.substitute(attributes.getValue("type"));
            if (type == null) {
                type = "artifact".equals(tag) ? "jar" : PatternMatcher.ANY_EXPRESSION;
            }
            String ext = settings.substitute(attributes.getValue("ext"));
            if (ext == null) {
                ext = type;
            }
            switch (state) {
                case State.DEP_ARTIFACT: {
                    String url = settings.substitute(attributes.getValue("url"));
                    Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
                            attributes, Arrays.asList("name", "type", "ext", "url", "conf"));
                    confAware = new DefaultDependencyArtifactDescriptor(dd, name, type, ext,
                            url == null ? null : new URL(url), extraAtt);
                    break;
                }
                case State.ARTIFACT_INCLUDE: {
                    PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher"));
                    String org = settings.substitute(attributes.getValue("org"));
                    if (org == null) {
                        org = PatternMatcher.ANY_EXPRESSION;
                    }
                    String module = settings.substitute(attributes.getValue("module"));
                    if (module == null) {
                        module = PatternMatcher.ANY_EXPRESSION;
                    }
                    ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
                    Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
                            attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher",
                                    "conf"));
                    confAware = new DefaultIncludeRule(aid, matcher, extraAtt);
                    break;
                }
                default: { // _state == ARTIFACT_EXCLUDE || EXCLUDE
                    PatternMatcher matcher = getPatternMatcher(attributes.getValue("matcher"));
                    String org = settings.substitute(attributes.getValue("org"));
                    if (org == null) {
                        org = PatternMatcher.ANY_EXPRESSION;
                    }
                    String module = settings.substitute(attributes.getValue("module"));
                    if (module == null) {
                        module = PatternMatcher.ANY_EXPRESSION;
                    }
                    ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
                    Map<String, String> extraAtt = ExtendableItemHelper.getExtraAttributes(settings,
                            attributes, Arrays.asList("org", "module", "name", "type", "ext", "matcher",
                                    "conf"));
                    confAware = new DefaultExcludeRule(aid, matcher, extraAtt);
                    break;
                }
            }
            String confs = settings.substitute(attributes.getValue("conf"));
            // only add confs if they are specified. if they aren't, endElement will handle this
            // only if there are no conf defined in sub elements
            if (confs != null && confs.length() > 0) {
                String[] configs = "*".equals(confs) ? getMd().getConfigurationsNames()
                        : splitToArray(confs);
                for (String config : configs) {
                    addConfiguration(config);
                }
            }
        }