Examples of Interpolator


Examples of org.codehaus.plexus.interpolation.Interpolator

  public static FormatTemplate template(final String format, final Server server) {
    return new FormatTemplate(format, new Object[0])
    {
      @Override
      protected String render() {
        final Interpolator interpolator = new RegexBasedInterpolator();
        final HashMap<String, Object> values = new HashMap<String, Object>();
        values.put("port", new ServerPortReader(server));
        interpolator.addValueSource(new MapBasedValueSource(values));
        try {
          return interpolator.interpolate(format);
        }
        catch (InterpolationException e) {
          Throwables.propagate(e);
          return null;
        }
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", 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

            if ( project != null && project.getProperties() != null )
            {
                filterProperties.putAll( project.getProperties() );
            }

            final Interpolator interpolator = new RegexBasedInterpolator();
            interpolator.addValueSource( new MapBasedValueSource( filterProperties ) );
            interpolator.addValueSource( new EnvarBasedValueSource() );
            interpolator.addValueSource( new ObjectBasedValueSource( project )
            {
                /** {@inheritDoc} */
                public Object getValue( final String expression )
                {
                    try
                    {
                        return ReflectionValueExtractor.evaluate( expression, project );
                    }
                    catch ( Exception e )
                    {
                        addFeedback( "Failed to extract \'" + expression + "\' from: " + project, e );
                    }

                    return null;
                }
            } );

            final DateBean bean = new DateBean();
            interpolator.addValueSource( new ObjectBasedValueSource( bean ) );

            reader = ReaderFactory.newXmlReader( docDescriptor );

            final String interpolatedDoc = interpolator.interpolate( IOUtil.toString( reader ) );

            if ( log != null && log.isDebugEnabled() )
            {
                log.debug( "Interpolated document descriptor ("
                        + docDescriptor.getAbsolutePath() + ")\n" + interpolatedDoc );
View Full Code Here

Examples of org.gephi.appearance.api.Interpolator

            public void actionPerformed(ActionEvent e) {
                RankingFunction function = (RankingFunction) model.getSelectedFunction();
                if (splineEditor == null) {
                    splineEditor = new SplineEditor(NbBundle.getMessage(AppearanceTopComponent.class, "AppearanceTopComponent.splineEditor.title"));
                }
                Interpolator interpolator = function.getRanking().getInterpolator();
                if (interpolator instanceof Interpolator.BezierInterpolator) {
                    Interpolator.BezierInterpolator bezierInterpolator = (Interpolator.BezierInterpolator) interpolator;
                    splineEditor.setControl1(bezierInterpolator.getControl1());
                    splineEditor.setControl2(bezierInterpolator.getControl2());
                } else {
View Full Code Here

Examples of org.gephi.ranking.api.Interpolator

        ranking = model.getRanking(ranking.getElementType(), ranking.getName());

        Workspace workspace = model.getWorkspace();
        GraphModel graphModel = graphController.getGraphModel(workspace);
        Graph graph = graphModel.getGraphVisible();
        Interpolator interpolator = model.getInterpolator();

        if (ranking.getElementType().equals(Ranking.NODE_ELEMENT)) {
            for (Node node : graph.getNodes()) {
                Number value = ranking.getValue(node);
                if (value != null) {
                    float normalizedValue = ranking.normalize(value);
                    if (transformer.isInBounds(normalizedValue)) {
                        normalizedValue = interpolator.interpolate(normalizedValue);
                        transformer.transform(node, normalizedValue);
                    }
                }
            }
        } else if (ranking.getElementType().equals(Ranking.EDGE_ELEMENT)) {
            for (Edge edge : graph.getEdges()) {
                Number value = ranking.getValue(edge);
                if (value != null) {
                    float normalizedValue = ranking.normalize(value);
                    if (transformer.isInBounds(normalizedValue)) {
                        normalizedValue = interpolator.interpolate(normalizedValue);
                        transformer.transform(edge, normalizedValue);
                    }
                }
            }
        }
View Full Code Here

Examples of org.jboss.seam.core.Interpolator

    }
   
    @Test
    public void testInterpolation()
    {
        Interpolator interpolator = Interpolator.instance();

        Assert.assertEquals(interpolator.interpolate("#0 #1 #2", 3, 5, 7), "3 5 7");
        Assert.assertEquals(interpolator.interpolate("{0} {1} {2}", 3, 5, 7), "3 5 7");

        // this tests that the result of an expression evaluation is not evaluated again
        Assert.assertEquals(interpolator.interpolate("{1}", "bad", "{0}"), "{0}");
       
        // this tests that embedded {} expressions are parsed correctly.
        Assert.assertEquals(interpolator.interpolate(CHOICE_EXPR, 0), "There are no files.");
        Assert.assertEquals(interpolator.interpolate(CHOICE_EXPR, 1), "There is one file.");
        Assert.assertEquals(interpolator.interpolate(CHOICE_EXPR, 2), "There are 2 files.");

        // test sequences of multiple #
        Assert.assertEquals(interpolator.interpolate("#0",2), "2");
        Assert.assertEquals(interpolator.interpolate("##0",2), "#2");
        Assert.assertEquals(interpolator.interpolate("###0",2), "##2");
       
        // test a value expression in the mix
        Contexts.getEventContext().set("contextVariable", "value");
        Assert.assertEquals(interpolator.interpolate("#{contextVariable}"), "value");
        Assert.assertEquals(interpolator.interpolate("#0 #{contextVariable} #1", "a", "z"), "a value z");
        Assert.assertEquals(interpolator.interpolate("#0 ##{contextVariable} #1", "a", "z"), "a #value z");
       
        Date date = new Date(0);
               
        Assert.assertEquals(interpolator.interpolate("{0,date,short}", date), DateFormat.getDateInstance(DateFormat.SHORT).format(date));
       
        // test that a messageformat error doesn't blow up
        Assert.assertEquals(interpolator.interpolate("{nosuchmessage}"), "{nosuchmessage}");
       
        try
        {
            interpolator.interpolate("hello #{", (Object) null);
            Assert.fail("interpolator not raised an exception");
        } catch (Throwable t)
        {
           
        }
View Full Code Here

Examples of org.jboss.seam.core.Interpolator

   
    static final String CHOICE_EXPR = "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.";
    @Test
    public void testInterpolation()
    {
        Interpolator interpolator = Interpolator.instance();

        Assert.assertEquals("3 5 7", interpolator.interpolate("#0 #1 #2", 3, 5, 7));
        Assert.assertEquals("3 5 7", interpolator.interpolate("{0} {1} {2}", 3, 5, 7));

        // this tests that the result of an expression evaluation is not evaluated again
        Assert.assertEquals("{0}", interpolator.interpolate("{1}", "bad", "{0}"));
       
        // this tests that embedded {} expressions are parsed correctly.
        Assert.assertEquals("There are no files.", interpolator.interpolate(CHOICE_EXPR, 0));
        Assert.assertEquals("There is one file.", interpolator.interpolate(CHOICE_EXPR, 1));
        Assert.assertEquals("There are 2 files.", interpolator.interpolate(CHOICE_EXPR, 2));
       
        Date date = new Date(0);
               
        Assert.assertEquals(DateFormat.getDateInstance(DateFormat.SHORT).format(date), interpolator.interpolate("{0,date,short}", date));
       
        // test that a messageformat error doesn't blow up
        Assert.assertEquals("{nosuchmessage}", interpolator.interpolate("{nosuchmessage}"));
       
        try {
            interpolator.interpolate("hello #{", (Object) null);
        } catch (Throwable t) {
            Assert.fail("interpolator raised an exception");
        }
    }
View Full Code Here

Examples of org.jboss.seam.core.Interpolator

   
    static final String CHOICE_EXPR = "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.";
    @Test
    public void testFail()
    {
        Interpolator interpolator = Interpolator.instance();

        Assert.assertEquals("3 5 7", interpolator.interpolate("#0 #1 #2", 3, 5, 7));
        Assert.assertEquals("3 5 7", interpolator.interpolate("{0} {1} {2}", 3, 5, 7));

        // this tests that the result of an expression evaluation is not evaluated again
        Assert.assertEquals("{0}", interpolator.interpolate("{1}", "bad", "{0}"));
       
        // this tests that embedded {} expressions are parsed correctly.
        Assert.assertEquals("There are no files.", interpolator.interpolate(CHOICE_EXPR, 0));
        Assert.assertEquals("There is one file.", interpolator.interpolate(CHOICE_EXPR, 1));
        Assert.assertEquals("There are 2 files.", interpolator.interpolate(CHOICE_EXPR, 2));
                  
        Assert.assertEquals("12/31/69", interpolator.interpolate("{0,date,short}", new Date(0)));
       
        // test that a messageformat error doesn't blow up
        Assert.assertEquals("{nosuchmessage}", interpolator.interpolate("{nosuchmessage}"));
    }
View Full Code Here

Examples of org.jdesktop.animation.timing.interpolation.Interpolator

        //The TimingFramework implementation doesn't respect the SMIL specification about the returned Y value
    /*Interpolator splines = new SplineInterpolator((float) control1.getX(),
        (float) control1.getY(),
        (float) control2.getX(), (float) control2.getY());*/

        Interpolator splines = new BezierInterpolator((float) control1.getX(),
                (float) control1.getY(),
                (float) control2.getX(), (float) control2.getY());

        return splines;
    }
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.