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


Java WriterFactory类代码示例

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


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

示例1: toXml

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Saves the {@link WebappStructure} to the specified file.
 *
 * @param webappStructure the structure to save
 * @param targetFile the file to use to save the structure
 * @throws IOException if an error occurred while saving the webapp structure
 */
public void toXml( WebappStructure webappStructure, File targetFile )
    throws IOException
{
    // CHECKSTYLE_OFF: LineLength
    Writer writer = null;
    try
    {
        if ( !targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs() )
        {
            throw new IOException( "Could not create parent [" + targetFile.getParentFile().getAbsolutePath() + "]" );
        }

        if ( !targetFile.exists() && !targetFile.createNewFile() )
        {
            throw new IOException( "Could not create file [" + targetFile.getAbsolutePath() + "]" );
        }
        writer = WriterFactory.newXmlWriter( targetFile );
        XSTREAM.toXML( webappStructure, writer );
    }
    finally
    {
        IOUtil.close( writer );
    }
    // CHECKSTYLE_ON: LineLength
}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:33,代码来源:WebappStructureSerializer.java

示例2: generate

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Generate the JNLP file.
 *
 * @throws Exception TODO
 */
public final void generate()
        throws Exception
{
    VelocityContext context = createAndPopulateContext();

    Writer writer = WriterFactory.newWriter( config.getOutputFile(), config.getEncoding() );

    try
    {
        velocityTemplate.merge( context, writer );
        writer.flush();
    }
    catch ( Exception e )
    {
        throw new Exception(
                "Could not generate the template " + velocityTemplate.getName() + ": " + e.getMessage(), e );
    }
    finally
    {
        writer.close();
    }

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

示例3: write

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
private void write( File metadataFile, Metadata metadata )
    throws RepositoryException
{
    Writer writer = null;
    try
    {
        metadataFile.getParentFile().mkdirs();
        writer = WriterFactory.newXmlWriter( metadataFile );
        new MetadataXpp3Writer().write( writer, metadata );
    }
    catch ( IOException e )
    {
        throw new RepositoryException( "Could not write metadata " + metadataFile + ": " + e.getMessage(), e );
    }
    finally
    {
        IOUtil.close( writer );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:MavenMetadata.java

示例4: write

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
public void write( File output, Map<String, Object> options, Settings settings )
    throws IOException
{
    if ( output == null )
    {
        throw new IllegalArgumentException( "output file missing" );
    }

    if ( settings == null )
    {
        throw new IllegalArgumentException( "settings missing" );
    }

    output.getParentFile().mkdirs();

    write( WriterFactory.newXmlWriter( output ), options, settings );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultSettingsWriter.java

示例5: write

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
public void write( File output, Map<String, Object> options, Model model )
    throws IOException
{
    if ( output == null )
    {
        throw new IllegalArgumentException( "output file missing" );
    }

    if ( model == null )
    {
        throw new IllegalArgumentException( "model missing" );
    }

    output.getParentFile().mkdirs();

    write( WriterFactory.newXmlWriter( output ), options, model );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultModelWriter.java

示例6: generatePomFile

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Generates a (temporary) POM file from the plugin configuration. It's the responsibility of the caller to delete
 * the generated file when no longer needed.
 *
 * @return The path to the generated POM file, never <code>null</code>.
 * @throws MojoExecutionException If the POM file could not be generated.
 */
private File generatePomFile()
        throws MojoExecutionException
{
    Model model = generateModel();

    Writer writer = null;
    try
    {
        File pomFile = File.createTempFile( "mvninstall", ".pom" );

        writer = WriterFactory.newXmlWriter(pomFile);
        new MavenXpp3Writer().write( writer, model );

        return pomFile;
    }
    catch ( IOException e )
    {
        throw new MojoExecutionException( "Error writing temporary POM file: " + e.getMessage(), e );
    }
    finally
    {
        IOUtil.close(writer);
    }
}
 
开发者ID:agaricusb,项目名称:SpecialSourceMP,代码行数:32,代码来源:InstallRemappedFileMojo.java

示例7: getTransformedResource

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
byte[] getTransformedResource()
    throws IOException
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 * 4 );

    Writer writer = WriterFactory.newXmlWriter( baos );
    try
    {
        Xpp3Dom dom = new Xpp3Dom( "component-set" );

        Xpp3Dom componentDom = new Xpp3Dom( "components" );

        dom.addChild( componentDom );

        for ( Xpp3Dom component : components.values() )
        {
            componentDom.addChild( component );
        }

        Xpp3DomWriter.write( writer, dom );

        writer.close();
        writer = null;
    }
    finally
    {
        IOUtil.close( writer );
    }

    return baos.toByteArray();
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:32,代码来源:ComponentsXmlResourceTransformer.java

示例8: getTransformedResource

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
byte[] getTransformedResource()
    throws IOException
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 * 4 );

    Writer writer = WriterFactory.newXmlWriter( baos );
    try
    {
        Xpp3Dom dom = new Xpp3Dom( "plugin" );

        Xpp3Dom componentDom = new Xpp3Dom( "mojos" );

        dom.addChild( componentDom );

        for ( Xpp3Dom mojo : mojos )
        {
            componentDom.addChild( mojo );
        }

        Xpp3DomWriter.write( writer, dom );

        writer.close();
        writer = null;
    }
    finally
    {
        IOUtil.close( writer );
    }

    return baos.toByteArray();
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:32,代码来源:PluginXmlResourceTransformer.java

示例9: doPackaging

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
public void doPackaging(PackagingContext context) throws Exception {
	Model model = context.getProject().getOriginalModel();
	model.getDependencies().clear();

	File f = new File(context.getProject().getBasedir(), "target/pom.xml");
	Writer w = WriterFactory.newXmlWriter(f);
	PomWriter.write(w, model);
	context.getProject().setFile(f);
}
 
开发者ID:dajester2013,项目名称:lucee-maven-plugin,代码行数:10,代码来源:NoDepsPomTask.java

示例10: updateVersion

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
public UpdateResult updateVersion() {
    List<File> changedPoms = new ArrayList<File>();
    List<String> errors = new ArrayList<String>();
    for (ReleasableModule module : reactor.getModulesInBuildOrder()) {
        try {
            MavenProject project = module.getProject();
            if (module.willBeReleased()) {
                log.info("Going to release " + module.getArtifactId() + " " + module.getNewVersion());
            }

            List<String> errorsForCurrentPom = alterModel(project, module.getNewVersion());
            errors.addAll(errorsForCurrentPom);

            File pom = project.getFile().getCanonicalFile();
            changedPoms.add(pom);
            Writer fileWriter = WriterFactory.newXmlWriter(pom);

            Model originalModel = project.getOriginalModel();
            try {
                MavenXpp3Writer pomWriter = new MavenXpp3Writer();
                pomWriter.write(fileWriter, originalModel);
            } finally {
                fileWriter.close();
            }
        } catch (Exception e) {
            return new UpdateResult(changedPoms, errors, e);
        }
    }
    return new UpdateResult(changedPoms, errors, null);
}
 
开发者ID:danielflower,项目名称:multi-module-maven-release-plugin,代码行数:31,代码来源:PomUpdater.java

示例11: writeFile

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Writes a StringBuilder into a file.
 *
 * @param outFile The file to read.
 * @param input The contents of the file.
 * @throws IOException when things go wrong.
 */
protected final void writeFile( File outFile, StringBuilder input )
    throws IOException
{
    Writer writer = WriterFactory.newXmlWriter( outFile );
    try
    {
        IOUtil.copy( input.toString(), writer );
    }
    finally
    {
        IOUtil.close( writer );
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:21,代码来源:AbstractVersionsUpdaterMojo.java

示例12: getTransformedResource

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
byte[] getTransformedResource()
    throws IOException
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 * 4 );

    Writer writer = WriterFactory.newXmlWriter( baos );
    try
    {
        Xpp3Dom dom = new Xpp3Dom( "component-set" );

        Xpp3Dom componentDom = new Xpp3Dom( "components" );

        dom.addChild( componentDom );

        for ( Xpp3Dom component : components.values() )
        {
            componentDom.addChild( component );
        }

        Xpp3DomWriter.write( writer, dom );
    }
    finally
    {
        IOUtil.close( writer );
    }

    return baos.toByteArray();
}
 
开发者ID:immutables,项目名称:maven-shade-plugin,代码行数:29,代码来源:ComponentsXmlResourceTransformer.java

示例13: getTransformedResource

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
byte[] getTransformedResource()
    throws IOException
{
    ByteArrayOutputStream baos = new ByteArrayOutputStream( 1024 * 4 );

    Writer writer = WriterFactory.newXmlWriter( baos );
    try
    {
        Xpp3Dom dom = new Xpp3Dom( "plugin" );

        Xpp3Dom componentDom = new Xpp3Dom( "mojos" );

        dom.addChild( componentDom );

        for ( Xpp3Dom mojo : mojos )
        {
            componentDom.addChild( mojo );
        }

        Xpp3DomWriter.write( writer, dom );
    }
    finally
    {
        IOUtil.close( writer );
    }

    return baos.toByteArray();
}
 
开发者ID:immutables,项目名称:maven-shade-plugin,代码行数:29,代码来源:PluginXmlResourceTransformer.java

示例14: writeFile

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Writes a StringBuilder into a file.
 *
 * @param outFile The file to read.
 * @param input   The contents of the file.
 * @throws IOException when things go wrong.
 */
protected final void writeFile( File outFile, StringBuilder input )
    throws IOException
{
    Writer writer = WriterFactory.newXmlWriter( outFile );
    try
    {
        IOUtil.copy( input.toString(), writer );
    }
    finally
    {
        IOUtil.close( writer );
    }
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:21,代码来源:AbstractVersionsUpdaterMojo.java

示例15: writeStringToFile

import org.codehaus.plexus.util.WriterFactory; //导入依赖的package包/类
/**
 * Write the given string to a file.
 * 
 * @param str
 * @param file
 * @throws IOException
 */
private void writeStringToFile(String str, File file) throws IOException {
    if (!file.exists() && file.isDirectory()) {
        return;
    }

    BufferedWriter bw = null;
    try {
        bw = new BufferedWriter(WriterFactory.newWriter(file, encoding));
        bw.write(str);
    }
    finally {
        IOUtil.close(bw);
    }
}
 
开发者ID:marmotadev,项目名称:eclipse-formatter-standalone,代码行数:22,代码来源:FormatExecutor.java


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