Package org.apache.openjpa.kernel
Class ResultShape<T>
- java.lang.Object
- 
- org.apache.openjpa.kernel.ResultShape<T>
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 public class ResultShape<T> extends java.lang.Object implements java.io.SerializableDescribes the shape of a query result.
 A shape is described as a Java class by the generic type argument T. A shape may contain zero or more shapes. A shape is categorized as follows:
- A primitive shape can not have child shapes e.g. Foo or float.
- A compound shape has zero or more child shapes e.g. Foo{} or Foo{String, int} or Foo{String,Bar{Double},int}.
- A nesting shape has one or more compound child shape(s). For example, Foo{String,Bar{Double},int}. On the other hand, Foo{String, int} is a compound shape but is not nesting because all its child shapes are primitive.
 A primitive category shape is declared during construction and immutable. The category of a non-primitive shape is mutable.
 Notice that all nested shapes are compound shapes but not all compound shapes are nesting.
 A compound shape can add other primitive shapes or nest other shapes to any arbitrary depth. However, a shape does not allow recursive nesting of shapes.
 Usage: The purpose of a shape is to populate an instance of T from an array of input values where each array element is further specified with a type and an alias. FillStrategy determines how a shape populates an instance of T by consuming the input array element values. The input data is presented as an Object[] with a parallel array of types because the primitive types (short, float etc.) are not preserved in the input array. For certain FillStrategy such as MAP or BEAN, the alias of the input array element are used to identify the Map key or setter methods respectively.- Since:
- 2.0.0
- Author:
- Pinaki Poddar
- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description ResultShape(java.lang.Class<T> cls)Construct a non-primitive shape with ASSIGN or ARRAY fill strategy.ResultShape(java.lang.Class<T> cls, boolean primitive)Construct a primitive or non-primitive shape with ASSIGN or ARRAY fill strategy.ResultShape(java.lang.Class<T> cls, FillStrategy<T> strategy)Construct a non-primitive shape with the given fill strategy.ResultShape(java.lang.Class<T> cls, FillStrategy<T> strategy, boolean primitive)Construct a shape with the given fill strategy.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultShape<T>add(java.lang.Class<?>... classes)Adds the given classes as child shapes of this shape.intargLength()Total number of arguments required to populate the shape and all its child shapes.java.lang.StringgetAlias()java.util.List<ResultShape<?>>getChildren()Gets all the child shapes.java.util.List<java.lang.Class<?>>getCompositeTypes()Gets the list of classes to compose this shape and all its children.java.util.Set<ResultShape<?>>getParents()Gets the immediate parents of this shape.FillStrategy<T>getStrategy()java.lang.Class<T>getType()Gets the type of instance populated by this shape.java.util.List<java.lang.Class<?>>getTypes()Gets the list of classes to compose this shape only i.e. without expanding the children's shape.booleanisCompound()Affirms if this shape can have child shapes.booleanisNested()Affirms if this shape is nested within other shapes.booleanisNesting()Affirms if at least one child shape of this shape is a compound shape.booleanisParent(ResultShape<?> p)Affirms if the given shape is a parent (or grandparent) of this shape.booleanisPrimitive()Affirms if this shape can not have any child shape.intlength()Number of arguments to populate this shape only.<X> ResultShape<X>nest(java.lang.Class<X> cls, FillStrategy strategy, java.lang.Class<?>... classes)Creates a new shape of type X with the given class arguments and nests the new shape within this shape.ResultShape<T>nest(ResultShape<?> shape)Nest the given shape.Tpack(java.lang.Object[] values, java.lang.Class<?>[] types, java.lang.String[] aliases)Fill this shape and its children with the given array element values.ResultShape<T>setAlias(java.lang.String alias)java.lang.StringtoString()Gets a human-readable representation of this shape.
 
- 
- 
- 
Constructor Detail- 
ResultShapepublic ResultShape(java.lang.Class<T> cls) Construct a non-primitive shape with ASSIGN or ARRAY fill strategy.
 - 
ResultShapepublic ResultShape(java.lang.Class<T> cls, boolean primitive) Construct a primitive or non-primitive shape with ASSIGN or ARRAY fill strategy. If the shape is declared as primitive then the given class can not be an array.
 - 
ResultShapepublic ResultShape(java.lang.Class<T> cls, FillStrategy<T> strategy) Construct a non-primitive shape with the given fill strategy.
 - 
ResultShapepublic ResultShape(java.lang.Class<T> cls, FillStrategy<T> strategy, boolean primitive) Construct a shape with the given fill strategy.
 
- 
 - 
Method Detail- 
getTypepublic java.lang.Class<T> getType() Gets the type of instance populated by this shape.
 - 
getStrategypublic FillStrategy<T> getStrategy() 
 - 
setAliaspublic ResultShape<T> setAlias(java.lang.String alias) 
 - 
getAliaspublic java.lang.String getAlias() 
 - 
getCompositeTypespublic java.util.List<java.lang.Class<?>> getCompositeTypes() Gets the list of classes to compose this shape and all its children. For example, a shape Foo{String,Bar{int, Date}, Double} will return {String, int, Date, Double}
 - 
getTypespublic java.util.List<java.lang.Class<?>> getTypes() Gets the list of classes to compose this shape only i.e. without expanding the children's shape. For example, a shape Foo{String,Bar{int, Date}, Double} will return {String, Bar, Double}
 - 
nestpublic <X> ResultShape<X> nest(java.lang.Class<X> cls, FillStrategy strategy, java.lang.Class<?>... classes) Creates a new shape of type X with the given class arguments and nests the new shape within this shape.- Returns:
- newly created nested shape
 
 - 
nestpublic ResultShape<T> nest(ResultShape<?> shape) Nest the given shape.- Parameters:
- shape- The given shape can not be a parent of this shape to prohibit recursive nesting.
- Returns:
- this shape itself
 
 - 
addpublic ResultShape<T> add(java.lang.Class<?>... classes) Adds the given classes as child shapes of this shape. The child shapes are primitive shapes.
 - 
getChildrenpublic java.util.List<ResultShape<?>> getChildren() Gets all the child shapes.
 - 
isCompoundpublic boolean isCompound() Affirms if this shape can have child shapes.
 - 
isPrimitivepublic boolean isPrimitive() Affirms if this shape can not have any child shape. A primitive shape uses ASSIGN strategy.
 - 
isNestingpublic boolean isNesting() Affirms if at least one child shape of this shape is a compound shape.
 - 
isNestedpublic boolean isNested() Affirms if this shape is nested within other shapes.
 - 
isParentpublic boolean isParent(ResultShape<?> p) Affirms if the given shape is a parent (or grandparent) of this shape.
 - 
getParentspublic java.util.Set<ResultShape<?>> getParents() Gets the immediate parents of this shape.
 - 
argLengthpublic int argLength() Total number of arguments required to populate the shape and all its child shapes.
 - 
lengthpublic int length() Number of arguments to populate this shape only.
 - 
packpublic T pack(java.lang.Object[] values, java.lang.Class<?>[] types, java.lang.String[] aliases) Fill this shape and its children with the given array element values. The parallel arrays contain the actual values, the types of these values and aliases. The type and alias information are used for packing Map or invoking constructor. The type can be different from what can be determined from array elements because of boxing of primitive types. The actual constructor argument types are sourced from types[] array.
 - 
toStringpublic java.lang.String toString() Gets a human-readable representation of this shape.- Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-