Class StandardColumnDescriptor
- java.lang.Object
-
- de.hybris.platform.impex.jalo.header.AbstractDescriptor
-
- de.hybris.platform.impex.jalo.header.AbstractColumnDescriptor
-
- de.hybris.platform.impex.jalo.header.StandardColumnDescriptor
-
- All Implemented Interfaces:
java.lang.Comparable<StandardColumnDescriptor>
public class StandardColumnDescriptor extends AbstractColumnDescriptor implements java.lang.Comparable<StandardColumnDescriptor>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
AbstractDescriptor.ColumnParams, AbstractDescriptor.DescriptorParams, AbstractDescriptor.HeaderParams
-
-
Constructor Summary
Constructors Constructor Description StandardColumnDescriptor(int position, HeaderDescriptor header, java.lang.String expr)Self-parsing constructor.StandardColumnDescriptor(int position, HeaderDescriptor header, java.lang.String expr, AbstractDescriptor.DescriptorParams params)Non-parsing constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.ObjectcalculateDefaultValue(Item existing)Determines the default value given with this descriptor.intcompareTo(StandardColumnDescriptor other)protected AbstractValueTranslatorcreateValueTranslator()Gets a value translator for translating values of this descriptor.java.lang.StringexportValue(java.lang.Object attributeValue)Tries to translate given attribute value to a string representing this value.static AttributeDescriptorfindAttributeDescriptor(HeaderDescriptor header, int position, java.lang.String ownType, java.lang.String qualifier)Tries to find the related attribute descriptor within composed type.static LanguagefindLanguage(HeaderDescriptor header, java.lang.String value)Tries to get the language given by iso code or PK as string.AttributeDescriptorgetAttributeDescriptor()Gets the related attribute descriptor within type.PKgetAttributeDescriptorPk()Gets the related attribute descriptor pk.java.lang.StringgetComposedTypeCode()Gets the type code specified in qualifier of this descriptor in header.java.lang.ObjectgetDefaultValue()Returns the default value associated with this descriptor.LanguagegetLanguage()Gets the language defined by language modifier.java.lang.StringgetLanguageIso()Deprecated.since ages - UsegetLanguageModifier()instead.java.lang.StringgetLanguageIsoCode()java.lang.StringgetLanguageModifier()java.lang.StringgetQualifier()Gets the qualifier of this column without prefix (If the qualifier is "Principal.uid", only "uid" will be returned, all until the first dot will be cut).java.lang.StringgetQualifierForComment()AbstractValueTranslatorgetValueTranslator()Returns the used translator instance for translating values.booleanhasDefaultValueDefinition()Checks whether the descriptor has given a default value or is virtual.java.lang.ObjectimportValue(java.lang.String cellValue, Item forItem)Translated the cell string value.booleanisAllowNull()Does the attribute allows null values?booleanisCaseInsensitiveStringAttribute()booleanisForceWrite()Should the attribute be updated even if it is read only?booleanisInitalOnly()Deprecated.since ages - UseisInitialOnly()insteadbooleanisInitialOnly()Is it an initial only attribute? (Not writable, not readable only and initial or just a PK).booleanisLocalized()Is it a localized descriptor?booleanisMandatory()Is it a mandatory attribute? (Not private and not optional).booleanisPartOf()Is it a part of attribute?booleanisReadable()Is it a readable attribute? (read flag is true).booleanisReadOnly()Is it a read only attribute? (Not writable, not initial and no PK).booleanisStringAttribute()booleanisUnique()Is it an unique attribute?booleanisVirtual()Is it a virtual attribute? (As values only default values are used)booleanisWritable()Is it a writable attribute? (write flag is true).java.lang.StringtoString()protected voidvalidate()-
Methods inherited from class de.hybris.platform.impex.jalo.header.AbstractColumnDescriptor
changePosition, createCSVDecorator, createTranslator, getCSVCellDecorator, getHeader, getValuePosition, shiftPosition
-
Methods inherited from class de.hybris.platform.impex.jalo.header.AbstractDescriptor
extractItemPathElements, extractModifiersMap, getDefinitionSrc, getDescriptorData, getDescriptorTranslator, parseColumnDescriptor, parseHeaderDescriptor
-
-
-
-
Constructor Detail
-
StandardColumnDescriptor
public StandardColumnDescriptor(int position, HeaderDescriptor header, java.lang.String expr) throws HeaderValidationExceptionSelf-parsing constructor. Instantiates a new descriptor instance with given expression. Modifier map will be created and related descriptor in target type and translator is determined.- Parameters:
position- position within headerheader- header instance this descriptor belongsexpr- descriptor expression within header expression- Throws:
HeaderValidationException- error while constructing descriptor
-
StandardColumnDescriptor
public StandardColumnDescriptor(int position, HeaderDescriptor header, java.lang.String expr, AbstractDescriptor.DescriptorParams params) throws HeaderValidationExceptionNon-parsing constructor. (Used for XML) As above constructor but without creating modifier map (will be given as parameter).- Parameters:
position- position within headerheader- header instance this descriptor belongsexpr- descriptor expression within header expressionparams- descriptor data holding modifier map- Throws:
HeaderValidationException- error while instantiation of instance
-
-
Method Detail
-
compareTo
public int compareTo(StandardColumnDescriptor other)
- Specified by:
compareToin interfacejava.lang.Comparable<StandardColumnDescriptor>
-
validate
protected void validate() throws HeaderValidationException- Overrides:
validatein classAbstractColumnDescriptor- Throws:
HeaderValidationException
-
findAttributeDescriptor
public static AttributeDescriptor findAttributeDescriptor(HeaderDescriptor header, int position, java.lang.String ownType, java.lang.String qualifier) throws HeaderValidationException
Tries to find the related attribute descriptor within composed type.- Parameters:
header- header where descriptor is locatedposition- position of descriptor within header definitionownType- type declaration used in header definitionqualifier- qualifier of the descriptor (for this qualifier is searched within all descriptors of given type)- Returns:
- related attribute descriptor within type or null if not existent
- Throws:
HeaderValidationException- error while determining descriptor like type is not existent
-
createValueTranslator
protected AbstractValueTranslator createValueTranslator() throws HeaderValidationException
Gets a value translator for translating values of this descriptor. If a custom translator is given in modifiers, this will be returned, else a translator appropriate to the attribute type.- Returns:
- value translator for translation of values
- Throws:
HeaderValidationException- illegal attribute type or malformed custom translator string
-
importValue
public final java.lang.Object importValue(java.lang.String cellValue, Item forItem) throws UnresolvedValueExceptionTranslated the cell string value. Throws aUnresolvedValueExceptionin the following cases:- the non-empty cell value could not resolved e.g. item reference did not locate a existing item
- the language configured for this column doesnt exist (yet)
- the cell value was empty but the configured default value string could not be resolved
- Parameters:
cellValue- the cell string valueforItem- the target item (optional: only if it already exists)- Returns:
- the translated value
- Throws:
UnresolvedValueException- see above
-
exportValue
public java.lang.String exportValue(java.lang.Object attributeValue) throws UnresolvedValueExceptionTries to translate given attribute value to a string representing this value.- Parameters:
attributeValue- attribute to translate- Returns:
- resulting string representing given attribute value
- Throws:
UnresolvedValueException- attribute can not be translated
-
hasDefaultValueDefinition
public boolean hasDefaultValueDefinition()
Checks whether the descriptor has given a default value or is virtual.- Returns:
- true if descriptor delivers a default value, otherwise false
-
getDefaultValue
public java.lang.Object getDefaultValue() throws UnresolvedValueExceptionReturns the default value associated with this descriptor.- Returns:
- default value or null if no value is given
- Throws:
UnresolvedValueException- default value can not be translated to an attribute
-
calculateDefaultValue
public java.lang.Object calculateDefaultValue(Item existing) throws UnresolvedValueException
Determines the default value given with this descriptor. Checks the modifier for an default definition and translates it. If not provided and descriptor virtual, it tries to construct from sub-default values using import function ofItemExpressionTranslatorwithnullvalue.- Parameters:
existing- existing item in case of part of- Returns:
- default value translated
- Throws:
UnresolvedValueException- default value definition can not be resolved to an existing value
-
getAttributeDescriptor
public AttributeDescriptor getAttributeDescriptor()
Gets the related attribute descriptor within type.- Returns:
- the attribute descriptor this descriptor is mapped to
-
getAttributeDescriptorPk
public PK getAttributeDescriptorPk()
Gets the related attribute descriptor pk.- Returns:
- the attribute descriptor pk
-
getComposedTypeCode
public java.lang.String getComposedTypeCode()
Gets the type code specified in qualifier of this descriptor in header.- Returns:
- code of defined type in qualifier or null, if qualifier was given without type code.
-
isLocalized
public boolean isLocalized()
Is it a localized descriptor?- Returns:
- true if descriptor is localized, false otherwise
-
isMandatory
public boolean isMandatory()
Is it a mandatory attribute? (Not private and not optional).- Returns:
- true if descriptor is mandatory, false otherwise
-
isUnique
public boolean isUnique()
Is it an unique attribute?- Returns:
- true if modifiers declare attribute UNIQUE, false otherwise
-
isVirtual
public boolean isVirtual()
Is it a virtual attribute? (As values only default values are used)- Returns:
- true if modifiers declare attribute VIRTUAL, false otherwise
-
isAllowNull
public boolean isAllowNull()
Does the attribute allows null values?- Returns:
- true if modifiers declare attribute ALLOW_NULL, false otherwise
-
isForceWrite
public boolean isForceWrite()
Should the attribute be updated even if it is read only?- Returns:
- true if modifiers declare attribute FORCE_WRITE, false otherwise
-
getLanguageIso
@Deprecated public java.lang.String getLanguageIso()
Deprecated.since ages - UsegetLanguageModifier()instead.Gets the value of modifierImpExConstants.Syntax.Modifier.LANGUAGE.- Returns:
- the set value of language modifier, null if no value is set (may be session language should be used)
-
getLanguageModifier
public java.lang.String getLanguageModifier()
-
getLanguageIsoCode
public java.lang.String getLanguageIsoCode()
-
isStringAttribute
public boolean isStringAttribute()
-
isCaseInsensitiveStringAttribute
public boolean isCaseInsensitiveStringAttribute()
-
getLanguage
public Language getLanguage() throws HeaderValidationException
Gets the language defined by language modifier.- Returns:
- the configured language; may be null if session language should be used
- Throws:
HeaderValidationException- specified language is invalidTODO replace it with Model method
-
findLanguage
public static Language findLanguage(HeaderDescriptor header, java.lang.String value) throws HeaderValidationException
Tries to get the language given by iso code or PK as string.- Parameters:
header- header instance for logging purposesvalue- iso code or pk string of needed language- Returns:
- language found instance
- Throws:
HeaderValidationException- iso code or PK string is not valid
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isInitalOnly
@Deprecated public boolean isInitalOnly()
Deprecated.since ages - UseisInitialOnly()instead
-
isInitialOnly
public boolean isInitialOnly()
Is it an initial only attribute? (Not writable, not readable only and initial or just a PK).- Returns:
- true if attribute is initial only, false otherwise
-
isReadOnly
public boolean isReadOnly()
Is it a read only attribute? (Not writable, not initial and no PK).- Returns:
- true if attribute is read only, otherwise false
-
isReadable
public boolean isReadable()
Is it a readable attribute? (read flag is true).- Returns:
- true if attribute is readable, otherwise false
-
isWritable
public boolean isWritable()
Is it a writable attribute? (write flag is true).- Returns:
- true if attribute is writable, otherwise false
-
isPartOf
public boolean isPartOf()
Is it a part of attribute?- Returns:
- true if it is part of, otherwise false
-
getValueTranslator
public AbstractValueTranslator getValueTranslator()
Returns the used translator instance for translating values.- Returns:
- used translator
-
getQualifier
public java.lang.String getQualifier()
Description copied from class:AbstractColumnDescriptorGets the qualifier of this column without prefix (If the qualifier is "Principal.uid", only "uid" will be returned, all until the first dot will be cut).- Overrides:
getQualifierin classAbstractColumnDescriptor- Returns:
- qualifier of this column
-
getQualifierForComment
public java.lang.String getQualifierForComment()
- Overrides:
getQualifierForCommentin classAbstractColumnDescriptor
-
-