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


Java ReaderFactory.newXmlReader方法代码示例

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


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

示例1: fromXml

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
/**
 * Reads the {@link WebappStructure} from the specified file.
 *
 * @param file the file containing the webapp structure
 * @return the webapp structure
 * @throws IOException if an error occurred while reading the structure
 */
public WebappStructure fromXml( File file )
    throws IOException
{
    Reader reader = null;

    try
    {
        reader = ReaderFactory.newXmlReader( file );
        return (WebappStructure) XSTREAM.fromXML( reader );
    }
    finally
    {
        IOUtil.close( reader );
    }
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:23,代码来源:WebappStructureSerializer.java

示例2: parseExpressionDocumentation

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
/**
 * <expressions>
 *   <expression>
 *     <syntax>project.distributionManagementArtifactRepository</syntax>
 *     <origin><![CDATA[
 *   <distributionManagement>
 *     <repository>
 *       <id>some-repo</id>
 *       <url>scp://host/path</url>
 *     </repository>
 *     <snapshotRepository>
 *       <id>some-snap-repo</id>
 *       <url>scp://host/snapshot-path</url>
 *     </snapshotRepository>
 *   </distributionManagement>
 *   ]]></origin>
 *     <usage><![CDATA[
 *   The repositories onto which artifacts should be deployed.
 *   One is for releases, the other for snapshots.
 *   ]]></usage>
 *   </expression>
 * <expressions>
 * @throws IOException
 * @throws XmlPullParserException
 */
private static Map parseExpressionDocumentation( InputStream docStream )
    throws IOException, XmlPullParserException
{
    Reader reader = new BufferedReader( ReaderFactory.newXmlReader( docStream ) );

    ParamdocXpp3Reader paramdocReader = new ParamdocXpp3Reader();

    ExpressionDocumentation documentation = paramdocReader.read( reader, true );

    List expressions = documentation.getExpressions();

    Map bySyntax = new HashMap();

    if ( expressions != null && !expressions.isEmpty() )
    {
        for ( Iterator it = expressions.iterator(); it.hasNext(); )
        {
            Expression expr = (Expression) it.next();

            bySyntax.put( expr.getSyntax(), expr );
        }
    }

    return bySyntax;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:51,代码来源:ExpressionDocumenter.java

示例3: readSettingsFile

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
private static Settings readSettingsFile( File settingsFile )
    throws IOException, XmlPullParserException
{
    Settings settings = null;

    Reader reader = null;

    try
    {
        reader = ReaderFactory.newXmlReader( settingsFile );

        SettingsXpp3Reader modelReader = new SettingsXpp3Reader();

        settings = modelReader.read( reader );
    }
    finally
    {
        IOUtil.close( reader );
    }

    return settings;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:23,代码来源:PomConstructionWithSettingsTest.java

示例4: readXmlFile

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
/**
 * Reads a file into a String.
 *
 * @param outFile The file to read.
 * @return String The content of the file.
 * @throws java.io.IOException when things go wrong.
 */
public static StringBuilder readXmlFile( File outFile )
    throws IOException
{
    try( Reader reader = ReaderFactory.newXmlReader( outFile ) )
    {
        return new StringBuilder( IOUtil.toString( reader ) );
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:16,代码来源:PomHelper.java

示例5: readFileContents

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
private String readFileContents( File file )
    throws IOException
{

    BufferedReader reader = null;
    StringBuilder fileContents = new StringBuilder();

    try
    {
        reader = new BufferedReader( ReaderFactory.newXmlReader( file ) );

        String line = null;

        while ( ( line = reader.readLine() ) != null )
        {
            fileContents.append( line );
        }

        return fileContents.toString();

    }
    finally
    {
        if ( reader != null )
        {
            reader.close();
        }
    }

}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:31,代码来源:VersionXmlGeneratorTest.java

示例6: findFragment

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
/**
 * @param buildException not null
 * @return the fragment XML part where the buildException occurs.
 * @since 1.7
 */
private String findFragment(BuildException buildException) {
    if (buildException == null || buildException.getLocation() == null
            || buildException.getLocation().getFileName() == null) {
        return null;
    }

    File antFile = new File(buildException.getLocation().getFileName());
    if (!antFile.exists()) {
        return null;
    }

    LineNumberReader reader = null;
    try {
        reader = new LineNumberReader(ReaderFactory.newXmlReader(antFile));
        String line = "";
        while ((line = reader.readLine()) != null) {
            if (reader.getLineNumber() == buildException.getLocation().getLineNumber()) {
                return "around Ant part ..." + line.trim() + "... @ " + buildException.getLocation().getLineNumber() + ":"
                        + buildException.getLocation().getColumnNumber() + " in " + antFile.getAbsolutePath();
            }
        }
    } catch (Exception e) {
        getLog().debug(e.getMessage(), e);
        return null;
    } finally {
        IOUtil.close(reader);
    }

    return null;
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:36,代码来源:DebianMojo.java

示例7: readXmlFile

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
/**
 * Reads a file into a String.
 *
 * @param outFile The file to read.
 * @return String The content of the file.
 * @throws java.io.IOException when things go wrong.
 */
public static StringBuilder readXmlFile( File outFile )
    throws IOException
{
    Reader reader = ReaderFactory.newXmlReader( outFile );

    try
    {
        return new StringBuilder( IOUtil.toString( reader ) );
    }
    finally
    {
        IOUtil.close( reader );
    }
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:22,代码来源:PomHelper.java

示例8: readMojos

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
public static Collection<MojoDescriptor> readMojos(InputStream is) throws IOException, XmlPullParserException {
  Reader reader = ReaderFactory.newXmlReader(is);
  org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor;
  try {
    pluginDescriptor = new PluginDescriptorBuilder().build(reader);
  } catch (PlexusConfigurationException e) {
    Throwables.propagateIfPossible(e.getCause(), IOException.class, XmlPullParserException.class);
    throw Throwables.propagate(e);
  }
  List<MojoDescriptor> result = new ArrayList<>();
  for (org.apache.maven.plugin.descriptor.MojoDescriptor mojo : pluginDescriptor.getMojos()) {
    result.add(toMojoDescriptor(mojo));
  }
  return result;
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:16,代码来源:LegacyPluginDescriptors.java

示例9: parse

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
@Override
public final void parse(final SourceCallback callback) throws ProcessingException, IOException {
    XmlStreamReader reader = ReaderFactory.newXmlReader(coverageFile);
    XMLStreamReader xml = createEventReader(reader);
    try {
        while (xml.hasNext()) {
            xml.next();
            onEvent(xml, callback);
        }
    } catch (XMLStreamException ex) {
        throw new ProcessingException(ex);
    } finally {
        close(xml);
        IOUtil.close(reader);
    }
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:17,代码来源:AbstractXmlEventParser.java

示例10: build

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
public PersistedToolchains build( File userToolchainsFile )
    throws MisconfiguredToolchainException
{
    PersistedToolchains toolchains = null;

    if ( userToolchainsFile != null && userToolchainsFile.isFile() )
    {
        Reader in = null;
        try
        {
            in = ReaderFactory.newXmlReader( userToolchainsFile );
            toolchains = new MavenToolchainsXpp3Reader().read( in );
        }
        catch ( Exception e )
        {
            throw new MisconfiguredToolchainException( "Cannot read toolchains file at "
                + userToolchainsFile.getAbsolutePath(), e );
        }
        finally
        {
            IOUtil.close( in );
        }
    }
    else if ( userToolchainsFile != null )
    {
        logger.debug( "Toolchains configuration was not found at " + userToolchainsFile );
    }

    return toolchains;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:31,代码来源:DefaultToolchainsBuilder.java

示例11: getLifecycleMapping

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
public Lifecycle getLifecycleMapping( String lifecycleId )
    throws IOException, XmlPullParserException
{
    if ( lifecycleMappings == null )
    {
        LifecycleConfiguration lifecycleConfiguration;

        Reader reader = null;
        try
        {
            reader = ReaderFactory.newXmlReader( getDescriptorStream( LIFECYCLE_DESCRIPTOR ) );

            lifecycleConfiguration = new LifecycleMappingsXpp3Reader().read( reader );
        }
        finally
        {
            IOUtil.close( reader );
        }

        lifecycleMappings = new HashMap<String, Lifecycle>();

        for ( Lifecycle lifecycle : lifecycleConfiguration.getLifecycles() )
        {
            lifecycleMappings.put( lifecycle.getId(), lifecycle );
        }
    }

    return lifecycleMappings.get( lifecycleId );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:30,代码来源:PluginDescriptor.java

示例12: build

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
private PluginDescriptor build( String resource )
    throws IOException, PlexusConfigurationException
{
    Reader reader = ReaderFactory.newXmlReader( getClass().getResourceAsStream( resource ) );

    return new PluginDescriptorBuilder().build( reader );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:8,代码来源:PluginDescriptorBuilderTest.java

示例13: processResource

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的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

示例14: processResource

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的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

示例15: buildProfiles

import org.codehaus.plexus.util.ReaderFactory; //导入方法依赖的package包/类
public ProfilesRoot buildProfiles( File basedir )
    throws IOException, XmlPullParserException
{
    File profilesXml = new File( basedir, PROFILES_XML_FILE );

    ProfilesRoot profilesRoot = null;

    if ( profilesXml.exists() )
    {
        ProfilesXpp3Reader reader = new ProfilesXpp3Reader();
        Reader profileReader = null;
        try
        {
            profileReader = ReaderFactory.newXmlReader( profilesXml );

            StringWriter sWriter = new StringWriter();

            IOUtil.copy( profileReader, sWriter );

            String rawInput = sWriter.toString();

            try
            {
                RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
                interpolator.addValueSource( new EnvarBasedValueSource() );

                rawInput = interpolator.interpolate( rawInput, "settings" );
            }
            catch ( Exception e )
            {
                getLogger().warn( "Failed to initialize environment variable resolver. Skipping environment "
                                      + "substitution in " + PROFILES_XML_FILE + "." );
                getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.", e );
            }

            StringReader sReader = new StringReader( rawInput );

            profilesRoot = reader.read( sReader );
        }
        finally
        {
            IOUtil.close( profileReader );
        }
    }

    return profilesRoot;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:48,代码来源:DefaultMavenProfilesBuilder.java


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