/** * Copy constructor. */ public Xpp3Dom( Xpp3Dom src ) { this( src, src.getName() ); }
public void addChild( Xpp3Dom xpp3Dom ) { xpp3Dom.setParent( this ); childList.add( xpp3Dom ); childMap.put( xpp3Dom.getName(), xpp3Dom ); }
public Xpp3Dom[] getChildren( String name ) { if ( null == childList ) { return EMPTY_DOM_ARRAY; } else { ArrayList<Xpp3Dom> children = new ArrayList<Xpp3Dom>(); int size = childList.size(); for ( Xpp3Dom aChildList : childList ) { Xpp3Dom configuration = (Xpp3Dom) aChildList; if ( name.equals( configuration.getName() ) ) { children.add( configuration ); } } return (Xpp3Dom[]) children.toArray( new Xpp3Dom[children.size()] ); } }
/** * @since 3.3.0 */ public ExtensionDescriptor build( InputStream is ) throws IOException { ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor(); Xpp3Dom dom; try { dom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( is ) ); } catch ( XmlPullParserException e ) { throw (IOException) new IOException( e.getMessage() ).initCause( e ); } if ( !"extension".equals( dom.getName() ) ) { throw new IOException( "Unexpected root element \"" + dom.getName() + "\", expected \"extension\"" ); } extensionDescriptor.setExportedPackages( parseStrings( dom.getChild( "exportedPackages" ) ) ); extensionDescriptor.setExportedArtifacts( parseStrings( dom.getChild( "exportedArtifacts" ) ) ); return extensionDescriptor; }
Iterator<Xpp3Dom> it = commonChildren.get( recessiveChild.getName() ); if ( it == null )
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(); }
childDom = dominant.getChild( recessiveChild.getName() );
private List<Object> toList(Xpp3Dom node, String childName) { List<Object> list = new ArrayList<>(); int n = node.getChildCount(); for (int i = 0; i < n; i++) { Xpp3Dom child = node.getChild(i); if (!childName.equals(child.getName())) { throw new YAMLException(format("child name: '%s' does not match expected name: '%s' at node %s", child.getName(), childName, node)); } Object childValue = child.getValue(); if (childValue == null) { childValue = toMap(child); } list.add(childValue); } return list; } }
void accept( ConfigVisitor visitor ) { ConfigVisitor nextVisitor = new ConfigVisitor(); nextVisitor.visit( this ); visitor.config.put( base.getName(), nextVisitor.config ); } }
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); } }
if ( "wagonProvider".equals( child.getName() ) )
for (int i = 0; i < n; i++) { Xpp3Dom child = node.getChild(i); String childName = child.getName(); if (isList) { // check for eventual list construction for (int j = 0, grandChildCount = child.getChildCount(); j < grandChildCount; j++) { String grandChildName = child.getChild(j).getName(); isList &= grandChildName.equals(singularName);
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 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 accept( ConfigVisitor visitor ) { if ( base.getChild( 0 ).getChildCount() == 0 ) { Config list = new Config(); for( Xpp3Dom child : base.getChildren() ) { list.add( child ); } visitor.config.put( base.getName(), list ); } else { Config list = new Config(); for( Xpp3Dom child : base.getChildren() ) { ConfigVisitor nextVisitor = new ConfigVisitor(); nextVisitor.visit( new Node( child ) ); list.add( nextVisitor.config.map ); } visitor.config.put( base.getName(), list ); } } }
public String getName() { if ( this.root == null ) { return null; } return this.root.getName(); }
private void readProfileProperties(TargetPlatformConfiguration result, Xpp3Dom resolverDom) { Xpp3Dom propertiesDom = resolverDom.getChild("profileProperties"); if (propertiesDom == null) { return; } Xpp3Dom[] propertyDomList = propertiesDom.getChildren(); for (Xpp3Dom propertyDom : propertyDomList) { result.addProfileProperty(propertyDom.getName(), propertyDom.getValue().trim()); } }
void accept( ConfigVisitor visitor ) { ConfigVisitor nextVisitor = new ConfigVisitor(); nextVisitor.visit( this ); visitor.config.put( base.getName(), nextVisitor.config ); } }
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 ) ); } }