當前位置: 首頁>>代碼示例>>Java>>正文


Java Xpp3Dom.getChildCount方法代碼示例

本文整理匯總了Java中org.codehaus.plexus.util.xml.Xpp3Dom.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Xpp3Dom.getChildCount方法的具體用法?Java Xpp3Dom.getChildCount怎麽用?Java Xpp3Dom.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.plexus.util.xml.Xpp3Dom的用法示例。


在下文中一共展示了Xpp3Dom.getChildCount方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: patchGwtModule

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
/**
 * Patches the IDE GWT module by replacing inheritance of Full.gwt.xml by
 * Full-with-excludes.gwt.xml.
 */
private void patchGwtModule() throws XmlPullParserException, IOException {
  String gwtModuleFileRelPath = getGwtModule().replace('.', '/') + ".gwt.xml";
  Path gwtModuleFilePath = Paths.get(outputDirectory.getPath(), gwtModuleFileRelPath);

  Xpp3Dom module = Xpp3DomBuilder.build(Files.newInputStream(gwtModuleFilePath), UTF_8.name());

  for (int i = module.getChildCount() - 1; i >= 0; i--) {
    Xpp3Dom child = module.getChild(i);

    if ("inherits".equals(child.getName())) {
      String moduleName = child.getAttribute("name");

      if (moduleName.equals(fullIdeGwtModule)) {
        child.setAttribute("name", fullIdeGwtModule + FULL_IDE_GWT_MODULE_SUFFIX);
        break;
      }
    }
  }

  try (Writer writer = new StringWriter()) {
    XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
    Xpp3DomWriter.write(xmlWriter, module);
    Files.write(gwtModuleFilePath, writer.toString().getBytes());
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:30,代碼來源:ProcessExcludesMojo.java

示例2: NarTestCompileBuildParticipant

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
public NarTestCompileBuildParticipant(MojoExecution execution, boolean runOnIncremental, boolean runOnConfiguration) {
	super(new MojoExecution(execution.getMojoDescriptor(), execution.getExecutionId(), execution.getSource()), runOnIncremental, runOnConfiguration);
	// Some versions of nar-maven-plugin don't have a nar-test-unpack goal
	// this means the test artifacts won't be available to us.
	// What we need to do is run the nar-testCompile goal without any tests
	// its configuration in order to just unpack.
	Xpp3Dom configuration = new Xpp3Dom(execution.getConfiguration());
	logger.debug("Configuration before: " + configuration);
	for (int i = 0; i < configuration.getChildCount(); ++i) {
		if ("tests".equals(configuration.getChild(i).getName())) {
			configuration.removeChild(i);
			break;
		}
	}
	logger.debug("Configuration after: " + configuration);
	getMojoExecution().setConfiguration(configuration);
}
 
開發者ID:maven-nar,項目名稱:m2e-nar,代碼行數:18,代碼來源:NarTestCompileBuildParticipant.java

示例3: getArtifacts

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
protected static String[] getArtifacts(Xpp3Dom config, String artifactTag) {
    Xpp3Dom oldArtifactsXml = config == null ? null : config.getChild(artifactTag);

    if (oldArtifactsXml == null) {
        return new String[0];
    }

    if (oldArtifactsXml.getChildCount() == 0) {
        String artifact = oldArtifactsXml.getValue();
        return new String[]{artifact};
    } else {
        String[] ret = new String[oldArtifactsXml.getChildCount()];
        for (int i = 0; i < oldArtifactsXml.getChildCount(); ++i) {
            ret[i] = oldArtifactsXml.getChild(i).getValue();
        }

        return ret;
    }
}
 
開發者ID:revapi,項目名稱:revapi,代碼行數:20,代碼來源:ReportAggregateMojo.java

示例4: processChildren

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
/**
 * Recursively process the DOM elements to inline any property values from the model.
 * @param userProperties
 * @param model
 * @param parent
 */
private void processChildren( Properties userProperties, Model model, Xpp3Dom parent )
{
    for ( int i = 0; i < parent.getChildCount(); i++ )
    {
        Xpp3Dom child = parent.getChild( i );

        if ( child.getChildCount() > 0 )
        {
            processChildren( userProperties, model, child );
        }
        if ( child.getValue() != null && child.getValue().startsWith( "${" ) )
        {
            String replacement = resolveProperty( userProperties, model.getProperties(), child.getValue() );

            if ( replacement != null && !replacement.isEmpty() )
            {
                logger.debug( "Replacing child value " + child.getValue() + " with " + replacement );
                child.setValue( replacement );
            }
        }

    }
}
 
開發者ID:release-engineering,項目名稱:pom-manipulation-ext,代碼行數:30,代碼來源:ModelIO.java

示例5: getValue

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
private static Object getValue( Xpp3Dom node )
{
    if ( node.getValue() != null )
    {
        return node.getValue();
    }
    else
    {
        List<Object> children = new ArrayList<Object>();
        for ( int i = 0; i < node.getChildCount(); i++ )
        {
            children.add( getValue( node.getChild( i ) ) );
        }
        return children;
    }
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:17,代碼來源:Xpp3DomNodePointer.java

示例6: propertiesBuilder

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
static @NonNull ConfigurationBuilder<Properties> propertiesBuilder(final @NonNull String propertyParameter) {
    return new ConfigurationBuilder<Properties>() {
        @Override
        public Properties build(Xpp3Dom conf, ExpressionEvaluator eval) {
            if (conf != null) {

                Xpp3Dom source = conf.getChild(propertyParameter);
                if (source != null) {
                    Properties toRet = new Properties();
                    Xpp3Dom[] childs = source.getChildren();
                    for (Xpp3Dom ch : childs) {
                            String val = ch.getValue();
                            if (val == null) {
                                //#168036
                                //we have the "property" named element now.
                                if (ch.getChildCount() == 2) {
                                    Xpp3Dom nameDom = ch.getChild("name"); //NOI18N
                                    Xpp3Dom valueDom = ch.getChild("value"); //NOI18N
                                    if (nameDom != null && valueDom != null) {
                                        String name = nameDom.getValue();
                                        String value = valueDom.getValue();
                                        if (name != null && value != null) {
                                            toRet.put(name, value);  //NOI18N
                                        }
                                    }
                                }
                                // #153063, #187648
                                toRet.put(ch.getName(), "");
                                continue;
                            }
                            toRet.put(ch.getName(), val.trim());  //NOI18N
                    }
                    return toRet;
                }
            }
            return null;
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:PluginPropertyUtils.java

示例7: findAndReplaceXpp3DOM

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
/**
 * Method findAndReplaceXpp3DOM.
 * 
 * @param counter
 * @param dom
 * @param name
 * @param parent
 * @return Element
 */
protected Element findAndReplaceXpp3DOM(Counter counter, Element parent, String name, Xpp3Dom dom)
{
    boolean shouldExist = dom != null && (dom.getChildCount() > 0 || dom.getValue() != null);
    Element element = updateElement(counter, parent, name, shouldExist);
    if (shouldExist) {
        replaceXpp3DOM(element, dom, new Counter(counter.getDepth() + 1));
    }
    return element;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:NetbeansBuildActionJDOMWriter.java

示例8: findAndReplaceXpp3DOM

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
/**
 * Method findAndReplaceXpp3DOM
 *
 * @param counter
 * @param dom
 * @param name
 * @param parent
 */
protected Element findAndReplaceXpp3DOM( Counter counter, Element parent, String name, Xpp3Dom dom )
{
    boolean shouldExist = dom != null && ( dom.getChildCount() > 0 || dom.getValue() != null );
    Element element = updateElement( counter, parent, name, shouldExist );
    if ( shouldExist )
    {
        replaceXpp3DOM( element, dom, new Counter( counter.getDepth() + 1 ) );
    }
    return element;
}
 
開發者ID:javiersigler,項目名稱:apache-maven-shade-plugin,代碼行數:19,代碼來源:MavenJDOMWriter.java

示例9: createFullIdeModuleWithExcludes

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
/** Creates copy of the Full.gwt.xml with removed '<inherits>' for the excluded GWT modules. */
private void createFullIdeModuleWithExcludes(Set<String> modulesToExclude)
    throws XmlPullParserException, IOException {
  String fullIdeGwtModulePath = fullIdeGwtModule.replace('.', '/') + ".gwt.xml";
  String fullIdeGwtModuleContent =
      getFileContent(new ZipFile(fullIdeArtifact.getFile()), fullIdeGwtModulePath);

  InputStream in = new ByteArrayInputStream(fullIdeGwtModuleContent.getBytes(UTF_8.name()));
  Xpp3Dom module = Xpp3DomBuilder.build(in, UTF_8.name());

  for (int i = module.getChildCount() - 1; i >= 0; i--) {
    Xpp3Dom child = module.getChild(i);

    if ("inherits".equals(child.getName())) {
      String moduleName = child.getAttribute("name");

      if (modulesToExclude.contains(moduleName)) {
        module.removeChild(i);
      }
    }
  }

  String moduleRelPath =
      fullIdeGwtModulePath.replace(".gwt.xml", FULL_IDE_GWT_MODULE_SUFFIX + ".gwt.xml");

  Path modulePath = Paths.get(outputDirectory.getPath(), moduleRelPath);

  try (Writer writer = new StringWriter()) {
    XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
    Xpp3DomWriter.write(xmlWriter, module);
    Files.write(modulePath, writer.toString().getBytes());
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:34,代碼來源:ProcessExcludesMojo.java

示例10: removeXpp3Node

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
public static boolean removeXpp3Node(Xpp3Dom parent,Xpp3Dom child) {
	int removeIndex=-1;
	for(int i=0;i<parent.getChildCount();i++){
		if (parent.getChild(i)==child){
			removeIndex=i;
			break;
		}
	}
	if (removeIndex==-1){
		return false;
	}else{
		parent.removeChild(removeIndex);
		return true;
	}
}
 
開發者ID:wso2,項目名稱:developer-studio,代碼行數:16,代碼來源:MavenUtils.java

示例11: extractConfig

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
private void extractConfig(final Map<String, Object> content,
                           final Xpp3Dom xmlData) {
    if (xmlData.getChildCount() > 0) {
        final Map<String, Object> config = new HashMap<>(xmlData.getChildCount());
        for (final Xpp3Dom child : xmlData.getChildren()) {
            extractConfig(config,
                          child);
        }
        content.put(xmlData.getName(),
                    config);
    } else {
        content.put(xmlData.getName(),
                    xmlData.getValue());
    }
}
 
開發者ID:kiegroup,項目名稱:kie-wb-common,代碼行數:16,代碼來源:MavenProjectConfigExecutor.java

示例12: processResource

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
public void processResource( String resource, InputStream is, List<Relocator> relocators )
    throws IOException
{
    Xpp3Dom newDom;

    try
    {
        BufferedInputStream bis = new BufferedInputStream( is )
        {
            public void close()
                throws IOException
            {
                // leave ZIP open
            }
        };

        Reader reader = ReaderFactory.newXmlReader( bis );

        newDom = Xpp3DomBuilder.build( reader );
    }
    catch ( Exception e )
    {
        throw (IOException) new IOException( "Error parsing components.xml in " + is ).initCause( e );
    }

    // Only try to merge in components if there are some elements in the component-set
    if ( newDom.getChild( "components" ) == null )
    {
        return;
    }

    Xpp3Dom[] children = newDom.getChild( "components" ).getChildren( "component" );

    for ( Xpp3Dom component : children )
    {
        String role = getValue( component, "role" );
        role = getRelocatedClass( role, relocators );
        setValue( component, "role", role );

        String roleHint = getValue( component, "role-hint" );

        String impl = getValue( component, "implementation" );
        impl = getRelocatedClass( impl, relocators );
        setValue( component, "implementation", impl );

        String key = role + ':' + roleHint;
        if ( components.containsKey( key ) )
        {
            // TODO: use the tools in Plexus to merge these properly. For now, I just need an all-or-nothing
            // configuration carry over

            Xpp3Dom dom = components.get( key );
            if ( dom.getChild( "configuration" ) != null )
            {
                component.addChild( dom.getChild( "configuration" ) );
            }
        }

        Xpp3Dom requirements = component.getChild( "requirements" );
        if ( requirements != null && requirements.getChildCount() > 0 )
        {
            for ( int r = requirements.getChildCount() - 1; r >= 0; r-- )
            {
                Xpp3Dom requirement = requirements.getChild( r );

                String requiredRole = getValue( requirement, "role" );
                requiredRole = getRelocatedClass( requiredRole, relocators );
                setValue( requirement, "role", requiredRole );
            }
        }

        components.put( key, component );
    }
}
 
開發者ID:javiersigler,項目名稱:apache-maven-shade-plugin,代碼行數:75,代碼來源:ComponentsXmlResourceTransformer.java

示例13: processResource

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
public void processResource( String resource, InputStream is, List<Relocator> relocators )
    throws IOException
{
    Xpp3Dom newDom;

    try
    {
        BufferedInputStream bis = new BufferedInputStream( is )
        {
            public void close()
                throws IOException
            {
                // leave ZIP open
            }
        };

        Reader reader = ReaderFactory.newXmlReader( bis );

        newDom = Xpp3DomBuilder.build( reader );
    }
    catch ( Exception e )
    {
        throw (IOException) new IOException( "Error parsing plugin.xml in " + is ).initCause( e );
    }

    // Only try to merge in mojos if there are some elements in the plugin
    if ( newDom.getChild( "mojos" ) == null )
    {
        return;
    }

    for ( Xpp3Dom mojo : newDom.getChild( "mojos" ).getChildren( "mojo" ) )
    {

        String impl = getValue( mojo, "implementation" );
        impl = getRelocatedClass( impl, relocators );
        setValue( mojo, "implementation", impl );

        Xpp3Dom parameters = mojo.getChild( "parameters" );
        if ( parameters != null )
        {
            for ( Xpp3Dom parameter : parameters.getChildren() )
            {
                String type = getValue( parameter, "type" );
                type = getRelocatedClass( type, relocators );
                setValue( parameter, "type", type );
            }
        }

        Xpp3Dom configuration = mojo.getChild( "configuration" );
        if ( configuration != null )
        {
            for ( Xpp3Dom configurationEntry : configuration.getChildren() )
            {
                String implementation = getAttribute( configurationEntry, "implementation" );
                implementation = getRelocatedClass( implementation, relocators );
                setAttribute( configurationEntry, "implementation", implementation );
            }
        }

        Xpp3Dom requirements = mojo.getChild( "requirements" );
        if ( requirements != null && requirements.getChildCount() > 0 )
        {
            for ( Xpp3Dom requirement : requirements.getChildren() )
            {
                String requiredRole = getValue( requirement, "role" );
                requiredRole = getRelocatedClass( requiredRole, relocators );
                setValue( requirement, "role", requiredRole );
            }
        }
        mojos.add( mojo );
    }
}
 
開發者ID:javiersigler,項目名稱:apache-maven-shade-plugin,代碼行數:74,代碼來源:PluginXmlResourceTransformer.java

示例14: removeChildren

import org.codehaus.plexus.util.xml.Xpp3Dom; //導入方法依賴的package包/類
private void removeChildren(Xpp3Dom parent) {
	while (parent.getChildCount() != 0)
		parent.removeChild(0);
}
 
開發者ID:alessandroleite,項目名稱:maven-jdev-plugin,代碼行數:5,代碼來源:JDeveloperMojo.java


注:本文中的org.codehaus.plexus.util.xml.Xpp3Dom.getChildCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。