Class Feature<T>
- java.lang.Object
-
- de.hybris.platform.catalog.jalo.classification.util.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.SerializableDeprecated.since ages - useFeatureinstead.Describes all singlevaluesbelonging to one product feature. This may be prepresented by aClassAttributeAssignmentor 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
FeatureContainerfor 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 Summary
Constructors Modifier Constructor Description protectedFeature(Feature<T> src)Deprecated.Clone constructor.protectedFeature(FeatureContainer parent, boolean localized)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidadd(SessionContext ctx, int index, FeatureValue<T> featureValue)Deprecated.protected voidassureOwnValue(FeatureValue<T> value)Deprecated.voidclear()Deprecated.Clears all values (for the current session languge if localized).voidclear(SessionContext ctx)Deprecated.Clears all values (for the specified session languge if localized).voidclearAll()Deprecated.Clears all values of this feature regardless of the session language.abstract Featureclone()Deprecated.FeatureValue<T>createValue(int index, T value)Deprecated.Creates a new value for this feature.abstract FeatureValue<T>createValue(SessionContext ctx, int index, T value)Deprecated.Creates a new value for this feature.FeatureValue<T>createValue(SessionContext ctx, T value)Deprecated.Creates a new value for this feature.FeatureValue<T>createValue(T value)Deprecated.Creates a new value for this feature.java.util.List<FeatureValue<T>>createValues(SessionContext ctx, java.util.Collection<T> values)Deprecated.Creates a list of new values for this feature.java.util.List<FeatureValue<T>>createValues(SessionContext ctx, T... values)Deprecated.Creates a list of new values for this feature.java.util.List<FeatureValue<T>>createValues(java.util.Collection<T> values)Deprecated.Creates a list of new values for this feature.java.util.List<FeatureValue<T>>createValues(T... values)Deprecated.Creates a list of new values for this feature.booleanequals(java.lang.Object obj)Deprecated.protected LanguageextractLanguage(SessionContext ctx)Deprecated.java.lang.StringgetAllDescriptions()Deprecated.Convenience method to gather all (different) value desciptions into one string.java.lang.StringgetAllDescriptions(SessionContext ctx)Deprecated.Convenience method to gather all (different) value desciptions into one string.java.text.DateFormatgetDateFormat(SessionContext ctx)Deprecated.Provides a date format for displaying date values according to the current locale.protected java.util.List<FeatureValue<T>>getLanguageValues(SessionContext ctx, Language language, boolean create)Deprecated.java.lang.StringgetName()Deprecated.Returns the name of this feature localized for the current session language.abstract java.lang.StringgetName(SessionContext ctx)Deprecated.Returns the name of this feature localized for the specified session language.java.text.NumberFormatgetNumberFormat(SessionContext ctx)Deprecated.Provides a number format for displaying number values according to the current locale.FeatureContainergetParent()Deprecated.Returns the containing feature container.protected abstract java.lang.StringgetUniqueKey()Deprecated.FeatureValue<T>getValue(int index)Deprecated.Returns the value at a given position for the current session language.FeatureValue<T>getValue(SessionContext ctx, int index)Deprecated.Returns the value at a given position for the specified session language.java.util.List<FeatureValue<T>>getValues()Deprecated.Returns all values for the specified language.java.util.List<FeatureValue<T>>getValues(SessionContext ctx)Deprecated.Returns all values for the specified language.java.util.List<T>getValuesDirect()Deprecated.Returns directly the content value of eachFeatureValuewithin this feature according to the current session language (if localized).java.util.List<T>getValuesDirect(SessionContext ctx)Deprecated.Returns directly the content value of eachFeatureValuewithin this feature according to specified context language (if localized).java.lang.StringgetValuesFormatted()Deprecated.Creates a string representation of the feature values of this feature.java.lang.StringgetValuesFormatted(SessionContext ctx)Deprecated.Creates a string representation of the feature values of this feature.inthashCode()Deprecated.booleanisEmpty()Deprecated.Tells whether or not the feature holds values.booleanisEmpty(SessionContext ctx)Deprecated.Tells whether or not the feature holds values.booleanisEmptyIgnoringLanguage()Deprecated.Tells whether or not the feature holds any value at all, regardless of any localization settings.protected booleanisFallbackEnabled(SessionContext ctx)Deprecated.booleanisLocalized()Deprecated.Tells whether or not the feature is able to hold different values per session language.static <X> TypedFeature<X>loadTyped(Product product, ClassAttributeAssignment assignment)Deprecated.Shortcut to manage just a single typed feature.static <X> TypedFeature<X>loadTyped(Product product, ClassificationAttribute attr)Deprecated.Shortcut to manage just a single typed feature.protected FeatureValue<T>loadValue(SessionContext ctx, ProductFeature datbaseItem)Deprecated.voidmoveValue(int index, FeatureValue<T> featureValue)Deprecated.Moves a value to a given position within the current session language.voidmoveValue(SessionContext ctx, int index, FeatureValue<T> featureValue)Deprecated.Moves a value to a given position within the specified session language.FeatureValue<T>remove(int index)Deprecated.Removes the value at a given position from the values of the current session language.FeatureValue<T>remove(SessionContext ctx, int index)Deprecated.Removes the value at a given position from the values of the given session language.booleanremove(SessionContext ctx, FeatureValue<T> featureValue)Deprecated.Removes a given value from the values of the given session language.booleanremoveValue(FeatureValue<T> featureValue)Deprecated.Removes a given value from the values of the current session language.voidsetLocalized(boolean isLocalized)Deprecated.Changes localization statuc of this feature.FeatureValue<T>setValue(SessionContext ctx, T value)Deprecated.Replaces all current feature values by a single newly create one for the given value object.FeatureValue<T>setValue(T value)Deprecated.Replaces all current feature values by a single newly create one for the given value object.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.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.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.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.intsize()Deprecated.Returns the amount of values stored inside this feature (for the current session language if localized).intsize(SessionContext ctx)Deprecated.Returns the amount of values stored inside this feature (for the specified session language if localized).java.lang.StringtoString()Deprecated.protected java.util.Collection<PK>writeToDatabase(int featurePosition)Deprecated.Stores all values of this feature into the database.
-
-
-
Constructor Detail
-
Feature
protected Feature(FeatureContainer parent, boolean localized)
Deprecated.
-
-
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 aFeatureContainerwhich is limited to this class-attribute assignment only.- Parameters:
product- the product to manage the feature (-values) forassignment- 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 aFeatureContainerwhich is limited to this attribute only.- Parameters:
product- the product to manage the feature (-values) forattr- 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:
toStringin classjava.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 returntrue.
-
clone
public abstract Feature clone() throws java.lang.CloneNotSupportedException
Deprecated.- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
hashCode
public final int hashCode()
Deprecated.- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
Deprecated.- Overrides:
equalsin classjava.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 valuectx- 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 valuesctx- 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 valuesctx- 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 valueindex- 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 valuectx- the context specifying the session languageindex- 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 insideFeatureValueinstances- Returns:
- the new
FeatureValueinstances
-
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 insideFeatureValueinstances- Returns:
- the new
FeatureValueinstances
-
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 insideFeatureValueinstances- Returns:
- the new
FeatureValueinstances
-
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 insideFeatureValueinstances- Returns:
- the new
FeatureValueinstances
-
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 newFeatureValue- Returns:
- the new
FeatureValueinstance
-
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 newFeatureValue- Returns:
- the new
FeatureValueinstance
-
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.IndexOutOfBoundsExceptionDeprecated.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 forfeatureValue- the new value to set- Throws:
java.lang.IndexOutOfBoundsException- if the index exceeds the current value list dimensionsJaloInvalidParameterException- 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 forfeatureValue- 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 forindex- 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 eachFeatureValuewithin 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 eachFeatureValuewithin 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
-
loadValue
protected FeatureValue<T> loadValue(SessionContext ctx, ProductFeature datbaseItem)
Deprecated.
-
getLanguageValues
protected java.util.List<FeatureValue<T>> getLanguageValues(SessionContext ctx, Language language, boolean create)
Deprecated.
-
extractLanguage
protected Language extractLanguage(SessionContext ctx)
Deprecated.
-
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
ProductFeatureitems holding these values
-
getUniqueKey
protected abstract java.lang.String getUniqueKey()
Deprecated.
-
assureOwnValue
protected void assureOwnValue(FeatureValue<T> value) throws JaloInvalidParameterException
Deprecated.- Throws:
JaloInvalidParameterException
-
add
protected void add(SessionContext ctx, int index, FeatureValue<T> featureValue) throws java.lang.IndexOutOfBoundsException
Deprecated.- Throws:
java.lang.IndexOutOfBoundsException
-
-