2 import java.util.Vector;
6 private Vector conjunctions;
7 public DNFFlag(FlagNode flag) {
8 DNFFlagAtom dfa=new DNFFlagAtom(flag, false);
9 conjunctions=new Vector();
10 Vector conjunct=new Vector();
12 conjunctions.add(conjunct);
15 conjunctions=new Vector();
18 /** Returns the number of conjunctions in the DNF form. */
21 return conjunctions.size();
24 /** Returns a Vector containing the terms in the n'th conjunction. */
26 public Vector get(int n) {
27 return (Vector) conjunctions.get(n);
30 /** This method negates a DNFFlag expression. */
32 public DNFFlag not() {
34 for (int i=0; i<conjunctions.size(); i++) {
35 Vector conj=(Vector)conjunctions.get(i);
37 for (int j=0; j<conj.size(); j++) {
38 DNFFlagAtom dfa=(DNFFlagAtom) conj.get(j);
39 DNFFlagAtom negdfa=new DNFFlagAtom(dfa.getFlagNode(),!dfa.getNegated());
40 DNFFlag tmp=new DNFFlag();
41 Vector v=new Vector();
42 tmp.conjunctions.add(v);
48 newflag=newflag.or(tmp);
53 notflag=notflag.and(newflag);
58 /** This method or's two DNFFlag expressions together. */
59 public DNFFlag or(DNFFlag dnf2) {
60 DNFFlag result=new DNFFlag();
61 for(int i=0; i<conjunctions.size(); i++) {
62 Vector conjunct=(Vector)conjunctions.get(i);
63 Vector newvector=new Vector();
64 result.conjunctions.add(newvector);
65 for(int j=0; j<conjunct.size(); j++) {
66 newvector.add(conjunct.get(j));
70 for(int i=0; i<dnf2.conjunctions.size(); i++) {
71 Vector conjunct=(Vector)dnf2.conjunctions.get(i);
72 Vector newvector=new Vector();
73 result.conjunctions.add(newvector);
74 for(int j=0; j<conjunct.size(); j++) {
75 newvector.add(conjunct.get(j));
81 /** This method and's two DNFFlag expressions together. */
82 public DNFFlag and(DNFFlag dnf2) {
83 DNFFlag result=new DNFFlag();
84 for(int i=0; i<conjunctions.size(); i++) {
85 for(int i2=0; i2<dnf2.conjunctions.size(); i2++) {
86 Vector conjunct=(Vector)conjunctions.get(i);
87 Vector conjunct2=(Vector)dnf2.conjunctions.get(i2);
88 Vector newconjunct=new Vector();
89 result.conjunctions.add(newconjunct);
90 for(int j=0; j<conjunct.size(); j++) {
91 newconjunct.add(conjunct.get(j));
93 for(int j2=0; j2<conjunct2.size(); j2++) {
94 newconjunct.add(conjunct2.get(j2));
101 public String toString() {
103 for(int i=0; i<conjunctions.size(); i++) {
106 Vector conjunct=(Vector)conjunctions.get(i);
107 for(int j=0; j<conjunct.size(); j++) {
110 value+=conjunct.get(j);