Class AbstractReference<TARGET extends IPropCnr>
- java.lang.Object
- com.iizix.prop.GProp<ReferenceString>
- com.iizix.prop.AbstractReference<TARGET>
- All Implemented Interfaces:
EventListener
,ICircularRetargetParent
,IGProp<ReferenceString>
,IPropReference
,java.lang.Cloneable
- Direct Known Subclasses:
AbstractBaseRelativeReference
,FixedVirtualizedAbstractReference
,ServerConfigEnvReference
,VSReference
public abstract class AbstractReference<TARGET extends IPropCnr> extends GProp<ReferenceString> implements IPropReference, ICircularRetargetParent
The Abstract Reference property class hold the reference to another property.- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface com.iizix.prop.IPropReference
IPropReference.ReferenceChangeEvent
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ERROR_ID
The ID of the property error.protected boolean
hasBeenValidated
Validation completed flag.static java.lang.String
QUICK_FIX_DELETE_PROP
Quick-fix ID for delete property, defined in "com.iizigo.quickfix.fixer.DeleteProperty".protected PropReference
reference
The instance of the property reference.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
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractReference()
Creates a Abstract Reference property with no name and with a null value.protected
AbstractReference(Atom propertyAtom)
Creates a Abstract Reference property with the specified name with a null value.protected
AbstractReference(Atom propertyAtom, java.lang.String newValue)
Creates a Abstract Reference property with the specified name and value.
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 string property value.protected void
assignError(java.lang.String err)
Assigns a property error message of ERROR severity with DeleteProperty quick-fix.protected void
assignNotFoundError(PropReference ref)
Assigns not found error.protected void
changeReference(java.lang.String oldName, java.lang.String newName, PropReference ref)
Called to update a reference from an old name to a new name.protected void
checkCreateReference(GEvent event)
Checks for tree to be valid in order to create the reference.protected void
clearError()
Clears the property error.protected void
clearFixedTarget()
Called to clear the fixed reference in case the reference is changed.AbstractReference<TARGET>
clone()
Cloning must duplicate reference into new tree.protected void
createUpdateReference(PropReference ref, boolean doReCheck, GEvent event)
Resolves or creates the reference.protected void
disposeReference()
Disposes of the reference and possible cached target.protected boolean
doPostResolve()
Returns if resolving of this reference should be done in post- (true) or pre-stage (false).protected boolean
equalsErrors(PropError pe1, PropError pe2, int how)
Processes error property verification.protected java.lang.Object
equalValues(GProp<?> compareTo, ReferenceString thisValue, ReferenceString compareValue, int how)
Checks for property value equality.protected TARGET
getFixedTarget()
Support for a fixed reference.protected java.lang.String
getLookupPropReference(ReferenceString name)
Creates the reference string to look-up from the ReferenceString.abstract java.lang.Class<?>
getPropertyClass()
Gets the class wanted.protected java.lang.Object
getPropValue0(java.lang.Object value, int index)
Gets the property value in another class form than the "native" one.java.lang.String
getReference()
Gets the reference string.abstract java.lang.String
getReferenceDescription()
Gets a short description of this reference, e.g.int
getReferences(java.util.List<Reference> references)
Gets the references of this property top others.ReferenceString
getReferenceString()
Gets the reference string.TARGET
getTargetReference()
Gets the target reference also trying to resolve the reference, i.e.TARGET
getTargetReference(GProp<?> anyPropertyInTree)
Gets the target reference also trying to resolve the reference, i.e.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.protected void
informClearError()
Called when the property has been cleared from error.protected void
informError()
Called when the property has an error.protected void
informResolved()
Called when the property has been resolved.protected void
initializeReferenceClone()
Initializes the new clone for references.boolean
initializeValue(PropMgr propertyManager, ReadTransaction trans)
Initializes the property value from a transaction.abstract boolean
isReferenceValid(GProp<?> property)
Validates the property reference that has been looked up.boolean
isValid()
Checks if the resolving of the reference is valid with the automatic resolving mechanism.void
onEventSelf(GEvent event)
Called when a property event is send to this property.protected void
onProjectNameChanged(ProjectNameEvent event)
Called when a project name has been changed.protected void
onPropDispose()
Property disposed of: dispose of reference.protected void
onPropParentChanged(PropCnr oldParent, PropCnr newParent)
Called when parent changed.protected void
onRefactored(java.lang.String oldName, java.lang.String newName)
Called when the property is refactored.protected void
onReferenceDisposed()
Called when the reference is disposed of.protected void
onReferenceEvent(ResolveReferencesEvent event)
Called to perform reference resolving.void
onReferenceEvent(PropReference ref, IPropReference.ReferenceChangeEvent event, GEvent triggerEvent)
Called when a property reference event occurs.protected java.lang.String
setLookedUpReference(java.lang.String name)
Sets the reference found that also has been validated.boolean
setPropValue(java.lang.String newValue)
Sets a new value for this 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.protected void
updateReference(GEvent event)
Called to establish a new reference after name change or parent-hood.void
validatePropType(java.lang.Object newValue)
Validates that the value to set is of ReferenceString instance.protected java.lang.String
validateReferenceScope(TARGET target)
Called when the a property container has been renamed or moved in order to perform validation of the reference, e.g.java.lang.String
wouldValidate(GProp<?> anyPropertyInTree)
Checks if the reference would be valid if this property is attached to a root property.Methods inherited from class com.iizix.prop.GProp
addPropError, addPropListener, convertPropError, dispose, equals, equals, 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, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParent, getTreeLock, getVSReference, hasChanged, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeElement, initializeGElement, initializeGProp, initializeProp, 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, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onPrepare, onPropInvalidateCache, onPropTreeInitialized, onPropValueSet, onRemoteEvent, onVirtualizationCompleted, onVirtualized, paramString, paramValue, 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
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.iizix.prop.ICircularRetargetParent
isCircularRetargetParent
Field Detail
ERROR_ID
public static final java.lang.String ERROR_ID
The ID of the property error.- See Also:
- Constant Field Values
QUICK_FIX_DELETE_PROP
public static final java.lang.String QUICK_FIX_DELETE_PROP
Quick-fix ID for delete property, defined in "com.iizigo.quickfix.fixer.DeleteProperty".- See Also:
- Constant Field Values
reference
protected PropReference reference
The instance of the property reference.
hasBeenValidated
protected boolean hasBeenValidated
Validation completed flag.
Constructor Detail
AbstractReference
protected AbstractReference()
Creates a Abstract Reference property with no name and with a null value.
AbstractReference
protected AbstractReference(Atom propertyAtom)
Creates a Abstract Reference property with the specified name with a null value.- Parameters:
propertyAtom
- the property atom.
AbstractReference
protected AbstractReference(Atom propertyAtom, java.lang.String newValue)
Creates a Abstract Reference property with the specified name and value.- Parameters:
propertyAtom
- the property atom.newValue
- the new string value for the property.
Method Detail
doPostResolve
protected boolean doPostResolve()
Returns if resolving of this reference should be done in post- (true) or pre-stage (false).- Returns:
- false by default, i.e. always in first pre-stage.
getFixedTarget
protected TARGET getFixedTarget()
Support for a fixed reference.Override to provide the support.
- Returns:
- The fixed reference to return in cases the target reference is needed, and also serves as a verification if a new reference should be created or not. Returning
null
causes normal behavior (default).
clearFixedTarget
protected void clearFixedTarget()
Called to clear the fixed reference in case the reference is changed. This will revert back to normal processing.The "clone" method does not change to be overridden to clear the fixed target as this method is called during cloning.
This method is called prior to calling "initializeReferenceClone()" during cloning.
Override to provide the support. It is important to also implement this method along with "getFixedTarget".
getReferenceString
public ReferenceString getReferenceString()
Gets the reference string.
setPropValue
public boolean setPropValue(java.lang.String newValue) throws PropValidateException
Sets a new value for this property. If any listener is present and the value has changed compare to the last value, the listener is informed.- Parameters:
newValue
- the new value.- Returns:
- boolean true for value has changed, false for same value as current value.
- Throws:
PropValidateException
- When the constraints are not met.
validatePropType
public void validatePropType(java.lang.Object newValue) throws PropTypeException
Validates that the value to set is of ReferenceString 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<TARGET extends IPropCnr>
- Specified by:
validatePropType
in classGProp<ReferenceString>
- Parameters:
newValue
- The new value to set.- Throws:
PropTypeException
- when the new value isn't of the correct class.
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<TARGET extends IPropCnr>
- Specified by:
getValueClasses
in classGProp<ReferenceString>
- 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.
appendPropValue
protected void appendPropValue(PropMgr propertyManager, SendTransaction trans, java.lang.Object value)
Appends the string property value. If uninitialized, an empty string is appended.- Specified by:
appendPropValue
in classGProp<ReferenceString>
- 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.
initializeValue
public boolean initializeValue(PropMgr propertyManager, ReadTransaction trans) throws PropException
Initializes the property value from a transaction.- Specified by:
initializeValue
in classGProp<ReferenceString>
- Parameters:
propertyManager
- the property manager.trans
- the transaction to initialize the property with.- Returns:
- true if the value has changed, false otherwise.
- Throws:
PropException
getReference
public java.lang.String getReference()
Gets the reference string.- Returns:
- The reference string or null if not set.
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<ReferenceString>
- 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<ReferenceString>
- 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.
disposeReference
protected void disposeReference()
Disposes of the reference and possible cached target.
onReferenceDisposed
protected void onReferenceDisposed()
Called when the reference is disposed of.
onPropDispose
protected void onPropDispose()
Property disposed of: dispose of reference.- Overrides:
onPropDispose
in classGProp<ReferenceString>
clone
public AbstractReference<TARGET> clone()
Cloning must duplicate reference into new tree.- Overrides:
clone
in classGProp<ReferenceString>
initializeReferenceClone
protected void initializeReferenceClone()
Initializes the new clone for references. Default processing is to clear the reference instance. The instance is created at a later stage when a the property is somehow attached to a valid property root.
equalValues
protected java.lang.Object equalValues(GProp<?> compareTo, ReferenceString thisValue, ReferenceString 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<ReferenceString>
- 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).
equalsErrors
protected boolean equalsErrors(PropError pe1, PropError pe2, int how)
Processes error property verification. The default processing is to verify the two error propertiespe1
andpe2
for equality ifincludeErrors
is 0 or 1, and returns true if the value is 2=no comparison with error properties.Override to verify property errors for reference properties.
- Overrides:
equalsErrors
in classGProp<ReferenceString>
- Parameters:
pe1
- The first error property, may be null.pe2
- The second error property, may be null.how
- Flags EQC_* values for equal checking.- Returns:
- Equality flag depending on
includeErrors
value.
getPropertyClass
public abstract java.lang.Class<?> getPropertyClass()
Gets the class wanted.
getReferences
public int getReferences(java.util.List<Reference> references)
Gets the references of this property top others. This method is typically used in the Designer to search for circular references during verification.- Specified by:
getReferences
in interfaceIGProp<TARGET extends IPropCnr>
- Overrides:
getReferences
in classGProp<ReferenceString>
- Parameters:
references
- The references array is filled in by this method.- Returns:
- The count of references added.
onEventSelf
public void onEventSelf(GEvent event)
Called when a property event is send to this property.A subclass can override this method to perform appropriate processing and is not required to call
super.onEventSelf(e)
.- Specified by:
onEventSelf
in interfaceIGProp<TARGET extends IPropCnr>
- Overrides:
onEventSelf
in classGProp<ReferenceString>
- Parameters:
event
- The property event.
onReferenceEvent
protected void onReferenceEvent(ResolveReferencesEvent event)
Called to perform reference resolving. A property should override this method if it needs to perform reference resolving and validation.Subclasses override this method and only subclasses extending
PropCnr
needs to callsuper.onReferenceEvent(ResolveReferenceEvent event)
.- Overrides:
onReferenceEvent
in classGProp<ReferenceString>
- Parameters:
event
- The resolve references event.
onProjectNameChanged
protected void onProjectNameChanged(ProjectNameEvent event)
Called when a project name has been changed.- Parameters:
event
- The project name event.
createUpdateReference
protected void createUpdateReference(PropReference ref, boolean doReCheck, GEvent event)
Resolves or creates the reference.
updateReference
protected void updateReference(GEvent event)
Called to establish a new reference after name change or parent-hood.
getLookupPropReference
protected java.lang.String getLookupPropReference(ReferenceString name)
Creates the reference string to look-up from the ReferenceString. Override this method for e.g. Base or Fixed Relative referencing.- Parameters:
name
- The reference name.- Returns:
- The property reference string to look-up.
setLookedUpReference
protected java.lang.String setLookedUpReference(java.lang.String name)
Sets the reference found that also has been validated. This method gives the opportunity for a subclass to remove e.g. the Base or Fixed Relative reference from the string start.- Parameters:
name
- The full reference.- Returns:
- The reference to set in this property as ReferenceString.
checkCreateReference
protected void checkCreateReference(GEvent event)
Checks for tree to be valid in order to create the reference. If OK and reference is not created, this will be done.Otherwise a validation is just performed.
onPropParentChanged
protected void onPropParentChanged(PropCnr oldParent, PropCnr newParent)
Called when parent changed.- Overrides:
onPropParentChanged
in classGProp<ReferenceString>
- Parameters:
oldParent
- The old parent (or null if none).newParent
- The new parent (or null if none).
clearError
protected void clearError()
Clears the property error.
assignNotFoundError
protected void assignNotFoundError(PropReference ref)
Assigns not found error.
assignError
protected void assignError(java.lang.String err)
Assigns a property error message of ERROR severity with DeleteProperty quick-fix.
onReferenceEvent
public void onReferenceEvent(PropReference ref, IPropReference.ReferenceChangeEvent event, GEvent triggerEvent)
Called when a property reference event occurs. The events are ReferenceChangeEvent.FOUND, FOUND_WRONG_CLASS, RENAMED, MOVED, NEW_PROPERTY, BROKEN.- Specified by:
onReferenceEvent
in interfaceIPropReference
- Parameters:
ref
- The property reference object.event
- The event.triggerEvent
- The event that triggered this reference event, null for none.
changeReference
protected void changeReference(java.lang.String oldName, java.lang.String newName, PropReference ref)
Called to update a reference from an old name to a new name. This will set the new property value as well as to perform required refactoring operations.- Parameters:
oldName
- The old name.newName
- The new name.ref
- The current reference instance.
onRefactored
protected void onRefactored(java.lang.String oldName, java.lang.String newName)
Called when the property is refactored. This method is called after rename of properties have been done. Override to process.- Parameters:
oldName
- The old name.newName
- The new name.
isValid
public boolean isValid()
Checks if the resolving of the reference is valid with the automatic resolving mechanism. Attempt to resolve again is always done depending on thedoResolve
flag.
wouldValidate
public java.lang.String wouldValidate(GProp<?> anyPropertyInTree)
Checks if the reference would be valid if this property is attached to a root property.- Parameters:
anyPropertyInTree
- Any property attached to a root.- Returns:
- null if it would validate, otherwise the error reason.
getTargetReference
public TARGET getTargetReference()
Gets the target reference also trying to resolve the reference, i.e. using automatic resolving mechanism.- Returns:
- The target reference instance, or
null
if not found.
getTargetReference
public TARGET getTargetReference(GProp<?> anyPropertyInTree)
Gets the target reference also trying to resolve the reference, i.e. using automatic resolving mechanism.- Returns:
- The target reference instance, or
null
if not found.
informResolved
protected void informResolved()
Called when the property has been resolved. Subclasses override this method to implement some behavior. The default implementation performs nothing, i.e. there is no need to callsuper.informResolved()
.
informError
protected void informError()
Called when the property has an error. Subclasses override this method to implement some behavior. The default implementation performs nothing, i.e. there is no need to callsuper.informError()
.
informClearError
protected void informClearError()
Called when the property has been cleared from error. Subclasses override this method to implement some behavior. The default implementation performs nothing, i.e. there is no need to callsuper.informClearError()
.
validateReferenceScope
protected java.lang.String validateReferenceScope(TARGET target)
Called when the a property container has been renamed or moved in order to perform validation of the reference, e.g. if a base property has been moved out of scope. The implementor can assign or clear property errors by returning the error string.- Parameters:
target
- Target reference to validate the scope of, i.e. the referenced property.- Returns:
- The error message, or null for valid. Default implementation returns null.
getReferenceDescription
public abstract java.lang.String getReferenceDescription()
Gets a short description of this reference, e.g. "VirtualSpace" or "Label For".- Specified by:
getReferenceDescription
in interfaceIPropReference
- Returns:
- The reference description string.
isReferenceValid
public abstract boolean isReferenceValid(GProp<?> property)
Validates the property reference that has been looked up.- Specified by:
isReferenceValid
in interfaceIPropReference
- Parameters:
property
- The property to validate.- Returns:
- true if valid, false otherwise.