1 /***
2 * Copyright 2003, 2004, 2005. CodeStreet LLC.
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 http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15 package com.codestreet.selector.parser;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 /***
21 * Class to represent a <tt>String</tt> literal. Immutable.
22 *
23 * @author Jawaid Hakim.
24 */
25 final class LiteralString implements IExpressionString
26 {
27 /***
28 * Factory.
29 *
30 * @param literal
31 * Literal.
32 * @return Instance.
33 */
34 public static synchronized LiteralString valueOf(final String literal)
35 {
36 LiteralString instance = (LiteralString) idMap_.get(literal);
37 if (instance == null)
38 {
39 instance = new LiteralString(literal);
40 idMap_.put(literal, instance);
41 }
42 return instance;
43 }
44
45 /***
46 * Ctor.
47 *
48 * @param literal
49 * String literal.
50 */
51 public LiteralString(final String literal)
52 {
53 literal_ = literal;
54 }
55
56 public Object eval(final Map identifiers)
57 {
58 return literal_;
59 }
60
61 public Object eval(final IValueProvider provider, final Object corr)
62 {
63 return literal_;
64 }
65
66 public String toString()
67 {
68 return literal_;
69 }
70
71 private final String literal_;
72
73 private static Map idMap_ = new HashMap();
74 }
This page was automatically generated by Maven