001: package com.jeta.forms.store;
002:
003: import java.io.IOException;
004:
005: /**
006: * An interface for reading primitives and objects from a persistent store. This
007: * interface is similar to java.io.DataInputStream but is slightly modified to
008: * support reading named primitives and objects (to support tagged formats such
009: * as XML). For those formats that don't use tags (i.e. standard Java
010: * serialization), the tag names are ignored.
011: *
012: * @author Jeff Tassin
013: */
014: public interface JETAObjectInput {
015:
016: /**
017: * Helper method that simply forwards the call to read("version")
018: */
019: public int readVersion() throws IOException;
020:
021: /**
022: * Reads an integer with the specified name from the store.
023: *
024: * @param tagName
025: * the name of the integer.
026: * @return the integer value with the specified name. Zero is returned if a
027: * value is not found with specified name.
028: */
029: public int readInt(String tagName) throws IOException;
030:
031: /**
032: * Reads an integer with the specified name from the store.
033: *
034: * @param tagName
035: * the name of the integer.
036: * @param defaultValue
037: * if the value is not found, the default value is returned.
038: * @return the integer value with the specified name (or the default value)
039: */
040: public int readInt(String tagName, int defaultValue)
041: throws IOException;
042:
043: /**
044: * Reads an object with the specified name from the store.
045: *
046: * @param tagName
047: * the name of the object.
048: * @return the object with the specified name. Null is returned if a value
049: * is not found with the specified name.
050: */
051: public Object readObject(String tabName)
052: throws ClassNotFoundException, IOException;
053:
054: /**
055: * Reads an String object with the specified name from the store.
056: *
057: * @param tagName
058: * the name of the object.
059: * @return the String with the specified name. Null is returned if a value
060: * is not found with the specified name.
061: */
062: public String readString(String string) throws IOException;
063:
064: /**
065: * Reads a boolean with the specified name from the store.
066: *
067: * @param tagName
068: * the name of the boolean.
069: * @return the boolean with the specified name. False is returned if a value
070: * is not found with the specified name.
071: */
072: public boolean readBoolean(String string) throws IOException;
073:
074: /**
075: * Reads a boolean with the specified name from the store.
076: *
077: * @param tagName
078: * the name of the integer.
079: * @param defaultValue
080: * if the value is not found, the default value is returned.
081: * @return the boolean value with the specified name (or the default value)
082: */
083: public boolean readBoolean(String tagName, boolean defaultValue)
084: throws IOException;
085:
086: /**
087: * Reads a float with the specified name from the store.
088: *
089: * @param tagName
090: * the name of the float.
091: * @return the float with the specified name. Zero is returned if a value is
092: * not found with the specified name.
093: */
094: public float readFloat(String string) throws IOException;
095:
096: /**
097: * Reads a float with the specified name from the store.
098: *
099: * @param tagName
100: * the name of the integer.
101: * @param defaultValue
102: * if the value is not found, the default value is returned.
103: * @return the float value with the specified name (or the default value)
104: */
105: public float readFloat(String tagName, float defaultValue)
106: throws IOException;
107:
108: /**
109: * Returns a JETAObjectInput instance for reading a super class of the
110: * object that is currently being read. This is needed those storage formats
111: * that don't automatically handle inheritance (i.e. XML). Java
112: * Serialization handles this automatically, so this is a no-op method and
113: * simply returns the same JETAObjectInput instance.
114: */
115: public JETAObjectInput getSuperClassInput();
116:
117: }
|