Examples of Interpolator


Examples of org.codehaus.plexus.interpolation.Interpolator

                {
                    IOUtil.close( in );
                }
            }

            Interpolator interpolator = new RegexBasedInterpolator();
            interpolator.addValueSource( new MapBasedValueSource( getInterpolationValueSource() ) );
            for ( String key : (Set<String>) ( (Map) props ).keySet() )
            {
                String value = props.getProperty( key );
                try
                {
                    value = interpolator.interpolate( value, "" );
                }
                catch ( InterpolationException e )
                {
                    throw new MojoExecutionException( "Failed to interpolate invoker properties: " + propertiesFile,
                                                      e );
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

                }
            }

            String tagNameFormat = getTagNameFormat(latestProject);
            getLog().debug("Start Tag name format = " + tagNameFormat);
            Interpolator interpolator = new StringSearchInterpolator("@{", "}");
            List<String> possiblePrefixes = java.util.Arrays.asList("project", "pom");
            Properties values = new Properties();
            values.setProperty("artifactId", project.getArtifactId());
            values.setProperty("groupId", project.getGroupId());
            values.setProperty("version", latest.toString());
            interpolator.addValueSource(new PrefixedPropertiesValueSource(possiblePrefixes, values, true));
            RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor(possiblePrefixes);
            try {
                startTag = interpolator.interpolate(tagNameFormat, recursionInterceptor);
            } catch (InterpolationException e) {
                throw new MojoExecutionException("Could not interpolate specified tag name format: " + tagNameFormat,
                        e);
            }
        }
        if (!SNAPSHOT_PATTERN.matcher(project.getVersion()).find()) {
            String tagNameFormat = getTagNameFormat(project);
            getLog().debug("End Tag name format = " + tagNameFormat);
            Interpolator interpolator = new StringSearchInterpolator("@{", "}");
            List<String> possiblePrefixes = java.util.Arrays.asList("project", "pom");
            Properties values = new Properties();
            values.setProperty("artifactId", project.getArtifactId());
            values.setProperty("groupId", project.getGroupId());
            values.setProperty("version", project.getVersion());
            interpolator.addValueSource(new PrefixedPropertiesValueSource(possiblePrefixes, values, true));
            RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor(possiblePrefixes);
            try {
                endTag = interpolator.interpolate(tagNameFormat, recursionInterceptor);
            } catch (InterpolationException e) {
                throw new MojoExecutionException("Could not interpolate specified tag name format: " + tagNameFormat,
                        e);
            }
        }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

public class PlexusInterpolationTest {
  @Test
  public void testInterpolation_withoutSource() throws Exception {
    String s = "Hello ${name}";
   
    Interpolator i = new RegexBasedInterpolator();
    Assert.assertEquals("Hello ${name}", i.interpolate(s));
  }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

   
    Properties props = new Properties();
    props.put("name", "World");
    ValueSource vs = new PropertiesBasedValueSource(props);
   
    Interpolator i = new RegexBasedInterpolator();
    i.addValueSource(vs);
    Assert.assertEquals("Hello World", i.interpolate(s));
  }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

      public Object getValue(String expression) {
        return "World";
      }
    };
   
    Interpolator i = new RegexBasedInterpolator();
    i.addValueSource(vs);
    Assert.assertEquals("Hello World", i.interpolate(s));
  }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

    {
        addFilterWrapper( new FileUtils.FilterWrapper()
        {
            public Reader getReader( Reader reader )
            {
                Interpolator propertiesInterpolator = new RegexBasedInterpolator();
                propertiesInterpolator.addValueSource( valueSource );
                return new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator,
                                                               InterpolatorFilterReaderLineEnding.DEFAULT_BEGIN_TOKEN,
                                                               InterpolatorFilterReaderLineEnding.DEFAULT_END_TOKEN,
                                                               false );
            }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

    {
        addFilterWrapper( new FileUtils.FilterWrapper()
        {
            public Reader getReader( Reader reader )
            {
                Interpolator propertiesInterpolator = new RegexBasedInterpolator( startRegExp, endRegExp );
                propertiesInterpolator.addValueSource( valueSource );
                return new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, startToken, endToken,
                                                               false );
            }
        } );
    }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

        @SuppressWarnings( "unchecked" )
        final Set<String> blacklistPkgs = FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_PACKAGE_PREFIXES;

        final FieldBasedObjectInterpolator objectInterpolator =
            new FieldBasedObjectInterpolator( blacklistFields, blacklistPkgs );
        final Interpolator interpolator = buildInterpolator( project, configSource );

        // TODO: Will this adequately detect cycles between prefixed property references and prefixed project
        // references??
        final RecursionInterceptor interceptor =
            new PrefixAwareRecursionInterceptor( InterpolationConstants.PROJECT_PREFIXES, true );

        try
        {
            objectInterpolator.interpolate( assembly, interpolator, interceptor );
        }
        catch ( final InterpolationException e )
        {
            throw new AssemblyInterpolationException( "Failed to interpolate assembly with ID: " + assembly.getId()
                            + ". Reason: " + e.getMessage(), e );
        }
        finally
        {
            interpolator.clearAnswers();
        }

        if ( objectInterpolator.hasWarnings() && getLogger().isDebugEnabled() )
        {
            final StringBuilder sb = new StringBuilder();
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

                }
            }

            String tagNameFormat = getTagNameFormat(latestProject);
            getLog().debug("Start Tag name format = " + tagNameFormat);
            Interpolator interpolator = new StringSearchInterpolator("@{", "}");
            List<String> possiblePrefixes = java.util.Arrays.asList("project", "pom");
            Properties values = new Properties();
            values.setProperty("artifactId", project.getArtifactId());
            values.setProperty("groupId", project.getGroupId());
            values.setProperty("version", previousVersion);
            interpolator.addValueSource(new PrefixedPropertiesValueSource(possiblePrefixes, values, true));
            RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor(possiblePrefixes);
            try {
                startTag = interpolator.interpolate(tagNameFormat, recursionInterceptor);
            } catch (InterpolationException e) {
                throw new MojoExecutionException("Could not interpolate specified tag name format: " + tagNameFormat,
                        e);
            }
        }
        if (!SNAPSHOT_PATTERN.matcher(project.getVersion()).find()) {
            String tagNameFormat = getTagNameFormat(project);
            getLog().debug("End Tag name format = " + tagNameFormat);
            Interpolator interpolator = new StringSearchInterpolator("@{", "}");
            List<String> possiblePrefixes = java.util.Arrays.asList("project", "pom");
            Properties values = new Properties();
            values.setProperty("artifactId", project.getArtifactId());
            values.setProperty("groupId", project.getGroupId());
            values.setProperty("version", project.getVersion());
            interpolator.addValueSource(new PrefixedPropertiesValueSource(possiblePrefixes, values, true));
            RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor(possiblePrefixes);
            try {
                endTag = interpolator.interpolate(tagNameFormat, recursionInterceptor);
            } catch (InterpolationException e) {
                throw new MojoExecutionException("Could not interpolate specified tag name format: " + tagNameFormat,
                        e);
            }
        }
View Full Code Here

Examples of org.codehaus.plexus.interpolation.Interpolator

    File file = new File(value).getCanonicalFile();
    properties.put(name, file.getPath());
  }

  private void interpolate() throws Exception {
    Interpolator interpolator = new StringSearchInterpolator();
    interpolator.addValueSource(new MapBasedValueSource(properties));
    interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
    interpolator.addValueSource(new EnvarBasedValueSource());

    for (Entry<String, String> entry : properties.entrySet()) {
      properties.put(entry.getKey(), interpolator.interpolate(entry.getValue()));
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.