public class Jlcm
extends java.lang.Object
implements java.io.Externalizable
A Jlcm object in Java can encapsulate a native LCM object which can be memory-resident or persistent (using the XSM C API) or a file. A LCM or XSM native object can contains dictionaries (aka associative tables or hash tables) and lists.
Author: Alain Hebert, Ecole Polytechnique de Montreal (2002)
Constructor and Description |
---|
Jlcm()
Use this constructor to create a Jlcm object without embedded LCM
object or file.
|
Jlcm(java.lang.String stype,
java.lang.String name)
Use this constructor to create a Jlcm object of a specified type.
|
Jlcm(java.lang.String stype,
java.lang.String name,
int lrda)
Use this constructor to create a Jlcm object of binary direct-access type.
|
Modifier and Type | Method and Description |
---|---|
void |
close(java.lang.String saccess)
Close a Jlcm object.
|
Jlcm |
copy(java.lang.String new_name)
Deep copy of a dictionary- or list-type Jlcm object into a memory-resident
Jlcm object.
|
Jlcm |
copy(java.lang.String new_name,
int imode)
Deep copy of a dictionary- or list-type Jlcm object into a memory-resident
or persistent Jlcm object.
|
void |
dump()
Dump the LCM content to the PrintWriter.
|
void |
except()
Cause an exception (used to debug XABORT in Java).
|
void |
expor()
Serialize and save the object content on a sequential file.
|
void |
expor(java.lang.String new_name)
Serialize and save the object content on a sequential file.
|
java.lang.Object |
get(int iset)
Recover a daughter Jlcm object or an elementary block of information
from a list-type Jlcm object.
|
java.lang.Object |
get(java.lang.String key)
Recover a daughter Jlcm object or an elementary block of information
from a dictionary-type Jlcm object.
|
int |
getAccess()
Return the access type of a Jlcm object.
|
java.lang.String |
getDirectory()
Return the name of the accessible directory of a dictionary-type
Jlcm object.
|
int |
getLength()
Return the length of a list-type Jlcm object.
|
int |
getLrda()
Return the number of words in a record of a direct access-type Jlcm object.
|
java.lang.String |
getName()
Return the name of the Jlcm object.
|
int |
getType()
Return the type of the Jlcm object.
|
boolean |
isEmpty()
Return true if the a dictionary-type Jlcm object is empty.
|
boolean |
isNew()
Return true if the dictionary-type Jlcm object is new.
|
jargon.Jlcm.Enumlcm |
keys()
Return an Enumeration object for iterating on the keys of an associative
table-type Jlcm object.
|
int |
length(int iset)
Return the length of a block of information in a list-type Jlcm object.
|
int |
length(java.lang.String key)
Return the length of a block of information in a dictionary-type
Jlcm object.
|
void |
lib()
Print the table of contents of a dictionary- or list-type Jlcm object.
|
Jlcm |
lis(int iset,
int ilong)
Creation of a daughter list in a list-type Jlcm object.
|
Jlcm |
lis(java.lang.String key,
int ilong)
Creation of a daughter list in a dictionary-type Jlcm object.
|
void |
open(java.lang.String saccess)
Open a new Jlcm object or reopen an existing Jlcm object already closed by
the close("KEEP") method.
|
void |
put(int iset,
java.lang.Object value)
Store an elementary block of information in a list-type Jlcm object.
|
void |
put(java.lang.String key,
java.lang.Object value)
Store an elementary block of information in a dictionary-type
Jlcm object.
|
void |
readExternal(java.io.ObjectInput in)
Implements the readExternal method of the Externalizable interface
used to restore the contents of the Jlcm object.
|
Jlcm |
rep(int iset)
Creation of a daughter dictionary in a list-type Jlcm object.
|
Jlcm |
rep(java.lang.String key)
Creation of a daughter dictionary in a dictionary-type Jlcm object.
|
int |
type(int iset)
Return the type of a block of information in a list-type Jlcm object.
|
int |
type(java.lang.String key)
Return the type of a block of information in a dictionary-type
Jlcm object.
|
void |
val()
Test the consistency of the complete native LCM object embedded in the
Jlcm object.
|
void |
val(java.lang.String key)
Test the consistency of the information below a key in a native LCM object
embedded in the Jlcm object.
|
void |
writeExternal(java.io.ObjectOutput out)
Implements the writeExternal method of the Externalizable interface
used to save the contents of the Jlcm object.
|
public Jlcm()
public Jlcm(java.lang.String stype, java.lang.String name)
stype
- type of the new LCM object. This variable is chosen among
the following values:
name
- creation name of the new LCM objectpublic Jlcm(java.lang.String stype, java.lang.String name, int lrda)
stype
- type of the new LCM object. Can only be "DA".name
- name of the new LCM objectlrda
- size in words of a direct-access recordpublic java.lang.String getName()
public int getType()
public int getLength()
public java.lang.String getDirectory()
public int getAccess()
public int getLrda()
public boolean isEmpty()
public boolean isNew()
public void open(java.lang.String saccess)
saccess
- type of open. This variable is chosen among the following
values:
public void put(java.lang.String key, java.lang.Object value)
key
- key identification of the block in the dictionaryvalue
- elementary block of information (an Object instance containing
a String or an array of identical values). These values can be integers (int),
real numbers (float or double), boolean or Complex objects.public void put(int iset, java.lang.Object value)
iset
- index of the block in the list. The first list element is
stored at index 0.value
- elementary block of information (an Object instance containing
a String or an array of identical values). These values can be integers (int),
real numbers (float or double), boolean or Complex objects.public int length(java.lang.String key)
key
- key identification of the block in the dictionarypublic int type(java.lang.String key)
key
- key identification of the block in the dictionarypublic int length(int iset)
iset
- index of the block in the list. The first list element is
stored at index 0.public int type(int iset)
iset
- index of the block in the list. The first list element is
stored at index 0.public java.lang.Object get(java.lang.String key)
key
- key identification of the block in the dictionarypublic java.lang.Object get(int iset)
iset
- index of the block in the list. The first list element is
stored at index 0.public jargon.Jlcm.Enumlcm keys()
Enumeration ee = my_lcm.keys(); while(ee.hasMoreElements()) { String key = (String)ee.nextElement(); System.out.println("element=" + key); }
public void close(java.lang.String saccess)
saccess
- ="KEEP": close without destruction of the object
content; ="DESTROY": close with destruction of the object content.public void lib()
public Jlcm rep(java.lang.String key)
key
- key identification of the daughter dictionarypublic Jlcm lis(java.lang.String key, int ilong)
key
- key identification of the daughter listilong
- length of the daughter listpublic Jlcm rep(int iset)
iset
- index the daughter dictionarypublic Jlcm lis(int iset, int ilong)
iset
- index of the daughter listilong
- length of the daughter listpublic Jlcm copy(java.lang.String new_name)
new_name
- name of the new Jlcm objectpublic Jlcm copy(java.lang.String new_name, int imode)
new_name
- name of the new Jlcm objectimode
- =1: to create a memory_resident Jlcm object; =2: to create
a persistent objectpublic void expor()
public void expor(java.lang.String new_name)
new_name
- name of the sequential file. This name must begin by
character "_".public void val()
public void val(java.lang.String key)
key
- key of the distionary-type Jlcm object where the consistency
ckeck starts.public void except()
public void dump()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
try{ FileOutputStream fo = new FileOutputStream("serialized_object"); ObjectOutputStream so = new ObjectOutputStream(fo); so.writeObject(my_lcm); so.flush(); } catch (Exception ex) { System.out.println(ex); System.exit(1); }
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
try{ FileInputStream fi = new FileInputStream("serialized_object"); ObjectInputStream si = new ObjectInputStream(fi); my_lcm = (Jlcm)si.readObject(); } catch (Exception ex) { System.out.println(ex); System.exit(1); }
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException