|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gate.util.AbstractFeatureBearer | +--gate.creole.AbstractResource | +--gate.creole.AbstractLanguageResource | +--gate.corpora.DocumentImpl | +--gate.db.DocumentWrapper
This class extends DocumentImpl adding database persistence via Jdbc.
Field Summary | |
protected Connection |
con
|
protected Database |
database
|
protected static Table[] |
DDL
|
private static boolean |
DEBUG
Debug flag |
protected long |
id
|
protected boolean |
isNew
|
protected PreparedStatement |
psAnnotation
|
protected PreparedStatement |
psNode
|
protected ResultSet |
rsAnnotations
|
protected ResultSet |
rsDocument
|
protected ResultSet |
rsFeatures
|
protected Statement |
stmt
|
Fields inherited from class gate.corpora.DocumentImpl |
content, defaultAnnots, documentListeners, encoding, features, gateListeners, markupAware, namedAnnotSets, nextAnnotationId, nextNodeId, serialVersionUID, sourceUrl, sourceUrlEndOffset, sourceUrlStartOffset, statusListeners, stringContent |
Fields inherited from class gate.creole.AbstractLanguageResource |
dataStore |
Constructor Summary | |
DocumentWrapper(Connection con,
Database db,
DocumentImpl doc)
Construction from Document. |
|
DocumentWrapper(Connection con,
Database ds,
long id)
Construction from ID. |
|
DocumentWrapper(DataStore ds,
DocumentImpl doc)
Construction from Document. |
|
DocumentWrapper(DataStore ds,
long id)
Construction from ID. |
|
DocumentWrapper(DataStore ds,
String urlString)
Construction from String representing URL |
|
DocumentWrapper(DataStore ds,
URL u)
Construction from URL; content read over the net. |
|
DocumentWrapper(DataStore ds,
URL u,
Long start,
Long end)
Construction from URL and offsets. |
|
DocumentWrapper(URL u,
String encoding,
Long start,
Long end)
Construction from URL and offsets. |
Method Summary | |
(package private) static void |
|
void |
beginTransaction()
Starts a transaction |
void |
commit()
Commits the reads/writes |
private void |
connectToDb()
Gets a new connection and starts a transaction on that connection |
private void |
DBInit()
This method is actually the persistent part of any of the constructors. |
void |
disconnect()
Disconnects from the Datastore object, i.e. |
DataStore |
getDataStore()
Returns the Datastore object associated to this persistent document. |
long |
getId()
Gets the database ID of this persistent object. |
boolean |
isNew()
Can be used to check if this document is an old one that has been retrieved from the databse or is a new one that has just been saved. |
void |
rollback()
Rolls back all the actions performed since the last beginTransaction call |
static boolean |
setupDatabase(DataStore ds)
Checks if the provided datastore id proper for storing persistent documents of this type. |
protected void |
writeAnnotation(String setName,
Annotation ann)
This method writes an annotation into the database. |
Methods inherited from class gate.creole.AbstractLanguageResource |
setDataStore, sync |
Methods inherited from class gate.creole.AbstractResource |
getName, setName |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait |
Methods inherited from interface gate.LanguageResource |
setDataStore, sync |
Methods inherited from interface gate.Resource |
init |
Methods inherited from interface gate.util.FeatureBearer |
getFeatures, getName, setFeatures, setName |
Field Detail |
private static final boolean DEBUG
protected long id
protected Database database
protected Connection con
protected Statement stmt
protected ResultSet rsDocument
protected ResultSet rsAnnotations
protected ResultSet rsFeatures
protected PreparedStatement psAnnotation
protected PreparedStatement psNode
protected boolean isNew
protected static Table[] DDL
Constructor Detail |
public DocumentWrapper(URL u, String encoding, Long start, Long end) throws IOException
public DocumentWrapper(DataStore ds, URL u, Long start, Long end) throws IOException, SQLException
public DocumentWrapper(DataStore ds, URL u) throws IOException, SQLException
public DocumentWrapper(DataStore ds, String urlString) throws IOException, SQLException
public DocumentWrapper(DataStore ds, DocumentImpl doc) throws IOException, SQLException
public DocumentWrapper(Connection con, Database db, DocumentImpl doc) throws IOException
public DocumentWrapper(DataStore ds, long id) throws IOException, NoSuchObjectException, SQLException
public DocumentWrapper(Connection con, Database ds, long id) throws IOException, NoSuchObjectException, SQLException
Method Detail |
private void DBInit() throws IOException, NoSuchObjectException
NoSuchObjectException
- when an attempt to read an inexistant
object from the database(e.g. when an invalid ID is used to retrieve a
document).IOException
- if an error occurs while trying to read the
document content.private void connectToDb() throws SQLException
protected void writeAnnotation(String setName, Annotation ann) throws SQLException, IOException
setName
- The name of the Annotation Set this annotation
belongs to.ann
- The annotation to be written into DB.SQLException
- if an error occurspublic void rollback() throws SQLException
rollback
in interface LRDBWrapper
public void beginTransaction() throws SQLException
beginTransaction
in interface LRDBWrapper
public void commit() throws SQLException
commit
in interface LRDBWrapper
public void disconnect() throws GateException
disconnect
in interface LRDBWrapper
public DataStore getDataStore()
getDataStore
in interface LanguageResource
getDataStore
in class AbstractLanguageResource
public boolean isNew()
public static boolean setupDatabase(DataStore ds)
ds
- a value of type 'DataStore'public long getId()
static void()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |