|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ast.AstObject
uk.ac.starlink.ast.KeyMap
public class KeyMap
Java interface to the AST KeyMap class - store a set of key/value pairs. The KeyMap class is used to store a set of values with associated keys which identify the values. The keys are strings. These may be case sensitive or insensitive as selected by the KeyCase attribute, and trailing spaces are ignored. The value associated with a key can be integer (signed 4 and 2 byte, or unsigned 1 byte), floating point (single or double precision), void pointer, character string or AST Object pointer. Each value can be a scalar or a one-dimensional vector. A KeyMap is conceptually similar to a Mapping in that a KeyMap transforms an input into an output - the input is the key, and the output is the value associated with the key. However, this is only a conceptual similarity, and it should be noted that the KeyMap class inherits from the Object class rather than the Mapping class. The methods of the Mapping class cannot be used with a KeyMap.
This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA 02110-1301, USA
In Java, you are probably better off using a Map
.
Field Summary | |
---|---|
static int |
AST__BADTYPE
Type constant represening no known type. |
static int |
AST__DOUBLETYPE
Type constant representing double type. |
static int |
AST__INTTYPE
Type constant representing int type. |
static int |
AST__OBJECTTYPE
Type constant representing AstObject type. |
static int |
AST__STRINGTYPE
Type constant representing String type. |
Fields inherited from class uk.ac.starlink.ast.AstObject |
---|
AST__BAD, AST__TUNULL, pointer |
Constructor Summary | |
---|---|
KeyMap()
Create a KeyMap. |
Method Summary | |
---|---|
AstObject |
mapGet0A(String key)
Retrieve an AstObject. |
String |
mapGet0C(String key)
Retrieve a string value. |
Double |
mapGet0D(String key)
Retrieve a double value. |
Integer |
mapGet0I(String key)
Retrieve an integer value. |
AstObject[] |
mapGet1A(String key)
Retrieve an array of AstObjects. |
String[] |
mapGet1C(String key,
int sleng)
Retrieve a string array. |
double[] |
mapGet1D(String key)
Retrieve a double array. |
int[] |
mapGet1I(String key)
Retrieve an integer array. |
boolean |
mapHasKey(String key)
Check if an entry with a given key exists in a KeyMap. |
String |
mapKey(int index)
Get the key at a given index within the KeyMap. |
int |
mapLength(String key)
Get the vector length of an entry in a KeyMap. |
void |
mapPut0A(String key,
AstObject value,
String comment)
Store an AstObject. |
void |
mapPut0C(String key,
String value,
String comment)
Store a string value. |
void |
mapPut0D(String key,
double value,
String comment)
Store a double value. |
void |
mapPut0I(String key,
int value,
String comment)
Store an integer value. |
void |
mapPut1A(String key,
AstObject[] value,
String comment)
Store an AstObject array. |
void |
mapPut1C(String key,
String[] value,
String comment)
Store a string array. |
void |
mapPut1D(String key,
double[] value,
String comment)
Store a double array. |
void |
mapPut1I(String key,
int[] value,
String comment)
Store an integer array. |
void |
mapRemove(String key)
Removed a named entry from a KeyMap. |
int |
mapSize()
Get the number of entries in a KeyMap. |
int |
mapType(String key)
Get the data type of an entry in a KeyMap. |
Methods inherited from class uk.ac.starlink.ast.AstObject |
---|
annul, clear, copy, delete, equals, finalize, getAstConstantI, getB, getC, getD, getF, getI, getID, getIdent, getL, getNobject, getObjSize, getRefCount, hashCode, isThreaded, reportVersions, sameObject, set, setB, setC, setD, setF, setI, setID, setIdent, setL, show, test, tune |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int AST__INTTYPE
public static final int AST__DOUBLETYPE
public static final int AST__STRINGTYPE
public static final int AST__OBJECTTYPE
public static final int AST__BADTYPE
Constructor Detail |
---|
public KeyMap()
AstException
- if an error occurred in the AST libraryMethod Detail |
---|
public void mapRemove(String key)
AstException
- if an error occurred in the AST librarypublic int mapSize()
AstException
- if an error occurred in the AST librarypublic int mapLength(String key)
key
- The character string identifying the KeyMap entry. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic boolean mapHasKey(String key)
key
- The character string identifying the KeyMap entry. Trailing spaces are
ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic String mapKey(int index)
This function is intended primarily as a means of iterating round all the elements in a KeyMap. For this purpose, the number of entries in the KeyMap should first be found using astMapSize and this function should then be called in a loop, with the index value going from zero to one less than the size of the KeyMap. The index associated with a given entry is determined by the SortBy attribute.
index
- The index into the KeyMap. The first entry has index
zero, and the last has index "size-1", where "size" is the value
returned by the astMapSize function.
AstException
- if an error occurred in the AST librarypublic int mapType(String key)
key
- The character string identifying the KeyMap entry. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic void mapPut0D(String key, double value, String comment)
key
- A character string to be stored with the value, which can later
be used to identify the value. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- value to storecomment
- A pointer to a null-terminated comment string to be stored with the
value. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut0I(String key, int value, String comment)
key
- A character string to be stored with the value, which can later
be used to identify the value. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- value to storecomment
- A pointer to a null-terminated comment string to be stored with the
value. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut0C(String key, String value, String comment)
key
- A character string to be stored with the value, which can later
be used to identify the value. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- value to storecomment
- A pointer to a null-terminated comment string to be stored with the
value. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut0A(String key, AstObject value, String comment)
key
- A character string to be stored with the value, which can later
be used to identify the value. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- value to storecomment
- A pointer to a null-terminated comment string to be stored with the
value. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic Double mapGet0D(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored. The supplied string is converted to upper
case before use if the KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic Integer mapGet0I(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored. The supplied string is converted to upper
case before use if the KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic String mapGet0C(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored. The supplied string is converted to upper
case before use if the KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic AstObject mapGet0A(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored. The supplied string is converted to upper
case before use if the KeyCase attribute is currently set to zero.
AstException
- if an error occurred in the AST librarypublic void mapPut1D(String key, double[] value, String comment)
key
- A character string to be stored with the values, which can later
be used to identify the values. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- array to storecomment
- A pointer to a null-terminated comment string to be stored with the
values. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut1I(String key, int[] value, String comment)
key
- A character string to be stored with the values, which can later
be used to identify the values. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- array to storecomment
- A pointer to a null-terminated comment string to be stored with the
values. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut1C(String key, String[] value, String comment)
key
- A character string to be stored with the values, which can later
be used to identify the values. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- array to storecomment
- A pointer to a null-terminated comment string to be stored with the
values. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic void mapPut1A(String key, AstObject[] value, String comment)
key
- A character string to be stored with the values, which can later
be used to identify the values. Trailing spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.value
- array to storecomment
- A pointer to a null-terminated comment string to be stored with the
values. A NULL pointer may be supplied, in which case no comment is
stored.
AstException
- if an error occurred in the AST librarypublic double[] mapGet1D(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
key
as a double array, or null
AstException
- if an error occurred in the AST librarypublic int[] mapGet1I(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
key
as an integer array, or null
AstException
- if an error occurred in the AST librarypublic String[] mapGet1C(String key, int sleng)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.sleng
- maximum length of any of the strings in the returned array;
any longer strings will be truncated
key
as a String array, or null
AstException
- if an error occurred in the AST librarypublic AstObject[] mapGet1A(String key)
key
- The character string identifying the value to be retrieved. Trailing
spaces are ignored.
The supplied string is converted to upper case before use if the
KeyCase attribute is currently set to zero.
key
as an AstObject array, or null
AstException
- if an error occurred in the AST library
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |