ini.trakem2.persistence
Class DBObject

java.lang.Object
  extended by ini.trakem2.persistence.DBObject
Direct Known Subclasses:
Display, Displayable, Layer, LayerThing, Project, ProjectThing, TemplateThing

public class DBObject
extends java.lang.Object

Base class of all objects that can be saved in a database or XML file.
Methods to add to, update in and remove from a database are called anyway for XML projects, and can thus be used to perform tasks on updating a specific object.


Field Summary
protected  long id
           
protected  Project project
           
 
Constructor Summary
DBObject(Loader loader)
          For the Project
DBObject(Project project)
          Create new and later add it to the database.
DBObject(Project project, long id)
          Reconstruct from database.
 
Method Summary
 boolean addToDatabase()
           
 void exportXML(java.lang.StringBuilder sb_body, java.lang.String indent, java.lang.Object any)
          Subclasses can override this method to store the instance as XML.
 long getId()
           
 java.lang.String getInfo()
          Returns id and project name; this method is meant to be overriden by any of the subclasses.
 Project getProject()
           
 java.lang.String getShortTitle()
          Sublcasses can override this method to provide a proper String, otherwise calls getTitle()
 java.lang.String getTitle()
          Sublcasses can override this method to provide a proper String, otherwise calls toString()
 java.lang.String getUniqueIdentifier()
          Create a unique String identifier for this object instance.
 boolean remove(boolean check)
          Subclasses can override this method to perform other tasks before removing itself from the database.
 boolean removeFromDatabase()
           
 boolean updateInDatabase(java.util.Set<java.lang.String> keys)
           
 boolean updateInDatabase(java.lang.String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected long id

project

protected Project project
Constructor Detail

DBObject

public DBObject(Project project)
Create new and later add it to the database.


DBObject

public DBObject(Project project,
                long id)
Reconstruct from database.


DBObject

public DBObject(Loader loader)
For the Project

Method Detail

getId

public final long getId()

getUniqueIdentifier

public java.lang.String getUniqueIdentifier()
Create a unique String identifier for this object instance. TODO The default implementation returns the project-specific id. This behaviour has to be overridden in order to get an identifier that is unique beyond the project scope, e.g. for use in cache file names.

Returns:
Unique name

getProject

public final Project getProject()

addToDatabase

public boolean addToDatabase()

updateInDatabase

public boolean updateInDatabase(java.lang.String key)

updateInDatabase

public boolean updateInDatabase(java.util.Set<java.lang.String> keys)

removeFromDatabase

public boolean removeFromDatabase()

remove

public boolean remove(boolean check)
Subclasses can override this method to perform other tasks before removing itself from the database.


exportXML

public void exportXML(java.lang.StringBuilder sb_body,
                      java.lang.String indent,
                      java.lang.Object any)
Subclasses can override this method to store the instance as XML.


getTitle

public java.lang.String getTitle()
Sublcasses can override this method to provide a proper String, otherwise calls toString()


getShortTitle

public java.lang.String getShortTitle()
Sublcasses can override this method to provide a proper String, otherwise calls getTitle()


getInfo

public java.lang.String getInfo()
Returns id and project name; this method is meant to be overriden by any of the subclasses.