| org.mmbase.bridge.FieldValue
All known Subclasses: org.mmbase.bridge.implementation.BasicFieldValue, org.mmbase.bridge.util.AbstractFieldValue,
FieldValue | public interface FieldValue (Code) | | This interface represents a value stored in a node.
author: Pierre van Rooden since: MMBase 1.6 version: $Id: FieldValue.java,v 1.12 2007/02/16 20:04:39 michiel Exp $ |
Method Summary | |
public boolean | canModify() Returns whether this value can be changed. | public Object | get() Returns the value as an Object.
The object type may vary and is dependent on how data was stored in a field.
I.e. | public Field | getField() Returns the Field object belonging to this value.
the field object. | public Node | getNode() Returns the Node to which this value belongs. | public boolean | isNull() | public void | set(Object value) Sets the value, passing any Object
The object type may vary and is generally stored in memory as-is, which means that,
generally, the get() method returns the same object.
Note that for an XML field String values are converted to a XML document, and individual builders
may make their own changes.
The object is converted to the actual type (using the getXXX() methods detailed above) once the node
is stored, though that does not affect the data in-memory until the Node is read anew from the storage.
Note that this behavior may change in the future and therefor code should not be dependent on this.
By preference, use the more specific methods for setting data (i.e. | public void | setBoolean(boolean value) Sets the value, passing a boolean value. | public void | setByte(byte[] value) Sets the value, passing a byte array. | public void | setDate(java.util.Date value) Sets the value, passing a java.util.Date object. | public void | setDouble(double value) Sets the value, passing a double value. | public void | setFLoat(float value) Sets the value, passing a float value. | public void | setInt(int value) Sets the value, passing a int value. | public void | setLong(long value) Sets the value, passing a long value. | public void | setNode(Node value) Sets the value, passing a Node. | public void | setObject(Object value) | public void | setString(String value) Sets the value, passing a String. | public void | setXML(org.w3c.dom.Document value) Sets the value, passing a org.w3c.dom.Document object. | public boolean | toBoolean() Returns the value as an boolean (true or false ).
If the actual value is a Boolean object, this call returns it's (primitive) boolean value.
If the actual value is a Number object, this call returns true
if the value is a positive, non-zero, value. | public byte[] | toByte() Returns the value as a byte array.
This function returns either the value of a byte field, or the byte value of a string
(converted using the default encoding, i.e. | public java.util.Date | toDate() | public double | toDouble() Returns the value as a double.
This function attempts to convert the value to a double.
Numeric fields are simply converted. | public float | toFloat() Returns the value as a float.
This function attempts to convert the value to a float.
Numeric fields are simply converted.
Boolean fields return 0.0 if false, and 1.0 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. | public int | toInt() Returns the value as an int.
This function attempts to convert the value to an int.
Numeric fields are simply converted. | public long | toLong() Returns the value as a long.
This function attempts to convert the value to a long.
Numeric fields are simply converted. | public Node | toNode() Returns the value as a Node. | public String | toString() Returns the value as a String. | public org.w3c.dom.Document | toXML() Returns the value as a org.w3c.dom.Document
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML. | public org.w3c.dom.Element | toXML(org.w3c.dom.Document tree) Returns the value as a org.w3c.dom.Element
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML. |
canModify | public boolean canModify()(Code) | | Returns whether this value can be changed.
Some field values (such as the values of the number, owner, and otype fields) cannot be changed
through this interface (but some may be changed through other means).
true if the value can be changed |
get | public Object get()(Code) | | Returns the value as an Object.
The object type may vary and is dependent on how data was stored in a field.
I.e. It may be possible for an Integer field to return it's value as a String
if it was stored that way in the first place.
the field value as an object |
getField | public Field getField()(Code) | | Returns the Field object belonging to this value.
the field object. Why not return Field? |
getNode | public Node getNode()(Code) | | Returns the Node to which this value belongs.
the Node object |
isNull | public boolean isNull()(Code) | | |
set | public void set(Object value)(Code) | | Sets the value, passing any Object
The object type may vary and is generally stored in memory as-is, which means that,
generally, the get() method returns the same object.
Note that for an XML field String values are converted to a XML document, and individual builders
may make their own changes.
The object is converted to the actual type (using the getXXX() methods detailed above) once the node
is stored, though that does not affect the data in-memory until the Node is read anew from the storage.
Note that this behavior may change in the future and therefor code should not be dependent on this.
By preference, use the more specific methods for setting data (i.e. setString()).
See Also: FieldValue.get Parameters: value - the field value as an Object |
setBoolean | public void setBoolean(boolean value)(Code) | | Sets the value, passing a boolean value.
This value is converted to a Boolean object.
See Also: FieldValue.toBoolean Parameters: value - the field value as a boolean |
setByte | public void setByte(byte[] value)(Code) | | Sets the value, passing a byte array.
See Also: FieldValue.toByte Parameters: value - the field value as a byte array |
setDate | public void setDate(java.util.Date value)(Code) | | Sets the value, passing a java.util.Date object.
See Also: FieldValue.toDate Parameters: value - the field value as a java.util.Date Document since: MMBase-1.8 |
setDouble | public void setDouble(double value)(Code) | | Sets the value, passing a double value.
This value is converted to a Double object.
See Also: FieldValue.toDouble Parameters: value - the field value as a double |
setFLoat | public void setFLoat(float value)(Code) | | Sets the value, passing a float value.
This value is converted to a Float object.
See Also: FieldValue.toFloat Parameters: value - the field value as a float |
setInt | public void setInt(int value)(Code) | | Sets the value, passing a int value.
This value is converted to a Integer object.
See Also: FieldValue.toInt Parameters: value - the field value as a int |
setLong | public void setLong(long value)(Code) | | Sets the value, passing a long value.
This value is converted to a Long object.
See Also: FieldValue.toLong Parameters: value - the field value as a long |
setNode | public void setNode(Node value)(Code) | | Sets the value, passing a Node.
See Also: FieldValue.toNode Parameters: value - the field value as a Node |
setString | public void setString(String value)(Code) | | Sets the value, passing a String.
See Also: FieldValue.toString Parameters: value - the field value as a String |
toBoolean | public boolean toBoolean()(Code) | | Returns the value as an boolean (true or false ).
If the actual value is a Boolean object, this call returns it's (primitive) boolean value.
If the actual value is a Number object, this call returns true
if the value is a positive, non-zero, value. In other words, values '0'
and '-1' are concidered false .
If the value is a string, this call returns true if
the value is "true" or "yes" (case-insensitive).
In all other cases (including calling byte fields), false
is returned.
the field value as a boolean |
toByte | public byte[] toByte()(Code) | | Returns the value as a byte array.
This function returns either the value of a byte field, or the byte value of a string
(converted using the default encoding, i.e. UTF8)
Other types of values return an empty byte-array.
the field value as a byte array |
toDate | public java.util.Date toDate()(Code) | | Returns the value as a java.util.Date
If the value cannot be converted, this method returns null
the field value as Date since: MMBase-1.8 |
toDouble | public double toDouble()(Code) | | Returns the value as a double.
This function attempts to convert the value to a double.
Numeric fields are simply converted. Double may be truncated.
Boolean fields return 0.0 if false, and 1.0 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1.0.
the field value as a double |
toFloat | public float toFloat()(Code) | | Returns the value as a float.
This function attempts to convert the value to a float.
Numeric fields are simply converted.
Boolean fields return 0.0 if false, and 1.0 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1.0.
the field value as a float |
toInt | public int toInt()(Code) | | Returns the value as an int.
This function attempts to convert the value to an int.
Numeric fields are simply converted. Double and float values may be truncated.
For Node values, the numeric key is returned.
Long values return -1 of the value is too large.
Boolean fields return 0 if false, and 1 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1
the field value as an int. |
toLong | public long toLong()(Code) | | Returns the value as a long.
This function attempts to convert the value to a long.
Numeric fields are simply converted. Double and float values may be truncated.
Boolean fields return 0 if false, and 1 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1
the field value as a long. |
toNode | public Node toNode()(Code) | | Returns the value as a Node.
This function attempts to retrieve the node represented by the value.
For numeric fields the node is retrieved using the numeric values as the node key.
String fields are used as Node aliases, withw hich to retrieve the Node.
If the node does not exist, or the value is of anotehr type, the function returns null .
the field value as a Node |
toString | public String toString()(Code) | | Returns the value as a String.
Byte arrays are converted to string using the default encoding (UTF8).
Node values return a string representation of their numeric key.
DOM Documents are serialized to a proper strign represnattion fo the xml.
For other values the result is calling the toString() method on the actual object.
the field value as a String |
toXML | public org.w3c.dom.Document toXML() throws IllegalArgumentException(Code) | | Returns the value as a org.w3c.dom.Document
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML.
If the value cannot be converted, this method returns null
the field value as a Document throws: IllegalArgumentException - if the Field is not of type TYPE_XML. |
toXML | public org.w3c.dom.Element toXML(org.w3c.dom.Document tree) throws IllegalArgumentException(Code) | | Returns the value as a org.w3c.dom.Element
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML.
This method fails (throws a IllegalArgumentException) if the Field is not of type TYPE_XML.
If the value cannot be converted, this method returns null
Parameters: tree - the DOM Document to which the Element is added(as the document root element) the field value as an Element throws: IllegalArgumentException - if the Field is not of type TYPE_XML. |
|
|