Package org.hippoecm.frontend.types
Class JavaTypeDescriptor
- java.lang.Object
-
- org.hippoecm.frontend.types.JavaTypeDescriptor
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.model.IDetachable
,org.apache.wicket.util.io.IClusterable
,IObservable
,ITypeDescriptor
- Direct Known Subclasses:
BuiltinTypeDescriptor
public class JavaTypeDescriptor extends Object implements ITypeDescriptor, org.apache.wicket.model.IDetachable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JavaTypeDescriptor(String name, String type, ITypeLocator locator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addField(IFieldDescriptor field)
Add a field to the type.void
addValidator(String validator)
protected void
checkMutable()
void
detach()
Map<String,IFieldDescriptor>
getDeclaredFields()
The map of fields that are declared in this type.IFieldDescriptor
getField(String key)
Retrieve the field associated with a key.Map<String,IFieldDescriptor>
getFields()
The map of fields that are declared in this type of any of its super types.String
getName()
The name of the type.List<ITypeDescriptor>
getSubTypes()
Retrieve all types that descend from the type.List<String>
getSuperTypes()
The super types of the type.String
getType()
The name of the underlying type can be different if this is a "pseudo" type.Set<String>
getValidators()
The symbolic names for validators associated with this type.boolean
isMixin()
Does the type correspond to a mixin, i.e.boolean
isMutable()
boolean
isNode()
Is the type a compound or mixin type, corresponding to a node type.boolean
isType(String typeName)
Returns true if this type istypeName
or a subtype oftypeName
, otherwise returnsfalse
.boolean
isValidationCascaded()
Returns true if validation is cascaded, i.e.void
removeField(String name)
Remove a field from the type.void
setIsMixin(boolean isMixin)
void
setIsNode(boolean isNode)
void
setIsValidationCascaded(boolean isCascaded)
void
setMutable(boolean mutable)
void
setObservationContext(IObservationContext context)
Before observation is started on the observable, an observation context is injected by the observer registry.void
setPrimary(String name)
Declare one of the fields to be the primary item.void
setSuperTypes(List<String> superTypes)
Set the super types of the type.void
startObservation()
When the firstIObserver
of this observable is registered with the observer registry, observation is started.void
stopObservation()
When the lastIObserver
unregisters, observation is stopped.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hippoecm.frontend.model.event.IObservable
equals, hashCode
-
-
-
-
Constructor Detail
-
JavaTypeDescriptor
public JavaTypeDescriptor(String name, String type, ITypeLocator locator)
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:ITypeDescriptor
The name of the type. It can be used to retrieve the type from a type store.- Specified by:
getName
in interfaceITypeDescriptor
- Returns:
- name of the type
-
getType
public String getType()
Description copied from interface:ITypeDescriptor
The name of the underlying type can be different if this is a "pseudo" type. This can be used to impose additional conditions on the original type, or to associate different templates with the type.For type descriptors that do not correspond to current or draft versions of a namespace, the prefix will be the JCR prefix. (E.g. myproject_0_0 when version 0.1 is current)
- Specified by:
getType
in interfaceITypeDescriptor
- Returns:
- the name of the real (JCR) type
-
getSuperTypes
public List<String> getSuperTypes()
Description copied from interface:ITypeDescriptor
The super types of the type. The type inherits fields from these types and the primary item, if it is defined in any of them. If the type is primitive, null will be returned.- Specified by:
getSuperTypes
in interfaceITypeDescriptor
- Returns:
- an immutable list of super types.
-
getSubTypes
public List<ITypeDescriptor> getSubTypes()
Description copied from interface:ITypeDescriptor
Retrieve all types that descend from the type.- Specified by:
getSubTypes
in interfaceITypeDescriptor
- Returns:
- an immutable list of sub types.
-
setSuperTypes
public void setSuperTypes(List<String> superTypes)
Description copied from interface:ITypeDescriptor
Set the super types of the type. If the type is a mixin type, then all of the super types must be mixin types too. This should not include nt:base for node types.- Specified by:
setSuperTypes
in interfaceITypeDescriptor
- Parameters:
superTypes
- the list of super types
-
getDeclaredFields
public Map<String,IFieldDescriptor> getDeclaredFields()
Description copied from interface:ITypeDescriptor
The map of fields that are declared in this type. This does not include the fields that are declared in any of the super types. If the type is primitive, null will be returned.- Specified by:
getDeclaredFields
in interfaceITypeDescriptor
- Returns:
- the list of fields declared in the type
-
getFields
public Map<String,IFieldDescriptor> getFields()
Description copied from interface:ITypeDescriptor
The map of fields that are declared in this type of any of its super types. If the type is primitive, null will be returned.- Specified by:
getFields
in interfaceITypeDescriptor
- Returns:
- an immutable list of fields in the type
-
getField
public IFieldDescriptor getField(String key)
Description copied from interface:ITypeDescriptor
Retrieve the field associated with a key.- Specified by:
getField
in interfaceITypeDescriptor
- Returns:
- the field descriptor
-
addField
public void addField(IFieldDescriptor field)
Description copied from interface:ITypeDescriptor
Add a field to the type.- Specified by:
addField
in interfaceITypeDescriptor
- Parameters:
field
- the field that is added to the type
-
removeField
public void removeField(String name)
Description copied from interface:ITypeDescriptor
Remove a field from the type.- Specified by:
removeField
in interfaceITypeDescriptor
- Parameters:
name
- the name of the field that is removed
-
setPrimary
public void setPrimary(String name)
Description copied from interface:ITypeDescriptor
Declare one of the fields to be the primary item. This is only valid when the field has been declared in the type, not in any of its super types. Additionally, none of the super types may have defined a primary item.- Specified by:
setPrimary
in interfaceITypeDescriptor
-
isNode
public boolean isNode()
Description copied from interface:ITypeDescriptor
Is the type a compound or mixin type, corresponding to a node type. False for the primitive types or any of their pseudo variants.- Specified by:
isNode
in interfaceITypeDescriptor
- Returns:
- whether the type corresponds to a node type
-
setIsNode
public void setIsNode(boolean isNode)
- Specified by:
setIsNode
in interfaceITypeDescriptor
-
isMixin
public boolean isMixin()
Description copied from interface:ITypeDescriptor
Does the type correspond to a mixin, i.e. can it be added dynamically to a Node.- Specified by:
isMixin
in interfaceITypeDescriptor
- Returns:
- whether the type corresponds to a mixin node type
-
setIsMixin
public void setIsMixin(boolean isMixin)
- Specified by:
setIsMixin
in interfaceITypeDescriptor
-
getValidators
public Set<String> getValidators()
Description copied from interface:ITypeDescriptor
The symbolic names for validators associated with this type.- Specified by:
getValidators
in interfaceITypeDescriptor
- Returns:
- the names of applicable validators
-
addValidator
public void addValidator(String validator)
- Specified by:
addValidator
in interfaceITypeDescriptor
-
isValidationCascaded
public boolean isValidationCascaded()
Description copied from interface:ITypeDescriptor
Returns true if validation is cascaded, i.e. whether fields with this type are automatically validated. When false, the field needs the "required" validator to get the field value validated.- Specified by:
isValidationCascaded
in interfaceITypeDescriptor
- Returns:
- whether fields of the type are automatically validated
-
setIsValidationCascaded
public void setIsValidationCascaded(boolean isCascaded)
- Specified by:
setIsValidationCascaded
in interfaceITypeDescriptor
- Parameters:
isCascaded
- are fields of this type always validated
-
setObservationContext
public void setObservationContext(IObservationContext context)
Description copied from interface:IObservable
Before observation is started on the observable, an observation context is injected by the observer registry. This context can be used to notify listeners.- Specified by:
setObservationContext
in interfaceIObservable
-
startObservation
public void startObservation()
Description copied from interface:IObservable
When the firstIObserver
of this observable is registered with the observer registry, observation is started. Implementations must notify observers until observation is stopped.An implementation should register listeners with external data sources, when appropriate. It is possible for an observable to register as an observer for another observable.
- Specified by:
startObservation
in interfaceIObservable
-
stopObservation
public void stopObservation()
Description copied from interface:IObservable
When the lastIObserver
unregisters, observation is stopped. Any listeners or observers registered by the observable must be unregistered by the implementation.- Specified by:
stopObservation
in interfaceIObservable
-
isType
public boolean isType(String typeName)
Description copied from interface:ITypeDescriptor
Returns true if this type istypeName
or a subtype oftypeName
, otherwise returnsfalse
.- Specified by:
isType
in interfaceITypeDescriptor
- Parameters:
typeName
- the name of a node type.- Returns:
- a boolean
-
checkMutable
protected void checkMutable()
-
isMutable
public boolean isMutable()
-
setMutable
public void setMutable(boolean mutable)
-
detach
public void detach()
- Specified by:
detach
in interfaceorg.apache.wicket.model.IDetachable
-
-