|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.graph.io.standard.AbstractReaderWriter org.geotools.graph.io.standard.DBReaderWriter
An implementation of GraphReaderWriter used for reading and writing graph
objects to and from a database.
Upon reading, the database is queried using
the getQuery() template method, and a representation of the objects to be
modelled by the graph are returned through a standard ResultSet. From each
tuple in the result set, the object is recreated via the template method
readInternal(ResultSet). The object is then passed to an underlying
graph generator and the graph components used to model the object are
constructed.
Upon writing, the graph is read component by component based
on set properties. If the NODES property is set, nodes will be written. If
the EDGES property is set, edges will be written as well. As each component
is processed, it is passed to the repspective template methods
writeNode(Statement,Node) and writeEdge(Statement,Edge). The methods then
execute a statement to create the database representation of the graph
component.
Field Summary | |
static java.lang.String |
DBNAME
Database name key |
static java.lang.String |
DRIVERCLASS
JDBC driver class name key |
static java.lang.String |
DRIVERURL
JDBC driver url |
static java.lang.String |
PORT
Database port key |
static java.lang.String |
SERVER
Database server key |
static java.lang.String |
TABLENAME
Table key |
static java.lang.String |
USERNAME
User name key |
Fields inherited from class org.geotools.graph.io.standard.AbstractReaderWriter |
BUILDER, EDGES, GENERATOR, NODES |
Constructor Summary | |
DBReaderWriter()
|
Method Summary | |
protected java.sql.Connection |
getConnection()
Opens a connection to the database, based on set properties. |
protected abstract java.lang.String |
getQuery()
Template method which returns the query to execute in order to read a graph from the database. |
Graph |
read()
Performs a graph read by querying the database and processing each tuple returned in the query. |
protected abstract java.lang.Object |
readInternal(java.sql.ResultSet rs)
Template method used to create the object represented by a tuple returned by the database query. |
void |
write(Graph g)
Performs a write on the graph out to the database. |
protected void |
writeEdge(java.sql.Statement st,
Edge edge)
Template method used to write an edge into the database. |
protected void |
writeNode(java.sql.Statement st,
Node node)
Template method used to write a node into the database. |
Methods inherited from class org.geotools.graph.io.standard.AbstractReaderWriter |
getProperty, setProperty, setProperty |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String DRIVERCLASS
public static final java.lang.String DRIVERURL
public static final java.lang.String SERVER
public static final java.lang.String PORT
public static final java.lang.String DBNAME
public static final java.lang.String USERNAME
public static final java.lang.String TABLENAME
Constructor Detail |
public DBReaderWriter()
Method Detail |
public Graph read() throws java.lang.Exception
java.lang.Exception
GraphReaderWriter.read()
public void write(Graph g) throws java.lang.Exception
g
- The graph to be
java.lang.Exception
protected java.sql.Connection getConnection() throws java.lang.Exception
java.lang.Exception
protected void writeNode(java.sql.Statement st, Node node)
st
- Statement used to execute write statement.node
- Node to write.protected void writeEdge(java.sql.Statement st, Edge edge)
st
- Statement used to execute write statement.edge
- Edge to write.protected abstract java.lang.String getQuery()
protected abstract java.lang.Object readInternal(java.sql.ResultSet rs) throws java.lang.Exception
rs
- ResultSet of query.
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |