EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class ConstructorExpressionStateObject

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractListHolderStateObject<StateObject>
          extended by org.eclipse.persistence.jpa.jpql.model.query.ConstructorExpressionStateObject
All Implemented Interfaces:
ListHolderStateObject<StateObject>, StateObject

public class ConstructorExpressionStateObject
extends AbstractListHolderStateObject<StateObject>

In the SELECT clause a constructor may be used in the SELECT list to return one or more Java instances. The specified class is not required to be an entity or to be mapped to the database. The constructor name must be fully qualified.

BNF: constructor_expression ::= NEW constructor_name(constructor_item {, constructor_item}*)

Version:
2.4
See Also:
ConstructorExpression
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String CLASS_NAME_PROPERTY
          Notifies the class name property has changed.
static java.lang.String CONSTRUCTOR_ITEMS_LIST
          Notify the list of StateObjects representing the constructor items.
 
Constructor Summary
ConstructorExpressionStateObject(StateObject parent)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.Class<?> type)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.Class<?> type, java.util.List<? extends StateObject> constructorItems)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.Class<?> type, java.lang.String jpqlFragment)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.String className)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.String className, java.util.List<? extends StateObject> constructorItems)
          Creates a new ConstructorExpressionStateObject.
ConstructorExpressionStateObject(StateObject parent, java.lang.String className, java.lang.String jpqlFragment)
          Creates a new ConstructorExpressionStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
 java.lang.String getClassName()
          Returns the fully qualified class name that will be used to retrieve the constructor.
 ConstructorExpression getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 IType getType()
          Returns the actual IType that was resolved or null if it could not be resolved.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
protected  java.lang.String listName()
          Returns the name that is uniquely identifying the list.
 void parse(java.lang.String jpqlFragment)
          Parses the given JPQL fragment, which represents the constructor's arguments.
protected  IType resolveType()
          Resolves the actual IType based on the class name.
 void setClassName(java.lang.CharSequence className)
          Sets the fully qualified class name that will be used to retrieve the constructor.
 void setClassName(java.lang.Class<?> type)
          Sets the fully qualified class name that will be used to retrieve the constructor.
protected  void setClassNameInternally(java.lang.CharSequence className)
          Sets the fully qualified class name that will be used to retrieve the constructor.
 void setExpression(ConstructorExpression expression)
          Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
 void setType(IType type)
          Sets the actual IType and updates the class name.
protected  void toTextInternal(java.lang.Appendable writer)
          Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractListHolderStateObject
addChildren, addItem, addItems, addListChangeListener, areChildrenEquivalent, canMoveDown, canMoveUp, getItem, hasItems, initialize, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener, toStringItems
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.persistence.jpa.jpql.model.query.StateObject
addPropertyChangeListener, children, decorate, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
 

Field Detail

CLASS_NAME_PROPERTY

public static final java.lang.String CLASS_NAME_PROPERTY
Notifies the class name property has changed.

See Also:
Constant Field Values

CONSTRUCTOR_ITEMS_LIST

public static final java.lang.String CONSTRUCTOR_ITEMS_LIST
Notify the list of StateObjects representing the constructor items.

See Also:
Constant Field Values
Constructor Detail

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.Class<?> type)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
type - The fully qualified name of the Java class to instantiate
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.Class<?> type,
                                        java.util.List<? extends StateObject> constructorItems)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
type - The Java class to instantiate
constructorItems - The list of arguments
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.Class<?> type,
                                        java.lang.String jpqlFragment)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
type - The Java class to instantiate
jpqlFragment - The portion of the JPQL query that represents the constructor's arguments
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.String className)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
className - The fully qualified name of the Java class to instantiate
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.String className,
                                        java.util.List<? extends StateObject> constructorItems)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
className - The fully qualified name of the Java class to instantiate
constructorItems - The list of arguments
Throws:
java.lang.NullPointerException - The given parent cannot be null

ConstructorExpressionStateObject

public ConstructorExpressionStateObject(StateObject parent,
                                        java.lang.String className,
                                        java.lang.String jpqlFragment)
Creates a new ConstructorExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
className - The fully qualified name of the Java class to instantiate
jpqlFragment - The portion of the JPQL query that represents the constructor's arguments
Throws:
java.lang.NullPointerException - The given parent cannot be null
Method Detail

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

getClassName

public java.lang.String getClassName()
Returns the fully qualified class name that will be used to retrieve the constructor.

Returns:
The fully qualified class name or an empty string if it is not defined

getExpression

public ConstructorExpression getExpression()
Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Specified by:
getExpression in interface StateObject
Overrides:
getExpression in class AbstractStateObject
Returns:
The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

getType

public IType getType()
Returns the actual IType that was resolved or null if it could not be resolved.

Returns:
The actual IType

isEquivalent

public boolean isEquivalent(StateObject stateObject)
Description copied from class: AbstractStateObject
Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Specified by:
isEquivalent in interface StateObject
Overrides:
isEquivalent in class AbstractStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

listName

protected java.lang.String listName()
Returns the name that is uniquely identifying the list.

Specified by:
listName in class AbstractListHolderStateObject<StateObject>
Returns:
The unique name identifying the list

parse

public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents the constructor's arguments.

Parameters:
jpqlFragment - The JPQL fragment, which represents either a single or multiple arguments

resolveType

protected IType resolveType()
Resolves the actual IType based on the class name.

Returns:
The IType with the fully qualified class name

setClassName

public void setClassName(java.lang.CharSequence className)
Sets the fully qualified class name that will be used to retrieve the constructor.

Parameters:
className - The fully qualified class name

setClassName

public void setClassName(java.lang.Class<?> type)
Sets the fully qualified class name that will be used to retrieve the constructor.

Parameters:
type - The type used to retrieve its fully qualified class name

setClassNameInternally

protected void setClassNameInternally(java.lang.CharSequence className)
Sets the fully qualified class name that will be used to retrieve the constructor.

Parameters:
className - The fully qualified class name

setExpression

public void setExpression(ConstructorExpression expression)
Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.

Parameters:
expression - The parsed object representing a NEW expression

setType

public void setType(IType type)
Sets the actual IType and updates the class name.

Parameters:
type - The new IType

toTextInternal

protected void toTextInternal(java.lang.Appendable writer)
                       throws java.io.IOException
Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.

Specified by:
toTextInternal in class AbstractStateObject
Parameters:
writer - The writer used to print out the string representation
Throws:
java.io.IOException - This should never happens, it is only required because Appendable is used instead of any concrete class

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference