Copyright © Rasmus Sten and contributors, 1997-2004

nu.dll.lyskom
Class Selection

java.lang.Object
  |
  +--nu.dll.lyskom.Selection
All Implemented Interfaces:
java.io.Serializable, Tokenizable

public class Selection
extends java.lang.Object
implements java.io.Serializable, Tokenizable

A Selection is tagged data, in which each object represent an ordered list of tags (keys) and perhaps some data belonging to each tag.

This implementation is not quite consistent with the LysKOM Protocol A specification, since each tag can contain multiple values (due to an early confusion during development), but it seems to be adequate for most needs.

Also, this implementation can only deal with "primitive" LysKOM types, such as INT32, Bitstring, Hollerith and their likes. If you try to set a Selection value to a KomTokenArray or another Selection, for example, you will get very unpredictable results.

See Also:
Serialized Form

Field Summary
static int DEBUG
           
 
Constructor Summary
Selection(int size)
          Creates a new Selection.
 
Method Summary
 nu.dll.lyskom.Selection add(int key, int value)
          Adds the tag key to this selection, with the value value.
 nu.dll.lyskom.Selection add(int key, java.lang.Object o)
          Adds the tag key to this Selection.
 boolean clear(int key)
          Clears the selection by removing the supplied key and its value(s).
 boolean contains(int key)
          Returns true if this Selection contains the tag key
 int countKeys()
          Returns the number of keys (supplied selectors) in this Selection.
 java.util.Enumeration get(int key)
          Deprecated. This should have no real use in the real world.
 java.lang.Object getFirst(int key)
          Deprecated. This should have no real use in the real world.
 int[] getIntArray(int no)
          Deprecated. This should have no real use in the real world.
 int getIntValue(int key)
          Returns an int representation of the data tagged with key, providing that the data is stored as an Integer.
 int[] getKeys()
          Returns an array of integers representing all the selectors (keys) in this Selection.
 nu.dll.lyskom.KomTime getTimeValue(int key)
          Returns a KomTime value stored with tag key.
 nu.dll.lyskom.KomToken getTokenValue(int key)
          Returns a KomToken value stored with tag key.
 java.util.Vector getVector(int key)
          Deprecated. This should have no real use in the real world.
 boolean remove(int key, java.lang.Object value)
          Removes the object value from the tag key.
 int size()
          Returns the number of "trail" values in this Selection.
 nu.dll.lyskom.KomToken toToken()
          Converts this selection into one KomToken object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final int DEBUG
See Also:
Constant Field Values
Constructor Detail

Selection

public Selection(int size)
Creates a new Selection. The size parameter specifies the highes possible tag number that will occur in this Selection.

Method Detail

add

public nu.dll.lyskom.Selection add(int key,
                                   java.lang.Object o)
Adds the tag key to this Selection. The supplied object may be null to indicate a tag without a trailing value.


add

public nu.dll.lyskom.Selection add(int key,
                                   int value)
Adds the tag key to this selection, with the value value.


contains

public boolean contains(int key)
Returns true if this Selection contains the tag key


get

public java.util.Enumeration get(int key)
                          throws NoSuchKeyException
Deprecated. This should have no real use in the real world.

Returns an Enumeration of all the values associated with the specified tag key.

NoSuchKeyException

getIntValue

public int getIntValue(int key)
Returns an int representation of the data tagged with key, providing that the data is stored as an Integer.


getTimeValue

public nu.dll.lyskom.KomTime getTimeValue(int key)
Returns a KomTime value stored with tag key.


getTokenValue

public nu.dll.lyskom.KomToken getTokenValue(int key)
Returns a KomToken value stored with tag key.


remove

public boolean remove(int key,
                      java.lang.Object value)
Removes the object value from the tag key. It does not remove the tag itself, which then becomes selector without a trailing value.

Returns:
true if the tag was found in this selection and contained value

clear

public boolean clear(int key)
Clears the selection by removing the supplied key and its value(s).

Returns:
true if the supplied key was found

getKeys

public int[] getKeys()
Returns an array of integers representing all the selectors (keys) in this Selection.


getVector

public java.util.Vector getVector(int key)
                           throws NoSuchKeyException
Deprecated. This should have no real use in the real world.

Returns a vector containing all elements associated with a key.

NoSuchKeyException

getIntArray

public int[] getIntArray(int no)
Deprecated. This should have no real use in the real world.

Returns an integer array containing all elements' values converted into integers, for a given key.


getFirst

public java.lang.Object getFirst(int key)
                          throws NoSuchKeyException
Deprecated. This should have no real use in the real world.

Returns the first object tagged with the supplied key.

NoSuchKeyException

countKeys

public int countKeys()
Returns the number of keys (supplied selectors) in this Selection.


size

public int size()
Returns the number of "trail" values in this Selection.


toToken

public nu.dll.lyskom.KomToken toToken()
Converts this selection into one KomToken object.

Specified by:
toToken in interface Tokenizable

Copyright © Rasmus Sten and contributors, 1997-2004