Each type in a 5800 system has a canonical representation as a string value. The canonical string representation of each type is shown in Table 4–1.
Table 4–1 Canonical String Representation of Data Types
Data Type |
Canonical String Representation |
---|---|
STRING |
The string itself. |
CHAR |
The string itself. |
BINARY |
Hexadecimal dump of the value with two hex digits per byte. |
LONG |
Result of Long.toString. For example, 88991 or -7975432785. |
DOUBLE |
Result of Double.toString. For example, 1.45 or NaN or -Infinity or -1.56E200. |
DATE |
YYYY-mm-dd. For example, 2001-01-01. |
TIME |
HH:mm:sss. For example, 12:02:01. |
TIMESTAMP |
YYYY-mm-ddThh:mm:ss.fffZ (time relative to UTC). For example, 1969-12-31T23:59:59.999Z. |
OBJECTID |
60-digit hexadecimal dump of the objectid. |
This canonical string encoding is used in the following places:
When exposing the field as a directory component or a filename component in a virtual view
When converting a typed value to a string as the result of the getAsString operation on a NameValueRecord or a QueryResultSet operation
When parsing a literal value as described in Literals for 5800 System Data Types to create a typed query value from a string representation of that value.
The inverse of the canonical string encoding is used in the following places:
It is always allowed to store a string value into any metadata field, no matter what the type of the field is. The actual data stored is the result of applying the canonical string decode operation to the incoming string value.
On a virtual view lookup operation, the canonical string decode operation is used on the supplied filename to derive the actual metadata values to look up, given their string representations in the filename.
The decode operation is allowed to accept incoming string values that would never be a legal output for an encode operation. Some examples of this include:
decodeBinary of an odd number of hex digits. The convention is to left-justify the supplied digits in the binary value. For example, the string "b0a" corresponds to the binary literal [b0a0].
decodeDate of a non-standard date format.
A double value encoded with a non-canonical number of digits. For example, .00145E20 instead of 1.45E17.
If you take a value V and encode it into a string S, and then perform the canonical decode operation on S to get a new value V’. Does V always equal V’? The answer is yes in most cases, but not always.
What is actually guaranteed is the weaker statement that if encode(V) = S and if decode(S)=V’, then encode(V’) is also equal to S.