KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > impl > ExpressionImpl


1 package org.apache.ws.jaxme.sqls.impl;
2
3 import org.apache.ws.jaxme.sqls.Expression;
4 import org.apache.ws.jaxme.sqls.Statement;
5
6
7 /** Default implementation of {@link org.apache.ws.jaxme.sqls.Expression}.
8  */

9 public class ExpressionImpl extends PartsImpl implements Expression {
10     /** Default implementation of {@link Expression.Type}.
11      */

12     public static class TypeImpl extends SQLFactoryImpl.IdentImpl implements Expression.Type {
13         private static final long serialVersionUID = 3834872498671071537L;
14         /** Creates a new instance with the given name.
15          */

16         public TypeImpl(String JavaDoc pName) {
17             super(pName);
18         }
19     }
20
21     private final Type type;
22
23     protected ExpressionImpl(Statement pStatement, Expression.Type pType) {
24         super(pStatement);
25         type = pType;
26     }
27
28     public Type getType() { return type; }
29
30     public int getMinimumParts() { return 1; }
31     public int getMaximumParts() {
32         if (Expression.PRODUCT.equals(type)
33             || Expression.SUM.equals(type)) {
34             return 0;
35         } else if (Expression.DIFFERENCE.equals(type)
36                    || Expression.QUOTIENT.equals(type)) {
37             return 2;
38         } else {
39             throw new IllegalStateException JavaDoc("Invalid type: " + type);
40         }
41     }
42 }
43
Popular Tags