View Javadoc

    1
    2   package st.ata.util;
    3
    4   import java.io.InputStream;
    5   import java.util.Date;
    6   import java.util.Iterator;
    7
    8   // Tested by: none (interface)
    9
    10  /*** Map from string keys to values.  The mapping is "strongly types",
    11   *  e.g., a value saved as an "int" cannot be retrieved as a "long" or
    12   *  a "string".  Throws {@link ClassCastException} if a type error
    13   *  occurs, {@link java.util.NoSuchElementException} if the key is not
    14   *  in the table. */
    15
    16  public interface AList {
    17      public static final int F_ARRAY = 128;
    18      public static final int F_ARRAY_ARRAY = 256;
    19      public static final int T_ALIST = 1;
    20      public static final int T_DATE = 2;
    21      public static final int T_INT = 3;
    22      public static final int T_LONG = 4;
    23      public static final int T_STRING = 5;
    24      public static final int T_INPUTSTREAM = 6;
    25      public static final int T_OBJECT = 7;
    26      public static final int T_UNDEFINED = 0;
    27
    28      /*** Returns an iterator of {@link String} containing all keys in
    29       *  this list */
    30      public Iterator getKeys();
    31
    32      public boolean containsKey(String key);
    33
    34      public Object getObject(String key);
    35      public void putObject(String key, Object val);
    36      public Object clone();
    37      public void remove(String key);
    38      /*** Returns an array of {@link String} containing all keys in
    39       *  this list */
    40
    41      public String[] getKeyArray();
    42      public int getInt(String key);
    43
    44      public long getLong(String key);
    45
    46      public String getString(String key);
    47
    48      public AList getAList(String key);
    49
    50      public Date getDate(String key);
    51
    52      public InputStream getInputStream(String key);
    53
    54      public int[] getIntArray(String key);
    55
    56      public long[] getLongArray(String key);
    57
    58      public String[] getStringArray(String key);
    59
    60      public AList[] getAListArray(String key);
    61
    62      public Date[] getDateArray(String key);
    63
    64      public InputStream[] getInputStreamArray(String key);
    65
    66      public String[][] getStringArrayArray(String key);
    67
    68      public void putInt(String key, int value);
    69
    70      public void putLong(String key, long value);
    71
    72      public void putString(String key, String value);
    73
    74      public void putAList(String key, AList value);
    75
    76      public void putDate(String key, Date value);
    77
    78      public void putInputStream(String key, InputStream value);
    79
    80      public void putIntArray(String key, int[] value);
    81
    82      public void putLongArray(String key, long[] value);
    83
    84      public void putStringArray(String key, String[] value);
    85
    86      public void putAListArray(String key, AList[] value);
    87
    88      public void putDateArray(String key, Date[] value);
    89
    90      public void putInputStreamArray(String key, InputStream[] value);
    91
    92      public void putStringArrayArray(String key, String[][] value);
    93
    94      /*** Return the type of the value associated with a key.  Returns
    95       *  one of either {@link #T_UNDEFINED}, if the key is not in the
    96       *  table, or {@link #T_ALIST}, {@link #T_DATE}, {@link #T_INT},
    97       *  {@link #T_LONG}, {@link #T_STRING}, {@link #T_STRING},
    98       *  {@link #T_INPUTSTREAM} or {@link #F_ARRAY}
    99       *  bitwise-ored with any of those. */
    100     public int getType(String key);
    101
    102
    103     /***
    104      *  Closes the object and releases any resources
    105      *  (for example, InputStreams) held by it.
    106      */
    107     public void close();
    108
    109     public AList newAList();
    110
    111     public void clear();
    112
    113     /***
    114      * Copy the iterator's keys from one AList to another.
    115      *
    116      * @param keys Iterator of String keys
    117      * @param other source AList
    118      */
    119     public void copyKeysFrom(Iterator keys, AList other);
    120
    121     /***
    122      * Provides a somewhat pretty (matching brackets for nesting)
    123      * string of AList.
    124      *
    125      * @return pretty String
    126      */
    127     public String toPrettyString();
    128 }