Skip to content

Commit acbce69

Browse files
committed
Reseted branch commit
1 parent 0eff699 commit acbce69

14 files changed

+735
-68
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Plexus-Interpolation
22
===============
33

4+
[![Build Status](https://travis-ci.org/codehaus-plexus/plexus-interpolation.svg?branch=master)](https://travis-ci.org/codehaus-plexus/plexus-interpolation)
5+
46
Components for interpolating `${}` strings and the like.
57

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</parent>
99

1010
<artifactId>plexus-interpolation</artifactId>
11-
<version>1.24-SNAPSHOT</version>
11+
<version>1.25-SNAPSHOT</version>
1212
<packaging>bundle</packaging>
1313

1414
<name>Plexus Interpolation API</name>
@@ -17,7 +17,7 @@
1717
<connection>scm:git:git@github.com:codehaus-plexus/plexus-interpolation.git</connection>
1818
<developerConnection>scm:git:git@github.com:codehaus-plexus/plexus-interpolation.git</developerConnection>
1919
<url>http://github.com/codehaus-plexus/plexus-interpolation</url>
20-
<tag>HEAD</tag>
20+
<tag>plexus-interpolation-1.24</tag>
2121
</scm>
2222

2323
<issueManagement>

src/main/java/org/codehaus/plexus/interpolation/EnvarBasedValueSource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,14 @@ public Object getValue( String expression )
110110

111111
return envars.getProperty( expr );
112112
}
113+
114+
/**
115+
* reset static variables acting as a cache for testing purposes only
116+
*/
117+
static void resetStatics()
118+
{
119+
envarsCaseSensitive = null;
120+
envarsCaseInsensitive = null;
121+
}
113122

114123
}

src/main/java/org/codehaus/plexus/interpolation/InterpolatorFilterReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public InterpolatorFilterReader( Reader in, Interpolator interpolator, String be
138138
*/
139139
public InterpolatorFilterReader( Reader in, Interpolator interpolator, RecursionInterceptor ri )
140140
{
141-
this( in, interpolator, DEFAULT_BEGIN_TOKEN, DEFAULT_END_TOKEN, new SimpleRecursionInterceptor() );
141+
this( in, interpolator, DEFAULT_BEGIN_TOKEN, DEFAULT_END_TOKEN, ri );
142142
}
143143

144144
/**

src/main/java/org/codehaus/plexus/interpolation/fixed/EnvarBasedValueSource.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,13 @@ public Object getValue( String expression, InterpolationState interpolationState
110110
return envars.getProperty( expr );
111111
}
112112

113+
/**
114+
* reset static variables acting as a cache for testing purposes only
115+
*/
116+
static void resetStatics()
117+
{
118+
envarsCaseSensitive = null;
119+
envarsCaseInsensitive = null;
120+
}
121+
113122
}

src/main/java/org/codehaus/plexus/interpolation/multi/MultiDelimiterStringSearchInterpolator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,17 @@ private String interpolate( String input, RecursionInterceptor recursionIntercep
201201

202202
if ( startIdx >= 0 && escapeString != null && escapeString.length() > 0 )
203203
{
204-
int startEscapeIdx = startIdx == 0 ? 0 : startIdx - escapeString.length();
204+
int startEscapeIdx = ( startIdx == 0 ) ? 0 : startIdx - escapeString.length();
205205
if ( startEscapeIdx >= 0 )
206206
{
207207
String escape = input.substring( startEscapeIdx, startIdx );
208208
if ( escape != null && escapeString.equals( escape ) )
209209
{
210210
result.append( wholeExpr );
211+
if ( startEscapeIdx > 0 )
212+
{
213+
--startEscapeIdx;
214+
}
211215
result.replace( startEscapeIdx, startEscapeIdx + escapeString.length(), "" );
212216
continue;
213217
}
@@ -388,6 +392,12 @@ public void setEscapeString( String escapeString )
388392
{
389393
this.escapeString = escapeString;
390394
}
395+
396+
public MultiDelimiterStringSearchInterpolator escapeString( String escapeString )
397+
{
398+
this.escapeString = escapeString;
399+
return this;
400+
}
391401

392402
public MultiDelimiterStringSearchInterpolator setDelimiterSpecs( LinkedHashSet<String> specs )
393403
{

src/main/java/org/codehaus/plexus/interpolation/os/OperatingSystemUtils.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
public final class OperatingSystemUtils
4040
{
4141

42+
private static EnvVarSource envVarSource = new DefaultEnvVarSource();
43+
4244
private OperatingSystemUtils()
4345
{
4446
}
@@ -62,16 +64,54 @@ public static Properties getSystemEnvVars( boolean caseSensitive )
6264
throws IOException
6365
{
6466
Properties envVars = new Properties();
65-
Map<String, String> envs = System.getenv();
67+
Map<String, String> envs = envVarSource.getEnvMap();
6668
for ( String key : envs.keySet() )
6769
{
6870
String value = envs.get( key );
69-
if ( !caseSensitive)
71+
if ( !caseSensitive )
7072
{
7173
key = key.toUpperCase( Locale.ENGLISH );
7274
}
7375
envVars.put( key, value );
7476
}
7577
return envVars;
7678
}
79+
80+
/**
81+
* Set the source object to load the environment variables from.
82+
* Default implementation should suffice. This is mostly for testing.
83+
* @param source the EnvVarSource instance that loads the environment variables.
84+
*
85+
* @since 3.1.2
86+
*/
87+
public static void setEnvVarSource( EnvVarSource source )
88+
{
89+
envVarSource = source;
90+
}
91+
92+
/**
93+
* Defines the functionality to load a Map of environment variables.
94+
*
95+
* @since 3.1.2
96+
*/
97+
public interface EnvVarSource
98+
{
99+
public Map<String, String> getEnvMap();
100+
}
101+
102+
/**
103+
* Default implementation to load environment variables.
104+
*
105+
* @since 3.1.2
106+
*/
107+
public static class DefaultEnvVarSource
108+
implements EnvVarSource
109+
{
110+
111+
public Map<String, String> getEnvMap()
112+
{
113+
return System.getenv();
114+
}
115+
116+
}
77117
}

0 commit comments

Comments
 (0)