Extension SDK 10.1.3.36.73

oracle.ide.persistence
Class NameSpace

java.lang.Object
  extended byoracle.ide.persistence.NameSpace
Direct Known Subclasses:
PackedNameSpace

public class NameSpace
extends java.lang.Object

The NameSpace class provides access to the persistent storage system.

General concept:

The persistent storage system is designed to store searchable information between jdev sessions.

The smallest ammount of information stored is a record consisting of a String key and a byte[] data. Both the key and the data array are of arbitrary size.

Keys are grouped together in NameSpaces, Each NameSpace contains it's own set of records. Individual users of NameSpace have to coordinate to avoid name conflict in NameSpaces names.

In version 1.0, all datas are stored in a single file in the user system directory, if for any reason 2 instances of jdev (on the same machine or not) atempt to use the same storage file, it will try to use and create if needed the next one, files will be called :

XXXX_N.stf

where XXXX is the base storage name and N a number. This means that if at any time 3 instances of jdev are launched you should have 3 files :

XXXX_0.stf, XXXX_1.stf and XXXX_3.stf Launching one more instance in parallel will create XXXX_4.stf and so on ....


Field Summary
protected static oracle.ide.persistence.StorageFile _store
           
static int NSTYPE_NORMAL
          Get a 'handle' on a NameSpace, If the NameSpace already exists, it will be opened or a new NameSpace will be created.
static int NSTYPE_PACKED
           
 
Method Summary
 void cancelAutoFlush()
           
 boolean checkRecord(java.lang.String key)
          Check if a key is present in the current namespace
 void close()
          Same as flush (in v 1.0)
static void deleteNameSpace(java.lang.String name)
          delete permanently all records of a given NameSpace and remove the NameSpace itself from the NameSpace list.
 void delRecord(java.lang.String key)
          Delete the record associated with the key, and remove the key itself.
 void flush()
          Saves all pending operations to disk, and tag the NameSpace 'clean'.
static NamedTimer getFlushTimer()
           
 java.util.Iterator getKeyIterator()
          Get an Iterator Object on all keys contained in this workspace.
 java.util.Iterator getKeyIterator(java.lang.String prefix)
          Get an Iterator Object on all keys contained in this workspace starting with the specified prefix.
 java.util.Iterator getKeyIterator(java.lang.String prefix, boolean ignorecase)
          Get an Iterator Object on all keys contained in this workspace starting with the specified prefix ignoring the case if needed.
static NameSpace getNameSpace(java.lang.String name)
           
static NameSpace getNameSpace(java.lang.String name, int type)
           
static java.util.Iterator getNameSpaceIterator()
          Get an Iterator Object on all nameSpace contained in the persistence system.
static java.util.Iterator getNameSpaceIterator(java.lang.String prefix)
          Get an Iterator Object on all nameSpace contained in the persistence system.
static java.util.Iterator getNameSpaceIterator(java.lang.String prefix, boolean ignorecase)
          Get an Iterator Object on all nameSpace contained in the persistence system.
 byte[] getRecord(java.lang.String key)
          Returns the datas (byte[]) associated with a key.
 java.io.InputStream getRecordStream(java.lang.String key)
          Returns an Stream object on the datas (byte[]) associated with a key.
 java.util.Iterator getReverseKeyIterator()
           
 java.util.Iterator getReverseKeyIterator(java.lang.String prefix)
           
 java.util.Iterator getReverseKeyIterator(java.lang.String prefix, boolean ignorecase)
           
static java.util.Iterator getReverseNameSpaceIterator()
           
static java.util.Iterator getReverseNameSpaceIterator(java.lang.String prefix)
           
static java.util.Iterator getReverseNameSpaceIterator(java.lang.String prefix, boolean ignorecase)
           
 void putRecord(java.lang.String key, byte[] data)
          Add or update the record associated with the key using a byte[].
 java.io.OutputStream putRecordStream(java.lang.String key)
          Add or update the record associated with the key using a stream To effectively enter the record the close() function have to be called on this OutputStream.
 void setAutoFlush(long delay)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_store

protected static oracle.ide.persistence.StorageFile _store

NSTYPE_NORMAL

public static final int NSTYPE_NORMAL
Get a 'handle' on a NameSpace, If the NameSpace already exists, it will be opened or a new NameSpace will be created.

If multiple Threads access the same NameSpace, they should all have their own NameSpace object to access it.

See Also:
Constant Field Values

NSTYPE_PACKED

public static final int NSTYPE_PACKED
See Also:
Constant Field Values
Method Detail

getNameSpaceIterator

public static java.util.Iterator getNameSpaceIterator()
Get an Iterator Object on all nameSpace contained in the persistence system. The next() function of this Iterator will always returns String objects

equivalent to getNameSpaceIterator("", false)

Returns:
Iterator on NameSpace names.

getReverseNameSpaceIterator

public static java.util.Iterator getReverseNameSpaceIterator()

getNameSpaceIterator

public static java.util.Iterator getNameSpaceIterator(java.lang.String prefix)
Get an Iterator Object on all nameSpace contained in the persistence system. starting with the specified prefix. This iterator will have no more elements once the prefix changes.

The next() function of this Iterator will always returns String objects

equivalent to getNameSpaceIterator(prefix, false)

Parameters:
prefix - Prefix of the wanted namespaces.
Returns:
Iterator on keys.

getReverseNameSpaceIterator

public static java.util.Iterator getReverseNameSpaceIterator(java.lang.String prefix)

getNameSpaceIterator

public static java.util.Iterator getNameSpaceIterator(java.lang.String prefix,
                                                      boolean ignorecase)
Get an Iterator Object on all nameSpace contained in the persistence system. starting with the specified prefix. ignoring the case if needed. For performance reasons, if ignorecase is true, this iterator will return the first 'matching group' of keys matching this prefix. for example if the NameSpaces are :

AAA, BBB, BBb, Bbb, Cxx, aaa, bBB, bbB

This iterator will have no more elements once the prefix changes.

getNameSpaceIterator('bb', true), will return only 3 keys :

BBB, BBb, Bbb

The next() function of this Iterator will always returns String objects

Parameters:
prefix - Prefix of the wanted keys.
ignorecase - Case sensitive or not ....
Returns:
Iterator on keys.

getReverseNameSpaceIterator

public static java.util.Iterator getReverseNameSpaceIterator(java.lang.String prefix,
                                                             boolean ignorecase)

getNameSpace

public static NameSpace getNameSpace(java.lang.String name,
                                     int type)

getNameSpace

public static NameSpace getNameSpace(java.lang.String name)

deleteNameSpace

public static void deleteNameSpace(java.lang.String name)
delete permanently all records of a given NameSpace and remove the NameSpace itself from the NameSpace list.

Parameters:
name - the name of the NameSpace to delete permanently.

getRecordStream

public java.io.InputStream getRecordStream(java.lang.String key)
Returns an Stream object on the datas (byte[]) associated with a key.

Parameters:
key - key of the record.
Returns:
An opened InputStream on the data record. or null if there is no record with that key.

getFlushTimer

public static NamedTimer getFlushTimer()

setAutoFlush

public void setAutoFlush(long delay)

cancelAutoFlush

public void cancelAutoFlush()

getRecord

public byte[] getRecord(java.lang.String key)
Returns the datas (byte[]) associated with a key.

Parameters:
key - key of the record.
Returns:
A byte[] containing the record data. or null if there is no record with that key.

flush

public void flush()
Saves all pending operations to disk, and tag the NameSpace 'clean'. If multiple threads are using the same NameSpace (using their own NameSpace Ojbect) only the last flush will tag the nameSpace clean.

All modifying operations will tag a NameSpace 'dirty' and it will be automaticaly erased during the next launch. don't forget to flush ...


close

public void close()
Same as flush (in v 1.0)

See Also:
flush()

delRecord

public void delRecord(java.lang.String key)
Delete the record associated with the key, and remove the key itself. After this operation the NameSpace will be tagged 'dirty', use flush sometime.

Parameters:
key - key name of the record.
See Also:
flush()

putRecordStream

public java.io.OutputStream putRecordStream(java.lang.String key)
Add or update the record associated with the key using a stream To effectively enter the record the close() function have to be called on this OutputStream.

Warning, NameSpace.flush() doesn't automaticaly close all 'openned' OutputStream you have to call close() on them before fvlushing the NameSpace.

After this operation the NameSpace will be tagged 'dirty', use flush sometime.

Parameters:
key - key name of the record.
Returns:
OutputStream on the datas associated with the key (use close to finalize the add / update).
See Also:
flush()

checkRecord

public boolean checkRecord(java.lang.String key)
Check if a key is present in the current namespace

Parameters:
key - key name of the record.
Returns:
true if the key is conatined in the namespace, false otherwise

putRecord

public void putRecord(java.lang.String key,
                      byte[] data)
Add or update the record associated with the key using a byte[].

After this operation the NameSpace will be tagged 'dirty', use flush sometime. If data is null or have a 0 length, no space will be allocated to store the data. get functions on this key will return either a 0 length array or an empty stream.

Parameters:
key - key name of the record.
data - byte[] containing the datas associated with the key.
See Also:
flush()

getKeyIterator

public java.util.Iterator getKeyIterator()
Get an Iterator Object on all keys contained in this workspace. The next() function of this Iterator will always returns String objects

equivalent to getKeyIterator("", false)

Returns:
Iterator on keys.

getReverseKeyIterator

public java.util.Iterator getReverseKeyIterator()

getKeyIterator

public java.util.Iterator getKeyIterator(java.lang.String prefix)
Get an Iterator Object on all keys contained in this workspace starting with the specified prefix. This iterator will have no more elements once the key prefix changes.

The next() function of this Iterator will always returns String objects

equivalent to getKeyIterator(prefix, false)

Parameters:
prefix - Prefix of the wanted keys.
Returns:
Iterator on keys.

getReverseKeyIterator

public java.util.Iterator getReverseKeyIterator(java.lang.String prefix)

getKeyIterator

public java.util.Iterator getKeyIterator(java.lang.String prefix,
                                         boolean ignorecase)
Get an Iterator Object on all keys contained in this workspace starting with the specified prefix ignoring the case if needed. For performance reasons, if ignorecase is true, this iterator will return the first 'matching group' of keys matching this prefix. for example if the keys are :

AAA, BBB, BBb, Bbb, Cxx, aaa, bBB, bbB

This iterator will have no more elements once the key prefix changes. getKeyIterator('bb', true), will return only 3 keys :

BBB, BBb, Bbb

The next() function of this Iterator will always returns String objects

Parameters:
prefix - Prefix of the wanted keys.
ignorecase - Case sensitive or not ....
Returns:
Iterator on keys.

getReverseKeyIterator

public java.util.Iterator getReverseKeyIterator(java.lang.String prefix,
                                                boolean ignorecase)

Extension SDK 10.1.3.36.73

 

Copyright © 1997, 2005, Oracle.All rights reserved.