View Javadoc

1   /*
2    * joey-rt and its relative products are published under the terms
3    * of the Apache Software License.
4    * 
5    * Created on 2004/11/19 17:04:18
6    */
7   package org.asyrinx.joey.om.condition;
8   
9   import java.util.ArrayList;
10  import java.util.Iterator;
11  import java.util.List;
12  
13  /***
14   * @author takeshi
15   */
16  public class Composite implements IConditionComposite {
17  
18      /***
19       *  
20       */
21      public Composite() {
22          super();
23      }
24  
25      /***
26       *  
27       */
28      public Composite(String operator) {
29          super();
30      }
31  
32      private String operator;
33  
34      /***
35       * @return Returns the operator.
36       */
37      public String getOperator() {
38          return operator;
39      }
40  
41      protected final List children = new ArrayList();
42  
43      /***
44       * @param operator
45       *            The operator to set.
46       */
47      public void setOperator(String operator) {
48          this.operator = operator;
49      }
50  
51      /***
52       * @param o
53       * @return
54       */
55      public boolean add(ICondition o) {
56          return children.add(o);
57      }
58  
59      /***
60       * 
61       * @param fieldName
62       * @param value
63       * @return
64       */
65      public ICondition add(String fieldName, Object value) {
66          final ICondition result = new Expression(fieldName, ICondition.EQUAL, value);
67          return (this.add(result)) ? result : null;
68      }
69  
70      /***
71       * 
72       * @param fieldName
73       * @param operator
74       * @param value
75       * @return
76       */
77      public ICondition add(String fieldName, String operator, Object value) {
78          final ICondition result = new Expression(fieldName, operator, value);
79          return (this.add(result)) ? result : null;
80      }
81  
82      /***
83       *  
84       */
85      public void clear() {
86          children.clear();
87      }
88  
89      /***
90       * @param o
91       * @return
92       */
93      public boolean contains(ICondition o) {
94          return children.contains(o);
95      }
96  
97      /***
98       * @param index
99       * @return
100      */
101     public ICondition get(int index) {
102         return (ICondition) children.get(index);
103     }
104 
105     /***
106      * @param o
107      * @return
108      */
109     public int indexOf(ICondition o) {
110         return children.indexOf(o);
111     }
112 
113     /***
114      * @return
115      */
116     public boolean isEmpty() {
117         return children.isEmpty();
118     }
119 
120     /***
121      * @return
122      */
123     public Iterator iterator() {
124         return children.iterator();
125     }
126 
127     /***
128      * @param o
129      * @return
130      */
131     public boolean remove(ICondition o) {
132         return children.remove(o);
133     }
134 
135     /***
136      * @return
137      */
138     public int size() {
139         return children.size();
140     }
141 
142 }