/** * 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 ) ) ); } }
String[] recessiveAttrs = recessive.getAttributeNames(); for ( String attr : recessiveAttrs )
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(); }
String[] recessiveAttrs = recessive.getAttributeNames(); for ( String attr : recessiveAttrs )
for (String attrName : node.getAttributeNames()) { map.put(ATTRIBUTE_PREFIX + attrName, node.getAttribute(attrName));
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 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 ) ) ); } }
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 String[] getAttributeNames() { return dom.getAttributeNames(); }
public String[] getAttributeNames() { return dom.getAttributeNames(); }
/** * Method writeDom * * @param dom * @param serializer */ public void writeDom(Xpp3Dom dom, XMLStreamWriter serializer) throws XMLStreamException { serializer.writeStartElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; serializer.writeAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( int i = 0; i < children.length; i++ ) { writeDom( children[i], serializer ); } String value = dom.getValue(); if ( value != null ) { serializer.writeCharacters( value ); } serializer.writeEndElement(); } //-- void writeDom(Xpp3Dom, XMLStreamWriter)
public List<String> getW32Icons() { Xpp3Dom domLauncher = dom.getChild("launcher"); if (domLauncher == null) { return null; } Xpp3Dom win = domLauncher.getChild("win"); if (win == null) { return null; } List<String> icons = new ArrayList<String>(); String useIco = win.getAttribute("useIco"); if (Boolean.valueOf(useIco)) { //for (Xpp3Dom ico : win.getChildren("ico")) { Xpp3Dom ico = win.getChild("ico"); //should be only 1 icons.add(ico.getAttribute("path")); } } else { for (Xpp3Dom bmp : win.getChildren("bmp")) { String[] attibuteNames = bmp.getAttributeNames(); if (attibuteNames != null && attibuteNames.length > 0) icons.add(bmp.getAttribute(bmp.getAttributeNames()[0])); } } return icons; }
/** * Method writeDom * * @param dom * @param serializer */ public void writeDom(Xpp3Dom dom, XMLStreamWriter serializer) throws XMLStreamException { serializer.writeStartElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; serializer.writeAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( int i = 0; i < children.length; i++ ) { writeDom( children[i], serializer ); } String value = dom.getValue(); if ( value != null ) { serializer.writeCharacters( value ); } serializer.writeEndElement(); } //-- void writeDom(Xpp3Dom, XMLStreamWriter)
/** * Method writeDom * * @param dom * @param serializer */ public void writeDom(Xpp3Dom dom, XMLStreamWriter serializer) throws XMLStreamException { serializer.writeStartElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( int i = 0; i < attributeNames.length; i++ ) { String attributeName = attributeNames[i]; serializer.writeAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( int i = 0; i < children.length; i++ ) { writeDom( children[i], serializer ); } String value = dom.getValue(); if ( value != null ) { serializer.writeCharacters( value ); } serializer.writeEndElement(); } //-- void writeDom(Xpp3Dom, XMLStreamWriter)
/** * Method writeXpp3DomToElement * * @param xpp3Dom * @param parentElement */ public void writeXpp3DomToElement(Xpp3Dom xpp3Dom, Element parentElement) { Element element = parentElement.addElement( xpp3Dom.getName() ); if ( xpp3Dom.getValue() != null ) { element.setText( xpp3Dom.getValue() ); } for ( Iterator i = Arrays.asList( xpp3Dom.getAttributeNames() ).iterator(); i.hasNext(); ) { String name = (String) i.next(); element.addAttribute( name, xpp3Dom.getAttribute( name ) ); } for ( Iterator i = Arrays.asList( xpp3Dom.getChildren() ).iterator(); i.hasNext(); ) { Xpp3Dom child = (Xpp3Dom) i.next(); writeXpp3DomToElement( child, element ); } } //-- void writeXpp3DomToElement(Xpp3Dom, Element)
/** * Method writeXpp3DomToElement * * @param xpp3Dom * @param parentElement */ public void writeXpp3DomToElement(Xpp3Dom xpp3Dom, Element parentElement) { Element element = parentElement.addElement( xpp3Dom.getName() ); if ( xpp3Dom.getValue() != null ) { element.setText( xpp3Dom.getValue() ); } for ( Iterator i = Arrays.asList( xpp3Dom.getAttributeNames() ).iterator(); i.hasNext(); ) { String name = (String) i.next(); element.addAttribute( name, xpp3Dom.getAttribute( name ) ); } for ( Iterator i = Arrays.asList( xpp3Dom.getChildren() ).iterator(); i.hasNext(); ) { Xpp3Dom child = (Xpp3Dom) i.next(); writeXpp3DomToElement( child, element ); } } //-- void writeXpp3DomToElement(Xpp3Dom, Element)
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 XmlPlexusConfiguration( Xpp3Dom dom ) { super( dom.getName(), dom.getValue() ); // attrs String[] attributes = dom.getAttributeNames(); for ( int i = 0; i < attributes.length; i++ ) { setAttribute( attributes[i], dom.getAttribute( attributes[i] ) ); } // children Xpp3Dom[] doms = dom.getChildren(); for ( int i = 0; i < doms.length; i++ ) { addChild( new XmlPlexusConfiguration( doms[i] ) ); } }
private void addChildren(final Xpp3Dom xpp3Dom, final ConfigurationElementBuilder builder) { builder.setText(xpp3Dom.getValue()); for (String attributeName : xpp3Dom.getAttributeNames()) { String attributeValue = xpp3Dom.getAttribute(attributeName); if (attributeValue != null) builder.addAttribute(attributeName, attributeValue); } for (Xpp3Dom child : xpp3Dom.getChildren()) { ConfigurationElementBuilder elementBuilder = builder.addChild(child.getName()); addChildren(child, elementBuilder); } }
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 ); } } } }