当前位置: 首页>>代码示例>>Java>>正文


Java PlexusConfiguration.getChild方法代码示例

本文整理汇总了Java中org.codehaus.plexus.configuration.PlexusConfiguration.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java PlexusConfiguration.getChild方法的具体用法?Java PlexusConfiguration.getChild怎么用?Java PlexusConfiguration.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.plexus.configuration.PlexusConfiguration的用法示例。


在下文中一共展示了PlexusConfiguration.getChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
private void write(PlexusConfiguration c, XMLWriter w, int depth) throws IOException {
  int count = c.getChildCount();

  if (count == 0) {
    writeTag(c, w, depth);
  } else {
    w.startElement(c.getName());
    writeAttributes(c, w);

    for (int i = 0; i < count; i++) {
      PlexusConfiguration child = c.getChild(i);

      write(child, w, depth + 1);
    }

    w.endElement();
  }
}
 
开发者ID:orctom,项目名称:was-maven-plugin,代码行数:19,代码来源:AntXmlPlexusConfigurationWriter.java

示例2: testNestedSchemasConverted

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
@Test
public void testNestedSchemasConverted() throws Exception {
    ModelNode topSchema = json("{\"type\": \"object\", \"properties\": {\"a\": {\"type\": \"string\"}}}");
    ModelNode nestedSchema = json("{\"type\": \"boolean\"}");

    Map<String, ModelNode> extensionSchemas = new HashMap<>();
    extensionSchemas.put("top", topSchema);
    extensionSchemas.put("top.nested", nestedSchema);

    ModelNode config = json("{\"top\": {\"a\": \"kachny\", \"nested\": true}}");

    PlexusConfiguration xml = SchemaDrivenJSONToXmlConverter.convertToXml(extensionSchemas, config);
    assertEquals(2, xml.getChildCount());

    PlexusConfiguration topXml = xml.getChild("top");
    assertNotNull(topXml);
    assertEquals("top", topXml.getName());
    assertEquals(1, topXml.getChildCount());
    assertEquals("a", topXml.getChild(0).getName());
    assertEquals("kachny", topXml.getChild("a").getValue());

    PlexusConfiguration nested = xml.getChild("top.nested");
    assertNotNull(nested);
    assertEquals(0, nested.getChildCount());
    assertEquals("true", nested.getValue());
}
 
开发者ID:revapi,项目名称:revapi,代码行数:27,代码来源:SchemaDrivenJSONToXmlConverterTest.java

示例3: getString

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
@CheckForNull
private String getString(MavenProject pom, String parameter) {
  MavenProject oldProject = session.getCurrentProject();
  try {
    // Switch to the project for which we try to resolve the property.
    session.setCurrentProject(pom);
    for (MojoExecution exec : mojoExecutions) {
      Xpp3Dom configuration = exec.getConfiguration();
      PlexusConfiguration pomConfiguration = new XmlPlexusConfiguration(configuration);
      PlexusConfiguration config = pomConfiguration.getChild(parameter);

      ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, exec);
      BasicStringConverter converter = new BasicStringConverter();

      String value = converter.fromExpression(config, expressionEvaluator);
      if (value != null) {
        return value;
      }
    }
  } catch (Exception e) {
    log.warn(String.format("Failed to get parameter '%s' for goal '%s': %s", parameter, COMPILE_GOAL, e.getMessage()));
  } finally {
    session.setCurrentProject(oldProject);
  }

  return null;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:28,代码来源:JavaVersionResolver.java

示例4: mergeXmlConfigFile

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
private void mergeXmlConfigFile(AnalysisContext.Builder ctxBld, ConfigurationFile configFile, Reader rdr)
        throws IOException, XmlPullParserException {
    XmlToJson<PlexusConfiguration> conv = new XmlToJson<>(revapi, PlexusConfiguration::getName,
            PlexusConfiguration::getValue, PlexusConfiguration::getAttribute, x -> Arrays.asList(x.getChildren()));

    PlexusConfiguration xml = new XmlPlexusConfiguration(Xpp3DomBuilder.build(rdr));

    String[] roots = configFile.getRoots();

    if (roots == null) {
        ctxBld.mergeConfiguration(conv.convert(xml));
    } else {
        roots: for (String r : roots) {
            PlexusConfiguration root = xml;
            boolean first = true;
            String[] rootPath = r.split("/");
            for (String name : rootPath) {
                if (first) {
                    first = false;
                    if (!name.equals(root.getName())) {
                        continue roots;
                    }
                } else {
                    root = root.getChild(name);
                    if (root == null) {
                        continue roots;
                    }
                }
            }

            ctxBld.mergeConfiguration(conv.convert(root));
        }
    }
}
 
开发者ID:revapi,项目名称:revapi,代码行数:35,代码来源:Analyzer.java

示例5: validateParameters

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
private void validateParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
                                 ExpressionEvaluator expressionEvaluator )
    throws ComponentConfigurationException, PluginParameterException
{
    if ( mojoDescriptor.getParameters() == null )
    {
        return;
    }

    List<Parameter> invalidParameters = new ArrayList<Parameter>();

    for ( Parameter parameter : mojoDescriptor.getParameters() )
    {
        if ( !parameter.isRequired() )
        {
            continue;
        }

        Object value = null;

        PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
        if ( config != null )
        {
            String expression = config.getValue( null );

            try
            {
                value = expressionEvaluator.evaluate( expression );

                if ( value == null )
                {
                    value = config.getAttribute( "default-value", null );
                }
            }
            catch ( ExpressionEvaluationException e )
            {
                String msg =
                    "Error evaluating the expression '" + expression + "' for configuration value '"
                        + configuration.getName() + "'";
                throw new ComponentConfigurationException( configuration, msg, e );
            }
        }

        if ( value == null && ( config == null || config.getChildCount() <= 0 ) )
        {
            invalidParameters.add( parameter );
        }
    }

    if ( !invalidParameters.isEmpty() )
    {
        throw new PluginParameterException( mojoDescriptor, invalidParameters );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:55,代码来源:DefaultMavenPluginManager.java

示例6: processConfiguration

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
public void processConfiguration(final ConverterLookup converterLookup,
		final Object object, final ClassLoader classLoader,
		final PlexusConfiguration configuration,
		final ExpressionEvaluator expressionEvaluator,
		final ConfigurationListener listener)
		throws ComponentConfigurationException {
	final int items = configuration.getChildCount();

	for (int i = 0; i < items; i++) {
		final PlexusConfiguration childConfiguration = configuration
				.getChild(i);

		final String elementName = childConfiguration.getName();

		Class<?> implementation;
		try {
			implementation = getClassForImplementationHint(null,
					childConfiguration, classLoader);
		} catch (final Exception e) {
			implementation = null; // fall back to original behavior
		}

		final ComponentValueSetter valueSetter = new ComponentValueSetter(
				fromXML(elementName), implementation, object,
				converterLookup, listener);

		valueSetter.configure(childConfiguration, classLoader,
				expressionEvaluator);
	}

	Class<?> mojoClass = object.getClass();

	while (mojoClass != Object.class) {
		Field[] declaredFields = mojoClass.getDeclaredFields();
		List<PropertyEditorField> editorSupportFields = new ArrayList<PropertyEditorField>();
		for (Field declaredField : declaredFields) {
			if (declaredField.isAnnotationPresent(PropertyEditor.class)) {
				PropertyEditorField propertyEditorField = new PropertyEditorField(
						object, declaredField);
				editorSupportFields.add(propertyEditorField);
			}
		}

		handlePropertyEditorFields(object, editorSupportFields,
				expressionEvaluator);
		mojoClass = mojoClass.getSuperclass();
	}
}
 
开发者ID:link-intersystems,项目名称:maven,代码行数:49,代码来源:PropertyEditorSupportConverter.java


注:本文中的org.codehaus.plexus.configuration.PlexusConfiguration.getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。