View Javadoc
1   package org.codehaus.plexus.interpolation.fixed;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.List;
23  import java.util.Properties;
24  
25  /**
26   * Legacy support. Allow trimming one of a set of expression prefixes, the lookup
27   * the remaining expression as a literal key from the wrapped properties instance.
28   * <br/>
29   * This is just a convenience implementation to provide a shorthand for constructing
30   * the properties value source and then wrapping it with a prefixed value-source wrapper.
31   *
32   * @version $Id$
33   */
34  public class PrefixedPropertiesValueSource
35      extends AbstractDelegatingValueSource
36  {
37  
38      /**
39       * Wrap the specified properties file with a new {@link org.codehaus.plexus.interpolation.PropertiesBasedValueSource}, then
40       * wrap that source with a new {@link org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper} that uses the specified
41       * expression prefix. Finally, set this wrapper source as a delegate for this
42       * instance to use.
43       *
44       * @param prefix     The expression prefix to trim
45       * @param properties The properties instance to wrap
46       */
47      public PrefixedPropertiesValueSource( String prefix, Properties properties )
48      {
49          super( new PrefixedValueSourceWrapper( new PropertiesBasedValueSource( properties ), prefix ) );
50      }
51  
52      /**
53       * Wrap the specified properties file with a new {@link org.codehaus.plexus.interpolation.PropertiesBasedValueSource}, then
54       * wrap that source with a new {@link org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper} that uses the specified
55       * expression-prefix list. Finally, set this wrapper source as a delegate for this
56       * instance to use.
57       *
58       * @param possiblePrefixes The expression-prefix list to trim
59       * @param properties       The properties instance to wrap
60       */
61      public PrefixedPropertiesValueSource( List<String> possiblePrefixes, Properties properties,
62                                            boolean allowUnprefixedExpressions )
63      {
64          super( new PrefixedValueSourceWrapper( new PropertiesBasedValueSource( properties ), possiblePrefixes,
65                                                 allowUnprefixedExpressions ) );
66      }
67  }