View Javadoc
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>Long</tt> literal. Immutable. 22 * 23 * @author Jawaid Hakim. 24 */ 25 final class LiteralLong implements IExpressionNumeric 26 27 { 28 /*** 29 * Factory. 30 * 31 * @param literal 32 * Literal. 33 * @return Instance. 34 */ 35 public static synchronized LiteralLong valueOf(final String literal) 36 { 37 LiteralLong instance = (LiteralLong) idMap_.get(literal); 38 if (instance == null) 39 { 40 instance = new LiteralLong(literal); 41 idMap_.put(literal, instance); 42 } 43 return instance; 44 } 45 46 /*** 47 * Ctor. 48 * 49 * @param literal 50 * Long literal. 51 */ 52 public LiteralLong(final String literal) 53 { 54 literal_ = new NumericValue(Long.valueOf(literal)); 55 } 56 57 public Object eval(final Map identifiers) 58 { 59 return literal_; 60 } 61 62 public Object eval(final IValueProvider provider, final Object corr) 63 { 64 return literal_; 65 } 66 67 public String toString() 68 { 69 return literal_.toString(); 70 } 71 72 private final NumericValue literal_; 73 74 private static Map idMap_ = new HashMap(); 75 }

This page was automatically generated by Maven