001: /*
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found in file GTPL, or at
004: * http://www.globus.org/toolkit/download/license.html. This notice must
005: * appear in redistributions of this file, with or without modification.
006: *
007: * Redistributions of this Software, with or without modification, must
008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009: * some other similar material which is provided with the Software (if
010: * any).
011: *
012: * Copyright 1999-2004 University of Chicago and The University of
013: * Southern California. All rights reserved.
014: */
015: package org.griphyn.cPlanner.classes;
016:
017: /**
018: * Class to capture reserved words.
019: * $Revision: 137 $
020: * @author Jens Vöckler
021: * @author Gaurang Mehta
022: */
023: class PoolConfigReservedWord implements PoolConfigToken {
024: /**
025: * token value for the reserved word "site".
026: */
027: public static final int SITE = 0;
028:
029: /**
030: * token value for the reserved word "version".
031: */
032: public static final int VERSION = 1;
033:
034: /**
035: * token value for the reserved word "lrc".
036: */
037: public static final int LRC = 2;
038:
039: /**
040: * token value for the reserved word "universe".
041: */
042: public static final int UNIVERSE = 3;
043:
044: /**
045: * token value for the reserved word "gridlaunch".
046: */
047: public static final int GRIDLAUNCH = 4;
048:
049: /**
050: * token value for the reserved word "workdir".
051: */
052: public static final int WORKDIR = 5;
053:
054: /**
055: * token value for the reserved word "gridftp".
056: */
057: public static final int GRIDFTP = 6;
058:
059: /**
060: * token value for the reserver word "profile".
061: */
062:
063: public static final int PROFILE = 7;
064:
065: /**
066: * token value for the reserved work sysinfo.
067: */
068:
069: public static final int SYSINFO = 8;
070:
071: /**
072: * Singleton implementation of a symbol table for reserved words.
073: */
074: private static java.util.Map m_symbolTable = null;
075:
076: /**
077: * Singleton access to the symbol table as a whole.
078: * @return Map
079: */
080: public static java.util.Map symbolTable() {
081: if (m_symbolTable == null) {
082: // only initialize once and only once, as needed.
083: m_symbolTable = new java.util.TreeMap();
084: m_symbolTable.put("site", new PoolConfigReservedWord(
085: PoolConfigReservedWord.SITE));
086: m_symbolTable.put("version", new PoolConfigReservedWord(
087: PoolConfigReservedWord.VERSION));
088: m_symbolTable.put("lrc", new PoolConfigReservedWord(
089: PoolConfigReservedWord.LRC));
090: m_symbolTable.put("universe", new PoolConfigReservedWord(
091: PoolConfigReservedWord.UNIVERSE));
092: m_symbolTable.put("gridlaunch", new PoolConfigReservedWord(
093: PoolConfigReservedWord.GRIDLAUNCH));
094: m_symbolTable.put("workdir", new PoolConfigReservedWord(
095: PoolConfigReservedWord.WORKDIR));
096: m_symbolTable.put("gridftp", new PoolConfigReservedWord(
097: PoolConfigReservedWord.GRIDFTP));
098: m_symbolTable.put("profile", new PoolConfigReservedWord(
099: PoolConfigReservedWord.PROFILE));
100: m_symbolTable.put("sysinfo", new PoolConfigReservedWord(
101: PoolConfigReservedWord.SYSINFO));
102: }
103:
104: return m_symbolTable;
105: }
106:
107: /**
108: * This instance variable captures the token value for the reserved word.
109: */
110: private int m_value;
111:
112: /**
113: * Initializes an instance of a reserved word token. The constructor
114: * is unreachable from the outside. Use symbol table lookups to obtain
115: * reserved word tokens.
116: * @param tokenValue is the token value to memorize.
117: * @see #symbolTable()
118: */
119: protected PoolConfigReservedWord(int tokenValue) {
120: m_value = tokenValue;
121: }
122:
123: /**
124: * Obtains the token value of a given reserved word token.
125: * @return the token value.
126: */
127: public int getValue() {
128: return this.m_value;
129: }
130: }
|