Class AbstractStringBasedModelInterpolator

  • All Implemented Interfaces:
    ModelInterpolator, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
    Direct Known Subclasses:
    RegexBasedModelInterpolator, StringSearchModelInterpolator

    public abstract class AbstractStringBasedModelInterpolator
    extends org.codehaus.plexus.logging.AbstractLogEnabled
    implements ModelInterpolator, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
    Use a regular expression search to find and resolve expressions within the POM.
    Version:
    $Id: AbstractStringBasedModelInterpolator.java 767323 2009-04-21 22:53:31Z jdcasey $
    Author:
    jdcasey Created on Feb 3, 2005
    • Constructor Detail

      • AbstractStringBasedModelInterpolator

        protected AbstractStringBasedModelInterpolator​(PathTranslator pathTranslator)
      • AbstractStringBasedModelInterpolator

        protected AbstractStringBasedModelInterpolator()
        Throws:
        java.io.IOException - This exception is not thrown any more, and needs to be removed.
    • Method Detail

      • interpolate

        public org.apache.maven.model.Model interpolate​(org.apache.maven.model.Model model,
                                                        java.util.Map<java.lang.String,​?> context,
                                                        boolean strict)
                                                 throws ModelInterpolationException
        Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve POM expressions, then re-parse into the resolved Model instance.
        NOTE: This will result in a different instance of Model being returned!!!
        Specified by:
        interpolate in interface ModelInterpolator
        Parameters:
        model - The inbound Model instance, to serialize and reference for expression resolution
        context - The other context map to be used during resolution
        Returns:
        The resolved instance of the inbound Model. This is a different instance!
        Throws:
        ModelInterpolationException
      • interpolate

        public java.lang.String interpolate​(java.lang.String src,
                                            org.apache.maven.model.Model model,
                                            java.io.File projectDir,
                                            ProjectBuilderConfiguration config,
                                            boolean debug)
                                     throws ModelInterpolationException
        Interpolates all expressions in the src parameter.

        The algorithm used for each expression is:

        • If it starts with either "pom." or "project.", the expression is evaluated against the model.
        • If the value is null, get the value from the context.
        • If the value is null, but the context contains the expression, don't replace the expression string with the value, and continue to find other expressions.
        • If the value is null, get it from the model properties.
        Specified by:
        interpolate in interface ModelInterpolator
        Parameters:
        overrideContext -
        outputDebugMessages -
        Throws:
        ModelInterpolationException
      • createValueSources

        protected java.util.List<org.codehaus.plexus.interpolation.ValueSource> createValueSources​(org.apache.maven.model.Model model,
                                                                                                   java.io.File projectDir,
                                                                                                   ProjectBuilderConfiguration config)
      • createPostProcessors

        protected java.util.List<org.codehaus.plexus.interpolation.InterpolationPostProcessor> createPostProcessors​(org.apache.maven.model.Model model,
                                                                                                                    java.io.File projectDir,
                                                                                                                    ProjectBuilderConfiguration config)
      • interpolateInternal

        protected java.lang.String interpolateInternal​(java.lang.String src,
                                                       java.util.List<org.codehaus.plexus.interpolation.ValueSource> valueSources,
                                                       java.util.List<org.codehaus.plexus.interpolation.InterpolationPostProcessor> postProcessors,
                                                       boolean debug)
                                                throws ModelInterpolationException
        Throws:
        ModelInterpolationException
      • getRecursionInterceptor

        protected org.codehaus.plexus.interpolation.RecursionInterceptor getRecursionInterceptor()
      • setRecursionInterceptor

        protected void setRecursionInterceptor​(org.codehaus.plexus.interpolation.RecursionInterceptor recursionInterceptor)
      • createInterpolator

        protected abstract org.codehaus.plexus.interpolation.Interpolator createInterpolator()
      • initialize

        public void initialize()
                        throws org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
        Specified by:
        initialize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
        Throws:
        org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
      • getInterpolator

        protected final org.codehaus.plexus.interpolation.Interpolator getInterpolator()