本文整理汇总了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());
}
}
示例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);
}
示例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;
}
}
示例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 );
}
}
}
}
示例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;
}
}
示例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;
}
};
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
}
示例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());
}
}
示例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 );
}
}
示例14: removeChildren
import org.codehaus.plexus.util.xml.Xpp3Dom; //导入方法依赖的package包/类
private void removeChildren(Xpp3Dom parent) {
while (parent.getChildCount() != 0)
parent.removeChild(0);
}