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


Java XmlPullParserException类代码示例

本文整理汇总了Java中org.codehaus.plexus.util.xml.pull.XmlPullParserException的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParserException类的具体用法?Java XmlPullParserException怎么用?Java XmlPullParserException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XmlPullParserException类属于org.codehaus.plexus.util.xml.pull包,在下文中一共展示了XmlPullParserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putMapping

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
 * Store a particular action mapping.
 * @param mapp an action mapping model
 * @param project a Maven project
 * @param config a configuration of that project
 * @throws IOException in case of trouble
 * @since 2.19
 */
public static void putMapping(NetbeansActionMapping mapp, Project project, ProjectConfiguration config) throws IOException {
    M2Configuration cfg = (M2Configuration) config;
    ActionToGoalMapping mapping;
    try {
        mapping = new NetbeansBuildActionXpp3Reader().read(new StringReader(cfg.getRawMappingsAsString()));
    } catch (XmlPullParserException x) {
        throw new IOException(x);
    }
    NetbeansActionMapping existing = null;
    for (NetbeansActionMapping m : mapping.getActions()) {
        if (m.getActionName().equals(mapp.getActionName())) {
            existing = m;
            break;
        }
    }
    if (existing != null) {
        mapping.getActions().set(mapping.getActions().indexOf(existing), mapp);
    } else {
        mapping.addAction(mapp);
    }
    CustomizerProviderImpl.writeNbActionsModel(project, mapping, M2Configuration.getFileNameExt(cfg.getId()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ModelHandle2.java

示例2: findMapAction

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
private NetbeansActionMapping findMapAction(Map<String, String> replaceMap, Project project, String actionName) throws XmlPullParserException, IOException {
    // TODO need some caching really badly here..
    Reader read = performDynamicSubstitutions(replaceMap, getRawMappingsAsString());
    ActionToGoalMapping mapping = reader.read(read);
    Iterator<NetbeansActionMapping> it = mapping.getActions().iterator();
    NetbeansActionMapping action = null;
    NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
    String prjPack = mp.getPackagingType();
    while (it.hasNext()) {
        NetbeansActionMapping elem = it.next();
        if (actionName.equals(elem.getActionName()) &&
                (elem.getPackagings().contains(prjPack.trim()) ||
                elem.getPackagings().contains("*") || elem.getPackagings().isEmpty())) {//NOI18N
            action = elem;
            break;
        }
    }
    return action;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractMavenActionsProvider.java

示例3: getIntegerValue

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
 * Method getIntegerValue.
 * 
 * @param s
 * @param strict
 * @param parser
 * @param attribute
 * @throws XmlPullParserException
 * @return int
 */
public int getIntegerValue(String s, String attribute, XmlPullParser parser, boolean strict)
    throws XmlPullParserException
{
    if ( s != null )
    {
        try
        {
            return Integer.valueOf( s ).intValue();
        }
        catch ( NumberFormatException e )
        {
            if ( strict )
            {
                throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, null );
            }
        }
    }
    return 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NetbeansBuildActionXpp3Reader.java

示例4: getLongValue

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
/**
 * Method getLongValue.
 * 
 * @param s
 * @param strict
 * @param parser
 * @param attribute
 * @throws XmlPullParserException
 * @return long
 */
public long getLongValue(String s, String attribute, XmlPullParser parser, boolean strict)
    throws XmlPullParserException
{
    if ( s != null )
    {
        try
        {
            return Long.valueOf( s ).longValue();
        }
        catch ( NumberFormatException e )
        {
            if ( strict )
            {
                throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, null );
            }
        }
    }
    return 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:NetbeansBuildActionXpp3Reader.java

示例5: changeVersionTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void changeVersionTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
    assertEquals(pomModelBeforeChange.getParent().getVersion(), "1.0");

    PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("pom.xml");

    assertNull(pomChangeParent.getGroupId());
    assertNull(pomChangeParent.getArtifactId());
    assertEquals(pomChangeParent.getVersion(), "2.0");

    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
    assertNull(executionResult.getException());

    Model pomModelAfterChange = getTransformedPomModel("pom.xml");
    assertEquals(pomModelAfterChange.getParent().getVersion(), "2.0");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:20,代码来源:PomChangeParentTest.java

示例6: changeParentTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void changeParentTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("pom.xml");

    assertEquals(pomModelBeforeChange.getParent().getGroupId(), "com.test");
    assertEquals(pomModelBeforeChange.getParent().getArtifactId(), "foo-parent");
    assertEquals(pomModelBeforeChange.getParent().getVersion(), "1.0");

    PomChangeParent pomChangeParent = new PomChangeParent().setGroupId("com.newgroupid").setArtifactId("newartifactid").setVersion("2.0").relative("pom.xml");

    assertEquals(pomChangeParent.getGroupId(), "com.newgroupid");
    assertEquals(pomChangeParent.getArtifactId(), "newartifactid");
    assertEquals(pomChangeParent.getVersion(), "2.0");


    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
    assertNull(executionResult.getException());

    Model pomModelAfterChange = getTransformedPomModel("pom.xml");
    assertEquals(pomModelAfterChange.getParent().getGroupId(), "com.newgroupid");
    assertEquals(pomModelAfterChange.getParent().getArtifactId(), "newartifactid");
    assertEquals(pomModelAfterChange.getParent().getVersion(), "2.0");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:26,代码来源:PomChangeParentTest.java

示例7: failTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void failTest() throws IOException, XmlPullParserException, CloneNotSupportedException {
    Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelBeforeChange.getParent());

    PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml");

    assertNull(pomChangeParent.getGroupId());
    assertNull(pomChangeParent.getArtifactId());
    assertEquals(pomChangeParent.getVersion(), "2.0");

    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
    assertEquals(executionResult.getException().getClass(), TransformationOperationException.class);
    assertEquals(executionResult.getException().getMessage(), "Pom file /src/main/resources/no_parent_pom.xml does not have a parent");

    Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelAfterChange.getParent());

    executionResult = pomChangeParent.clone().failIfNotPresent().execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:24,代码来源:PomChangeParentTest.java

示例8: noOpTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void noOpTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelBeforeChange.getParent());

    PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml").noOpIfNotPresent();

    assertNull(pomChangeParent.getGroupId());
    assertNull(pomChangeParent.getArtifactId());
    assertEquals(pomChangeParent.getVersion(), "2.0");

    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.NO_OP);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
    assertNull(executionResult.getException());

    Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelAfterChange.getParent());
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:20,代码来源:PomChangeParentTest.java

示例9: warnTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void warnTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelBeforeChange.getParent());

    PomChangeParent pomChangeParent = new PomChangeParent("2.0").relative("/src/main/resources/no_parent_pom.xml").warnIfNotPresent();

    assertNull(pomChangeParent.getGroupId());
    assertNull(pomChangeParent.getArtifactId());
    assertEquals(pomChangeParent.getVersion(), "2.0");

    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.WARNING);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file /src/main/resources/no_parent_pom.xml");
    assertNull(executionResult.getException());
    assertEquals(executionResult.getWarnings().size(), 1);
    assertEquals(executionResult.getWarnings().get(0).getClass(), TransformationOperationException.class);
    assertEquals(executionResult.getWarnings().get(0).getMessage(), "Pom file /src/main/resources/no_parent_pom.xml does not have a parent");

    Model pomModelAfterChange = getTransformedPomModel("/src/main/resources/no_parent_pom.xml");
    assertNull(pomModelAfterChange.getParent());
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:23,代码来源:PomChangeParentTest.java

示例10: invalidOperationTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void invalidOperationTest() throws IOException, XmlPullParserException {
    // You have to either set the version only, or the group id AND artifact id AND version.
    // Here only the group id is being set
    PomChangeParent pomChangeParent = new PomChangeParent().setGroupId("com.test").relative("pom.xml");

    assertEquals(pomChangeParent.getGroupId(), "com.test");
    assertNull(pomChangeParent.getArtifactId());
    assertNull(pomChangeParent.getVersion());

    TOExecutionResult executionResult = pomChangeParent.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
    assertEquals(pomChangeParent.getDescription(), "Change parent artifact in POM file pom.xml");
    assertEquals(executionResult.getException().getClass(), TransformationOperationException.class);
    assertEquals(executionResult.getException().getMessage(), "Invalid POM parent transformation operation");

    Model pomModelAfterChange = getTransformedPomModel("pom.xml");
    assertEquals(pomModelAfterChange.getParent().getGroupId(), "com.test");
    assertEquals(pomModelAfterChange.getParent().getArtifactId(), "foo-parent");
    assertEquals(pomModelAfterChange.getParent().getVersion(), "1.0");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:22,代码来源:PomChangeParentTest.java

示例11: addPluginWithVersionTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void addPluginWithVersionTest() throws IOException, XmlPullParserException {
	Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
	assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
	assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
	assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");

       PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin", "2.10.4").relative("pom.xml");
	TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
	assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);

	Model pomModelAfterChange = getTransformedPomModel("pom.xml");
	assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
       Plugin plugin = new Plugin();
       plugin.setGroupId("org.apache.maven.plugins");
       plugin.setArtifactId("maven-javadoc-plugin");
       assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
       assertEquals(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion(), "2.10.4");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:20,代码来源:PomAddPluginTest.java

示例12: addPluginWithoutVersionTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void addPluginWithoutVersionTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");

    PomAddPlugin pomAddPlugin = new PomAddPlugin("org.apache.maven.plugins", "maven-javadoc-plugin").relative("pom.xml");
    TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.SUCCESS);

    Model pomModelAfterChange = getTransformedPomModel("pom.xml");
    assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 2);
    Plugin plugin = new Plugin();
    plugin.setGroupId("org.apache.maven.plugins");
    plugin.setArtifactId("maven-javadoc-plugin");
    assertTrue(pomModelAfterChange.getBuild().getPlugins().contains(plugin));
    assertNull(pomModelAfterChange.getBuild().getPluginsAsMap().get("org.apache.maven.plugins:maven-javadoc-plugin").getVersion());
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:20,代码来源:PomAddPluginTest.java

示例13: defaultIfPresentTest

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
@Test
public void defaultIfPresentTest() throws IOException, XmlPullParserException {
    Model pomModelBeforeChange = getOriginalPomModel("pom.xml");
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().size(), 1);
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
    assertEquals(pomModelBeforeChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");

    // Trying to add the same plugin
    PomAddPlugin pomAddPlugin = new PomAddPlugin().setArtifact("org.codehaus.mojo:cobertura-maven-plugin").relative("pom.xml");
    TOExecutionResult executionResult = pomAddPlugin.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TOExecutionResult.Type.ERROR);
    assertNull(executionResult.getDetails());
    assertEquals(executionResult.getException().getMessage(), "Plugin org.codehaus.mojo:cobertura-maven-plugin is already present in pom.xml");

    Model pomModelAfterChange = getTransformedPomModel("pom.xml");
    assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 1);
    assertEquals(pomModelAfterChange.getBuild().getPlugins().size(), 1);
    assertEquals(pomModelAfterChange.getBuild().getPlugins().get(0).getGroupId(), "org.codehaus.mojo");
    assertEquals(pomModelAfterChange.getBuild().getPlugins().get(0).getArtifactId(), "cobertura-maven-plugin");
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:21,代码来源:PomAddPluginTest.java

示例14: fromPom

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
public static CarnotzetModuleCoordinates fromPom(@NonNull Path pom) {
	Model result;
	try {
		BufferedReader in = new BufferedReader(Files.newBufferedReader(pom, StandardCharsets.UTF_8));
		MavenXpp3Reader reader = new MavenXpp3Reader();
		result = reader.read(in);
	}
	catch (XmlPullParserException | IOException e) {
		throw new CarnotzetDefinitionException(e);
	}
	String groupId = result.getGroupId();
	String version = result.getVersion();
	if (groupId == null) {
		groupId = result.getParent().getGroupId();
	}
	if (version == null) {
		version = result.getParent().getVersion();
	}
	return new CarnotzetModuleCoordinates(groupId, result.getArtifactId(), version, null);
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:21,代码来源:CarnotzetModuleCoordinates.java

示例15: getEnforcerPlugin

import org.codehaus.plexus.util.xml.pull.XmlPullParserException; //导入依赖的package包/类
public Plugin getEnforcerPlugin(MavenProject project)
        throws MavenExecutionException {
    StringBuilder configString = new StringBuilder()
            .append("<configuration><rules>")
            .append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
            .append("</rules></configuration>");
    Xpp3Dom config = null;
    try {
        config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
    } catch (XmlPullParserException | IOException ex) {
        throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
    }

    PluginExecution execution = new PluginExecution();
    execution.setId("no-snapshot-deps");
    execution.addGoal("enforce");
    execution.setConfiguration(config);

    Plugin result = new Plugin();
    result.setArtifactId("maven-enforcer-plugin");
    result.setVersion("1.4.1");
    result.addExecution(execution);

    return result;
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:26,代码来源:Plugins.java


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