|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoscript.data.Value
oscript.data.OObject
oscript.data.Database
A database provides persistant storage.... for example
var cache = new Database("cache.db"); cache.foo.bar = "something";
Field Summary | |
static java.lang.String[] |
MEMBER_NAMES
|
static java.lang.String |
PARENT_TYPE_NAME
|
static Value |
TYPE
The type object for an instance of Object. |
static java.lang.String |
TYPE_NAME
|
Fields inherited from class oscript.data.OObject |
EMPTY_EXPR_LIST_EVALUATOR |
Fields inherited from class oscript.data.Value |
DEBUG, NULL, UNDEFINED |
Constructor Summary | |
Database(AbstractFile file)
Class Constructor. |
|
Database(AbstractFile file,
boolean sideEffects)
Class Constructor. |
|
Database(AbstractFile file,
java.lang.ClassLoader loader)
Class Constructor. |
|
Database(AbstractFile file,
java.lang.ClassLoader loader,
boolean sideEffects)
Class Constructor. |
|
Database(MemberTable args)
Class Constructor. |
Method Summary | |
protected void |
finalize()
Make sure we flush before we're gc'd. |
void |
flush()
Flush contents to file. |
Value |
get(java.lang.String key)
|
Value |
get(Value key)
Get an entry from the database. |
Value |
getMember(int id,
boolean exception)
Get a member of this object. |
protected Value |
getTypeImpl()
Get the type of this object. |
java.util.Iterator |
keys()
|
protected void |
populateMemberSet(java.util.Set s,
boolean debugger)
Derived classes that implement getMember(int, boolean) should also
implement this. |
void |
put(java.lang.String key,
Value val)
|
void |
put(Value key,
Value val)
Put an entry into the database. |
void |
remove(java.lang.String key)
|
void |
remove(Value key)
|
Methods inherited from class oscript.data.OObject |
castToString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Value TYPE
public static final java.lang.String PARENT_TYPE_NAME
public static final java.lang.String TYPE_NAME
public static final java.lang.String[] MEMBER_NAMES
Constructor Detail |
public Database(AbstractFile file)
file
- the file to read from and store topublic Database(AbstractFile file, boolean sideEffects)
file
- the file to read from and store tosideEffects
- can be set to false
if you do not
expect side effects (ie. member of database is not mutable). If
true
, the database is always flushed at exit,
regardless of whether there have been any put() operations.public Database(AbstractFile file, java.lang.ClassLoader loader)
file
- the file to read from and store toloader
- an optional class loader used to resolve
class references when loading the database from diskpublic Database(AbstractFile file, java.lang.ClassLoader loader, boolean sideEffects)
file
- the file to read from and store toloader
- an optional class loader used to resolve
class references when loading the database from disksideEffects
- can be set to false
if you do not
expect side effects (ie. member of database is not mutable). If
true
, the database is always flushed at exit,
regardless of whether there have been any put() operations.public Database(MemberTable args)
args
- arguments to this constructor
PackagedScriptObjectException(Exception)
- if wrong number of argsMethod Detail |
protected void finalize()
protected Value getTypeImpl()
Value.getType()
.
getTypeImpl
in class OObject
public void flush()
public Value get(Value key)
key
is a "." seperated
path, for example "foo.bar".
key
- the key
null
if none.public Value get(java.lang.String key)
public void put(Value key, Value val)
key
is a "." seperated
path, for example "foo.bar".
key
- the keyval
- the new valuepublic void put(java.lang.String key, Value val)
public java.util.Iterator keys()
public void remove(Value key)
public void remove(java.lang.String key)
public Value getMember(int id, boolean exception) throws PackagedScriptObjectException
getMember
in class OObject
id
- the id of the symbol that maps to the memberexception
- whether an exception should be thrown if the
member object is not resolved
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException
protected void populateMemberSet(java.util.Set s, boolean debugger)
getMember(int, boolean)
should also
implement this.
populateMemberSet
in class OObject
s
- the set to populatedebugger
- true
if being used by debugger, in
which case both public and private/protected field names should
be returnedgetMember(int, boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |