1 16 35 93 package org.apache.cocoon.util; 94 95 import java.util.Vector ; 96 97 109 public class EnumerationFactory { 110 111 private static Vector allObjects = new Vector (0, 1); 114 private int pos; 115 private String image; 116 117 123 public EnumerationFactory(String image) { 124 this.pos = allObjects.size(); 125 this.image = image; 126 allObjects.addElement(this); 127 } 128 129 public EnumerationFactory() { 130 this (""); 131 } 132 133 136 141 public boolean lt(EnumerationFactory e) { return this.getPos() < e.getPos(); 143 } 144 145 public boolean le(EnumerationFactory e) { return this.getPos() <= e.getPos(); 147 } 148 149 public boolean gt(EnumerationFactory e) { return this.getPos() > e.getPos(); 151 } 152 153 public boolean ge(EnumerationFactory e) { return this.getPos() >= e.getPos (); 155 } 156 157 159 162 public int getPos() { return pos; 164 } 165 166 170 public static EnumerationFactory getVal(int value) { return (EnumerationFactory)allObjects.elementAt(value); 172 } 173 174 177 public static EnumerationFactory getFirst() { return getVal(0); 179 } 180 181 public static EnumerationFactory getLast() { return getVal(allObjects.size() - 1); 183 } 184 185 public EnumerationFactory getNext () { return getVal(this.getPos() + 1); 187 } 188 189 public EnumerationFactory getPrev () { return getVal(this.getPos() - 1); 191 } 192 193 196 public String toString() { return image; 198 } 199 200 public static EnumerationFactory getObject(String image) { EnumerationFactory found; 202 for (int i = 0 ; i < allObjects.size() ; i++) { 205 found = (EnumerationFactory) allObjects.elementAt(i); 206 if (found.toString().equals(image)) { 207 return found; 208 } 209 } 210 return null; 211 } 212 } 213 | Popular Tags |