01: package org.ofbiz.rules.parse.chars;
02:
03: import java.util.*;
04: import org.ofbiz.rules.parse.*;
05:
06: /**
07: * <p><b>Title:</b> Specific Char
08: * <p><b>Description:</b> None
09: * <p>Copyright (c) 1999 Steven J. Metsker.
10: * <p>Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
11: *
12: * <p>Permission is hereby granted, free of charge, to any person obtaining a
13: * copy of this software and associated documentation files (the "Software"),
14: * to deal in the Software without restriction, including without limitation
15: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16: * and/or sell copies of the Software, and to permit persons to whom the
17: * Software is furnished to do so, subject to the following conditions:
18: *
19: * <p>The above copyright notice and this permission notice shall be included
20: * in all copies or substantial portions of the Software.
21: *
22: * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
26: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
27: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
28: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29: *
30: * <br>
31: * <p>A SpecificChar matches a specified character from a character
32: * assembly.
33: *
34: * @author Steven J. Metsker
35: * @version 1.0
36: */
37: public class SpecificChar extends Terminal {
38:
39: /**
40: * the character to match
41: */
42: protected Character character;
43:
44: /**
45: * Constructs a SpecificChar to match the specified char.
46: *
47: * @param char the character to match
48: * @return a SpecificChar to match a Character constructed
49: * from the specified char.
50: */
51: public SpecificChar(char c) {
52: this (new Character(c));
53: }
54:
55: /**
56: * Constructs a SpecificChar to match the specified character.
57: *
58: * @param character the character to match
59: * @return a SpecificChar to match the specified character
60: */
61: public SpecificChar(Character character) {
62: this .character = character;
63: }
64:
65: /**
66: * Returns true if an assembly's next element is equal to the
67: * character this object was constructed with.
68: *
69: * @param object an element from an assembly
70: * @return true, if an assembly's next element is equal to
71: * the character this object was constructed with
72: */
73: public boolean qualifies(Object o) {
74: Character c = (Character) o;
75:
76: return c.charValue() == character.charValue();
77: }
78:
79: /**
80: * Returns a textual description of this parser.
81: *
82: * @param vector a list of parsers already printed in
83: * this description
84: * @return string a textual description of this parser
85: * @see Parser#toString()
86: */
87: public String unvisitedString(List visited) {
88: return character.toString();
89: }
90: }
|