org.vrspace.neurogrid
Class NGObject

java.lang.Object
  extended byorg.vrspace.neurogrid.NGObject
Direct Known Subclasses:
Event, EventType, Keyword, Node, Predicate, Uri, UriDesc, UriTriple, Weight

public abstract class NGObject
extends java.lang.Object

Generic import record.

See Also:
RecordParser

Field Summary
protected  DBAdapter db
           
protected  long db_id
           
 
Constructor Summary
protected NGObject()
          Constructor intended for subclasses which use more atributes than id and name.
 
Method Summary
 java.lang.String deleteStatement()
          delete from tablename where db_id = this.db_id
 java.util.Iterator fieldIterator()
          Returns Iterator thru public fields.
protected  java.util.Iterator fieldIterator(java.lang.reflect.Field[] fields)
           
 NGObject fromText(java.io.Reader in)
           
 java.lang.String getID()
           
 java.lang.String getTable()
          Returns table name.
 void init()
          This initializes NGObject.
 java.lang.String insertStatement()
          insert into tablename (field,...) values (value,...)
abstract  NGObject next()
           
 java.lang.String nullify(java.lang.Object val)
           
 java.lang.String stringify(java.lang.Object val)
           
 java.lang.String stringify(java.lang.String name, java.lang.Object val)
           
 java.lang.String toString()
          Returns string containing id and name of this record
 java.lang.String toText()
           
 java.lang.String updateStatement()
          update tablename set field=value,...
protected  void verify()
          Check if exists in database, update in-memory db_id if so
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

db_id

protected long db_id

db

protected DBAdapter db
Constructor Detail

NGObject

protected NGObject()
Constructor intended for subclasses which use more atributes than id and name.

Method Detail

toString

public java.lang.String toString()
Returns string containing id and name of this record


init

public void init()
This initializes NGObject. Called when loads from the database, all field values are set. Used to construct whatever maps/sets this object belongs to. NOTE: this may not be necessary for NG, it's a bit more general model


getID

public java.lang.String getID()

fieldIterator

public java.util.Iterator fieldIterator()
Returns Iterator thru public fields. Iterator returns Map.Entry objects, key is Field, value is field value.


fieldIterator

protected java.util.Iterator fieldIterator(java.lang.reflect.Field[] fields)

nullify

public java.lang.String nullify(java.lang.Object val)

stringify

public java.lang.String stringify(java.lang.Object val)

stringify

public java.lang.String stringify(java.lang.String name,
                                  java.lang.Object val)

insertStatement

public java.lang.String insertStatement()
insert into tablename (field,...) values (value,...)


updateStatement

public java.lang.String updateStatement()
update tablename set field=value,... where db_id = this.db_id


deleteStatement

public java.lang.String deleteStatement()
delete from tablename where db_id = this.db_id


toText

public java.lang.String toText()

fromText

public NGObject fromText(java.io.Reader in)

getTable

public java.lang.String getTable()
Returns table name. Implement where one class maps to one table, field to field, otherwise override insert/update/deleteStatement()

See Also:
insertStatement(), updateStatement(), deleteStatement()

next

public abstract NGObject next()

verify

protected void verify()
Check if exists in database, update in-memory db_id if so