001: package st.ata.util;
002:
003: import java.io.InputStream;
004: import java.util.Date;
005: import java.util.Iterator;
006:
007: // Tested by: none (interface)
008:
009: /** Map from string keys to values. The mapping is "strongly types",
010: * e.g., a value saved as an "int" cannot be retrieved as a "long" or
011: * a "string". Throws {@link ClassCastException} if a type error
012: * occurs, {@link java.util.NoSuchElementException} if the key is not
013: * in the table. */
014:
015: public interface AList {
016: public static final int F_ARRAY = 128;
017: public static final int F_ARRAY_ARRAY = 256;
018: public static final int T_ALIST = 1;
019: public static final int T_DATE = 2;
020: public static final int T_INT = 3;
021: public static final int T_LONG = 4;
022: public static final int T_STRING = 5;
023: public static final int T_INPUTSTREAM = 6;
024: public static final int T_OBJECT = 7;
025: public static final int T_UNDEFINED = 0;
026:
027: /** Returns an iterator of {@link String} containing all keys in
028: * this list */
029: public Iterator getKeys();
030:
031: public boolean containsKey(String key);
032:
033: public Object getObject(String key);
034:
035: public void putObject(String key, Object val);
036:
037: public Object clone();
038:
039: public void remove(String key);
040:
041: /** Returns an array of {@link String} containing all keys in
042: * this list */
043:
044: public String[] getKeyArray();
045:
046: public int getInt(String key);
047:
048: public long getLong(String key);
049:
050: public String getString(String key);
051:
052: public AList getAList(String key);
053:
054: public Date getDate(String key);
055:
056: public InputStream getInputStream(String key);
057:
058: public int[] getIntArray(String key);
059:
060: public long[] getLongArray(String key);
061:
062: public String[] getStringArray(String key);
063:
064: public AList[] getAListArray(String key);
065:
066: public Date[] getDateArray(String key);
067:
068: public InputStream[] getInputStreamArray(String key);
069:
070: public String[][] getStringArrayArray(String key);
071:
072: public void putInt(String key, int value);
073:
074: public void putLong(String key, long value);
075:
076: public void putString(String key, String value);
077:
078: public void putAList(String key, AList value);
079:
080: public void putDate(String key, Date value);
081:
082: public void putInputStream(String key, InputStream value);
083:
084: public void putIntArray(String key, int[] value);
085:
086: public void putLongArray(String key, long[] value);
087:
088: public void putStringArray(String key, String[] value);
089:
090: public void putAListArray(String key, AList[] value);
091:
092: public void putDateArray(String key, Date[] value);
093:
094: public void putInputStreamArray(String key, InputStream[] value);
095:
096: public void putStringArrayArray(String key, String[][] value);
097:
098: /** Return the type of the value associated with a key. Returns
099: * one of either {@link #T_UNDEFINED}, if the key is not in the
100: * table, or {@link #T_ALIST}, {@link #T_DATE}, {@link #T_INT},
101: * {@link #T_LONG}, {@link #T_STRING}, {@link #T_STRING},
102: * {@link #T_INPUTSTREAM} or {@link #F_ARRAY}
103: * bitwise-ored with any of those. */
104: public int getType(String key);
105:
106: /**
107: * Closes the object and releases any resources
108: * (for example, InputStreams) held by it.
109: */
110: public void close();
111:
112: public AList newAList();
113:
114: public void clear();
115:
116: /**
117: * Copy the iterator's keys from one AList to another.
118: *
119: * @param keys Iterator of String keys
120: * @param other source AList
121: */
122: public void copyKeysFrom(Iterator keys, AList other);
123:
124: /**
125: * Provides a somewhat pretty (matching brackets for nesting)
126: * string of AList.
127: *
128: * @return pretty String
129: */
130: public String toPrettyString();
131: }
|