org.nakedobjects.metamodel.spec
Class JavaSpecification

java.lang.Object
  extended by org.nakedobjects.metamodel.facets.FacetHolderImpl
      extended by org.nakedobjects.metamodel.runtimecontext.spec.IntrospectableSpecificationAbstract
          extended by org.nakedobjects.metamodel.spec.JavaSpecification
All Implemented Interfaces:
DebugInfo, FacetHolder, DefaultProvider, Dirtiable, NakedObjectActionContainer, NakedObjectAssociationContainer, Hierarchical, Identified, IntrospectableSpecification, NakedObjectSpecification, Specification

public class JavaSpecification
extends IntrospectableSpecificationAbstract
implements DebugInfo, FacetHolder


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nakedobjects.metamodel.spec.NakedObjectSpecification
NakedObjectSpecification.CreationMode
 
Field Summary
 
Fields inherited from class org.nakedobjects.metamodel.runtimecontext.spec.IntrospectableSpecificationAbstract
fields, fullName, identifier, objectActions, superClassSpecification
 
Constructor Summary
JavaSpecification(java.lang.Class<?> cls, NakedObjectReflectorAbstract reflector, RuntimeContext runtimeContext)
           
 
Method Summary
 void addSubclass(NakedObjectSpecification subclass)
          Add the class for the specified specification as a subclass of this specification's class.
 void clearDirty(NakedObject object)
          Clear the dirty flag so that a call to isDirty(), and before markDirty() is called, will return false;
 java.lang.Object createObject(NakedObjectSpecification.CreationMode creationMode)
          Create and optionally initialize object.
 void debugData(DebugString debug)
          Debug details describing the object being investigated
 java.lang.String debugTitle()
          The title for the debug information
protected  NakedObjectAction[] getActions(NakedObjectAction[] availableActions, NakedObjectActionType type)
           
 NakedObjectAssociation getAssociation(java.lang.String id)
          Get the field object representing the field with the specified field identifier.
 java.lang.String getDescription()
          Returns the description, if any, of the specification.
 java.lang.String getIconName(NakedObject reference)
          Returns the name of an icon to use for the specified object.
 NakedObjectMember getMember(java.lang.reflect.Method method)
           
 NakedObjectAction getObjectAction(NakedObjectActionType type, java.lang.String nameParmsIdentityString)
          Get the action object represented by the specified identity string.
 NakedObjectAction getObjectAction(NakedObjectActionType type, java.lang.String id, NakedObjectSpecification[] parameters)
          Returns the action of the specified type with the specified signature.
 java.lang.String getPluralName()
          Returns the plural name for objects of this specification.
 java.lang.String getShortName()
          Returns the class name without the package.
 java.lang.String getSingularName()
          Returns the singular name for objects of this specification.
 java.lang.String getTitle(NakedObject object)
          Returns the title string for the specified object.
 boolean hasSubclasses()
          Returns true if the subclasses() method will return an array of one or more elements (ie, not an empty array).
 NakedObjectSpecification[] interfaces()
          Get the list of specifications for all the interfaces that the class represented by this specification implements.
 void introspect(FacetDecoratorSet decorator)
          Discovers what attributes and behaviour the type specified by this specification.
 boolean isAbstract()
           
 boolean isCollectionOrIsAggregated()
          Whether objects of this type are a collection or are intrinsically aggregated.
 boolean isDirty(NakedObject object)
          Checks if the specified object has been changed, and hence needs persisting.
 boolean isFinal()
          Whether or not this specification's class is marked as final, that is it may not have subclasses, and hence methods that could be overridden.
 boolean isIntrospected()
          Added to try to track down a race condition.
 boolean isOfType(NakedObjectSpecification specification)
          Determines if this class represents the same class, or a subclass, of the specified class.
 boolean isService()
           
 void markAsService()
          TODO: should ensure that service has at least one user action; fix when specification knows of its hidden methods.
 void markDirty(NakedObject object)
          Mark the specified object as having been changed, and hence needing persisting.
 Persistability persistability()
          Determines if objects of this specification can be persisted or not.
 NakedObjectSpecification[] subclasses()
          Get the list of specifications for the subclasses of the class represented by this specification
 java.lang.String toString()
           
 
Methods inherited from class org.nakedobjects.metamodel.runtimecontext.spec.IntrospectableSpecificationAbstract
createTitleInteractionContext, createValidityInteractionContext, getAssociationList, getAssociationList, getAssociations, getAssociations, getAuthenticationSession, getCollectionList, getDefaultValue, getFacet, getFullName, getIdentifier, getInstance, getObjectActionList, getObjectActions, getPropertyList, getRuntimeContext, getServiceActions, getServiceActionsFor, isCollection, isEncodeable, isImmutable, isObject, isParseable, isValid, isValidResult, isValueOrIsAggregated, setIntrospected, superclass
 
Methods inherited from class org.nakedobjects.metamodel.facets.FacetHolderImpl
addFacet, addFacet, containsFacet, getFacets, getFacetTypes, removeFacet, removeFacet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.metamodel.facets.FacetHolder
addFacet, addFacet, containsFacet, getFacet, getFacets, getFacetTypes, removeFacet, removeFacet
 

Constructor Detail

JavaSpecification

public JavaSpecification(java.lang.Class<?> cls,
                         NakedObjectReflectorAbstract reflector,
                         RuntimeContext runtimeContext)
Method Detail

addSubclass

public void addSubclass(NakedObjectSpecification subclass)
Description copied from interface: Hierarchical
Add the class for the specified specification as a subclass of this specification's class.

Specified by:
addSubclass in interface Hierarchical
Overrides:
addSubclass in class IntrospectableSpecificationAbstract

hasSubclasses

public boolean hasSubclasses()
Description copied from interface: Hierarchical
Returns true if the subclasses() method will return an array of one or more elements (ie, not an empty array).

Specified by:
hasSubclasses in interface Hierarchical
Overrides:
hasSubclasses in class IntrospectableSpecificationAbstract

interfaces

public NakedObjectSpecification[] interfaces()
Description copied from interface: Hierarchical
Get the list of specifications for all the interfaces that the class represented by this specification implements.

Specified by:
interfaces in interface Hierarchical
Overrides:
interfaces in class IntrospectableSpecificationAbstract

subclasses

public NakedObjectSpecification[] subclasses()
Description copied from interface: Hierarchical
Get the list of specifications for the subclasses of the class represented by this specification

Specified by:
subclasses in interface Hierarchical
Overrides:
subclasses in class IntrospectableSpecificationAbstract

isOfType

public boolean isOfType(NakedObjectSpecification specification)
Determines if this class represents the same class, or a subclass, of the specified class.

Specified by:
isOfType in interface Hierarchical
Overrides:
isOfType in class IntrospectableSpecificationAbstract

introspect

public void introspect(FacetDecoratorSet decorator)
Description copied from interface: IntrospectableSpecification
Discovers what attributes and behaviour the type specified by this specification.

As specifications are cyclic (specifically a class will reference its subclasses, which in turn reference their superclass) they need be created first, and then later work out its internals. This allows for cyclic references to the be accommodated as there should always a specification available even though it might not be complete.

Specified by:
introspect in interface IntrospectableSpecification

isIntrospected

public boolean isIntrospected()
Added to try to track down a race condition.

Specified by:
isIntrospected in interface IntrospectableSpecification
Overrides:
isIntrospected in class IntrospectableSpecificationAbstract

getMember

public NakedObjectMember getMember(java.lang.reflect.Method method)

getAssociation

public NakedObjectAssociation getAssociation(java.lang.String id)
Description copied from interface: NakedObjectAssociationContainer
Get the field object representing the field with the specified field identifier.

Specified by:
getAssociation in interface NakedObjectAssociationContainer

getObjectAction

public NakedObjectAction getObjectAction(NakedObjectActionType type,
                                         java.lang.String id,
                                         NakedObjectSpecification[] parameters)
Description copied from interface: NakedObjectActionContainer
Returns the action of the specified type with the specified signature.

Specified by:
getObjectAction in interface NakedObjectActionContainer

getObjectAction

public NakedObjectAction getObjectAction(NakedObjectActionType type,
                                         java.lang.String nameParmsIdentityString)
Description copied from interface: NakedObjectActionContainer
Get the action object represented by the specified identity string.

The identity string should be Identifier.toNameParmsIdentityString().

Specified by:
getObjectAction in interface NakedObjectActionContainer

getActions

protected NakedObjectAction[] getActions(NakedObjectAction[] availableActions,
                                         NakedObjectActionType type)
Overrides:
getActions in class IntrospectableSpecificationAbstract

isCollectionOrIsAggregated

public boolean isCollectionOrIsAggregated()
Description copied from interface: NakedObjectSpecification
Whether objects of this type are a collection or are intrinsically aggregated.

In effect, means has got a CollectionFacet and/or got the AggregatedFacet.

Specified by:
isCollectionOrIsAggregated in interface NakedObjectSpecification
Overrides:
isCollectionOrIsAggregated in class IntrospectableSpecificationAbstract

isAbstract

public boolean isAbstract()
Specified by:
isAbstract in interface NakedObjectSpecification
Overrides:
isAbstract in class IntrospectableSpecificationAbstract

isFinal

public boolean isFinal()
Description copied from class: IntrospectableSpecificationAbstract
Whether or not this specification's class is marked as final, that is it may not have subclasses, and hence methods that could be overridden.

Note - not used at present.

Overrides:
isFinal in class IntrospectableSpecificationAbstract

isService

public boolean isService()
Specified by:
isService in interface NakedObjectSpecification
Overrides:
isService in class IntrospectableSpecificationAbstract

getShortName

public java.lang.String getShortName()
Description copied from interface: NakedObjectSpecification
Returns the class name without the package. Removes the text up to, and including the last period (".").

Specified by:
getShortName in interface NakedObjectSpecification

getSingularName

public java.lang.String getSingularName()
Description copied from interface: NakedObjectSpecification
Returns the singular name for objects of this specification.

Specified by:
getSingularName in interface NakedObjectSpecification

getPluralName

public java.lang.String getPluralName()
Description copied from interface: NakedObjectSpecification
Returns the plural name for objects of this specification.

Specified by:
getPluralName in interface NakedObjectSpecification

getDescription

public java.lang.String getDescription()
Description copied from interface: NakedObjectSpecification
Returns the description, if any, of the specification.

Specified by:
getDescription in interface NakedObjectSpecification

getTitle

public java.lang.String getTitle(NakedObject object)
Description copied from interface: NakedObjectSpecification
Returns the title string for the specified object.

Specified by:
getTitle in interface NakedObjectSpecification

getIconName

public java.lang.String getIconName(NakedObject reference)
Description copied from interface: NakedObjectSpecification
Returns the name of an icon to use for the specified object.

Specified by:
getIconName in interface NakedObjectSpecification
Overrides:
getIconName in class IntrospectableSpecificationAbstract

persistability

public Persistability persistability()
Description copied from interface: NakedObjectSpecification
Determines if objects of this specification can be persisted or not. If it can be persisted (i.e. it return something other than Persistability.TRANSIENT NakedObject.isPersistent() will indicated whether the object is persistent or not. If they cannot be persisted then NakedObject. NakedObjectSpecification.persistability() should be ignored.

Specified by:
persistability in interface NakedObjectSpecification
Overrides:
persistability in class IntrospectableSpecificationAbstract

createObject

public java.lang.Object createObject(NakedObjectSpecification.CreationMode creationMode)
Description copied from interface: NakedObjectSpecification
Create and optionally initialize object.

Specified by:
createObject in interface NakedObjectSpecification
Overrides:
createObject in class IntrospectableSpecificationAbstract

isDirty

public boolean isDirty(NakedObject object)
Description copied from interface: Dirtiable
Checks if the specified object has been changed, and hence needs persisting.

Specified by:
isDirty in interface Dirtiable
Overrides:
isDirty in class IntrospectableSpecificationAbstract
See Also:
Dirtiable.markDirty(NakedObject), Dirtiable.clearDirty(NakedObject)

clearDirty

public void clearDirty(NakedObject object)
Description copied from interface: Dirtiable
Clear the dirty flag so that a call to isDirty(), and before markDirty() is called, will return false;

Specified by:
clearDirty in interface Dirtiable
Overrides:
clearDirty in class IntrospectableSpecificationAbstract
See Also:
Dirtiable.isDirty(NakedObject), Dirtiable.markDirty(NakedObject)

markDirty

public void markDirty(NakedObject object)
Description copied from interface: Dirtiable
Mark the specified object as having been changed, and hence needing persisting.

Specified by:
markDirty in interface Dirtiable
Overrides:
markDirty in class IntrospectableSpecificationAbstract
See Also:
Dirtiable.isDirty(NakedObject), Dirtiable.clearDirty(NakedObject)

markAsService

public void markAsService()
TODO: should ensure that service has at least one user action; fix when specification knows of its hidden methods.
 if (objectActions != null && objectActions.length == 0) {
     throw new NakedObjectSpecificationException("Service object " + getFullName() + " should have at least one user action");
 }
 

Specified by:
markAsService in interface IntrospectableSpecification

debugData

public void debugData(DebugString debug)
Description copied from interface: DebugInfo
Debug details describing the object being investigated

Specified by:
debugData in interface DebugInfo

debugTitle

public java.lang.String debugTitle()
Description copied from interface: DebugInfo
The title for the debug information

Specified by:
debugTitle in interface DebugInfo

toString

public java.lang.String toString()
Overrides:
toString in class IntrospectableSpecificationAbstract


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.