]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/TestDataModule.java
go
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / TestDataModule.java
1 //##header J2SE15
2 /**
3  *******************************************************************************
4  * Copyright (C) 2001-2009, International Business Machines Corporation and    *
5  * others. All Rights Reserved.                                                *
6  *******************************************************************************
7  */
8 package com.ibm.icu.dev.test;
9
10 import java.util.Iterator;
11
12 /**
13  * Represents a collection of test data described in a file.
14  * 
15  */
16 public interface TestDataModule {
17     /**
18      * Return the name of this test data module.
19      */
20     public String getName();
21
22     /**
23      * Get additional data related to the module, e.g. DESCRIPTION,
24      * global settings.  Might be null.
25      */
26     public DataMap getInfo();
27
28     /**
29      * Returns the TestData corresponding to name, or null if name not
30      * found in this module.  Throw error if name is not found.  
31      * @throws DataModuleFormatError
32      */
33     public TestData getTestData(String name) throws DataModuleFormatError;
34
35     /**
36      * @return Iterator<TestData>
37      */
38     public Iterator getTestDataIterator();
39
40     public static class Factory{
41
42         static final TestDataModule get(String baseName, String localeName) throws DataModuleFormatError {
43             return new ResourceModule(baseName, localeName);
44         }
45     }
46
47     public static class DataModuleFormatError extends Exception{
48         /**
49          * For serialization
50          */
51         private static final long serialVersionUID = 4312521272388482529L;
52         public DataModuleFormatError(String msg){
53             super(msg);
54         }
55 //#if defined(FOUNDATION10) || defined(J2SE13)
56 //#else
57         public DataModuleFormatError(String msg, Throwable cause){
58             super(msg, cause);
59         }
60         public DataModuleFormatError(Throwable cause) {
61             super(cause);
62         }
63 //#endif
64     }
65     
66     /**
67      * Represents a single test in the module.
68      */
69     public static interface TestData {
70         public String getName();
71         /**
72          * Get additional data related to the test data, e.g. DESCRIPTION,
73          * global settings.  Might be null.
74          */
75         public DataMap getInfo();
76         /**
77          * @return Iterator<DataMap>
78          */
79         public Iterator getSettingsIterator();
80         /**
81          * @return Iterator<DataMap>
82          */
83         public Iterator getDataIterator();
84     }
85
86     /**
87      * Map-like interface for accessing key-value pairs by key.
88      * If the vaule is not found by given key, return null. 
89      * The behavior is analogous the get() method of the Map interface.
90      * 
91      * @author Raymond Yang
92      */
93     public interface DataMap {
94 //    public abstract boolean    isDefined(String key);
95 //
96     public abstract Object     getObject(String key);
97     public abstract String     getString(String key);
98 //    public abstract char       getChar(String key);
99 //    public abstract int        getInt(String key);
100 //    public abstract byte       getByte(String key);
101 //    public abstract boolean    getBoolean(String key);
102 //
103 //    public abstract Object[]   getObjectArray(String key);
104 //    public abstract String[]   getStringArray(String key);
105 //    public abstract char[]     getCharArray(String key);
106 //    public abstract int[]      getIntArray(String key);
107 //    public abstract byte[]     getByteArray(String key);
108 //    public abstract boolean[]  getBooleanArray(String key);
109     }
110 }
111