int ch = read(); if ( ch == -1 )
protected Reader getInterpolationConfigurationReader( Reader reader ) { return new InterpolationFilterReader( reader, new ContextMapAdapter( containerContext ) ); }
public static void interpolationFileCopy(File from, File dest, Map<String, String> variables) throws IOException { // we may also need to create any parent directories if (dest.getParentFile() != null && !dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); } FileReader fileReader = new FileReader(from); InterpolationFilterReader filterReader = new InterpolationFilterReader(fileReader, ImmutableMap.<String, Object>copyOf(variables)); FileWriter fos = new FileWriter(dest); int readChar = -1; while ((readChar = filterReader.read()) != -1) { fos.write(readChar); } // close everything fileReader.close(); fos.close(); }
/** * Replaces all properties having the style * <code>${some.property}</code> with the value * of the specified property if there is one. * * @param properties the properties used to perform the replacement. * @param string the fileContents to perform replacement on. */ private String replaceProperties(final Properties properties, final String string) throws IOException { final StringReader stringReader = new StringReader(string); InterpolationFilterReader reader = new InterpolationFilterReader(stringReader, properties, "${", "}"); reader.reset(); reader = new InterpolationFilterReader( reader, new BeanProperties(this.project), BEGIN_TOKEN, END_TOKEN); reader = new InterpolationFilterReader( reader, new BeanProperties(this.project), BEGIN_TOKEN, END_TOKEN); return ResourceUtils.getContents(reader); }
InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, new ContextMapAdapter( context ) );
public static void interpolationFileCopy( File from, File dest, Map<String, String> variables ) throws IOException { // we may also need to create any parent directories if ( dest.getParentFile() != null && !dest.getParentFile().exists() ) { dest.getParentFile().mkdirs(); } FileReader fileReader = new FileReader( from ); InterpolationFilterReader filterReader = new InterpolationFilterReader( fileReader, variables ); FileWriter fos = new FileWriter( dest ); int readChar = -1; while ( ( readChar = (int) filterReader.read() ) != -1 ) { fos.write( readChar ); } // close everything fileReader.close(); fos.close(); }
/** * Replaces all properties having the style * <code>${some.property}</code> with the value * of the specified property if there is one. * * @param properties the properties used to perform the replacement. * @param string the fileContents to perform replacement on. */ private String replaceProperties( final Properties properties, final String string) throws IOException { final StringReader stringReader = new StringReader(string); InterpolationFilterReader reader = new InterpolationFilterReader(stringReader, properties, "${", "}"); reader.reset(); reader = new InterpolationFilterReader( reader, new BeanProperties(this.getProject()), BEGIN_TOKEN, END_TOKEN); reader = new InterpolationFilterReader( reader, new BeanProperties(this.getSettings()), BEGIN_TOKEN, END_TOKEN); return ResourceUtils.getContents(reader); }
protected void setUp() throws Exception { assertTrue( "Maven 3.2.4 or better is required", MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 ); configurator = getContainer().lookup( ComponentConfigurator.class, "basic" ); InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() ); XmlStreamReader reader = new XmlStreamReader( is ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() ); PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader ); Artifact artifact = lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(), pluginDescriptor.getVersion(), ".jar" ); artifact.setFile( getPluginArtifactFile() ); pluginDescriptor.setPluginArtifact( artifact ); pluginDescriptor.setArtifacts( Arrays.asList( artifact ) ); for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() ) { getContainer().addComponentDescriptor( desc ); } mojoDescriptors = new HashMap<String, MojoDescriptor>(); for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() ) { mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor ); } }
final InterpolationFilterReader reader = new InterpolationFilterReader( new StringReader(value), (Map<String, Object>) (Map) dict); final StringWriter writer = new StringWriter(value.length()); final int ch; try { ch = reader.read(); } catch (IOException e) {
/** * Skips characters. This method will block until some characters are available, an I/O error occurs, or the end of * the stream is reached. * * @param n The number of characters to skip * @return the number of characters actually skipped * @exception IllegalArgumentException If <code>n</code> is negative. * @exception IOException If an I/O error occurs */ public long skip( long n ) throws IOException { if ( n < 0L ) { throw new IllegalArgumentException( "skip value is negative" ); } for ( long i = 0; i < n; i++ ) { if ( read() == -1 ) { return i; } } return n; }
public Reader getReader(Reader fileReader, Map filterProperties) { return new InterpolationFilterReader( fileReader, filterProperties, "${", "}" ); } },
final InterpolationFilterReader reader = new InterpolationFilterReader( new StringReader(value), (Map<String, Object>) (Map) dict); final StringWriter writer = new StringWriter(value.length()); final int ch; try { ch = reader.read(); } catch (IOException e) {
replaceIndex = 0; return read();
public Reader getReader(Reader fileReader, Map filterProperties) { return new InterpolationFilterReader( fileReader, filterProperties, "@", "@" ); } }
int ch = read(); if ( ch == -1 )
public Reader getReader(Reader fileReader, Properties filterProperties) { return new InterpolationFilterReader(fileReader, filterProperties, "${", "}"); } },
/** * Skips characters. This method will block until some characters are * available, an I/O error occurs, or the end of the stream is reached. * * @param n The number of characters to skip * * @return the number of characters actually skipped * * @exception IllegalArgumentException If <code>n</code> is negative. * @exception IOException If an I/O error occurs */ public long skip( long n ) throws IOException { if ( n < 0L ) { throw new IllegalArgumentException( "skip value is negative" ); } for ( long i = 0; i < n; i++ ) { if ( read() == -1 ) { return i; } } return n; }
public Reader getReader(Reader fileReader, Properties filterProperties) { return new InterpolationFilterReader(fileReader, filterProperties, "@", "@"); } }};
replaceIndex = 0; return read();
private static void writeFilteredFile( DaemonGenerationRequest request, Daemon daemon, Reader reader, File outputFile, Map context ) throws DaemonGeneratorException { InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, context, "@", "@" ); writeFile( outputFile, interpolationFilterReader ); }