Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus</artifactId>
<version>11</version>
<version>14</version>
</parent>

<artifactId>plexus-interpolation</artifactId>
Expand All @@ -16,8 +17,8 @@
<scm>
<connection>scm:git:https://github.com/codehaus-plexus/plexus-interpolation.git</connection>
<developerConnection>scm:git:https://github.com/codehaus-plexus/plexus-interpolation.git</developerConnection>
<url>http://github.com/codehaus-plexus/plexus-interpolation/tree/${project.scm.tag}/</url>
<tag>master</tag>
<url>http://github.com/codehaus-plexus/plexus-interpolation/tree/${project.scm.tag}/</url>
</scm>

<issueManagement>
Expand Down Expand Up @@ -60,15 +61,17 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<configuration>
<content>${project.reporting.outputDirectory}</content><!-- mono-module doesn't require site:stage -->
<content>${project.reporting.outputDirectory}</content>
<!-- mono-module doesn't require site:stage -->
</configuration>
<executions>
<execution>
<id>scm-publish</id>
<phase>site-deploy</phase><!-- deploy site with maven-scm-publish-plugin -->
<!-- deploy site with maven-scm-publish-plugin -->
<goals>
<goal>publish-scm</goal>
</goals>
<phase>site-deploy</phase>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,31 @@

import java.util.List;

public abstract class AbstractDelegatingValueSource
implements ValueSource
{

public abstract class AbstractDelegatingValueSource implements ValueSource {

private final ValueSource delegate;

protected AbstractDelegatingValueSource( ValueSource delegate )
{
if ( delegate == null )
{
throw new NullPointerException( "Delegate ValueSource cannot be null." );
protected AbstractDelegatingValueSource(ValueSource delegate) {
if (delegate == null) {
throw new NullPointerException("Delegate ValueSource cannot be null.");
}

this.delegate = delegate;
}

protected ValueSource getDelegate()
{

protected ValueSource getDelegate() {
return delegate;
}

public Object getValue( String expression )
{
return getDelegate().getValue( expression );
public Object getValue(String expression) {
return getDelegate().getValue(expression);
}

public void clearFeedback()
{

public void clearFeedback() {
delegate.clearFeedback();
}

public List getFeedback()
{
public List getFeedback() {
return delegate.getFeedback();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
* value of the second expression, which is resolved from the wrapped value
* source.</p>
*/
public abstract class AbstractFunctionValueSourceWrapper
implements ValueSource
{
public abstract class AbstractFunctionValueSourceWrapper implements ValueSource {

private final ValueSource valueSource;

Expand All @@ -40,8 +38,7 @@ public abstract class AbstractFunctionValueSourceWrapper
*
* @param valueSource The value source to wrap
*/
protected AbstractFunctionValueSourceWrapper( ValueSource valueSource )
{
protected AbstractFunctionValueSourceWrapper(ValueSource valueSource) {
this.valueSource = valueSource;
}

Expand All @@ -56,26 +53,23 @@ protected AbstractFunctionValueSourceWrapper( ValueSource valueSource )
* for the current expression.</li>
* </ol>
*/
public Object getValue( String expression )
{
Object value = valueSource.getValue( expression );
public Object getValue(String expression) {
Object value = valueSource.getValue(expression);

String expr = expression;

if ( valueSource instanceof QueryEnabledValueSource )
{
if (valueSource instanceof QueryEnabledValueSource) {
expr = ((QueryEnabledValueSource) valueSource).getLastExpression();
}

return executeFunction( expr, value );
return executeFunction(expr, value);
}

/**
* Retrieve the embedded value source.
* @return {@link ValueSource}
*/
protected ValueSource getValueSource()
{
protected ValueSource getValueSource() {
return valueSource;
}

Expand All @@ -87,6 +81,5 @@ protected ValueSource getValueSource()
* @param value The value for the current expression, resolved by the embedded {@link ValueSource}
* @return The result of modifying the current expression's value using the function named by the last expression.
*/
protected abstract Object executeFunction( String expression, Object value );

protected abstract Object executeFunction(String expression, Object value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,34 @@
import java.util.ArrayList;
import java.util.List;

public abstract class AbstractValueSource
implements ValueSource
{

public abstract class AbstractValueSource implements ValueSource {

private final List feedback;

protected AbstractValueSource( boolean usesFeedback )
{
if ( usesFeedback )
{

protected AbstractValueSource(boolean usesFeedback) {
if (usesFeedback) {
feedback = new ArrayList();
}
else
{
} else {
feedback = null;
}
}

public void clearFeedback()
{
if ( feedback != null )
{
public void clearFeedback() {
if (feedback != null) {
feedback.clear();
}
}

public List getFeedback()
{
public List getFeedback() {
return feedback;
}

protected void addFeedback( String message )
{
feedback.add( message );
protected void addFeedback(String message) {
feedback.add(message);
}

protected void addFeedback( String message, Throwable cause )
{
feedback.add( message );
feedback.add( cause );

protected void addFeedback(String message, Throwable cause) {
feedback.add(message);
feedback.add(cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
*
* TODO: Really really needs a way to communicate errors.
*/
public interface BasicInterpolator
{
public interface BasicInterpolator {
/**
* See {@link org.codehaus.plexus.interpolation.Interpolator#interpolate(String, String, org.codehaus.plexus.interpolation.RecursionInterceptor)}.
* <p>
Expand All @@ -34,8 +33,7 @@ public interface BasicInterpolator
* @return the interpolated string.
* @throws InterpolationException in case of an error.
*/
String interpolate( String input )
throws InterpolationException;
String interpolate(String input) throws InterpolationException;

/**
* See {@link org.codehaus.plexus.interpolation.Interpolator#interpolate(String, String, org.codehaus.plexus.interpolation.RecursionInterceptor)}.
Expand All @@ -52,6 +50,5 @@ String interpolate( String input )
* @return the interpolated string.
* @throws InterpolationException in case of an error.
*/
String interpolate( String input, RecursionInterceptor recursionInterceptor )
throws InterpolationException;
String interpolate(String input, RecursionInterceptor recursionInterceptor) throws InterpolationException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,18 @@
* limitations under the License.
*/

import org.codehaus.plexus.interpolation.os.OperatingSystemUtils;

import java.io.IOException;
import java.util.Properties;

import org.codehaus.plexus.interpolation.os.OperatingSystemUtils;

/**
* {@link ValueSource} which resolves expressions against the environment variables
* available from the underlying operating system (and possibly, the shell environment
* that created the present Java process). If the expression starts with 'env.',
* this prefix is trimmed before resolving the rest as an environment variable name.
*/
public class EnvarBasedValueSource
extends AbstractValueSource
{
public class EnvarBasedValueSource extends AbstractValueSource {

private static Properties envarsCaseSensitive;
private static Properties envarsCaseInsensitive;
Expand All @@ -43,9 +41,8 @@ public class EnvarBasedValueSource
*
* @throws IOException in case of an error.
*/
public EnvarBasedValueSource() throws IOException
{
this( true );
public EnvarBasedValueSource() throws IOException {
this(true);
}

/**
Expand All @@ -55,29 +52,21 @@ public EnvarBasedValueSource() throws IOException
* case-sensitive manner for lookups
* @throws IOException in case of an error.
*/
public EnvarBasedValueSource( boolean caseSensitive ) throws IOException
{
super( false );
public EnvarBasedValueSource(boolean caseSensitive) throws IOException {
super(false);
this.caseSensitive = caseSensitive;
this.envars = getEnvars( caseSensitive );
this.envars = getEnvars(caseSensitive);
}

private static synchronized Properties getEnvars( boolean caseSensitive )
throws IOException
{
if ( caseSensitive )
{
if ( envarsCaseSensitive == null )
{
envarsCaseSensitive = OperatingSystemUtils.getSystemEnvVars( caseSensitive );
private static synchronized Properties getEnvars(boolean caseSensitive) throws IOException {
if (caseSensitive) {
if (envarsCaseSensitive == null) {
envarsCaseSensitive = OperatingSystemUtils.getSystemEnvVars(caseSensitive);
}
return envarsCaseSensitive;
}
else
{
if ( envarsCaseInsensitive == null )
{
envarsCaseInsensitive = OperatingSystemUtils.getSystemEnvVars( caseSensitive );
} else {
if (envarsCaseInsensitive == null) {
envarsCaseInsensitive = OperatingSystemUtils.getSystemEnvVars(caseSensitive);
}
return envarsCaseInsensitive;
}
Expand All @@ -92,30 +81,25 @@ private static synchronized Properties getEnvars( boolean caseSensitive )
* @param expression envar expression, like 'HOME' or 'env.HOME'
* @return the environment variable value for the given expression
*/
public Object getValue( String expression )
{
public Object getValue(String expression) {
String expr = expression;

if ( expr.startsWith( "env." ) )
{
expr = expr.substring( "env.".length() );
if (expr.startsWith("env.")) {
expr = expr.substring("env.".length());
}

if ( !caseSensitive )
{
if (!caseSensitive) {
expr = expr.toUpperCase();
}

return envars.getProperty( expr );
return envars.getProperty(expr);
}

/**
* reset static variables acting as a cache for testing purposes only
*/
static void resetStatics()
{
static void resetStatics() {
envarsCaseSensitive = null;
envarsCaseInsensitive = null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* limitations under the License.
*/


/**
* Represents a {@link ValueSource} which provides information back to the caller
* about what may have gone wrong while resolving the value for an expression.
Expand All @@ -25,7 +24,4 @@
*
* @deprecated Rolled into {@link ValueSource} now.
*/
public interface FeedbackEnabledValueSource
extends ValueSource
{
}
public interface FeedbackEnabledValueSource extends ValueSource {}
Loading