本文整理汇总了Java中org.codehaus.plexus.util.ReaderFactory类的典型用法代码示例。如果您正苦于以下问题:Java ReaderFactory类的具体用法?Java ReaderFactory怎么用?Java ReaderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReaderFactory类属于org.codehaus.plexus.util包,在下文中一共展示了ReaderFactory类的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 );
}
}
示例2: copyNbmResources
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
private void copyNbmResources()
throws MojoExecutionException
{
try
{
if ( StringUtils.isEmpty( encoding ) && isFilteringEnabled( nbmResources ) )
{
getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!" );
}
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( Arrays.asList( nbmResources ), clusterDir, project, encoding,
Collections.EMPTY_LIST, Collections.EMPTY_LIST, session );
mavenResourcesExecution.setEscapeWindowsPaths( true );
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException ex )
{
throw new MojoExecutionException( ex.getMessage(), ex );
}
}
示例3: readFileAsString
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
/**
* Read the given file and return the content as a string.
*
* @param file
* @return
* @throws java.io.IOException
*/
private String readFileAsString(File file) throws java.io.IOException {
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = null;
try {
reader = new BufferedReader(ReaderFactory.newReader(file, encoding));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
}
finally {
IOUtil.close(reader);
}
return fileData.toString();
}
示例4: 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;
}
示例5: 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;
}
示例6: read
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
public Model read( InputStream input, Map<String, ?> options )
throws IOException
{
if ( input == null )
{
throw new IllegalArgumentException( "input stream missing" );
}
try
{
return read( ReaderFactory.newXmlReader( input ), isStrict( options ), getSource( options ) );
}
finally
{
IOUtil.close( input );
}
}
示例7: readFileAsString
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
/**
* Read the given file and return the content as a string.
*
* @param file
* @return
* @throws java.io.IOException
*/
private String readFileAsString(File file) throws java.io.IOException {
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = null;
try {
reader = new BufferedReader(ReaderFactory.newReader(file, encoding));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
} finally {
IOUtil.close(reader);
}
return fileData.toString();
}
示例8: filter
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
protected void filter(File sourceFile, File targetFile)
throws MojoExecutionException {
try {
if (StringUtils.isEmpty(encoding)) {
getLog().warn(
"File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!");
}
targetFile.getParentFile().mkdirs();
@SuppressWarnings("rawtypes")
List filters = mavenFileFilter.getDefaultFilterWrappers(project, null, true, session, null);
mavenFileFilter.copyFile(sourceFile, targetFile, true, filters, encoding, true);
} catch (MavenFilteringException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
示例9: ProjectStub
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
/**
* Default constructor
*/
public ProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model;
try {
model = pomReader.read(ReaderFactory.newXmlReader(new File(getBasedir(), "pom.xml")));
setModel(model);
} catch (Exception e) {
throw new RuntimeException(e);
}
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
Build build = new Build();
build.setFinalName(model.getArtifactId());
build.setDirectory(getBasedir() + "/target");
build.setSourceDirectory(getBasedir() + "/src/main/java");
build.setOutputDirectory(getBasedir() + "/target/classes");
build.setTestSourceDirectory(getBasedir() + "/src/test/java");
build.setTestOutputDirectory(getBasedir() + "/target/test-classes");
setBuild(build);
List<String> compileSourceRoots = new ArrayList<String>();
compileSourceRoots.add(getBasedir() + "/src/main/java");
setCompileSourceRoots(compileSourceRoots);
List<String> testCompileSourceRoots = new ArrayList<String>();
testCompileSourceRoots.add(getBasedir() + "/src/test/java");
setTestCompileSourceRoots(testCompileSourceRoots);
}
示例10: setUp
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
File pluginPom = getTestFile("pom.xml");
Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(pluginPom));
artifactId = pluginPomDom.getChild("artifactId").getValue();
groupId = resolveFromRootThenParent(pluginPomDom, "groupId");
version = resolveFromRootThenParent(pluginPomDom, "version");
super.setUp();
}
示例11: ProjectStub
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
public ProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model;
try {
model = pomReader.read(ReaderFactory.newXmlReader(new File(getBasedir(), "pom.xml")));
setModel(model);
} catch (Exception e) {
throw new RuntimeException(e);
}
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
List<String> compileSourceRoots = new ArrayList<>();
compileSourceRoots.add(getBasedir() + "/src/main/java");
setCompileSourceRoots(compileSourceRoots);
List<String> testCompileSourceRoots = new ArrayList<>();
testCompileSourceRoots.add(getBasedir() + "/src/test/java");
setTestCompileSourceRoots(testCompileSourceRoots);
setupBuild(model);
setupDependencyArtifacts(model);
}
示例12: TypeScriptDTOGeneratorMojoProjectStub
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
/** Default constructor */
public TypeScriptDTOGeneratorMojoProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model;
try {
model = pomReader.read(ReaderFactory.newXmlReader(new File(getBasedir(), "pom.xml")));
setModel(model);
} catch (Exception e) {
throw new RuntimeException(e);
}
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
Build build = new Build();
build.setFinalName(model.getArtifactId());
build.setDirectory(getBasedir() + "/target");
build.setSourceDirectory(getBasedir() + "/src/main/java");
build.setOutputDirectory(getBasedir() + "/target/classes");
build.setTestSourceDirectory(getBasedir() + "/src/test/java");
build.setTestOutputDirectory(getBasedir() + "/target/test-classes");
setBuild(build);
List compileSourceRoots = new ArrayList();
compileSourceRoots.add(getBasedir() + "/src/main/java");
setCompileSourceRoots(compileSourceRoots);
List testCompileSourceRoots = new ArrayList();
testCompileSourceRoots.add(getBasedir() + "/src/test/java");
setTestCompileSourceRoots(testCompileSourceRoots);
}
示例13: DynaModuleListGeneratorMojoProjectStub
import org.codehaus.plexus.util.ReaderFactory; //导入依赖的package包/类
/** Default constructor */
public DynaModuleListGeneratorMojoProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model;
try {
model = pomReader.read(ReaderFactory.newXmlReader(new File(getBasedir(), "pom.xml")));
setModel(model);
} catch (Exception e) {
throw new RuntimeException(e);
}
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
setDependencies(model.getDependencies());
Build build = new Build();
build.setFinalName(model.getArtifactId());
build.setDirectory(getBasedir() + "/target");
build.setSourceDirectory(getBasedir() + "/src/main/java");
build.setOutputDirectory(getBasedir() + "/target/classes");
build.setTestSourceDirectory(getBasedir() + "/src/test/java");
build.setTestOutputDirectory(getBasedir() + "/target/test-classes");
setBuild(build);
List compileSourceRoots = new ArrayList();
compileSourceRoots.add(getBasedir() + "/src/main/java");
setCompileSourceRoots(compileSourceRoots);
List testCompileSourceRoots = new ArrayList();
testCompileSourceRoots.add(getBasedir() + "/src/test/java");
setTestCompileSourceRoots(testCompileSourceRoots);
}
示例14: 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 ) );
}
}
示例15: 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();
}
}
}