Package de.hybris.platform.jalo.type
Class CollectionType
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable
public class CollectionType extends Type
A type representing a typed collection.The actual type of the collection may be one of the following:
- collection ( use
COLLECTION) - set ( use
SET) which contains unique elements - list ( use
LIST) which is ordered
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCollectionType.CollectionTypeImplThe presistence layer implementation interface.-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.type.Type
Type.TypeImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.type.TypeManagerManaged
TypeManagerManaged.TypeManagerManagedImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImpl
-
Nested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException
-
-
Field Summary
Fields Modifier and Type Field Description static intCOLLECTIONThe default collection type constants.static java.lang.StringCOLLECTION_ENUM_CODEThe default collection enum code .static java.lang.StringELEMENT_TYPEThe collection element type attribute string constant.static intLISTThe list collection type constants.static java.lang.StringLIST_ENUM_CODEThe list collection enum code.static intSETThe set collection type constants.static java.lang.StringSET_ENUM_CODEThe set collection enum code.static intSORTED_SETDeprecated.since agesstatic java.lang.StringSORTED_SET_ENUM_CODEDeprecated.since agesstatic java.lang.StringTYPE_OF_COLLECTIONThe type of collection attribute string constant.static java.lang.StringTYPE_OF_COLLECTION_ENUM_CODEThe code of the typeOfCollection enumeration type.static java.lang.StringTYPE_OF_COLLECTION_INTERNALThe internal type of collection attribute string constant.-
Fields inherited from class de.hybris.platform.jalo.type.Type
CODE, DEFAULTVALUE, DESCRIPTION, XMLDEFINITION
-
Fields inherited from class de.hybris.platform.jalo.type.TypeManagerManaged
AUTOCREATE, DEPRECATED, EXTENSION_NAME, GENERATE, NAME
-
Fields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLED
-
Fields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPE
-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description CollectionType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intconvertTypeOfCollectionEnumToInt(EnumerationValue enumeration)Converts typeOfCollection enums into intern int codes.protected EnumerationValueconvertTypeOfCollectionIntToEnum(int type)Converts typeOfCollection internal int representation int enum values.protected ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes)Generic item creation method.protected static java.lang.StringescapeForCollection(java.lang.String raw)java.lang.StringexportXMLDefinition(org.znerd.xmlenc.XMLOutputter xout)protected CollectionType.CollectionTypeImplgetCollectionTypeImpl()Internal access to persistence layer implementation.TypegetElementType()Returns the type of the elements of this collection type.TypegetElementType(SessionContext ctx)Returns the type of the elements of this collection.static int[]getEscapedCollectionPositions(java.lang.String escaped, int startFrom)protected Item.ItemAttributeMapgetNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)Cuts the following attribute values which are already set during actual item creation:Type.CODEELEMENT_TYPETYPE_OF_COLLECTIONintgetTypeOfCollection()EnumerationValuegetTypeOfCollectionEnum()Returns the type of this collection as enumeration value.java.lang.StringgetXMLDefinition()Assembles the XML definition string to put inside aitems.xml.booleanisAssignableFrom(Type type)Tests whether this collection type is assignable from another collection type.booleanisInstance(java.lang.Object o)Tests if a given object is instance of this collection type.protected booleanisTypeAssignableFrom(int type1, int type2)Checks assignability between types of collection:COLLECTIONis assignable from allSETis assignable fromSETandSORTED_SETLISTis assignable fromLISTandSORTED_SETSORTED_SETis assignable fromSORTED_SETonlyjava.util.CollectionnewInstance()Returns an empty collection if the specified type (see @link #getTypeOfCollection()}).java.lang.ObjectparseValue(SessionContext ctx, java.lang.String value)reads a collection of '(' + escaped element string + ')'.java.lang.StringtoString(SessionContext ctx, java.lang.Object value)Writes a collection as '(' + escaped element string + ')'.protected static java.lang.StringunescapeForCollection(java.lang.String escaped)-
Methods inherited from class de.hybris.platform.jalo.type.Type
compareTo, getAllDescriptions, getAllDescriptions, getCode, getDefaultValue, getDefaultValue, getDescription, getDescription, getTypeImpl, setAllDescriptions, setAllDescriptions, setDefaultValue, setDefaultValue, setDescription, setDescription, toString
-
Methods inherited from class de.hybris.platform.jalo.type.TypeManagerManaged
getAllNames, getAllNames, getExtensionName, getImpl, getName, getName, isAutocreate, isDeprecated, isGenerate, setAllNames, setAllNames, setAutocreate, setExtensionName, setGenerate, setName, setName
-
Methods inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedProperty
-
Methods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getImplementation, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setProperty
-
Methods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getDefaultAttributeModes, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRelatedItems, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isMarkModifiedDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setRelatedItems, setTransientObject, setUseTA, useTA, writeReplace
-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
Field Detail
-
TYPE_OF_COLLECTION_ENUM_CODE
public static final java.lang.String TYPE_OF_COLLECTION_ENUM_CODE
The code of the typeOfCollection enumeration type.- See Also:
getTypeOfCollectionEnum(), Constant Field Values
-
COLLECTION
public static final int COLLECTION
The default collection type constants.- See Also:
getTypeOfCollection(), Constant Field Values
-
COLLECTION_ENUM_CODE
public static final java.lang.String COLLECTION_ENUM_CODE
The default collection enum code .- See Also:
getTypeOfCollectionEnum(), Constant Field Values
-
SET
public static final int SET
The set collection type constants.- See Also:
getTypeOfCollection(), Constant Field Values
-
SET_ENUM_CODE
public static final java.lang.String SET_ENUM_CODE
The set collection enum code.- See Also:
getTypeOfCollectionEnum(), Constant Field Values
-
LIST
public static final int LIST
The list collection type constants.- See Also:
- Constant Field Values
-
LIST_ENUM_CODE
public static final java.lang.String LIST_ENUM_CODE
The list collection enum code.- See Also:
getTypeOfCollectionEnum(), Constant Field Values
-
SORTED_SET
@Deprecated public static final int SORTED_SET
Deprecated.since agesThe sorted set collection type constants.- See Also:
getTypeOfCollection(), Constant Field Values
-
SORTED_SET_ENUM_CODE
@Deprecated public static final java.lang.String SORTED_SET_ENUM_CODE
Deprecated.since agesThe sorted set collection enum code.- See Also:
getTypeOfCollectionEnum(), Constant Field Values
-
ELEMENT_TYPE
public static final java.lang.String ELEMENT_TYPE
The collection element type attribute string constant.- See Also:
- Constant Field Values
-
TYPE_OF_COLLECTION
public static final java.lang.String TYPE_OF_COLLECTION
The type of collection attribute string constant.- See Also:
- Constant Field Values
-
TYPE_OF_COLLECTION_INTERNAL
public static final java.lang.String TYPE_OF_COLLECTION_INTERNAL
The internal type of collection attribute string constant.Since this attribute is private is may only be used for FlexibleSearch queries like this example:
"... WHERE {" + CollectionType.TYPE_OF_COLLECTION_INTERNAL + "} = " + CollectionType.SET + " ..."Its value can be retrieved manually by
getTypeOfCollection().- See Also:
- Constant Field Values
-
-
Method Detail
-
convertTypeOfCollectionEnumToInt
protected int convertTypeOfCollectionEnumToInt(EnumerationValue enumeration) throws JaloInvalidParameterException
Converts typeOfCollection enums into intern int codes.- Throws:
JaloInvalidParameterException
-
convertTypeOfCollectionIntToEnum
protected EnumerationValue convertTypeOfCollectionIntToEnum(int type) throws JaloInvalidParameterException
Converts typeOfCollection internal int representation int enum values.- Throws:
JaloInvalidParameterException
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
Generic item creation method.Requires the following attributes:
Optionally the type of collection may be defined byTYPE_OF_COLLECTION.- Specified by:
createItemin classItem- Parameters:
ctx- the current session context which this item is created withintype- the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )- Returns:
- the new item instance
- Throws:
JaloBusinessException- indicates an error during creation - any changes will be rollbacked
-
getNonInitialAttributes
protected Item.ItemAttributeMap getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)
Cuts the following attribute values which are already set during actual item creation:- Overrides:
getNonInitialAttributesin classItem- Parameters:
ctx- session context with language = NULLallAttributes- aItemAttributeMapcontaning attribute values.- Returns:
- a
ItemAttributeMapcontaining all attribute values, which belong to non-initial attributes.
-
toString
public java.lang.String toString(SessionContext ctx, java.lang.Object value) throws JaloInvalidParameterException
Writes a collection as '(' + escaped element string + ')'. The element string representation is escaped so that each occurence of '(', ')' or ',' is prepended by a '\'.- Specified by:
toStringin classType- Throws:
JaloInvalidParameterException- Since:
- 2.10
-
getEscapedCollectionPositions
public static int[] getEscapedCollectionPositions(java.lang.String escaped, int startFrom)- Since:
- 2.10
-
escapeForCollection
protected static final java.lang.String escapeForCollection(java.lang.String raw)
- Since:
- 2.10
-
unescapeForCollection
protected static final java.lang.String unescapeForCollection(java.lang.String escaped)
- Since:
- 2.10
-
parseValue
public java.lang.Object parseValue(SessionContext ctx, java.lang.String value) throws JaloInvalidParameterException
reads a collection of '(' + escaped element string + ')'. The element string representation must be escaped so that each occurence of '(', ')' or ',' is prepended by a '\'.- Specified by:
parseValuein classType- Throws:
JaloInvalidParameterException- Since:
- 2.10
-
getElementType
public Type getElementType()
Returns the type of the elements of this collection type.
-
getElementType
public Type getElementType(SessionContext ctx)
Returns the type of the elements of this collection.
-
getTypeOfCollection
public int getTypeOfCollection()
- Returns:
- the internal type of the collection as one of
SET,LIST,COLLECTION.
-
getTypeOfCollectionEnum
public EnumerationValue getTypeOfCollectionEnum()
Returns the type of this collection as enumeration value. The enumeration type can be retrieved using ist code constantTYPE_OF_COLLECTION_ENUM_CODE. Its values got the codes
-
newInstance
public java.util.Collection newInstance()
Returns an empty collection if the specified type (see @link #getTypeOfCollection()}).
-
getXMLDefinition
public java.lang.String getXMLDefinition()
Assembles the XML definition string to put inside aitems.xml.- Specified by:
getXMLDefinitionin classType
-
exportXMLDefinition
public java.lang.String exportXMLDefinition(org.znerd.xmlenc.XMLOutputter xout)
- Specified by:
exportXMLDefinitionin classTypeManagerManaged
-
getCollectionTypeImpl
protected CollectionType.CollectionTypeImpl getCollectionTypeImpl()
Internal access to persistence layer implementation.
-
isAssignableFrom
public boolean isAssignableFrom(Type type)
Tests whether this collection type is assignable from another collection type. This is only true if this type's element type is assignable from the other collection type's element type and the type of collections are assignable.- Specified by:
isAssignableFromin classType- Parameters:
type- the type to be checked.- See Also:
isTypeAssignableFrom(int, int)
-
isTypeAssignableFrom
protected boolean isTypeAssignableFrom(int type1, int type2)Checks assignability between types of collection:-
COLLECTIONis assignable from all -
SETis assignable fromSETandSORTED_SET -
LISTis assignable fromLISTandSORTED_SET -
SORTED_SETis assignable fromSORTED_SETonly
-
-
isInstance
public boolean isInstance(java.lang.Object o)
Tests if a given object is instance of this collection type. This checks the type of collection and each element of being instance of the element type.Since all elements are checked this method is considerably costly so use with care!
- Specified by:
isInstancein classType- Parameters:
o- the object to be checked.
-
-