001: package com.bostechcorp.cbesb.common.trn;
002:
003: import java.util.Vector;
004:
005: public enum Function {
006:
007: LENGTH {
008: public String getString() {
009: return "length";
010: }
011:
012: public int getValue() {
013: return 0;
014: }
015:
016: public boolean isNodeFunction() {
017: return false;
018: }
019:
020: },
021:
022: COUNT {
023: public String getString() {
024: return "count";
025: }
026:
027: public int getValue() {
028: return 1;
029: }
030:
031: public boolean isNodeFunction() {
032: return true;
033: }
034:
035: },
036:
037: GETFIRSTCHILDNAME {
038: public String getString() {
039: return "getFirstChildName";
040: }
041:
042: public int getValue() {
043: return 2;
044: }
045:
046: public boolean isNodeFunction() {
047: return true;
048: }
049:
050: };
051:
052: abstract public int getValue();
053:
054: abstract public String getString();
055:
056: abstract public boolean isNodeFunction();
057:
058: private static final Function[] VALUES_ARRAY = new Function[] {
059: LENGTH, COUNT, GETFIRSTCHILDNAME, };
060:
061: public static String[] getAllFunctions() {
062: String[] result = new String[VALUES_ARRAY.length];
063: for (int i = 0; i < VALUES_ARRAY.length; ++i) {
064: Function function = VALUES_ARRAY[i];
065: result[i] = function.getString();
066: }
067: return result;
068: }
069:
070: public static String[] getStringFunctions() {
071: Vector<String> result = new Vector<String>();
072: for (int i = 0; i < VALUES_ARRAY.length; ++i) {
073: Function function = VALUES_ARRAY[i];
074: if (!function.isNodeFunction())
075: result.add(function.getString());
076: }
077: return result.toArray(new String[0]);
078: }
079:
080: public static String[] getNodeFunctions() {
081: Vector<String> result = new Vector<String>();
082: for (int i = 0; i < VALUES_ARRAY.length; ++i) {
083: Function function = VALUES_ARRAY[i];
084: if (function.isNodeFunction())
085: result.add(function.getString());
086: }
087: return result.toArray(new String[0]);
088: }
089:
090: public static Function get(String literal) {
091: for (int i = 0; i < VALUES_ARRAY.length; ++i) {
092: Function result = VALUES_ARRAY[i];
093: if (result.getString().equals(literal)) {
094: return result;
095: }
096: }
097: return null;
098: }
099:
100: /**
101: * Returns the '<em><b>CBR Type</b></em>' literal with the specified integer value.
102: * <!-- begin-user-doc -->
103: * <!-- end-user-doc -->
104: * @generated
105: */
106: public static Function get(int value) {
107:
108: return VALUES_ARRAY[value];
109: }
110:
111: }
|