Package org.apache.openjpa.lib.conf
Class Value
java.lang.Object
org.apache.openjpa.lib.conf.Value
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BooleanValue
,ClassListValue
,DoubleValue
,FileValue
,IntValue
,ObjectValue
,StringListValue
,StringValue
A configuration value.
- Author:
- Marc Prud'hommeaux, Pinaki Poddar
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEquivalentKey
(String other) Adds a moniker that is equivalent to the original property key used during construction.void
addListener
(ValueListener listener) Listener for value changes.Alias the given setting.protected String
Alias the given setting.protected void
Asserts if this receiver can be changed.clone()
boolean
Useoriginal value
instead ofcurrent value
because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract.abstract Object
get()
Get the actual data stored in this value.String[]
Aliases for the value in the form key1, value1, key2, value2, ...The default value for the property as a string.Gets the unmodifiable view of the equivalent keys or an empty set if no equivalent key has been added.The name of the getter method for the instantiated value of this property(as opposed to the string value)protected abstract String
Return the internal string form of this value.Gets unmodifable list of listeners for value changes.The key under which this value was loaded, or null.Gets the original value.The property name that will be used when setting or getting this value in aMap
.Gets unmodifiable view of all the property keys set on this receiver.getScope()
A class defining the scope in which this value is defined.Return a stringified version of this value.abstract Class<?>
Returns the type of the property that this Value represents.int
hashCode()
Useoriginal value
instead ofcurrent value
because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract.void
hide()
Hides the value of this Value from being output to the caller.boolean
Whether or not the alias list defines all possible settings for this value.boolean
Affirms if this receiver can be mutated even when the configuration it belongs to has beenfrozen
.boolean
isHidden()
Affirms if the value for this Value is visible.boolean
Affirms if this Value is used for internal purpose only and not exposed as a supported property.void
Marks this Value for internal purpose only.boolean
Affirms if the given key matches the property (or any of its equivalent).void
removeListener
(ValueListener listener) void
Replaces an existing alias, or adds the given alias to the front of the alias list if it does not already exist.protected String[]
Set an alias into a current alias list, returning the new list.void
setAliases
(String[] aliases) Aliases for the value in the form key1, value1, key2, value2, ...void
setAliasListComprehensive
(boolean aliasListIsComprehensive) Whether or not the alias list defines all possible settings for this value.void
setDefault
(String def) The default value for the property as a string.void
setDynamic
(boolean flag) Sets if this receiver can be mutated even when the configuration it belongs to has beenfrozen
.void
setInstantiatingGetter
(String getter) The name of the getter method for the instantiated value of this property(as opposed to the string value).protected abstract void
setInternalObject
(Object obj) Set this value from an object.protected abstract void
setInternalString
(String str) Set this value from the given string.void
setLoadKey
(String key) Sets key under which this value was loaded.void
Set this value as an object.void
setProperty
(String prop) The property name that will be used when setting or getting this value in aMap
.void
A class defining the scope in which this value is defined.void
Set this value from the given string.toString()
Unalias the given setting.protected String
Unalias the given setting.void
Subclasses should call this method when their internal value changes.
-
Field Details
-
INVISIBLE
- See Also:
-
-
Constructor Details
-
Value
public Value()Default constructor. -
Value
Constructor. Supply the property name.- See Also:
-
-
Method Details
-
getProperty
The property name that will be used when setting or getting this value in aMap
. -
setProperty
The property name that will be used when setting or getting this value in aMap
. -
addEquivalentKey
Adds a moniker that is equivalent to the original property key used during construction.- Since:
- 2.0.0
-
getEquivalentKeys
Gets the unmodifiable view of the equivalent keys or an empty set if no equivalent key has been added.- Since:
- 2.0.0
-
getPropertyKeys
Gets unmodifiable view of all the property keys set on this receiver. The 0-th element in the returned list is always the same as the original key returned bygetProperty()
method.- Since:
- 2.0.0
-
matches
Affirms if the given key matches the property (or any of its equivalent).- Since:
- 2.0.0
-
getLoadKey
The key under which this value was loaded, or null. -
setLoadKey
Sets key under which this value was loaded. -
getAliases
Aliases for the value in the form key1, value1, key2, value2, ... All alias values must be in string form. -
setAliases
Aliases for the value in the form key1, value1, key2, value2, ... All alias values must be in string form.To avoid potential side-effects, this method copies the array passed in.
-
setAlias
Replaces an existing alias, or adds the given alias to the front of the alias list if it does not already exist. All alias values must be in string form. -
setAlias
Set an alias into a current alias list, returning the new list. -
isAliasListComprehensive
public boolean isAliasListComprehensive()Whether or not the alias list defines all possible settings for this value. If so, an error will be generated when attempting to invoke any method on this value with an unknown option. -
setAliasListComprehensive
public void setAliasListComprehensive(boolean aliasListIsComprehensive) Whether or not the alias list defines all possible settings for this value. If so, an error will be generated when attempting to invoke any method on this value with an unknown option. -
alias
Alias the given setting. -
alias
Alias the given setting. -
unalias
Unalias the given setting. -
unalias
Unalias the given setting. -
getDefault
The default value for the property as a string. -
setDefault
The default value for the property as a string. -
getInstantiatingGetter
The name of the getter method for the instantiated value of this property(as opposed to the string value) -
setInstantiatingGetter
The name of the getter method for the instantiated value of this property(as opposed to the string value). If the string starts withthis.
, then the getter will be looked up on the value instance itself. Otherwise, the getter will be looked up on the configuration instance. -
getScope
A class defining the scope in which this value is defined. This will be used by the configuration framework to look up metadata about the value. -
setScope
A class defining the scope in which this value is defined. This will be used by the configuration framework to look up metadata about the value. -
getString
Return a stringified version of this value. If the current value has a short alias key, the alias key is returned. -
setString
Set this value from the given string. If the given string is null or empty and a default is defined, the default is used. If the given string(or default) is an alias key, it will be converted to the corresponding value internally.
If this Value is being set to a non-default value for the first time (as designated byoriginalString
being null), then the value is remembered as original. This original value is used for equality and hashCode computation if this Value isdynamic
. -
setObject
Set this value as an object.
If this Value is being set to a non-default value for the first time (as designated byoriginalString
being null), then the value is remembered as original. This original value is used for equality and hashCode computation if this Value isdynamic
. -
getOriginalValue
Gets the original value. Original value denotes the Stringified form of this Value, from which it has been set, if ever. If this Value has never been set to a non-default value, then returns the default value, which itself can be null.- Since:
- 1.1.0
-
getValueType
Returns the type of the property that this Value represents. -
getInternalString
Return the internal string form of this value. -
setInternalString
Set this value from the given string. -
setInternalObject
Set this value from an object. -
getListeners
Gets unmodifable list of listeners for value changes. -
addListener
Listener for value changes. -
removeListener
-
valueChanged
public void valueChanged()Subclasses should call this method when their internal value changes. -
assertChangeable
protected void assertChangeable()Asserts if this receiver can be changed. Subclasses must invoke this method before changing its internal state. This receiver can not be changed if all of the following is true- this receiver is not dynamic
- ValueListener attached to this receiver is a Configuration
- Configuration is read-only
-
setDynamic
public void setDynamic(boolean flag) Sets if this receiver can be mutated even when the configuration it belongs to has beenfrozen
.- Since:
- 1.1.0
-
isDynamic
public boolean isDynamic()Affirms if this receiver can be mutated even when the configuration it belongs to has beenfrozen
.- Since:
- 1.1.0
-
hashCode
public int hashCode()Useoriginal value
instead ofcurrent value
because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract. -
equals
Useoriginal value
instead ofcurrent value
because they are one and the same for non-dynamic Values and ensures that modifying dynamic Values do not impact equality or hashCode contract. -
clone
-
isHidden
public boolean isHidden()Affirms if the value for this Value is visible. Certain sensitive value such as password can be made invisible so that it is not returned to the user code. -
hide
public void hide()Hides the value of this Value from being output to the caller. -
isPrivate
public boolean isPrivate()Affirms if this Value is used for internal purpose only and not exposed as a supported property.- See Also:
-
makePrivate
public void makePrivate()Marks this Value for internal purpose only. -
get
Get the actual data stored in this value. -
toString
-