Class StandardColumnDescriptor

    • Constructor Detail

      • StandardColumnDescriptor

        public StandardColumnDescriptor​(int position,
                                        HeaderDescriptor header,
                                        java.lang.String expr)
                                 throws HeaderValidationException
        Self-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 header
        header - header instance this descriptor belongs
        expr - 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 HeaderValidationException
        Non-parsing constructor. (Used for XML) As above constructor but without creating modifier map (will be given as parameter).
        Parameters:
        position - position within header
        header - header instance this descriptor belongs
        expr - descriptor expression within header expression
        params - descriptor data holding modifier map
        Throws:
        HeaderValidationException - error while instantiation of instance
    • Method Detail

      • 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 located
        position - position of descriptor within header definition
        ownType - type declaration used in header definition
        qualifier - 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 UnresolvedValueException
        Translated the cell string value. Throws a UnresolvedValueException in 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 value
        forItem - 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 UnresolvedValueException
        Tries 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 UnresolvedValueException
        Returns 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 of ItemExpressionTranslator with null value.
        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 modifier ImpExConstants.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 invalid

        TODO 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 purposes
        value - 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:
        toString in class java.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: AbstractColumnDescriptor
        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).
        Overrides:
        getQualifier in class AbstractColumnDescriptor
        Returns:
        qualifier of this column