Package com.iizix.prop
Class MultiProp<VALUE>
- java.lang.Object
- com.iizix.prop.GProp<java.lang.Object[]>
- com.iizix.prop.MultiProp<VALUE>
- All Implemented Interfaces:
EventListener
,IGProp<java.lang.Object[]>
,java.lang.Cloneable
- Direct Known Subclasses:
Color4Prop
,Int4Prop
,String4Prop
,Unit4Prop
public abstract class MultiProp<VALUE> extends GProp<java.lang.Object[]>
The multiple property class holds the property name, a common value or an array of different properties (typically 4 for e.g. GColor's for the "Border Color" property).- Author:
- Christopher Mindus
Field Summary
Fields inherited from class com.iizix.prop.GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_USER_1, PROP_USER_2
Fields inherited from interface com.iizix.prop.IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
appendPropValue(PropMgr propertyManager, SendTransaction trans, java.lang.Object value)
Appends the bounds property value.protected abstract void
appendPropValueItem(SendTransaction trans, VALUE value)
Appends the property value item to a transaction.abstract VALUE
createValue(ReadTransaction trans)
Creates a property value from a transaction.protected abstract VALUE
createValue(org.w3c.dom.Element element)
Method to override for the implementor.protected java.lang.Object
equalValues(GProp<?> compareTo, java.lang.Object[] thisValue, java.lang.Object[] compareValue, int how)
Checks for property value equality.VALUE
getPropValue(int index)
Gets an indexed property value.protected java.lang.Object
getPropValue0(java.lang.Object value, int index)
Gets the property value in another class form than the "native" one.VALUE
getPropValueDefault()
Gets the default value.VALUE
getRealPropValue(int realIndex)
Gets the "real" indexed property value (default index=0, other indexes+1).java.lang.Class<?>[]
getValueClasses()
Gets the list of possible native Java classes that can be used to set a value usingsetPropertyValue
, in order of importance.int
getValueCount()
Gets the value count.void
initializeElement(org.w3c.dom.Element element)
Called when the XML file for the property tree is serialized from properties.void
initializeProp(org.w3c.dom.Element element)
Called to initialize the property from anElement
.boolean
initializeValue(PropMgr propertyManager, ReadTransaction trans)
Initializes the property value from a transaction.protected abstract void
initializeValueElement(VALUE value, org.w3c.dom.Element element)
Method to override for the implementor.protected int
modifyPropValue(java.lang.Object oldValue, java.lang.Object newValue, PropMgr propMgr)
Called when setting a new value for this property.protected java.lang.String
paramValue(java.lang.Object value)
Formats the value as a string to add toparamString
.boolean
setPropValue(VALUE value, int index)
Sets an indexed property value.boolean
setPropValueDefault(VALUE value)
Sets the default value.boolean
setPropValues(java.lang.Object[] values)
Sets all property values at once along with a default value.boolean
setPropValues(VALUE singleValue)
Sets all property values at once to a single value.boolean
setPropValues(VALUE defaultValue, java.lang.Object[] values)
Sets all property values at once along with a default value.boolean
setRealPropValue(VALUE value, int realIndex)
Sets the value at "real" index.protected void
setup(int count, java.lang.Class<?> valueClass)
Sets up the property.protected java.lang.Object
toNativeValue0(java.lang.Object value, int index)
Tries conversion of possibly accepted properties values using thesetPropertyValue
method into the most preferred property value type.void
validatePropType(java.lang.Object newValue)
Validates that the value to set is of GColor instance.Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, clone, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalsTree, extendsClone, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientSessionGyro, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropBaseReference, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getReferences, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParent, getTreeLock, getVSReference, hasChanged, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCommunicating, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, list, list, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onEventSelf, onPrepare, onPropDispose, onPropInvalidateCache, onPropParentChanged, onPropTreeInitialized, onPropValueSet, onReferenceEvent, onRemoteEvent, onVirtualizationCompleted, onVirtualized, paramString, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, resolveRuntimeReferences, setChanged, setConstraints, setConstraints, setCreateRequiredProp, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, shouldSerializeToXML, throwIfReadOnly, toElementString, toNativeValue, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, validatePropValue, verify, verifyHasPropertyItem, virtualize, warning, warning, warning
Constructor Detail
MultiProp
protected MultiProp()
Creates a color property with no name and with a null value.
MultiProp
public MultiProp(Atom propertyAtom)
Creates a color property with the specified name with a null value.- Parameters:
propertyAtom
- the property atom.
Method Detail
getValueClasses
public java.lang.Class<?>[] getValueClasses()
Gets the list of possible native Java classes that can be used to set a value usingsetPropertyValue
, in order of importance. Note that loss of precision in data if e.g. an Float property accepts a Double. However, thesetPropertyValue
throwsIllegalArgumentException
if the range in invalid, e.g. conversion of a Integer to a Byte, and the value is not -127 to 128.- Specified by:
getValueClasses
in interfaceIGProp<VALUE>
- Specified by:
getValueClasses
in classGProp<java.lang.Object[]>
- Returns:
- The array of Java classes that can be accepted in the
setPropertyValue
method. The first type is the "native" or most preferred type. The array is at least one item in length and never null.
setup
protected final void setup(int count, java.lang.Class<?> valueClass)
Sets up the property.- Parameters:
count
- The count of values.valueClass
- The class for the values.
modifyPropValue
protected int modifyPropValue(java.lang.Object oldValue, java.lang.Object newValue, PropMgr propMgr) throws PropException
Called when setting a new value for this property. This method is normally not overridden by subclasses, but e.g. for properties containing arrays, this may be handled here, in order not modify the "oldValue" (such as an array, but rather to change it with the data from the "newValue").- Overrides:
modifyPropValue
in classGProp<java.lang.Object[]>
- Parameters:
oldValue
- The old value.newValue
- The new value.propMgr
- The property manager for remote change, null for local.- Returns:
- 1 for value has changed, 0 for same value as current value, -1 for not processed. 2 can also be returned to indicate the current value has been modified with new contents. This is e.g. the case for the StringMapProp.
- Throws:
PropException
- when the new value doesn't validate correctly.
equalValues
protected java.lang.Object equalValues(GProp<?> compareTo, java.lang.Object[] thisValue, java.lang.Object[] compareValue, int how)
Checks for property value equality. The object is of the correct type for the respective property type. The Atoms and other properties such as Private/Extends has already been checked for equality or correctness.- Overrides:
equalValues
in classGProp<java.lang.Object[]>
- Parameters:
compareTo
- The comparing-to property that contains the value.thisValue
- This property value (for synchronization reasons).compareValue
- Another property value.how
- Flags EQC_* values for equal checking.- Returns:
- The property not being equal, null for equal (both values null).
getValueCount
public int getValueCount()
Gets the value count.
validatePropType
public void validatePropType(java.lang.Object newValue) throws PropTypeException
Validates that the value to set is of GColor instance.Note: When this method is called, synchronization is done at the property itself, so no synchronization on the tree should be done.
- Specified by:
validatePropType
in interfaceIGProp<VALUE>
- Specified by:
validatePropType
in classGProp<java.lang.Object[]>
- Parameters:
newValue
- The new value to set.- Throws:
PropTypeException
- when the new value isn't of the correct class.
getPropValueDefault
public VALUE getPropValueDefault()
Gets the default value.- Returns:
- The default value set at last call to setDefaultValue.
getPropValue
public VALUE getPropValue(int index)
Gets an indexed property value. If the value is not set for this index, the default is returned.- Parameters:
index
- The index.- Returns:
- The property value, null if none has been set anywhere.
getRealPropValue
public VALUE getRealPropValue(int realIndex)
Gets the "real" indexed property value (default index=0, other indexes+1).- Parameters:
realIndex
- The "real" index.- Returns:
- The property value or null for none.
setPropValueDefault
public boolean setPropValueDefault(VALUE value) throws PropException
Sets the default value.- Parameters:
value
- The new default value.- Returns:
- change-flag.
- Throws:
PropException
- If value is not of correct type.
setPropValue
public boolean setPropValue(VALUE value, int index) throws PropException
Sets an indexed property value. If set to null, the default value is set (if defined).- Parameters:
value
- The value.index
- The index.- Returns:
- The change-flag.
- Throws:
PropException
- If value is not of correct type.
setRealPropValue
public boolean setRealPropValue(VALUE value, int realIndex) throws PropException
Sets the value at "real" index.- Parameters:
value
- The new default value.realIndex
- The "real" index.- Returns:
- change-flag.
- Throws:
PropException
- If value is not of correct type.
setPropValues
public boolean setPropValues(VALUE singleValue) throws PropException
Sets all property values at once to a single value. The default value is also set with this call.- Parameters:
singleValue
- The single value to set for all values, including the default value.- Returns:
- The change-flag.
- Throws:
PropException
- If value is not of correct type.
setPropValues
public boolean setPropValues(java.lang.Object[] values) throws PropException
Sets all property values at once along with a default value.- Parameters:
values
- The new values.- Returns:
- The change-flag.
- Throws:
PropException
- If value is not of correct type.
setPropValues
public boolean setPropValues(VALUE defaultValue, java.lang.Object[] values) throws PropException
Sets all property values at once along with a default value.- Parameters:
defaultValue
- The new default value.values
- The new values.- Returns:
- The change-flag.
- Throws:
PropException
- If value is not of correct type.
appendPropValue
protected void appendPropValue(PropMgr propertyManager, SendTransaction trans, java.lang.Object value)
Appends the bounds property value.- Specified by:
appendPropValue
in classGProp<java.lang.Object[]>
- Parameters:
propertyManager
- the property manager instance.trans
- transaction to append the properties to.value
- the value to append to the transaction, a reference to the current property value.
appendPropValueItem
protected abstract void appendPropValueItem(SendTransaction trans, VALUE value)
Appends the property value item to a transaction.- Parameters:
trans
- The transaction.value
- The value to append.
initializeValue
public boolean initializeValue(PropMgr propertyManager, ReadTransaction trans) throws PropException
Initializes the property value from a transaction.- Specified by:
initializeValue
in classGProp<java.lang.Object[]>
- Parameters:
propertyManager
- the property manager.trans
- the transaction to initialize the property with.- Returns:
- true if the value has changed, false otherwise.
- Throws:
PropException
createValue
public abstract VALUE createValue(ReadTransaction trans)
Creates a property value from a transaction.
initializeProp
public void initializeProp(org.w3c.dom.Element element) throws PropException
Called to initialize the property from anElement
. The property should initialize itself from attributes and nodes with appropriate information.- Overrides:
initializeProp
in classGProp<java.lang.Object[]>
- Parameters:
element
- TheElement
.- Throws:
PropException
- when the initialization fails.
initializeElement
public void initializeElement(org.w3c.dom.Element element)
Called when the XML file for the property tree is serialized from properties. The property should fill attributes and nodes with appropriate information.The attribute "sort" may be set to "client", "server" or not present, i.e. no sorting. The setting "server" indicates that the Server provides the sorting rule to use, settable for each client session programmatically.
After the element, elements "string" builds up all text entries containing the strings.
- Overrides:
initializeElement
in classGProp<java.lang.Object[]>
- Parameters:
element
- TheElement
.
initializeValueElement
protected abstract void initializeValueElement(VALUE value, org.w3c.dom.Element element)
Method to override for the implementor.Initializes an XML Element from a value in the array.
- Parameters:
value
- The value to "stream" to the XML element.element
- The XML value element, attributes "index" "null" are "taken".
createValue
protected abstract VALUE createValue(org.w3c.dom.Element element) throws java.lang.Exception
Method to override for the implementor.Creates an value in the property array from an Element.
- Parameters:
element
- The XML value element, attributes "index" and "null" are "taken".- Throws:
java.lang.Exception
- For errors.
getPropValue0
protected java.lang.Object getPropValue0(java.lang.Object value, int index) throws java.lang.Exception
Gets the property value in another class form than the "native" one. This method tries conversion of a "native" property value into another class type. This method is used when filling in a POJO variable (Plain Old Java Object Field) from a "native" property value.- Specified by:
getPropValue0
in classGProp<java.lang.Object[]>
- Parameters:
value
- The property value.index
- The index in the Class array returned bygetValueClasses()
.- Returns:
- The property value in the requested class, after conversion.
- Throws:
java.lang.Exception
- Other exceptions that could occur.
toNativeValue0
protected java.lang.Object toNativeValue0(java.lang.Object value, int index) throws java.lang.Exception
Tries conversion of possibly accepted properties values using thesetPropertyValue
method into the most preferred property value type. If the input value already is of the preferred type, the same object is returned.- Specified by:
toNativeValue0
in classGProp<java.lang.Object[]>
- Parameters:
value
- The input value to convert to native value.index
- The index in the array returned bygetValueClasses()
, or -1 if not found.- Returns:
- The converted input value in the preferred property value object type.
- Throws:
java.lang.Exception
- For conversion exceptions.
paramValue
protected java.lang.String paramValue(java.lang.Object value)
Formats the value as a string to add toparamString
. The default is to do "value.toString()" if value is not null, otherwise "[null]" is returned.- Overrides:
paramValue
in classGProp<java.lang.Object[]>