Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.db
Class AbstractDBObject

java.lang.Object
  extended by oracle.javatools.db.AbstractDBObject

All Implemented Interfaces:
DBObject, Copyable, DynamicPropertySet
Direct Known Subclasses:
AbstractBuildableObject, AbstractChildDBObject, DataTypeSynonym, PredefinedDataType

public abstract class AbstractDBObject
extends java.lang.Object
implements DBObject

Provides an abstract implementation of the DBObject interface.

Since:
9.0.5
For internal use only. Application developers should not use this

Nested Class Summary
protected  class AbstractDBObject.ChildSupport
           
protected  class AbstractDBObject.ListenerSupport
          Utility class for caching a list of DBObjectListeners and firing events to them.

 

Field Summary

 

Fields inherited from interface oracle.javatools.db.DBObject
COMMENT

 

Constructor Summary
protected AbstractDBObject()
          Constructs a new instance.
protected AbstractDBObject(java.lang.String name)
          Constructs a new instance with the specified name.
protected AbstractDBObject(java.lang.String name, DBObjectID id)
          Constructs a new instance with the specified name and id.

 

Method Summary
protected  void changeParent(ChildDBObject oldChild, ChildDBObject newChild)
          Changes the parent by removing this object as the parent on the oldChild and setting this object as the parent of the newChild.
protected  int compareToImpl(AbstractDBObject target)
           
protected
<T> T
copyObject(T value, DBObject copy, IDPolicy idPolicy)
          Recursive function that can copy all objects supported as properties in the API.
 DBObject copyTo(DBObject target, boolean temporaryCopy)
          Copies the state of this object to another instance.
protected  DBObject copyTo(DBObject target, DBObject copyParent, IDPolicy idPolicy)
          Internal copy method used by the API to perform copy operations.
 DBObject copyTo(DBObject target, IDPolicy idPolicy)
          Copies the state of this object to another instance.
 java.lang.Object copyTo(java.lang.Object target)
          Implementation of the Copyable interface that copies the state of this DBObject to another instance.
protected  void copyToImpl(AbstractDBObject copy, DBObject copyParent, IDPolicy idPolicy)
          Implementation method for making a copy of this object.
 boolean equals(java.lang.Object other)
           
protected  boolean equalsImpl(AbstractDBObject other)
          Equals implementation for testing equality with another AbstractDBObject.
 DBObject findOwnedObject(DBObjectID id)
          Returns a child of this object that has the given ID.
protected  DBObject findOwnedObject(DBObjectID id, boolean deep)
          Finds an owned object with the given ID, optionally recursing into the owned object heirachy.
 DBObject findOwnedObject(java.lang.String type, java.lang.String name)
          Final implementation uses getChildrenImpl( String type ) and searches through the contained DBObjects by name.
protected  AbstractDBObject.ChildSupport getChildSupport(java.lang.String propName)
           
 DBObjectID getID()
          Retrieves the object ID associated with this object.
 java.lang.String getName()
          Retrieves the name of this object.
 DBObject[] getOwnedObjects()
          Final implementation calls getOwnedObjectsImpl with a null argument for the type.
 DBObject[] getOwnedObjects(java.lang.String... types)
          Final implementation calls getOwnedObjectsImpl with the given types.
protected  void getOwnedObjectsImpl(java.util.Collection<DBObject> objs, java.lang.String... types)
          Used by all the final children methods.
 java.util.Map getProperties()
          Returns null if no properties are set.
 java.lang.Object getProperty(java.lang.String key)
          Retrieves the value associated with a property.
 java.lang.Object getProperty(java.lang.String key, java.lang.Object defaultValue)
          Retrieves the value associated with a property.
 DBObjectID[] getReferenceIDs()
          Final implementation that calls the internal getReferenceIDsImpl() method.
protected  void getReferenceIDsImpl(java.util.Collection<DBObjectID> refs)
          Used by the final getReferenceID() implementation.
 int hashCode()
           
protected  void includeOwnedObject(java.util.Collection<DBObject> objs, DBObject obj, java.lang.String... types)
           
protected  boolean includesType(DBObject obj, java.lang.String... types)
          Use to check the types parameter when implementing the getOwnedObjectsImpl method.
protected  boolean includesType(java.lang.String type, java.lang.String... types)
          Use to check the types parameter when implementing the getOwnedObjectsImpl method.
protected  void removeThisAsParent(ChildDBObject child)
          If the given child object has this object as a parent, this method will remove the parent setting.
 boolean replaceReferenceIDs(java.util.Map<DBObjectID,DBObjectID> idMap)
          Override in subclasses to replace reference IDs as appropriate.
 void setID(DBObjectID id)
          Sets the object ID associated with this object.
 void setName(java.lang.String name)
          Sets the name of this object.
 void setProperties(java.util.Map properties)
          Sets the properties of this object to be those in the given Map.
 void setProperty(java.lang.String key, java.lang.Object value)
          Sets the value for a property.
 java.lang.String toString()
           

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface oracle.javatools.db.DBObject
getParent, getType

 

Constructor Detail

AbstractDBObject

protected AbstractDBObject()
Constructs a new instance.

AbstractDBObject

protected AbstractDBObject(java.lang.String name)
Constructs a new instance with the specified name.
Parameters:
name - a string representing the name of this object.

AbstractDBObject

protected AbstractDBObject(java.lang.String name,
                           DBObjectID id)
Constructs a new instance with the specified name and id.
Parameters:
name - a string representing the name of this object.
id - the id for this object.

Method Detail

copyTo

public final java.lang.Object copyTo(java.lang.Object target)
Description copied from interface: DBObject
Implementation of the Copyable interface that copies the state of this DBObject to another instance. If null is specified for the target, a new instance will be created.

The entire state of the object will be copied, with a few exceptions. In particular, any observers registered will NOT be copied. In cases where this instance contains child DBObjects, new instances of those children will be created, and the state copied to them. The copy will thus contain its own unique state; after making the copy, changing one instance will not cause any changes to occur to the copy. The properties will be copied; however, copies will not be made of the values referenced by the properties - thus, the copy will refer to the same instance as the original. Child objects that are copied will still point to the original parent; it is the responsibility of a copied parent to update the parent of copies of its children point to the copy of itself.

If the object, or any child object has an ID set, the equivalent object in the copy will be given a TemporaryObjectID that does not reference back to the original object. See DBObject.copyTo(DBObject, boolean) for details.

Specified by:
copyTo in interface DBObject
Specified by:
copyTo in interface Copyable
Parameters:
target - The object to copy to. If target is null, a new instance will be created, and the state will be copied to that object.
Returns:
the copy.
See Also:
DBObject.copyTo(DBObject, boolean)

copyTo

public final DBObject copyTo(DBObject target,
                             boolean temporaryCopy)
Description copied from interface: DBObject
Copies the state of this object to another instance. If null is specified for the target, a new instance will be created.

The entire state of the object will be copied. In cases where this instance contains child DBObjects, new instances of those children will be created, and the state copied to them. The copy will thus contain its own unique state; after making the copy, changing one instance will not cause any changes to occur to the copy. The properties will be copied; however, copies will not be made of the values referenced by the properties - thus, the copy will refer to the same instance as the original.

The includeID parameter governs what happens to any ids (on this object, or on any children). If true a TemporaryObjectID will be assigned to the copy of any DBObject, that points back to the original object. If false a TemporaryObjectID will be assigned to the copy of any DBObject that already has an ID, but it will not point back to the original.

Specified by:
copyTo in interface DBObject
Parameters:
target - The object to copy to. If target is null, a new instance will be created, and the state will be copied to that object.
temporaryCopy - Whether to include a TemporaryObjectID that points back to the original for every object.
Returns:
the copy.
See Also:
TemporaryObjectID, DBObject.copyTo(java.lang.Object)

copyTo

public final DBObject copyTo(DBObject target,
                             IDPolicy idPolicy)
Description copied from interface: DBObject
Copies the state of this object to another instance. If null is specified for the target, a new instance will be created.

The entire state of the object will be copied. In cases where this instance contains child DBObjects, new instances of those children will be created, and the state copied to them. The copy will thus contain its own unique state; after making the copy, changing one instance will not cause any changes to occur to the copy. The properties will be copied; however, copies will not be made of the values referenced by the properties - thus, the copy will refer to the same instance as the original.

The idPolicy is used to control the IDs set on all objects in the copy.

Specified by:
copyTo in interface DBObject
Parameters:
target - The object to copy to. If target is null, a new instance will be created, and the state will be copied to that object.
idPolicy - The policy for the IDs set in the copy.
Returns:
the copy.
See Also:
TemporaryObjectID, DBObject.copyTo(java.lang.Object), DBObject.copyTo(DBObject, boolean)

copyTo

protected final DBObject copyTo(DBObject target,
                                DBObject copyParent,
                                IDPolicy idPolicy)
Internal copy method used by the API to perform copy operations. All objects must implement this method if they are instantiable objects. Abstract objects (e.g. Relation) must NOT implement this method. The implementation should delegate to the copyToImpl method to copy the actual properties.

This method does not fix internal reference ids on copy. That is done by the calling DBObject.copyTo(DBObject, IDPolicy) method.

See Also:
DBObject.copyTo(java.lang.Object), DBObject.copyTo(DBObject, boolean), copyToImpl(oracle.javatools.db.AbstractDBObject, oracle.javatools.db.DBObject, oracle.javatools.db.IDPolicy)
For internal use only. Application developers should not use this

copyToImpl

protected void copyToImpl(AbstractDBObject copy,
                          DBObject copyParent,
                          IDPolicy idPolicy)
Implementation method for making a copy of this object. To add custom copyTo logic, a subclass must override this method (exactly), and must call back to the super implementation.
Parameters:
copy - the copy being created of this object
copyParent - if this object is being copied underneath a parent, this parameter is the copy of the parent of this object, which will therefore need to be the parent of the copy of this object.
idPolicy - the policy for copying the object's ID.

copyObject

protected <T> T copyObject(T value,
                           DBObject copy,
                           IDPolicy idPolicy)
Recursive function that can copy all objects supported as properties in the API.

equals

public final boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

equalsImpl

protected boolean equalsImpl(AbstractDBObject other)
Equals implementation for testing equality with another AbstractDBObject. Override this method (with exact signature) to customise the equality comparison.

compareToImpl

protected int compareToImpl(AbstractDBObject target)

toString

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setName

public void setName(java.lang.String name)
Description copied from interface: DBObject
Sets the name of this object.
Specified by:
setName in interface DBObject
Parameters:
name - a string containing the new name for this object.

getName

public java.lang.String getName()
Description copied from interface: DBObject
Retrieves the name of this object.
Specified by:
getName in interface DBObject
Returns:
a string containing the name of this object.

setID

public void setID(DBObjectID id)
Description copied from interface: DBObject
Sets the object ID associated with this object. Note that the ID should only be set at most once. Implementations should ensure that the id is not reset.
Specified by:
setID in interface DBObject
Parameters:
id - the DBObjectID to be associated with this object

getID

public final DBObjectID getID()
Description copied from interface: DBObject
Retrieves the object ID associated with this object.
Specified by:
getID in interface DBObject
Returns:
the DBObjectID associated with this object

getProperties

public java.util.Map getProperties()
Returns null if no properties are set.
Specified by:
getProperties in interface DynamicPropertySet

getProperty

public java.lang.Object getProperty(java.lang.String key)
Description copied from interface: DynamicPropertySet
Retrieves the value associated with a property.
Specified by:
getProperty in interface DynamicPropertySet
Parameters:
key - the property key for which a value is desired. exists.
Returns:
the value of the requested property, or a null value if the property does not exist or is not set.

getProperty

public final java.lang.Object getProperty(java.lang.String key,
                                          java.lang.Object defaultValue)
Description copied from interface: DynamicPropertySet
Retrieves the value associated with a property. If no value exists for the requested property, the specified default value is returned.
Specified by:
getProperty in interface DynamicPropertySet
Parameters:
key - the property key for which a value is desired.
defaultValue - the value to return if no value currently exists.
Returns:
the value of the requested property, or the default value if the property does not exist.

setProperties

public void setProperties(java.util.Map properties)
Sets the properties of this object to be those in the given Map. The keys in the map must be Strings. For backwards compatability this cannot be used to remove values for properties for which there is a set method (for example if the given Map doesn't contain the "name" key, the name of this object will not be removed).
Specified by:
setProperties in interface DynamicPropertySet
Parameters:
properties - the new properties for this object.
Throws:
java.lang.ClassCastException - if any key in the given Map isn't a String.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Description copied from interface: DynamicPropertySet
Sets the value for a property. Setting a value to null removes that property.
Specified by:
setProperty in interface DynamicPropertySet
Parameters:
key - the property key to set
value - the value to set

removeThisAsParent

protected final void removeThisAsParent(ChildDBObject child)
If the given child object has this object as a parent, this method will remove the parent setting.

changeParent

protected final void changeParent(ChildDBObject oldChild,
                                  ChildDBObject newChild)
Changes the parent by removing this object as the parent on the oldChild and setting this object as the parent of the newChild.

getOwnedObjects

public final DBObject[] getOwnedObjects()
Final implementation calls getOwnedObjectsImpl with a null argument for the type. Subclasses must override getOwnedObjectsImpl as appropriate.
Specified by:
getOwnedObjects in interface DBObject
Returns:
the children of the object, null if none.
See Also:
getOwnedObjectsImpl(java.util.Collection<oracle.javatools.db.DBObject>, java.lang.String...), DBObject.getOwnedObjects()

getOwnedObjects

public final DBObject[] getOwnedObjects(java.lang.String... types)
Final implementation calls getOwnedObjectsImpl with the given types. Subclasses must override getOwnedObjectsImpl as appropriate.
Specified by:
getOwnedObjects in interface DBObject
See Also:
getOwnedObjectsImpl(java.util.Collection<oracle.javatools.db.DBObject>, java.lang.String...), DBObject.getOwnedObjects(java.lang.String...)

findOwnedObject

public final DBObject findOwnedObject(java.lang.String type,
                                      java.lang.String name)
Final implementation uses getChildrenImpl( String type ) and searches through the contained DBObjects by name. Subclasses must override getChildrenImpl as appropriate.
Specified by:
findOwnedObject in interface DBObject
Parameters:
type - the DBObject type for the child to be returned (e.g. Column.TYPE)
name - the name of the DBObject to be returned
Returns:
the appropriate child object, if one exists.
See Also:
getOwnedObjectsImpl(java.util.Collection<oracle.javatools.db.DBObject>, java.lang.String...), DBObject.findOwnedObject(java.lang.String, java.lang.String)

findOwnedObject

public DBObject findOwnedObject(DBObjectID id)
Returns a child of this object that has the given ID. The child is located by comparing IDs, not by calling resolveID() which is quicker. The method does not recurse to look for children of children. This method is a candidate for adding to the DBObject interface.
Specified by:
findOwnedObject in interface DBObject
Parameters:
id - the id to look for
Returns:
a child object found with that id.

findOwnedObject

protected final DBObject findOwnedObject(DBObjectID id,
                                         boolean deep)
Finds an owned object with the given ID, optionally recursing into the owned object heirachy.
Parameters:
id - the object ID to look for
deep - whether to recurse further into owned objects' owned objects (and so on)
Returns:
a found object with the given ID.

getOwnedObjectsImpl

protected void getOwnedObjectsImpl(java.util.Collection<DBObject> objs,
                                   java.lang.String... types)
Used by all the final children methods. Subclasses should start with super.getOwnedObjectsImpl(type) and then add to the passed list. Use includesType to check the types vararg.
Parameters:
types - a vararg of the type(s) to search for
objs - a Collection of the apppropriate children.
See Also:
includesType(java.lang.String, java.lang.String...)

includeOwnedObject

protected final void includeOwnedObject(java.util.Collection<DBObject> objs,
                                        DBObject obj,
                                        java.lang.String... types)

includesType

protected final boolean includesType(java.lang.String type,
                                     java.lang.String... types)
Use to check the types parameter when implementing the getOwnedObjectsImpl method. For example to check for Columns:

if ( includesType( Column.TYPE, types ) ) ...

Parameters:
type - the type we're interested in
types - the types parameter passed to getOwnedObjectsImpl
Returns:
true if we should include the given type in our processing

includesType

protected final boolean includesType(DBObject obj,
                                     java.lang.String... types)
Use to check the types parameter when implementing the getOwnedObjectsImpl method. For example to check for a column:

if ( includesType( column, types ) ) ...

Parameters:
obj - the object to test whether we should include
types - the types parameter passed to getOwnedObjectsImpl
Returns:
true if we should include the given object in our processing

getReferenceIDs

public final DBObjectID[] getReferenceIDs()
Final implementation that calls the internal getReferenceIDsImpl() method. Subclasses should override that method.
Specified by:
getReferenceIDs in interface DBObject
Returns:
all property values that are DBObjectIDs.
See Also:
getReferenceIDsImpl(java.util.Collection<oracle.javatools.db.DBObjectID>), DBObject.getReferenceIDs()

getReferenceIDsImpl

protected void getReferenceIDsImpl(java.util.Collection<DBObjectID> refs)
Used by the final getReferenceID() implementation. The list should not contain null values, or be null. Subclasses should start with super.getReferenceIDsImpl() and then add to the passed list as appopriate.
Parameters:
refs - the collection of ids this object references

replaceReferenceIDs

public boolean replaceReferenceIDs(java.util.Map<DBObjectID,DBObjectID> idMap)
Override in subclasses to replace reference IDs as appropriate. Always call super in the overridden implementation to make sure the default implementation (which checks the property map) is called.
Specified by:
replaceReferenceIDs in interface DBObject
Parameters:
idMap - key = old DBObjectID, value = new DBObjectID
Returns:
true if any ids were replaced.

getChildSupport

protected final AbstractDBObject.ChildSupport getChildSupport(java.lang.String propName)

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


Copyright © 1997, 2012, Oracle. All rights reserved.