001: //##header
002: /**
003: *******************************************************************************
004: * Copyright (C) 2001-2006, International Business Machines Corporation and *
005: * others. All Rights Reserved. *
006: *******************************************************************************
007: */package com.ibm.icu.dev.test;
008:
009: import java.util.Iterator;
010:
011: /**
012: * Represents a collection of test data described in a file.
013: *
014: */
015: public interface TestDataModule {
016: /**
017: * Return the name of this test data module.
018: */
019: public String getName();
020:
021: /**
022: * Get additional data related to the module, e.g. DESCRIPTION,
023: * global settings. Might be null.
024: */
025: public DataMap getInfo();
026:
027: /**
028: * Returns the TestData corresponding to name, or null if name not
029: * found in this module. Throw error if name is not found.
030: * @throws DataModuleFormatError
031: */
032: public TestData getTestData(String name)
033: throws DataModuleFormatError;
034:
035: /**
036: * @return Iterator<TestData>
037: */
038: public Iterator getTestDataIterator();
039:
040: public static class Factory {
041:
042: static final TestDataModule get(String baseName,
043: String localeName) throws DataModuleFormatError {
044: return new ResourceModule(baseName, localeName);
045: }
046: }
047:
048: public static class DataModuleFormatError extends Exception {
049: public DataModuleFormatError(String msg) {
050: super (msg);
051: }
052:
053: //#ifndef FOUNDATION
054: public DataModuleFormatError(String msg, Throwable cause) {
055: super (msg, cause);
056: }
057:
058: public DataModuleFormatError(Throwable cause) {
059: super (cause);
060: }
061: //#endif
062: }
063:
064: /**
065: * Represents a single test in the module.
066: */
067: public static interface TestData {
068: public String getName();
069:
070: /**
071: * Get additional data related to the test data, e.g. DESCRIPTION,
072: * global settings. Might be null.
073: */
074: public DataMap getInfo();
075:
076: /**
077: * @return Iterator<DataMap>
078: */
079: public Iterator getSettingsIterator();
080:
081: /**
082: * @return Iterator<DataMap>
083: */
084: public Iterator getDataIterator();
085: }
086:
087: /**
088: * Map-like interface for accessing key-value pairs by key.
089: * If the vaule is not found by given key, return null.
090: * The behavior is analogous the get() method of the Map interface.
091: *
092: * @author Raymond Yang
093: */
094: public interface DataMap {
095: // public abstract boolean isDefined(String key);
096: //
097: public abstract Object getObject(String key);
098:
099: public abstract String getString(String key);
100: // public abstract char getChar(String key);
101: // public abstract int getInt(String key);
102: // public abstract byte getByte(String key);
103: // public abstract boolean getBoolean(String key);
104: //
105: // public abstract Object[] getObjectArray(String key);
106: // public abstract String[] getStringArray(String key);
107: // public abstract char[] getCharArray(String key);
108: // public abstract int[] getIntArray(String key);
109: // public abstract byte[] getByteArray(String key);
110: // public abstract boolean[] getBooleanArray(String key);
111: }
112: }
|