View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.jcr.query.qom;
25  
26  import javax.jcr.query.qom.DynamicOperand;
27  import javax.jcr.query.qom.QueryObjectModelConstants;
28  import javax.jcr.query.qom.StaticOperand;
29  import org.modeshape.graph.query.model.Comparison;
30  import org.modeshape.graph.query.model.Operator;
31  
32  /**
33   * 
34   */
35  public class JcrComparison extends Comparison implements JcrConstraint, javax.jcr.query.qom.Comparison {
36  
37      private static final long serialVersionUID = 1L;
38  
39      /**
40       * @param operand1
41       * @param operator
42       * @param operand2
43       */
44      public JcrComparison( JcrDynamicOperand operand1,
45                            Operator operator,
46                            JcrStaticOperand operand2 ) {
47          super(operand1, operator, operand2);
48      }
49  
50      /**
51       * {@inheritDoc}
52       * 
53       * @see org.modeshape.graph.query.model.Comparison#operand1()
54       */
55      @Override
56      public JcrDynamicOperand operand1() {
57          return (JcrDynamicOperand)super.operand1();
58      }
59  
60      /**
61       * {@inheritDoc}
62       * 
63       * @see org.modeshape.graph.query.model.Comparison#operand2()
64       */
65      @Override
66      public JcrStaticOperand operand2() {
67          return (JcrStaticOperand)super.operand2();
68      }
69  
70      /**
71       * {@inheritDoc}
72       * 
73       * @see javax.jcr.query.qom.Comparison#getOperand1()
74       */
75      @Override
76      public DynamicOperand getOperand1() {
77          return operand1();
78      }
79  
80      /**
81       * {@inheritDoc}
82       * 
83       * @see javax.jcr.query.qom.Comparison#getOperand2()
84       */
85      @Override
86      public StaticOperand getOperand2() {
87          return operand2();
88      }
89  
90      /**
91       * {@inheritDoc}
92       * 
93       * @see javax.jcr.query.qom.Comparison#getOperator()
94       */
95      @Override
96      public String getOperator() {
97          switch (operator()) {
98              case EQUAL_TO:
99                  return QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO;
100             case GREATER_THAN:
101                 return QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN;
102             case GREATER_THAN_OR_EQUAL_TO:
103                 return QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO;
104             case LESS_THAN:
105                 return QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN;
106             case LESS_THAN_OR_EQUAL_TO:
107                 return QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO;
108             case LIKE:
109                 return QueryObjectModelConstants.JCR_OPERATOR_LIKE;
110             case NOT_EQUAL_TO:
111                 return QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO;
112         }
113         assert false;
114         return null;
115     }
116 }