001: package com.jeta.forms.store;
002:
003: import java.io.IOException;
004:
005: /**
006: * An interface for writing primitives and objects to a persistent store. This
007: * interface is similar to java.io.DataOutputStream but is slightly modified to
008: * support writing 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 JETAObjectOutput {
015:
016: /**
017: * Helper method that simply forwards the call to write("version", version)
018: */
019: public void writeVersion(int version) throws IOException;
020:
021: /**
022: * Writes an integer with the specified name to the store.
023: *
024: * @param tagName
025: * the name of the integer.
026: * @param value
027: * the value to write
028: */
029: public void writeInt(String tagName, int value) throws IOException;
030:
031: /**
032: * Writes an integer with the specified name to the store. If the value is
033: * the same as the default value, the store has the option of not saving the
034: * value.
035: *
036: * @param tagName
037: * @param value
038: * @param defaultValue
039: */
040: public void writeInt(String string, int value, int defaultValue)
041: throws IOException;
042:
043: /**
044: * Writes an object with the specified name to the store.
045: *
046: * @param tagName
047: * the name of the object.
048: * @param obj
049: * the object to write
050: */
051: public void writeObject(String tagName, Object obj)
052: throws IOException;
053:
054: /**
055: * Writes a boolean with the specified name to the store.
056: *
057: * @param tagName
058: * the name of the boolean.
059: * @param bval
060: * the value to write
061: */
062: public void writeBoolean(String string, boolean bval)
063: throws IOException;
064:
065: /**
066: * Writes a boolean with the specified name to the store. If the value is
067: * the same as the default value, the store has the option of not saving the
068: * value.
069: *
070: * @param tagName
071: * the name of the boolean.
072: * @param bval
073: * the value to write
074: */
075: public void writeBoolean(String string, boolean bval,
076: boolean defaultValue) throws IOException;
077:
078: /**
079: * Writes an float with the specified name to the store.
080: *
081: * @param tagName
082: * the name of the float.
083: * @param fval
084: * the value to write
085: */
086: public void writeFloat(String string, float fval)
087: throws IOException;
088:
089: /**
090: * Writes a float with the specified name to the store. If the value is the
091: * same as the default value, the store has the option of not saving the
092: * value.
093: *
094: * @param tagName
095: * @param value
096: * @param defaultValue
097: */
098: public void writeFloat(String string, float value,
099: float defaultValue) throws IOException;
100:
101: /**
102: * Returns a JETAObjectOutput instance for writing a super class of the
103: * object that is currently being written. This is needed those storage
104: * formats that don't automatically handle inheritance (i.e. XML). Java
105: * Serialization handles this automatically, so this is a no-op method and
106: * simply returns the same JETAObjectOutput instance.
107: *
108: * @param superClass
109: * an optional super class. This is mainly used for making the
110: * XML a little clearer.
111: */
112: public JETAObjectOutput getSuperClassOutput(Class superClass);
113:
114: }
|