01: package com.jeta.forms.store.xml.parser;
02:
03: import java.io.IOException;
04:
05: import com.jeta.forms.store.JETAObjectInput;
06:
07: public class XMLObjectInput implements JETAObjectInput {
08:
09: private JETAPersistableHandler m_handler;
10:
11: public XMLObjectInput(JETAPersistableHandler handler) {
12: m_handler = handler;
13: assert (m_handler != null);
14: }
15:
16: public int readVersion() throws IOException {
17: // return readInt( "version" );
18: return Integer.MAX_VALUE;
19: }
20:
21: public int readInt(String propName) throws IOException {
22: Object pvalue = m_handler.getProperty(propName);
23: return (pvalue == null ? 0 : Integer
24: .parseInt(pvalue.toString()));
25: }
26:
27: public Object readObject(String propName)
28: throws ClassNotFoundException, IOException {
29: return m_handler.getProperty(propName);
30: }
31:
32: public String readString(String propName) throws IOException {
33: Object pvalue = m_handler.getProperty(propName);
34: return (pvalue == null ? null : pvalue.toString());
35: }
36:
37: public boolean readBoolean(String propName) throws IOException {
38: Object pvalue = m_handler.getProperty(propName);
39: return (pvalue == null ? false : Boolean.valueOf(
40: pvalue.toString()).booleanValue());
41: }
42:
43: public float readFloat(String propName) throws IOException {
44: Object pvalue = m_handler.getProperty(propName);
45: return (pvalue == null ? 0.0f : Float.parseFloat(pvalue
46: .toString()));
47: }
48:
49: public JETAObjectInput getSuperClassInput() {
50: return new XMLObjectInput((JETAPersistableHandler) m_handler
51: .getSuperClassHandler());
52: }
53:
54: public int readInt(String propName, int defaultValue)
55: throws IOException {
56: Object pvalue = m_handler.getProperty(propName);
57: return (pvalue == null ? defaultValue : Integer.parseInt(pvalue
58: .toString()));
59: }
60:
61: public boolean readBoolean(String propName, boolean defaultValue)
62: throws IOException {
63: Object pvalue = m_handler.getProperty(propName);
64: return (pvalue == null ? defaultValue : Boolean.valueOf(
65: pvalue.toString()).booleanValue());
66: }
67:
68: public float readFloat(String propName, float defaultValue)
69: throws IOException {
70: Object pvalue = m_handler.getProperty(propName);
71: return (pvalue == null ? defaultValue : Float.parseFloat(pvalue
72: .toString()));
73: }
74:
75: }
|