private List<String> parseStrings( Xpp3Dom dom ) { List<String> strings = null; if ( dom != null ) { strings = new ArrayList<>(); for ( Xpp3Dom child : dom.getChildren() ) { String string = child.getValue(); if ( string != null ) { string = string.trim(); if ( string.length() > 0 ) { strings.add( string ); } } } } return strings; }
Xpp3Dom[] dominantChildren = dominant.getChildren(); Xpp3Dom[] dominantChildren = dominant.getChildren( childName ); if ( dominantChildren.length > 0 )
Xpp3Dom[] children = recessive.getChildren(); for ( Xpp3Dom recessiveChild : children ) if ( isNotEmpty( idValue ) ) for ( Xpp3Dom dominantChild : dominant.getChildren() )
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(); }
private List<String> extract(String childname, Xpp3Dom config) { final Xpp3Dom subelement = config.getChild(childname); if (subelement != null) { List<String> result = new LinkedList<>(); final Xpp3Dom[] children = subelement.getChildren(); for (Xpp3Dom child : children) { result.add(child.getValue()); } return result; } return Collections.emptyList(); }
/** * Template method for exporting shared libraries and packages. By default, the pom needs to be parsed again to find which * dependencies need to be shared. */ protected void doExportSharedLibrariesResourcesAndPackages(Plugin packagingPlugin) { Object configuration = packagingPlugin.getConfiguration(); if (configuration != null) { Xpp3Dom sharedLibrariesDom = ((Xpp3Dom) configuration).getChild(SHARED_LIBRARIES_FIELD); if (sharedLibrariesDom != null) { Xpp3Dom[] sharedLibraries = sharedLibrariesDom.getChildren(SHARED_LIBRARY_FIELD); if (sharedLibraries != null) { for (Xpp3Dom sharedLibrary : sharedLibraries) { String groupId = getAttribute(sharedLibrary, GROUP_ID); String artifactId = getAttribute(sharedLibrary, ARTIFACT_ID); findAndExportSharedLibrary(groupId, artifactId); } } } } }
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); } }
Xpp3Dom additionalPluginDependenciesDom = ((Xpp3Dom) configuration).getChild(ADDITIONAL_PLUGIN_DEPENDENCIES_FIELD); if (additionalPluginDependenciesDom != null) { Xpp3Dom[] plugins = additionalPluginDependenciesDom.getChildren(PLUGIN_FIELD); if (plugins != null) { for (Xpp3Dom plugin : plugins) { Xpp3Dom dependenciesDom = plugin.getChild(PLUGIN_DEPENDENCIES_FIELD); if (dependenciesDom != null) { for (Xpp3Dom dependency : dependenciesDom.getChildren(PLUGIN_DEPENDENCY_FIELD)) { String dependencyGroupId = getAttribute(dependency, GROUP_ID); String dependencyArtifactId = getAttribute(dependency, ARTIFACT_ID);
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 ); } } }
Xpp3Dom[] pluginElements = pluginsRootElement.getChildren();
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 PlexusConfiguration[] getChildren() { Xpp3Dom[] doms = dom.getChildren(); PlexusConfiguration[] children = new XmlPlexusConfiguration[doms.length]; for ( int i = 0; i < children.length; i++ ) { children[i] = new XmlPlexusConfiguration( doms[i] ); } return children; }
public PlexusConfiguration[] getChildren() { Xpp3Dom[] doms = dom.getChildren(); PlexusConfiguration[] children = new XmlPlexusConfiguration[doms.length]; for ( int i = 0; i < children.length; i++ ) { children[i] = new XmlPlexusConfiguration( doms[i] ); } return children; }
public PlexusConfiguration[] getChildren( String name ) { Xpp3Dom[] doms = dom.getChildren( name ); PlexusConfiguration[] children = new XmlPlexusConfiguration[doms.length]; for ( int i = 0; i < children.length; i++ ) { children[i] = new XmlPlexusConfiguration( doms[i] ); } return children; }
public List<PluginRef> getPlugins() { ArrayList<PluginRef> plugins = new ArrayList<PluginRef>(); for (Xpp3Dom pluginDom : dom.getChildren("plugin")) { plugins.add(new PluginRef(pluginDom)); } return Collections.unmodifiableList(plugins); }
public List<FeatureRef> getFeatures() { ArrayList<FeatureRef> features = new ArrayList<FeatureRef>(); for (Xpp3Dom featureDom : dom.getChildren("feature")) { features.add(new FeatureRef(featureDom)); } return Collections.unmodifiableList(features); }
public List<Feature> getFeatures() { ArrayList<Feature> features = new ArrayList<>(); for (Xpp3Dom featureDom : dom.getChildren("feature")) { features.add(new Feature(featureDom)); } return Collections.unmodifiableList(features); }
@Override protected void addNotify() { setKeys(dom.getChildren()); } }
private static Xpp3Dom getOrCreateChild(Xpp3Dom node, String key) { int childIndex = getIndex(key); if (node.getChildren(removeIndexSnippet(key)).length <= childIndex) { Xpp3Dom child = new Xpp3Dom(removeIndexSnippet(key)); node.addChild(child); return child; } return node.getChildren(removeIndexSnippet(key))[childIndex]; }
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 ) ); } }