private Xpp3Dom newDom( String name, String value ) { Xpp3Dom dom = new Xpp3Dom( name ); dom.setValue( value ); return dom; }
/** * 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 ) ) ); } }
private Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
dominant.setValue( recessive.getValue() );
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor ) { Xpp3Dom dom = new Xpp3Dom( "configuration" ); PlexusConfiguration c = mojoDescriptor.getMojoConfiguration(); PlexusConfiguration[] ces = c.getChildren(); if ( ces != null ) { for ( PlexusConfiguration ce : ces ) { String value = ce.getValue( null ); String defaultValue = ce.getAttribute( "default-value", null ); if ( value != null || defaultValue != null ) { Xpp3Dom e = new Xpp3Dom( ce.getName() ); e.setValue( value ); if ( defaultValue != null ) { e.setAttribute( "default-value", defaultValue ); } dom.addChild( e ); } } } return dom; }
dominant.setValue( recessive.getValue() );
public static Xpp3Dom newParameter( String name, String value ) { Xpp3Dom child = new Xpp3Dom( name ); child.setValue( value ); return child; } }
private Xpp3Dom toXpp3DomTree(String name, Map<String, Object> config) { Xpp3Dom xConfig = new Xpp3Dom(name); for (Entry<String, Object> entry : config.entrySet()) { if (entry.getValue() instanceof String) { Xpp3Dom node = new Xpp3Dom(entry.getKey()); node.setValue(entry.getValue().toString()); xConfig.addChild(node); } else { @SuppressWarnings("unchecked") // Guaranteed by #configurationMap() Map<String, Object> childMap = (Map<String, Object>) entry.getValue(); // Recurse. Xpp3Dom child = toXpp3DomTree(entry.getKey(), childMap); xConfig.addChild(child); } } return xConfig; }
private Xpp3Dom toDom(Xpp3Dom parent, Map<Object, Object> map) { for (Map.Entry<Object, Object> entry : map.entrySet()) { String key = entry.getKey().toString(); Object entryValue = entry.getValue(); Xpp3Dom child = new Xpp3Dom(key); if (key.startsWith(ATTRIBUTE_PREFIX)) { toAttribute(parent, key.replace(ATTRIBUTE_PREFIX, ""), entryValue); continue; } // lists need the insertion of intermediate XML DOM nodes which hold the actual values if (entryValue instanceof List && !((List) entryValue).isEmpty()) { toDom(child, key, (List) entryValue); } else if (entryValue instanceof Map) { //noinspection unchecked child = toDom(child, (Map) entryValue); } else { // if not a list or map then copy the string value child.setValue(entryValue.toString()); } parent.addChild(child); } return parent; }
private Xpp3Dom nodeToXpp3(final Node node) { Xpp3Dom dom = new Xpp3Dom((String) node.name()); Object value = node.value(); if (value instanceof String) { dom.setValue(String.valueOf(value)); } Map attrs = node.attributes(); for (Object key : attrs.keySet()) { dom.setAttribute(String.valueOf(key), String.valueOf(attrs.get(key))); } for (Object child : node.children()) { if (child instanceof Node) { dom.addChild(nodeToXpp3((Node) child)); } } return dom; } }
sharedLibrariesDom.addChild(sharedLibraryDom); Xpp3Dom groupIdDom = new Xpp3Dom("groupId"); groupIdDom.setValue(dependency.getGroupId()); sharedLibraryDom.addChild(groupIdDom); Xpp3Dom artifactIdDom = new Xpp3Dom("artifactId"); artifactIdDom.setValue(dependency.getArtifactId()); sharedLibraryDom.addChild(artifactIdDom);
private Plugin createMuleMavenPlugin() { Plugin plugin = new Plugin(); plugin.setGroupId(MULE_MAVEN_PLUGIN_GROUP_ID); plugin.setArtifactId(MULE_MAVEN_PLUGIN_ARTIFACT_ID); plugin.setVersion(MULE_MAVEN_PLUGIN_VERSION); Xpp3Dom configuration = new Xpp3Dom("configuration"); plugin.setConfiguration(configuration); Xpp3Dom sharedLibrariesDom = new Xpp3Dom("sharedLibraries"); configuration.addChild(sharedLibrariesDom); dependencies.stream().filter(sharedLibraries::contains) .forEach(sharedLibrary -> { Xpp3Dom sharedLibraryDom = new Xpp3Dom("sharedLibrary"); sharedLibrariesDom.addChild(sharedLibraryDom); Xpp3Dom groupIdDom = new Xpp3Dom("groupId"); groupIdDom.setValue(sharedLibrary.getGroupId()); sharedLibraryDom.addChild(groupIdDom); Xpp3Dom artifactIdDom = new Xpp3Dom("artifactId"); artifactIdDom.setValue(sharedLibrary.getArtifactId()); sharedLibraryDom.addChild(artifactIdDom); }); return plugin; }
private Xpp3Dom newDom( String name, String value ) { Xpp3Dom dom = new Xpp3Dom( name ); dom.setValue( value ); return dom; }
private static void setValue( Xpp3Dom dom, String element, String value ) { Xpp3Dom child = dom.getChild( element ); if ( child == null || value == null || value.length() <= 0 ) { return; } child.setValue( value ); }
private static void setValue( Xpp3Dom dom, String element, String value ) { Xpp3Dom child = dom.getChild( element ); if ( child == null || value == null || value.length() <= 0 ) { return; } child.setValue( value ); }
private static Xpp3Dom addChild( Xpp3Dom parent, String childName, String childValue ) { Xpp3Dom child = new Xpp3Dom( childName ); child.setValue( childValue ); parent.addChild( child ); return parent; }
protected void addPlugins(MavenProject artifactMavenProject, Artifact artifact) { Plugin plugin = CAppMavenUtils.createPluginEntry(artifactMavenProject,"org.wso2.maven","maven-synapse-plugin",WSO2MavenPluginConstantants.MAVEN_SYNAPSE_PLUGIN_VERSION,true); Xpp3Dom configuration = (Xpp3Dom)plugin.getConfiguration(); //add configuration Xpp3Dom aritfact = CAppMavenUtils.createConfigurationNode(configuration,"artifact"); aritfact.setValue(artifact.getFile().getName()); }