Package com.iizix.prop
Class MultiProp<VALUE>
- All Implemented Interfaces:
EventListener
,IGProp<Object[]>
,Cloneable
- Direct Known Subclasses:
Color4Prop
,Int4Prop
,String4Prop
,Unit4Prop
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_INCLUDE_PRIVATE, EQC_SAVE_FILE, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATE
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendPropValue
(PropMgr propertyManager, SendTransaction trans, 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
(Element element) Method to override for the implementor.protected Object
equalValues
(GProp<?> compareTo, Object[] thisValue, Object[] compareValue, int how) Checks for property value equality.getPropValue
(int index) Gets an indexed property value.protected Object
getPropValue0
(Object value, int index) Gets the property value in another class form than the "native" one.Gets the default value.getRealPropValue
(int realIndex) Gets the "real" indexed property value (default index=0, other indexes+1).Class<?>[]
Gets the list of possible native Java classes that can be used to set a value usingsetPropertyValue
, in order of importance.int
Gets the value count.void
initializeElement
(Element element) Called when the XML file for the property tree is serialized from properties.void
initializeProp
(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, Element element) Method to override for the implementor.protected int
modifyPropValue
(Object oldValue, Object newValue, PropMgr propMgr) Called when setting a new value for this property.protected String
paramValue
(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
(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, 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 final void
Sets up the property.protected Object
toNativeValue0
(Object value, int index) Tries conversion of possibly accepted properties values using thesetPropertyValue
method into the most preferred property value type.void
validatePropType
(Object newValue) Validates that the value to set is of GColor instance.Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, appendProp, clone, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalsTree, 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, getReferencePropNameNoAssert, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParentNoAssert, getTreeLock, getVSReference, hasChanged, hasCircularReferencesError, 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, isPropRootLoading, isPropRootTreeModificationsAllowed, isPropUSER, isPropValueTreeLockNeeded, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, isSibling, list, list, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onEventSelf, onPrepare, onPropDispose, onPropInvalidateCache, onPropParentChanged, onPropTreeInitialized, onPropValueSet, onReferenceEvent, onRemoteEvent, onVirtualizationCompleted, paramString, 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, virtualize, warning, warning, warning
Constructor Details
MultiProp
protected MultiProp()Creates a color property with no name and with a null value.MultiProp
Creates a color property with the specified name with a null value.- Parameters:
propertyAtom
- the property atom.
Method Details
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<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
Sets up the property.- Parameters:
count
- The count of values.valueClass
- The class for the values.
modifyPropValue
protected int modifyPropValue(Object oldValue, 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<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 Object equalValues(GProp<?> compareTo, Object[] thisValue, 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<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
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<Object[]>
- Parameters:
newValue
- The new value to set.- Throws:
PropTypeException
- when the new value isn't of the correct class.
getPropValueDefault
Gets the default value.- Returns:
- The default value set at last call to setDefaultValue.
getPropValue
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
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
Sets the default value.- Parameters:
value
- The new default value.- Returns:
- change-flag.
- Throws:
PropException
- If value is not of correct type.
setPropValue
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
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
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
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
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
Appends the bounds property value.- Specified by:
appendPropValue
in classGProp<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
Appends the property value item to a transaction.- Parameters:
trans
- The transaction.value
- The value to append.
initializeValue
Initializes the property value from a transaction.- Specified by:
initializeValue
in classGProp<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
Creates a property value from a transaction.initializeProp
Called to initialize the property from anElement
. The property should initialize itself from attributes and nodes with appropriate information.- Overrides:
initializeProp
in classGProp<Object[]>
- Parameters:
element
- TheElement
.- Throws:
PropException
- when the initialization fails.
initializeElement
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<Object[]>
- Parameters:
element
- TheElement
.
initializeValueElement
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
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:
Exception
- For errors.
getPropValue0
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<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:
Exception
- Other exceptions that could occur.
toNativeValue0
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<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:
Exception
- For conversion exceptions.
paramValue
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<Object[]>
- Parameters:
value
- The property value.- Returns:
- The String representation of the value.