private void inheritPackageAttributes( Map<String, AttributeDescr> pkgAttributes, RuleDescr ruleDescr ) { if (pkgAttributes == null) { return; } for (AttributeDescr attrDescr : pkgAttributes.values()) { String name = attrDescr.getName(); AttributeDescr ruleAttrDescr = ruleDescr.getAttributes().get( name ); if (ruleAttrDescr == null) { ruleDescr.getAttributes().put( name, attrDescr ); } } }
public void addRule( final RuleDescr rule ) { if ( this.rules == Collections.EMPTY_LIST ) { this.rules = new ArrayList<RuleDescr>( 1 ); } for ( final AttributeDescr at : attributes ) { // check if rule overrides the attribute if ( !rule.getAttributes().containsKey( at.getName() ) ) { // if not, use default value rule.addAttribute( at ); } } this.rules.add( rule ); }
private String processRules(final List rules) { String ruleList = ""; for ( final Iterator iterator = rules.iterator(); iterator.hasNext(); ) { final RuleDescr ruleDescr = (RuleDescr) iterator.next(); String rule = "<rule name=\"" + ruleDescr.getName() + "\">" + XmlDumper.eol; final String attribute = processAttribute( ruleDescr.getAttributes().values() ); String lhs = ""; if ( ruleDescr.getLhs().getDescrs() != Collections.EMPTY_LIST ) { lhs = "<lhs>" + processDescrList( ruleDescr.getLhs().getDescrs() ) + "</lhs>"; } else { lhs = "<lhs> </lhs>"; } final String rhs = "<rhs>" + replaceIllegalChars( (String) ruleDescr.getConsequence() ) + "</rhs>" + XmlDumper.eol; rule += attribute; rule += lhs; rule += rhs; rule += "</rule>"; ruleList += rule; } return ruleList + XmlDumper.eol; }
final RuleDescr ruleDescr = context.getRuleDescr(); for ( final AttributeDescr attributeDescr : ruleDescr.getAttributes().values() ) { final String name = attributeDescr.getName(); if ( name.equals( "no-loop" ) ) {