View Javadoc

1   /*
2    * Copyright 2004-2005 Dan Washusen
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.reactive.beans.factory.config;
18  
19  /***
20   * Allows for configuration of individual bean property values from a configuration resource.
21   *
22   * @author Dan Washusen
23   * @version $Id: AbstractPlaceholder.java,v 1.1 2004/12/26 23:42:29 dan_washusen Exp $
24   * @since 16/12/2004
25   */
26  public abstract class AbstractPlaceholder
27          implements Placeholder {
28      protected Class type;
29      protected String key;
30  
31      /***
32       * The constructor calls the {@link #determineType(String)} and {@link #determineKey(String)} methods to determine
33       * the placeholders type and the placeholders key respectivly.
34       * @param value The value to construct a placeholder out of
35       */
36      public AbstractPlaceholder(String value) {
37          this.key = determineKey(value);
38          this.type = determineType(value);
39      }
40  
41      public String getKey() {
42          return key;
43      }
44  
45      public Class getType() {
46          return type;
47      }
48  
49      /***
50       * Determines the class that the placeholder will evaluate to.
51       * @param value The String representation of the placeholder
52       * @return The Class representation of the placeholders type
53       */
54      protected abstract Class determineType(String value);
55  
56      /***
57       * Determines the key that the {@link PlaceholderMatcher} will use to evaluate the placeholder.
58       * @param value The String representation of the placeholder
59       * @return The key that the {@link PlaceholderMatcher} will use to evaluate the placeholder
60       */
61      protected abstract String determineKey(String value);
62  }