ca.sqlpower.wabit
Class WabitDataSource

java.lang.Object
  extended by ca.sqlpower.wabit.AbstractWabitObject
      extended by ca.sqlpower.wabit.WabitDataSource
All Implemented Interfaces:
WabitObject

public class WabitDataSource
extends AbstractWabitObject

An implementation of WabitObject that wraps a data sources. This data source can be any implementation of SPDataSource.


Constructor Summary
WabitDataSource(ca.sqlpower.sql.SPDataSource ds)
          Creates a WabitDataSource wrapper for the given data source.
 
Method Summary
 boolean allowsChildren()
          Returns true if this object may contain children.
 int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
          Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.
 CleanupExceptions cleanup()
          Default cleanup method that does nothing.
 boolean equals(java.lang.Object obj)
           
 java.util.List<WabitObject> getChildren()
          Returns an unmodifiable list of the children in this WabitObject.
 java.util.List<WabitObject> getDependencies()
          Returns a list of all WabitObjects that this Wabit object is dependent on.
 ca.sqlpower.sql.SPDataSource getSPDataSource()
           
 java.lang.String getUUID()
          Gets the UUID associated with this instance's data source.
 int hashCode()
           
protected  boolean removeChildImpl(WabitObject child)
          This is the object specific implementation of removeChild.
 void removeDependency(WabitObject dependency)
          Removes the given object as a dependency of this object.
 void setUUID(java.lang.String uuid)
          Sets the UUID associated with this instance's data source.
 
Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject
addChild, addChildImpl, addWabitListener, begin, beginTransaction, commit, commitTransaction, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, generateNewUUID, getChildren, getName, getParent, getSession, isForegroundThread, removeChild, removeWabitListener, rollback, rollbackTransaction, runInBackground, runInForeground, setName, setParent, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WabitDataSource

public WabitDataSource(@Nonnull
                       ca.sqlpower.sql.SPDataSource ds)
Creates a WabitDataSource wrapper for the given data source. The newly created WabitDataSource's name tracks changes to the underlying data source's name.

It is vitally important to call cleanup() on a WabitDataSource when you are done with it. If you attach the WabitDataSource to a workspace, cleanup will be done automatically the session is closed, but if the object you create does not get attached to a session, cleanup is your own responsibility.

Parameters:
ds - The data source to wrap. Must not be null.
Method Detail

cleanup

public CleanupExceptions cleanup()
Description copied from class: AbstractWabitObject
Default cleanup method that does nothing. Override and implement this method if cleanup is necessary.

Specified by:
cleanup in interface WabitObject
Overrides:
cleanup in class AbstractWabitObject
Returns:
A collection of exceptions and errors that occurred during cleanup if any occurred.

getUUID

public java.lang.String getUUID()
Gets the UUID associated with this instance's data source. This class does not store its own UUID, as in implementation, these instances are instantiated and removed often, but the data source they are wrapping stays constant.

Specified by:
getUUID in interface WabitObject
Overrides:
getUUID in class AbstractWabitObject
Returns:
The UUID, a unique identifying string associated with this instance's data source.

setUUID

public void setUUID(java.lang.String uuid)
Sets the UUID associated with this instance's data source. This class does not store its own UUID, as in implementation, these instances are instantiated and removed often, but the data source they are wrapping stays constant.

Specified by:
setUUID in interface WabitObject
Overrides:
setUUID in class AbstractWabitObject
Parameters:
The - UUID, a unique identifying string associated with this instance's data source.

allowsChildren

public boolean allowsChildren()
Description copied from interface: WabitObject
Returns true if this object may contain children. Not all types of WabitObjects can be a child to any WabitObject.

See Also:
WabitObject.childPositionOffset(Class)

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
Description copied from interface: WabitObject
Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.


getChildren

public java.util.List<WabitObject> getChildren()
Description copied from interface: WabitObject
Returns an unmodifiable list of the children in this WabitObject. If there are no children in this WabitObject an empty list should be returned.


getSPDataSource

public ca.sqlpower.sql.SPDataSource getSPDataSource()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class AbstractWabitObject

hashCode

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

removeDependency

public void removeDependency(WabitObject dependency)
Description copied from interface: WabitObject
Removes the given object as a dependency of this object. For this object to no longer be dependent on the given dependency all of its children must also not be dependent on the given dependency when this method returns. This may remove this object from its parent if necessary.


getDependencies

public java.util.List<WabitObject> getDependencies()
Description copied from interface: WabitObject
Returns a list of all WabitObjects that this Wabit object is dependent on. Children of a WabitObject are not dependencies and will not be returned in this list. If there are no objects this Wabit object is dependent on an empty list should be returned. These are only the immediate dependencies of this object. If you want to find the dependencies of this object's dependencies as well it may be useful to look at WorkspaceGraphModel to make a full graph of all of the dependencies.


removeChildImpl

protected boolean removeChildImpl(WabitObject child)
Description copied from class: AbstractWabitObject
This is the object specific implementation of removeChild. There are checks in the removeChild method to ensure the child being removed has no dependencies and is a child of this object.

Specified by:
removeChildImpl in class AbstractWabitObject
See Also:
AbstractWabitObject.removeChild(WabitObject)


Copyright © 2009. All Rights Reserved.