Class Feature<T>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    TypedFeature, UntypedFeature

    @Deprecated
    public abstract class Feature<T>
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    Deprecated.
    since ages - useFeature instead.
    Describes all single values belonging to one product feature. This may be prepresented by a ClassAttributeAssignment or simply a unique qualifier.

    To add new values use the creation methods like this:

            Feature<String> f = ...;
        FeatureValue<String> newOne = f.createValue( "Blah" );
        newOne.setDescription("This is just a test");
        // another way
        List<FeatureValue> newOnes = f.createValues( "foo", "bar" );
    
        // to fetch all value objects
        List<FeatureValue> fValues = f.getValues();
        // to fetch just plain values directly (without value object)
        List<String> stringValues = f.getValuesDirect();
     

    Please note that any changes made to one instance are not automatically persistet (contrary to normal Item behaviour) - see FeatureContainer for how to store and load feature values.

    There are some shortcut methods for single-feature management as well:

            Product p = // my product
            ClassAttributeAssignment asgnmt = // my assigned attribute
            // assuming that we've got a number attribute:
            TypedFeature<Number> feat = Feature.loadTyped( p, asgnmt );
            // delete existing values
            feat.clearAll();
            // add some new values
            feat.createValues( 123.45, 0.815, 555 );
            // now store it by using automatically created container
            feat.getParent().store();
     
    See Also:
    FeatureContainer, FeatureValue, Serialized Form
    • Constructor Detail

      • Feature

        protected Feature​(FeatureContainer parent,
                          boolean localized)
        Deprecated.
      • Feature

        protected Feature​(Feature<T> src)
                   throws java.lang.CloneNotSupportedException
        Deprecated.
        Clone constructor.
        Throws:
        java.lang.CloneNotSupportedException
    • Method Detail

      • loadTyped

        public static <X> TypedFeature<X> loadTyped​(Product product,
                                                    ClassAttributeAssignment assignment)
        Deprecated.
        Shortcut to manage just a single typed feature. This will automatically create a FeatureContainer which is limited to this class-attribute assignment only.
        Parameters:
        product - the product to manage the feature (-values) for
        assignment - the class-attribute assignment to manage
        Returns:
        the new typed feature
      • loadTyped

        public static <X> TypedFeature<X> loadTyped​(Product product,
                                                    ClassificationAttribute attr)
                                             throws JaloInvalidParameterException
        Deprecated.
        Shortcut to manage just a single typed feature. This will automatically create a FeatureContainer which is limited to this attribute only.
        Parameters:
        product - the product to manage the feature (-values) for
        attr - the attribute to manage
        Returns:
        the new typed feature
        Throws:
        JaloInvalidParameterException - if the attribute is actually not assigned to any of the product's classes or if the attribute is ambiguous since there are multiple assignments
      • toString

        public java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object
      • getParent

        public FeatureContainer getParent()
        Deprecated.
        Returns the containing feature container.
      • setLocalized

        public void setLocalized​(boolean isLocalized)
        Deprecated.
        Changes localization statuc of this feature.

        Please note that this will modify the contained values: if the feature is made unlocalized all language dependent values are merged together into one value list. So eetting the feature localized again wont restore the original language-value mappings!

        Parameters:
        isLocalized - switches localization on or off
      • isLocalized

        public boolean isLocalized()
        Deprecated.
        Tells whether or not the feature is able to hold different values per session language.

        This means all value getter and setter methods ( e.g. getValues(SessionContext)) work upon different value lists according to the session language specified within the session context or current session language where no context is specified.

      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Tells whether or not the feature holds values.

        Please note that this method respects the localization status. So for localized features it will only tell if there are no values within the value list belonging to the current session language!

        See Also:
        isEmptyIgnoringLanguage()
      • isEmpty

        public boolean isEmpty​(SessionContext ctx)
        Deprecated.
        Tells whether or not the feature holds values.

        Please note that this method respects the localization status. So for localized features it will only tell if there are no values within the value list belonging to the specified session language!

        Parameters:
        ctx - the session context defining the value list session language
        See Also:
        isEmptyIgnoringLanguage()
      • isEmptyIgnoringLanguage

        public boolean isEmptyIgnoringLanguage()
        Deprecated.
        Tells whether or not the feature holds any value at all, regardless of any localization settings. So as soon as a localized feature holds at least one value in one language dependent value list this method will return true.
      • clone

        public abstract Feature clone()
                               throws java.lang.CloneNotSupportedException
        Deprecated.
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • hashCode

        public final int hashCode()
        Deprecated.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object obj)
        Deprecated.
        Overrides:
        equals in class java.lang.Object
      • createValue

        public FeatureValue<T> createValue​(T value)
        Deprecated.
        Creates a new value for this feature. The value is appended to the existing values list (for the current session language if the feature is localized).
        Parameters:
        value - the new value
        Returns:
        the value object
      • createValue

        public FeatureValue<T> createValue​(SessionContext ctx,
                                           T value)
        Deprecated.
        Creates a new value for this feature. The value is appended to the existing values list ( for the specified session language if the feature is localized).
        Parameters:
        value - the new value
        ctx - the context specifying the session language
        Returns:
        the value object
      • createValues

        public java.util.List<FeatureValue<T>> createValues​(java.util.Collection<T> values)
        Deprecated.
        Creates a list of new values for this feature. These values are appended to the existing values list for the current session language (if localized).
        Parameters:
        values - the new values
        Returns:
        the value objects
      • createValues

        public java.util.List<FeatureValue<T>> createValues​(SessionContext ctx,
                                                            java.util.Collection<T> values)
        Deprecated.
        Creates a list of new values for this feature. These values are appended to the existing values list for the specified session language (if localized).
        Parameters:
        values - the new values
        ctx - the context specifying the session language
        Returns:
        the value objects
      • createValues

        public java.util.List<FeatureValue<T>> createValues​(T... values)
        Deprecated.
        Creates a list of new values for this feature. These values are appended to the existing values list for the current session language (if localized).
        Parameters:
        values - the new values
        Returns:
        the value objects
      • createValues

        public java.util.List<FeatureValue<T>> createValues​(SessionContext ctx,
                                                            T... values)
        Deprecated.
        Creates a list of new values for this feature. These values are appended to the existing values list for the specified session language (if localized).
        Parameters:
        values - the new values
        ctx - the context specifying the session language
        Returns:
        the value objects
      • createValue

        public FeatureValue<T> createValue​(int index,
                                           T value)
        Deprecated.
        Creates a new value for this feature. The value is inserted into the existing values list for the specified session language.
        Parameters:
        value - the new value
        index - the position to insert the new value at
        Returns:
        the value object
      • createValue

        public abstract FeatureValue<T> createValue​(SessionContext ctx,
                                                    int index,
                                                    T value)
        Deprecated.
        Creates a new value for this feature. The value is inserted into the existing values list for the specified session language.
        Parameters:
        value - the new value
        ctx - the context specifying the session language
        index - the position to insert the new value at
        Returns:
        the value object
      • setValues

        public java.util.List<FeatureValue<T>> setValues​(T... values)
        Deprecated.
        Replaces all current feature values by newly create ones for the given list of value objects. For localized features this will replace the values belonging to the current session language.
        Parameters:
        values - the raw value objects to wrap inside FeatureValue instances
        Returns:
        the new FeatureValue instances
      • setValues

        public java.util.List<FeatureValue<T>> setValues​(SessionContext ctx,
                                                         T... values)
        Deprecated.
        Replaces all current feature values by newly create ones for the given list of value objects.
        Parameters:
        ctx - the session context to specify the session language ( for localized features only)
        values - the raw value objects to wrap inside FeatureValue instances
        Returns:
        the new FeatureValue instances
      • setValues

        public java.util.List<FeatureValue<T>> setValues​(java.util.List<T> values)
        Deprecated.
        Replaces all current feature values by newly create ones for the given list of value objects. For localized features this will replace the values belonging to the current session language.
        Parameters:
        values - the raw value objects to wrap inside FeatureValue instances
        Returns:
        the new FeatureValue instances
      • setValues

        public java.util.List<FeatureValue<T>> setValues​(SessionContext ctx,
                                                         java.util.List<T> values)
        Deprecated.
        Replaces all current feature values by newly create ones for the given list of value objects.
        Parameters:
        ctx - specifies the session language (for localized features only)
        values - the raw value objects to wrap inside FeatureValue instances
        Returns:
        the new FeatureValue instances
      • setValue

        public FeatureValue<T> setValue​(T value)
        Deprecated.
        Replaces all current feature values by a single newly create one for the given value object. For localized features this will replace all values belonging to the current session language.
        Parameters:
        value - the raw value object to wrap inside a new FeatureValue
        Returns:
        the new FeatureValue instance
      • setValue

        public FeatureValue<T> setValue​(SessionContext ctx,
                                        T value)
        Deprecated.
        Replaces all current feature values by a single newly create one for the given value object.
        Parameters:
        ctx - specifies the session language (for localized features only)
        value - the raw value object to wrap inside a new FeatureValue
        Returns:
        the new FeatureValue instance
      • clearAll

        public void clearAll()
        Deprecated.
        Clears all values of this feature regardless of the session language.
      • clear

        public void clear()
        Deprecated.
        Clears all values (for the current session languge if localized).
      • clear

        public void clear​(SessionContext ctx)
        Deprecated.
        Clears all values (for the specified session languge if localized).
        Parameters:
        ctx - the session context defining the session language
      • getValue

        public FeatureValue<T> getValue​(int index)
                                 throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Returns the value at a given position for the current session language.
        Parameters:
        index -
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
      • getValue

        public FeatureValue<T> getValue​(SessionContext ctx,
                                        int index)
                                 throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Returns the value at a given position for the specified session language.
        Parameters:
        index -
        ctx - the session context defining the language to get values for
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
      • isFallbackEnabled

        protected boolean isFallbackEnabled​(SessionContext ctx)
        Deprecated.
      • moveValue

        public void moveValue​(int index,
                              FeatureValue<T> featureValue)
                       throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Moves a value to a given position within the current session language.
        Parameters:
        index -
        featureValue - the new value to set
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
      • moveValue

        public void moveValue​(SessionContext ctx,
                              int index,
                              FeatureValue<T> featureValue)
                       throws java.lang.IndexOutOfBoundsException,
                              JaloInvalidParameterException
        Deprecated.
        Moves a value to a given position within the specified session language.
        Parameters:
        index -
        ctx - the session context defining the language to set values for
        featureValue - the new value to set
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
        JaloInvalidParameterException - if the feature value doesnt belong to this feature
      • removeValue

        public boolean removeValue​(FeatureValue<T> featureValue)
        Deprecated.
        Removes a given value from the values of the current session language.
        Parameters:
        featureValue - the value to remove
        Returns:
        true if the value actually belonged to the value list, false otherwise
      • remove

        public boolean remove​(SessionContext ctx,
                              FeatureValue<T> featureValue)
                       throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Removes a given value from the values of the given session language.
        Parameters:
        ctx - the session context defining the language to remove values for
        featureValue - the value to remove
        Returns:
        true if the value actually belonged to the value list, false otherwise
        Throws:
        java.lang.IndexOutOfBoundsException
      • remove

        public FeatureValue<T> remove​(int index)
                               throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Removes the value at a given position from the values of the current session language.
        Parameters:
        index - the value position
        Returns:
        the value stored at this position
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
      • remove

        public FeatureValue<T> remove​(SessionContext ctx,
                                      int index)
                               throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Removes the value at a given position from the values of the given session language.
        Parameters:
        ctx - the session context defining the language to remove values for
        index - the value position
        Returns:
        the value stored at this position
        Throws:
        java.lang.IndexOutOfBoundsException - if the index exceeds the current value list dimensions
      • size

        public int size()
        Deprecated.
        Returns the amount of values stored inside this feature (for the current session language if localized).
      • size

        public int size​(SessionContext ctx)
        Deprecated.
        Returns the amount of values stored inside this feature (for the specified session language if localized).
        Parameters:
        ctx - the session context specifiying the session language to count values for
      • getValues

        public java.util.List<FeatureValue<T>> getValues()
        Deprecated.
        Returns all values for the specified language.
      • getValues

        public java.util.List<FeatureValue<T>> getValues​(SessionContext ctx)
        Deprecated.
        Returns all values for the specified language.
        Parameters:
        ctx - the session context defining the language to change values for
        Returns:
        all values stored for this language
      • getValuesDirect

        public java.util.List<T> getValuesDirect()
        Deprecated.
        Returns directly the content value of each FeatureValue within this feature according to the current session language (if localized).
      • getValuesDirect

        public java.util.List<T> getValuesDirect​(SessionContext ctx)
        Deprecated.
        Returns directly the content value of each FeatureValue within this feature according to specified context language (if localized).
        Parameters:
        ctx - the session context defining the language to get values for
      • getAllDescriptions

        public java.lang.String getAllDescriptions()
        Deprecated.
        Convenience method to gather all (different) value desciptions into one string.
      • getAllDescriptions

        public java.lang.String getAllDescriptions​(SessionContext ctx)
        Deprecated.
        Convenience method to gather all (different) value desciptions into one string.
        Parameters:
        ctx - the session context defining which langauge should be used for localized values
      • getName

        public java.lang.String getName()
        Deprecated.
        Returns the name of this feature localized for the current session language.
      • getName

        public abstract java.lang.String getName​(SessionContext ctx)
        Deprecated.
        Returns the name of this feature localized for the specified session language.
      • getNumberFormat

        public java.text.NumberFormat getNumberFormat​(SessionContext ctx)
        Deprecated.
        Provides a number format for displaying number values according to the current locale.
      • getDateFormat

        public java.text.DateFormat getDateFormat​(SessionContext ctx)
        Deprecated.
        Provides a date format for displaying date values according to the current locale.
      • getValuesFormatted

        public java.lang.String getValuesFormatted()
        Deprecated.
        Creates a string representation of the feature values of this feature. If the feature is localized the values belonging to the current session language are displayed. If multiple values exist the're separated by ,.
      • getValuesFormatted

        public java.lang.String getValuesFormatted​(SessionContext ctx)
        Deprecated.
        Creates a string representation of the feature values of this feature. If multiple values exist the're separated by ,.
        Parameters:
        ctx - the session context which defines the language to choose the value for
      • writeToDatabase

        protected java.util.Collection<PK> writeToDatabase​(int featurePosition)
        Deprecated.
        Stores all values of this feature into the database.
        Parameters:
        featurePosition - the feature position - specified by the enclosing container
        Returns:
        the PKs of all persistent ProductFeature items holding these values
      • getUniqueKey

        protected abstract java.lang.String getUniqueKey()
        Deprecated.
      • add

        protected void add​(SessionContext ctx,
                           int index,
                           FeatureValue<T> featureValue)
                    throws java.lang.IndexOutOfBoundsException
        Deprecated.
        Throws:
        java.lang.IndexOutOfBoundsException