kom.gateway
Class KomData

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--kom.gateway.KomData
Direct Known Subclasses:
Build.KOMhome, Build.KOMquery, Build.KOMsub

public class KomData
extends java.util.Hashtable

Base class for KOM objects

See Also:
Serialized Form

Field Summary
private static int ADDKEYANY
           
private static int ADDKEYFIRST
           
private static int ADDKEYLAST
           
 
Fields inherited from class java.util.Hashtable
count, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, serialVersionUID, table, threshold, values, VALUES
 
Constructor Summary
KomData()
          Basic constructor.
KomData(KomData kd)
          Constructor for a copy
KomData(java.lang.String data)
          Constructs KomData from String representation
 
Method Summary
 void add(java.lang.String key, java.lang.String value)
          Stores a value as a String or as a Vector element, but only if the key and the value are non-null.
static KomData create(java.lang.Object o)
          Creates a KomData object from an Object (String or KomData instance)
private  void debugLog(java.lang.String s)
           
 void display()
           
 void disppriv()
           
private  void errorLog(java.lang.String s)
           
 java.lang.String get(java.lang.String key)
          Gets a String value
private  void getAllData(java.lang.String data)
          Parses a String as a KomData representation
private  int getBDATA(java.lang.String key, java.lang.String data, int beg)
          Parses a counted data field
private  int getCDATA(java.lang.String key, java.lang.String data, int beg)
          Parses a LF-delimited data field
static KomData getData(java.lang.String data)
          Constructs a KomData object from a String
static KomData getElem(java.util.Vector vec, int i)
          Constructs a KomData object from a String Vector element
 StringList getKeyList()
          Generator for key names.
 java.lang.String[] getKeys()
          Gets the key names.
 java.lang.String getName()
          Gets value of "Cname"
private  int getPDATA(java.lang.String key, java.lang.String data, int beg)
          Parses a space-delimited data field
(package private)  java.lang.String[] getStringValues(java.lang.String key)
          Gets a String array for a Vector value
static java.util.Vector getStringVector(java.lang.String key, java.lang.String data)
          Constructs a Vector from a String.
 java.util.Vector getValues(java.lang.String key)
          Gets a (String) Vector value
 void init(KomData kd)
          Copies another KomData object contents to this
static boolean isEmpty(java.lang.String data)
          Is the string empty or null?
private  boolean mayput(java.lang.String key, java.lang.Object value, int place)
          Checks if the key/value pair may be put into the hashtable, and updates "keys" if so.
 void normal()
           
 void publish(java.lang.String orig)
           
 void put(java.lang.String key, java.lang.String value)
          Stores a String value if both key and value are non-null
 void put(java.lang.String key, java.util.Vector values)
          Stores a Vector of (String) values if both key and value are non-null
private static java.lang.String putBDATA(java.lang.String key, java.lang.String value)
           
private static java.lang.String putCDATA(java.lang.String key, java.lang.String value)
           
static java.lang.String putData(java.lang.String key, java.lang.String value)
          Constructs a data field representing the key and value
 void putfirst(java.lang.String key, java.lang.String value)
          Stores a value, placing its key first in the "keys" array.
 void putid(java.lang.String id)
           
 void putlast(java.lang.String key, java.lang.String value)
          Stores a value, placing its key last in the "keys" array.
private static java.lang.String putPDATA(java.lang.String key, java.lang.String value)
           
 void putValue(KomData kd, java.lang.String key)
          Copies a value from another object
 void qput(java.lang.String key, java.lang.String value)
          Stores a value if not null or ""
 java.lang.Object remove(java.lang.String key)
          Removes a key and its value
 void setName(java.lang.String name)
          Sets the "Cname" value
 void setValue(java.lang.String key, java.lang.String value)
          Sets the value for a non-null key
 java.lang.String toString()
          Constructs a String representation of this object
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, values, writeObject
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

ADDKEYANY

private static final int ADDKEYANY

ADDKEYFIRST

private static final int ADDKEYFIRST

ADDKEYLAST

private static final int ADDKEYLAST
Constructor Detail

KomData

public KomData()
Basic constructor. Initialize with a dummy "keys" value

KomData

public KomData(KomData kd)
Constructor for a copy
Parameters:
kd - Object whose contents will be copied into this object

KomData

public KomData(java.lang.String data)
Constructs KomData from String representation
Parameters:
data - toString() representation of object
Method Detail

init

public void init(KomData kd)
Copies another KomData object contents to this
Parameters:
kd - KomData object

getKeys

public java.lang.String[] getKeys()
Gets the key names.
Returns:
Array of key names

getKeyList

public StringList getKeyList()
Generator for key names.
Returns:
StringList

getAllData

private void getAllData(java.lang.String data)
Parses a String as a KomData representation
Parameters:
data - String representing object

getData

public static KomData getData(java.lang.String data)
Constructs a KomData object from a String
Parameters:
data - String representation

create

public static KomData create(java.lang.Object o)
Creates a KomData object from an Object (String or KomData instance)

getStringVector

public static java.util.Vector getStringVector(java.lang.String key,
                                               java.lang.String data)
Constructs a Vector from a String. The String consists of elements "key: count data" where the key is the same for all elements.
Parameters:
key - Key value, e g "info*", "cont*".
data - String representation

getBDATA

private int getBDATA(java.lang.String key,
                     java.lang.String data,
                     int beg)
Parses a counted data field
Parameters:
key - Field key
data - Data String
beg - Pos of count (in "key: count value...")
Returns:
pos in data following value

getCDATA

private int getCDATA(java.lang.String key,
                     java.lang.String data,
                     int beg)
Parses a LF-delimited data field
Parameters:
key - Field key
data - Data String
beg - Pos of value (in "key: value\n...")
Returns:
pos in data following value

getPDATA

private int getPDATA(java.lang.String key,
                     java.lang.String data,
                     int beg)
Parses a space-delimited data field
Parameters:
key - Field key
data - Data String
beg - Pos of value (in "key: value ...")
Returns:
pos in data following value

getName

public java.lang.String getName()
Gets value of "Cname"

get

public java.lang.String get(java.lang.String key)
Gets a String value
Parameters:
key - Field key
Returns:
value for key

getValues

public java.util.Vector getValues(java.lang.String key)
Gets a (String) Vector value
Parameters:
key - Field key (ends with a '*' character)
Returns:
value for key (a Vector)

getStringValues

java.lang.String[] getStringValues(java.lang.String key)
Gets a String array for a Vector value
Parameters:
key - Field key (ends with a '*' character)
Returns:
String array

setName

public void setName(java.lang.String name)
Sets the "Cname" value
Parameters:
name - New value

setValue

public void setValue(java.lang.String key,
                     java.lang.String value)
Sets the value for a non-null key
Parameters:
key - Key, ignored if null
value - Stored under key if key != null

putValue

public void putValue(KomData kd,
                     java.lang.String key)
Copies a value from another object
Parameters:
kd - Copy value for key from this object
key - Key, no effect if null

qput

public void qput(java.lang.String key,
                 java.lang.String value)
Stores a value if not null or ""
Parameters:
key - Field key
value - Value, stored if != null && != ""

remove

public java.lang.Object remove(java.lang.String key)
Removes a key and its value
Parameters:
key - Key

put

public void put(java.lang.String key,
                java.lang.String value)
Stores a String value if both key and value are non-null
Parameters:
key - Field key
value - Stored under key if non-null (and key is non-null)

mayput

private boolean mayput(java.lang.String key,
                       java.lang.Object value,
                       int place)
Checks if the key/value pair may be put into the hashtable, and updates "keys" if so.
Parameters:
key - Key for value
value - Value (String or Vector)
place - 0 if no order is imposed, -1 if the key should be put first, +1 if the key should be put last. If necessary, an existing key is moved.
Returns:
true if key and value are both non-null

put

public void put(java.lang.String key,
                java.util.Vector values)
Stores a Vector of (String) values if both key and value are non-null
Parameters:
key - Field key
values - Stored under key if non-null (and key is non-null)

putfirst

public void putfirst(java.lang.String key,
                     java.lang.String value)
Stores a value, placing its key first in the "keys" array.
Parameters:
key - Field key.
value - Value of field, stored if non-null and key != null

putlast

public void putlast(java.lang.String key,
                    java.lang.String value)
Stores a value, placing its key last in the "keys" array.
Parameters:
key - Field key.
value - Value of field, stored if non-null and key != null

add

public void add(java.lang.String key,
                java.lang.String value)
Stores a value as a String or as a Vector element, but only if the key and the value are non-null.
Parameters:
key - Field key. If it ends with '*', the value should be placed in a Vector, otherwise store it as a simple String
value - String value

toString

public java.lang.String toString()
Constructs a String representation of this object
Overrides:
toString in class java.util.Hashtable
Returns:
String which can be used to reconstruct the object.

getElem

public static KomData getElem(java.util.Vector vec,
                              int i)
Constructs a KomData object from a String Vector element
Parameters:
vec - Vector of String representations of KomData objects
i - Index in vec
Returns:
new KomData object

putData

public static java.lang.String putData(java.lang.String key,
                                       java.lang.String value)
Constructs a data field representing the key and value
Parameters:
key - Field key
value - Value String Represents the value according to the initial character of the key String: C: LF-delimited "key: value\n" P: Space-delimited "key: value " other: Counted. "key: nn value"

putBDATA

private static java.lang.String putBDATA(java.lang.String key,
                                         java.lang.String value)

putCDATA

private static java.lang.String putCDATA(java.lang.String key,
                                         java.lang.String value)

putPDATA

private static java.lang.String putPDATA(java.lang.String key,
                                         java.lang.String value)

isEmpty

public static boolean isEmpty(java.lang.String data)
Is the string empty or null?
Parameters:
data - String
Returns:
true if string == null or == ""

publish

public void publish(java.lang.String orig)

putid

public void putid(java.lang.String id)

display

public void display()

normal

public void normal()

disppriv

public void disppriv()

debugLog

private void debugLog(java.lang.String s)

errorLog

private void errorLog(java.lang.String s)