|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.domain.DomainService
com.arsdigita.cms.ACSObjectFactory
Provides static methods to instantiate proper subclasses of ACSObject
domain objects, based on the object
type and the Java class name.
ACSObject
Field Summary | |
static String |
versionId
|
Constructor Summary | |
ACSObjectFactory()
|
Method Summary | |
static com.arsdigita.kernel.ACSObject |
castACSObject(com.arsdigita.kernel.ACSObject obj)
Attempt to "cast" an ACSObject to a proper
ACSObject subclass. |
static com.arsdigita.kernel.ACSObject |
castACSObject(com.arsdigita.persistence.DataObject obj)
Attempt to "cast" a DataObject to a proper
ACSObject subclass. |
static ContentItem |
castContentItem(ContentItem item)
"Cast" the ContentItem to its proper subclass, based on the
values in its content type. |
static ContentItem |
castContentItem(com.arsdigita.persistence.DataObject obj)
Attempt to "cast" a DataObject to a proper
ContentItem subclass. |
static ContentItem |
castContentItem(com.arsdigita.persistence.DataObject obj,
boolean useContentType)
Attempt to "cast" a DataObject to a proper
ContentItem subclass. |
static ContentItem |
castContentItem(com.arsdigita.domain.DomainObject obj)
Attempt to "cast" a DomainObject to a proper
ContentItem subclass. |
static com.arsdigita.kernel.ACSObject |
createACSObject(String javaClassName)
Instantiate a subclass of ACSObject ,
blatantly disregarding ObjectType. |
static com.arsdigita.kernel.ACSObject |
createACSObject(String javaClassName,
String objectType)
Create a proper subclass of ACSObject . |
static Collection |
getKeyAttributeNames(com.arsdigita.persistence.metadata.ObjectType type)
Get an array of all attribute names which comprise the type's primary key |
static Collection |
getKeyAttributes(com.arsdigita.persistence.metadata.ObjectType type)
Get a collection of all attributes which comprise the type's primary key |
static com.arsdigita.persistence.metadata.ObjectType |
getSpecificObjectType(com.arsdigita.kernel.ACSObject obj)
Attempt to retrieve the true object type of the item from the "object_type" column of ACSObject . |
static com.arsdigita.kernel.ACSObject |
loadACSObject(Class javaClass,
String objectType,
BigDecimal id)
Load a proper subclass of the ACSObject domain object
from the database |
static com.arsdigita.kernel.ACSObject |
loadACSObject(String javaClass,
String objectType,
BigDecimal id)
Load a proper subclass of the ACSObject domain object
from the database |
Methods inherited from class com.arsdigita.domain.DomainService |
add, add, clear, get, getDataCollection, getDataObject, remove, remove, set, setAssociation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public ACSObjectFactory()
Method Detail |
public static com.arsdigita.kernel.ACSObject loadACSObject(Class javaClass, String objectType, BigDecimal id)
ACSObject
domain object
from the database
javaClass
- The Java Class
to be instantiatedobjectType
- the object type of the object to instantiated; should
extend the ACSObject
id
- the primary key for the new object
javaClass
public static com.arsdigita.kernel.ACSObject loadACSObject(String javaClass, String objectType, BigDecimal id)
ACSObject
domain object
from the database
javaClass
- The name of the Java class to be instantiatedobjectType
- the object type of the object to instantiate; should
extend the ACSObject
id
- the primary key for the new object
javaClass
public static ContentItem castContentItem(ContentItem item)
ContentItem
to its proper subclass, based on the
values in its content type. Return the item itself on failure.
Note that this method performs 2 extra database hits: one hit to get the content type, and another hit to get the new item.
item
- the ContentItem
to cast
ContentItem
, such as
ContentPage
public static com.arsdigita.persistence.metadata.ObjectType getSpecificObjectType(com.arsdigita.kernel.ACSObject obj)
ACSObject
.
On failure, return the type which is recorder in the
item's OID
obj
- the ACSObject
public static com.arsdigita.kernel.ACSObject castACSObject(com.arsdigita.persistence.DataObject obj)
DataObject
to a proper
ACSObject
subclass. Return null if the data object
does not represent an ACSObject
.
This method assumes that the Java class name is the same as the object type name of the object. If this assumption fails, the method will return null.
If the assumption turns out to be true, this method
will try to instantiate the desired object with the
constructor public Foo(DataObject obj)
.
If the constructor does not exist, the method will
return null.
The data object obj
is specialized to the right
subclass if that is necessary.
obj
- the DataObject
to cast
ACSObject
,
or null on failurecastContentItem(com.arsdigita.cms.ContentItem)
public static com.arsdigita.kernel.ACSObject castACSObject(com.arsdigita.kernel.ACSObject obj)
ACSObject
to a proper
ACSObject
subclass. Return the original
object on failure
This method assumes that the Java class name is the same as the object type name of the object. If this assumption fails, the method will return null.
obj
- the ACSObject
to cast
ACSObject
,
or null on failurecastContentItem(com.arsdigita.cms.ContentItem)
public static ContentItem castContentItem(com.arsdigita.persistence.DataObject obj, boolean useContentType)
DataObject
to a proper
ContentItem
subclass. Return null if the data object
does not represent a content item.
Note that this method performs 2 extra database hits: one hit to get the content type, and another hit to get the new item.
obj
- the DataObject
to castuseContentType
- if true, try to access the item's content type
in order to get the Java class name. If false, assume that
the java class name is the same as the object type.
ContentItem
, such as
ContentPage
public static ContentItem castContentItem(com.arsdigita.persistence.DataObject obj)
DataObject
to a proper
ContentItem
subclass. Return null if the data object
does not represent a content item.
Note that this method performs 2 extra database hits: one hit to get the content type, and another hit to get the new item.
obj
- the DataObject
to cast
ContentItem
, such as
ContentPage
public static ContentItem castContentItem(com.arsdigita.domain.DomainObject obj)
DomainObject
to a proper
ContentItem
subclass. Return null if the domain object
does not represent a content item.
Note that this method performs 2 extra database hits: one hit to get the content type, and another hit to get the new item.
obj
- the DomainObject
to cast
ContentItem
, such as
ContentPage
public static com.arsdigita.kernel.ACSObject createACSObject(String javaClassName, String objectType)
ACSObject
. Requires the class
designated by javaClassName
to have a constructor
with a single String parameter. The String parameter should specify
the object type of the new object.
javaClassName
- The name of the Java Class
to be instantiatedobjectType
- the object type of the object to instantiated; should
extend the ACSObject
ACSObject
on success, null on failurepublic static com.arsdigita.kernel.ACSObject createACSObject(String javaClassName)
ACSObject
,
blatantly disregarding ObjectType.
javaClassName
- The name of the Java Class
to be instantiated
ACSObject
on success, null on failurepublic static Collection getKeyAttributes(com.arsdigita.persistence.metadata.ObjectType type)
public static Collection getKeyAttributeNames(com.arsdigita.persistence.metadata.ObjectType type)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |