Source code: com/thermidor/xml/output/OutputType.java
1 package com.thermidor.xml.output;
2 import java.io.Serializable;
3 import java.util.HashMap;
4 import java.util.Collection;
5 import java.util.Iterator;
6 import java.util.NoSuchElementException;
7 import com.thermidor.util.Enum;
8 /**
9
10 This enumeration details the types of output mechansim that can be
11 used by the Output class in stack based output.
12
13 */
14 public final class OutputType extends Enum{
15 private static final HashMap MAP;
16 private static final Collection VALUES;
17 /**
18 * Sybmolic Constant for the FILE enum member
19 */
20 public static final int ID_FILE=0;
21 /**
22 *
23 Output will be directed to a file.
24
25 */
26 public static final OutputType FILE;
27 /**
28 * Sybmolic Constant for the APPEND enum member
29 */
30 public static final int ID_APPEND=1;
31 /**
32 *
33 Output will be appended to a file.
34
35 */
36 public static final OutputType APPEND;
37 /**
38 * Sybmolic Constant for the STRING enum member
39 */
40 public static final int ID_STRING=2;
41 /**
42 *
43 Output will be concatentated to a string.
44
45 */
46 public static final OutputType STRING;
47 /**
48 * Sybmolic Constant for the PRINTWRITER enum member
49 */
50 public static final int ID_PRINTWRITER=3;
51 /**
52 *
53 Output will be feed to an existing open print writer.
54
55 */
56 public static final OutputType PRINTWRITER;
57 /**
58 * Sybmolic Constant for the NUL enum member
59 */
60 public static final int ID_NUL=4;
61 /**
62 *
63 Output will be ignored.
64
65 */
66 public static final OutputType NUL;
67 static{
68 MAP=new HashMap();
69 FILE=new OutputType(ID_FILE,"FILE");
70 MAP.put(FILE.id,FILE);
71 APPEND=new OutputType(ID_APPEND,"APPEND");
72 MAP.put(APPEND.id,APPEND);
73 STRING=new OutputType(ID_STRING,"STRING");
74 MAP.put(STRING.id,STRING);
75 PRINTWRITER=new OutputType(ID_PRINTWRITER,"PRINTWRITER");
76 MAP.put(PRINTWRITER.id,PRINTWRITER);
77 NUL=new OutputType(ID_NUL,"NUL");
78 MAP.put(NUL.id,NUL);
79 VALUES=MAP.values();
80 }
81 public static OutputType resolve(String val)
82 throws NoSuchElementException{
83 Iterator it=VALUES.iterator();
84 while(it.hasNext()){
85 Object o=it.next();
86 if(o.toString().equals(val)){
87 return (OutputType)o;
88 }
89 }
90 throw new NoSuchElementException();
91 }
92 public OutputType(int token,String value){
93 super(value,token);
94 }
95 private Object readResolve(){
96 return MAP.get(id);
97 }
98 }
99