/** * Copy constructor with alternative name. */ public Xpp3Dom( Xpp3Dom src, String name ) { this.name = name; int childCount = src.getChildCount(); childList = new ArrayList<Xpp3Dom>( childCount ); childMap = new HashMap<String, Xpp3Dom>( childCount << 1 ); setValue( src.getValue() ); String[] attributeNames = src.getAttributeNames(); for ( String attributeName : attributeNames ) { setAttribute( attributeName, src.getAttribute( attributeName ) ); } for ( int i = 0; i < childCount; i++ ) { addChild( new Xpp3Dom( src.getChild( i ) ) ); } }
if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) && StringUtils.isNotEmpty( parameter.getImplementation() ) )
String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); for ( String attr : recessiveAttrs ) if ( isEmpty( dominant.getAttribute( attr ) ) ) dominant.setAttribute( attr, recessive.getAttribute( attr ) ); String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE ); for ( Xpp3Dom recessiveChild : children ) String idValue = recessiveChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE ); if ( idValue.equals( dominantChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE ) ) )
public String getVersion() { return dom.getAttribute( "version" ); } }
String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); for ( String attr : recessiveAttrs ) if ( isEmpty( dominant.getAttribute( attr ) ) ) dominant.setAttribute( attr, recessive.getAttribute( attr ) ); String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE );
if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) && StringUtils.isNotEmpty( parameter.getImplementation() ) )
public static void write( XMLWriter xmlWriter, Xpp3Dom dom, boolean escape ) { // TODO: move to XMLWriter? xmlWriter.startElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( String attributeName : attributeNames ) { xmlWriter.addAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( Xpp3Dom aChildren : children ) { write( xmlWriter, aChildren, escape ); } String value = dom.getValue(); if ( value != null ) { if ( escape ) { xmlWriter.writeText( value ); } else { xmlWriter.writeMarkup( value ); } } xmlWriter.endElement(); }
public String getRepositoryLocation() { Xpp3Dom repositoryDom = dom.getChild( "repository" ); if ( repositoryDom == null ) { return null; } return repositoryDom.getAttribute( "location" ); }
map.put(ATTRIBUTE_PREFIX + attrName, node.getAttribute(attrName));
public Map<String, String> getMappings() { final Map<String, String> result = new LinkedHashMap<String, String>(); final Xpp3Dom mappingsDom = dom.getChild("mappings"); if (mappingsDom != null) { for (final Xpp3Dom ruleDom : mappingsDom.getChildren("rule")) { result.put(ruleDom.getAttribute("filter"), ruleDom.getAttribute("output")); } } return result; } }
public XmlPlexusConfiguration( Xpp3Dom dom ) { super( dom.getName(), dom.getValue() ); // attrs String[] attributes = dom.getAttributeNames(); for (String attribute : attributes) { setAttribute(attribute, dom.getAttribute(attribute)); } // children int childCount = dom.getChildCount(); for ( int i = 0; i < childCount; i++ ) { addChild( new XmlPlexusConfiguration( dom.getChild( i ) ) ); } }
private static void setAttribute( Xpp3Dom dom, String attribute, String value ) { String attr = dom.getAttribute( attribute ); if ( attr == null || value == null || value.length() <= 0 ) { return; } dom.setAttribute( attribute, value ); }
private void generateConfig(Xpp3Dom node, StringBuilder sb, String indent) { String tagName = node.getName(); String tagValue = node.getValue(); if (node.getParent() == null) { sb.append(indent + ".tag(\"" + tagName + "\", " + tagName + " -> {" + br); } if (tagValue != null) { sb.append(indent + " " + calculateXMLIndent(node) + tagName + ".content(\"" + tagValue + "\");" + br); } String[] attributeNames = node.getAttributeNames(); for (int i = 0; i < attributeNames.length; i++) { String attributeName = attributeNames[i]; sb.append(indent + calculateXMLIndent(node) + " " + tagName + ".attribute(\"" + attributeName + "\", \"" + node.getAttribute(attributeName) + "\");" + br); } Xpp3Dom[] children = node.getChildren(); for (int i = 0; i < children.length; i++) { Xpp3Dom child = children[i]; sb.append(indent + calculateXMLIndent(child) + child.getParent().getName() + ".child(\"" + child.getName() + "\"," + child.getName() + " -> {" + br); generateConfig(child, sb, indent); sb.append(indent + calculateXMLIndent(child) + "});" + br); } if (node.getParent() == null) { sb.append(indent + calculateXMLIndent(node) + "})" + br); } }
public String getPublic() { Xpp3Dom node = xml.getChild( "public" ); return ( node == null ? "public" : node.getAttribute( "path" ) ); }
void visit( Node node ) { for( String name: node.base.getAttributeNames() ) { new Leaf( "@" + name, node.base.getAttribute( name ) .replaceAll( "'", "\\\\'" ) ).accept( this ); } for ( Xpp3Dom child : node.base.getChildren() ) { if ( child.getChildCount() == 0 && child.getAttributeNames().length == 0 ) { new Leaf( child.getName(), child.getValue() ).accept( this ); } else if ( ( child.getChildCount() > 1 && child.getChild(0).getName().equals( child.getChild( 1 ).getName() ) ) || ( child.getChildCount() == 1 && child.getName().equals( child.getChild( 0 ).getName() + "s" ) ) ) { new ListNode( child ).accept( this ); } else { new Node( child ).accept( this ); } } } }
public boolean getWindowsUseIco() { Xpp3Dom winDom = dom.getChild("win"); if (winDom == null) { return false; } boolean useIco = Boolean.parseBoolean(winDom.getAttribute("useIco")); return useIco; }
public XmlPlexusConfiguration( final Xpp3Dom dom ) { super( dom.getName(), dom.getValue() ); for ( final String attribute : dom.getAttributeNames() ) { setAttribute( attribute, dom.getAttribute( attribute ) ); } for ( final Xpp3Dom child : dom.getChildren() ) { addChild( new XmlPlexusConfiguration( child ) ); } }
public Map<String, String> getMacosxIcon() { Xpp3Dom macosxDom = dom.getChild("macosx"); if (macosxDom == null) { return Collections.emptyMap(); } Map<String, String> mac = new HashMap<String, String>(); putIfNotNull(mac, ICON_LINUX, macosxDom.getAttribute(ICON_LINUX)); return Collections.unmodifiableMap(mac); }
public String getMacIcon(){ Xpp3Dom domLauncher = dom.getChild("launcher"); if (domLauncher == null) { return null; } Xpp3Dom linux = domLauncher.getChild("macosx"); if (linux == null) { return null; } return linux.getAttribute("icon"); } }
public String getLinuxIcon(){ Xpp3Dom domLauncher = dom.getChild("launcher"); if (domLauncher == null) { return null; } Xpp3Dom linux = domLauncher.getChild("linux"); if (linux == null) { return null; } return linux.getAttribute("icon"); }