org.hibernate.ejb.criteria.expression
Class BinaryArithmeticOperation<N extends Number>

java.lang.Object
  extended by org.hibernate.ejb.criteria.AbstractNode
      extended by org.hibernate.ejb.criteria.expression.AbstractTupleElement<X>
          extended by org.hibernate.ejb.criteria.expression.SelectionImpl<T>
              extended by org.hibernate.ejb.criteria.expression.ExpressionImpl<N>
                  extended by org.hibernate.ejb.criteria.expression.BinaryArithmeticOperation<N>
All Implemented Interfaces:
Serializable, javax.persistence.criteria.Expression<N>, javax.persistence.criteria.Selection<N>, TupleElement<N>, BinaryOperatorExpression<N>, ExpressionImplementor<N>, ParameterContainer, Renderable, SelectionImplementor<N>, TupleElementImplementor<N>

public class BinaryArithmeticOperation<N extends Number>
extends ExpressionImpl<N>
implements BinaryOperatorExpression<N>, Serializable

Models standard arithmetc operations with two operands.

Author:
Steve Ebersole
See Also:
Serialized Form

Nested Class Summary
static class BinaryArithmeticOperation.Operation
           
 
Nested classes/interfaces inherited from interface org.hibernate.ejb.criteria.ParameterContainer
ParameterContainer.Helper
 
Constructor Summary
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, Class<N> resultType, BinaryArithmeticOperation.Operation operator, javax.persistence.criteria.Expression<? extends N> lhs, javax.persistence.criteria.Expression<? extends N> rhs)
          Creates an arithmethic operation based on 2 expressions.
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, Class<N> javaType, BinaryArithmeticOperation.Operation operator, javax.persistence.criteria.Expression<? extends N> lhs, N rhs)
          Creates an arithmethic operation based on an expression and a literal.
BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder, Class<N> javaType, BinaryArithmeticOperation.Operation operator, N lhs, javax.persistence.criteria.Expression<? extends N> rhs)
          Creates an arithmetic operation based on an expression and a literal.
 
Method Summary
static Class<? extends Number> determineReturnType(Class<? extends Number> defaultType, javax.persistence.criteria.Expression<? extends Number> expression)
          Helper for determining the appropriate operation return type based on one of the operands as an expression.
static Class<? extends Number> determineReturnType(Class<? extends Number> defaultType, Number numberLiteral)
          Helper for determining the appropriate operation return type based on one of the operands as a literal.
 javax.persistence.criteria.Expression<? extends N> getLeftHandOperand()
          Get the left-hand operand.
 BinaryArithmeticOperation.Operation getOperator()
           
 javax.persistence.criteria.Expression<? extends N> getRightHandOperand()
          Get the right-hand operand.
 void registerParameters(ParameterRegistry registry)
          Register any parameters contained within this query component with the given registry.
 String render(CriteriaQueryCompiler.RenderingContext renderingContext)
           
 String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
           
 
Methods inherited from class org.hibernate.ejb.criteria.expression.ExpressionImpl
as, asBigDecimal, asBigInteger, asDouble, asFloat, asInteger, asLong, asString, in, in, in, in, isNotNull, isNull
 
Methods inherited from class org.hibernate.ejb.criteria.expression.SelectionImpl
alias, getCompoundSelectionItems, getValueHandlers, isCompoundSelection
 
Methods inherited from class org.hibernate.ejb.criteria.expression.AbstractTupleElement
forceConversion, getAlias, getJavaType, getValueHandler, resetJavaType, setAlias
 
Methods inherited from class org.hibernate.ejb.criteria.AbstractNode
criteriaBuilder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.persistence.criteria.Expression
as, in, in, in, in, isNotNull, isNull
 
Methods inherited from interface javax.persistence.criteria.Selection
alias, getCompoundSelectionItems, isCompoundSelection
 
Methods inherited from interface javax.persistence.TupleElement
getAlias, getJavaType
 
Methods inherited from interface org.hibernate.ejb.criteria.SelectionImplementor
getValueHandlers
 
Methods inherited from interface org.hibernate.ejb.criteria.TupleElementImplementor
getValueHandler
 

Constructor Detail

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 Class<N> resultType,
                                 BinaryArithmeticOperation.Operation operator,
                                 javax.persistence.criteria.Expression<? extends N> lhs,
                                 javax.persistence.criteria.Expression<? extends N> rhs)
Creates an arithmethic operation based on 2 expressions.

Parameters:
criteriaBuilder - The builder for query components.
resultType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand.
rhs - The right-hand operand

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 Class<N> javaType,
                                 BinaryArithmeticOperation.Operation operator,
                                 javax.persistence.criteria.Expression<? extends N> lhs,
                                 N rhs)
Creates an arithmethic operation based on an expression and a literal.

Parameters:
criteriaBuilder - The builder for query components.
javaType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand
rhs - The right-hand operand (the literal)

BinaryArithmeticOperation

public BinaryArithmeticOperation(CriteriaBuilderImpl criteriaBuilder,
                                 Class<N> javaType,
                                 BinaryArithmeticOperation.Operation operator,
                                 N lhs,
                                 javax.persistence.criteria.Expression<? extends N> rhs)
Creates an arithmetic operation based on an expression and a literal.

Parameters:
criteriaBuilder - The builder for query components.
javaType - The operation result type
operator - The operator (type of operation).
lhs - The left-hand operand (the literal)
rhs - The right-hand operand
Method Detail

determineReturnType

public static Class<? extends Number> determineReturnType(Class<? extends Number> defaultType,
                                                          javax.persistence.criteria.Expression<? extends Number> expression)
Helper for determining the appropriate operation return type based on one of the operands as an expression.

Parameters:
defaultType - The default return type to use if we cannot determine the java type of 'expression' operand.
expression - The operand.
Returns:
The appropriate return type.

determineReturnType

public static Class<? extends Number> determineReturnType(Class<? extends Number> defaultType,
                                                          Number numberLiteral)
Helper for determining the appropriate operation return type based on one of the operands as a literal.

Parameters:
defaultType - The default return type to use if we cannot determine the java type of 'numberLiteral' operand.
numberLiteral - The operand.
Returns:
The appropriate return type.

getOperator

public BinaryArithmeticOperation.Operation getOperator()

getRightHandOperand

public javax.persistence.criteria.Expression<? extends N> getRightHandOperand()
Get the right-hand operand.

Specified by:
getRightHandOperand in interface BinaryOperatorExpression<N extends Number>
Returns:
The right-hand operand.

getLeftHandOperand

public javax.persistence.criteria.Expression<? extends N> getLeftHandOperand()
Get the left-hand operand.

Specified by:
getLeftHandOperand in interface BinaryOperatorExpression<N extends Number>
Returns:
The left-hand operand.

registerParameters

public void registerParameters(ParameterRegistry registry)
Register any parameters contained within this query component with the given registry.

Specified by:
registerParameters in interface ParameterContainer
Parameters:
registry - The parameter registry with which to register.

render

public String render(CriteriaQueryCompiler.RenderingContext renderingContext)
Specified by:
render in interface Renderable

renderProjection

public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext)
Specified by:
renderProjection in interface Renderable


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.