KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > mns > ElementsOrAttributes


1 package com.thaiopensource.validate.mns;
2
3 class ElementsOrAttributes {
4   private static final int ELEMENTS_FLAG = 01;
5   private static final int ATTRIBUTES_FLAG = 02;
6
7   static final ElementsOrAttributes NEITHER = new ElementsOrAttributes(0);
8   static final ElementsOrAttributes ELEMENTS = new ElementsOrAttributes(ELEMENTS_FLAG);
9   static final ElementsOrAttributes ATTRIBUTES = new ElementsOrAttributes(ATTRIBUTES_FLAG);
10   static final ElementsOrAttributes BOTH = new ElementsOrAttributes(ELEMENTS_FLAG|ATTRIBUTES_FLAG);
11
12   private static final ElementsOrAttributes values[] = {
13     NEITHER,
14     ELEMENTS,
15     ATTRIBUTES,
16     BOTH
17   };
18
19   private int flags = 0;
20
21   private ElementsOrAttributes(int flags) {
22     this.flags = flags;
23   }
24
25   ElementsOrAttributes addElements() {
26     return values[flags | ELEMENTS_FLAG];
27   }
28
29   ElementsOrAttributes addAttributes() {
30     return values[flags | ATTRIBUTES_FLAG];
31   }
32
33   boolean containsAttributes() {
34     return (flags & ATTRIBUTES_FLAG) != 0;
35   }
36
37   boolean containsElements() {
38     return (flags & ELEMENTS_FLAG) != 0;
39   }
40
41 }
42
Popular Tags