KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > implementation > BasicFieldValue


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.bridge.implementation;
12 import org.mmbase.bridge.*;
13
14 /**
15  * This is the basic implementation of the Field Value interface.
16  *
17  * @author Pierre van Rooden
18  * @version $Id: BasicFieldValue.java,v 1.10 2005/12/29 19:24:11 michiel Exp $
19  * @since MMBase-1.6
20  */

21 public class BasicFieldValue implements FieldValue {
22
23     private Node node = null;
24     private Field field = null;
25
26     public BasicFieldValue (Node node, Field field) {
27         this.node = node;
28         this.field = field;
29     }
30
31     public boolean canModify() {
32         // rather simple... should maybe ask Node
33
return (field!=null) ||
34                "number".equals(field.getName()) ||
35                "otype".equals(field.getName()) ||
36                "owner".equals(field.getName()) ||
37                "snumber".equals(field.getName()) ||
38                "dnumber".equals(field.getName()) ||
39                "rnumber".equals(field.getName());
40     }
41
42     public boolean isNull() {
43         return node.isNull(field.getName());
44     }
45
46     public Object JavaDoc get() {
47         return node.getValue(field.getName());
48     }
49
50     public Object JavaDoc getField() {
51         return field;
52     }
53
54     public Node getNode() {
55         return node;
56     }
57
58     public boolean toBoolean() {
59         return node.getBooleanValue(field.getName());
60     }
61
62     public byte[] toByte() {
63         return node.getByteValue(field.getName());
64     }
65
66     public float toFloat() {
67         return node.getFloatValue(field.getName());
68     }
69
70     public double toDouble() {
71         return node.getDoubleValue(field.getName());
72     }
73
74     public long toLong() {
75         return node.getLongValue(field.getName());
76     }
77
78     public int toInt() {
79         return node.getIntValue(field.getName());
80     }
81
82     public Node toNode() {
83         return node.getNodeValue(field.getName());
84     }
85
86     public String JavaDoc toString() {
87         return node.getStringValue(field.getName());
88     }
89
90     public org.w3c.dom.Document JavaDoc toXML() throws IllegalArgumentException JavaDoc {
91         return node.getXMLValue(field.getName());
92     }
93
94     public org.w3c.dom.Element JavaDoc toXML(org.w3c.dom.Document JavaDoc tree) throws IllegalArgumentException JavaDoc {
95         return node.getXMLValue(field.getName(), tree);
96     }
97
98     public java.util.Date JavaDoc toDate() {
99         return node.getDateValue(field.getName());
100     }
101
102     public void set(Object JavaDoc value) {
103         node.setValue(field.getName(), value);
104     }
105
106     public void setObject(Object JavaDoc value) {
107         node.setObjectValue(field.getName(), value);
108     }
109
110     public void setBoolean(boolean value) {
111         node.setBooleanValue(field.getName(),value);
112     }
113
114     public void setFLoat(float value) {
115         node.setFloatValue(field.getName(),value);
116     }
117
118     public void setDouble(double value) {
119         node.setDoubleValue(field.getName(),value);
120     }
121
122     public void setLong(long value) {
123         node.setLongValue(field.getName(),value);
124     }
125
126     public void setInt(int value) {
127         node.setIntValue(field.getName(),value);
128     }
129
130     public void setByte(byte[] value) {
131         node.setByteValue(field.getName(),value);
132     }
133
134     public void setString(String JavaDoc value) {
135         node.setStringValue(field.getName(),value);
136     }
137
138     public void setNode(Node value) {
139         node.setNodeValue(field.getName(),value);
140     }
141
142     public void setXML(org.w3c.dom.Document JavaDoc value) {
143         node.setXMLValue(field.getName(),value);
144     }
145
146
147     public void setDate(java.util.Date JavaDoc value) {
148         node.setDateValue(field.getName(), value);
149     }
150
151 }
152
Popular Tags