com.davisor.data
Class URLTextType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.TextType
              extended bycom.davisor.data.URLTextType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
URLTextOutputType

public class URLTextType
extends TextType

URLTextType defines a data type that writes and reads URL-encoded text strings.

Since:
JDK1.1
See Also:
URLTextOutputType, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static URLTextType DEFAULT
          Default text type.
static java.lang.String TYPENAME
          Type name ("URLTEXT").
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  URLTextType()
          Default constructor.
  URLTextType(java.lang.String dataName)
          Creates a new default type with no identity.
  URLTextType(java.lang.String dataName, java.lang.String id, java.util.Map metaData, int maxLength, java.lang.String prefix)
          Creates a new URL text type.
  URLTextType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Constructs a new type with given spesification.
protected URLTextType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, int maxLength, java.lang.String prefix)
          Creates a new URL text type.
  URLTextType(URLTextType utt)
          Copy constructor.
 
Method Summary
 java.lang.String check(java.lang.String data)
          Verifies that a text string is URL-encoded.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 float getCompatibility(java.lang.Class type)
          Gets an estimate of how well this type could represent objects of the given class.
 java.lang.String getFormat()
          Gets the current type specification string.
 java.lang.Class getValueClass()
          Gets value container class.
 void setFormat(java.lang.String format)
          Sets the URL text specification.
 java.lang.String stringValue(java.lang.String stringValue)
          Verifies that a text string is URL-encoded.
 DataValue toData(java.lang.String stringValue, java.text.ParsePosition status)
          Converts a string to a data value.
 
Methods inherited from class com.davisor.data.TextType
equals, getMaxLength, getPrefix, getSQLCode, hashCode, setMaxLength, setPrefix, stringValue, zero
 
Methods inherited from class com.davisor.data.Type
ceil, check, compare, create, create, create, create, create, dup, floor, format, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toData, toData, toData, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final URLTextType DEFAULT
Default text type.


TYPENAME

public static final java.lang.String TYPENAME
Type name ("URLTEXT").

See Also:
Constant Field Values
Constructor Detail

URLTextType

public URLTextType()
Default constructor.


URLTextType

public URLTextType(URLTextType utt)
Copy constructor.


URLTextType

public URLTextType(java.lang.String dataName)
Creates a new default type with no identity.

Parameters:
dataName - data name (may be null)

URLTextType

public URLTextType(java.lang.String dataName,
                   java.lang.String id,
                   java.lang.String format)
Constructs a new type with given spesification.

This is the constructor the SQL type mapper Type.create(Integer,String,String,String) method will call to create a type that matches given SQL type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
format - type spesification (may be null)
See Also:
setFormat(java.lang.String)

URLTextType

public URLTextType(java.lang.String dataName,
                   java.lang.String id,
                   java.util.Map metaData,
                   int maxLength,
                   java.lang.String prefix)
Creates a new URL text type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
maxLength - maximum text length
prefix - mandatory text prefix (may be null)

URLTextType

protected URLTextType(java.lang.String typeName,
                      java.lang.String dataName,
                      java.lang.String id,
                      java.util.Map metaData,
                      int maxLength,
                      java.lang.String prefix)
Creates a new URL text type.

Parameters:
typeName - type name
dataName - data name (may be null)
id - type identity (may be null)
metaData - type meta data map (may be null)
maxLength - maximum text length
prefix - mandatory text prefix (may be null)
Method Detail

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class TextType

stringValue

public java.lang.String stringValue(java.lang.String stringValue)
                             throws InvalidDataException
Verifies that a text string is URL-encoded. This is done by URL-decoding the string first, and then URL-encoding it again.

Parameters:
stringValue - data string
Returns:
verified and possible altered data string
Throws:
InvalidDataException - if verification fails
See Also:
setFormat(java.lang.String), Type.check(java.lang.String)

check

public java.lang.String check(java.lang.String data)
                       throws InvalidDataException
Verifies that a text string is URL-encoded.

Overrides:
check in class TextType
Parameters:
data - data string
Returns:
Data string.
Throws:
InvalidDataException - never
See Also:
stringValue(java.lang.String), Type.check(java.lang.String)

getCompatibility

public float getCompatibility(java.lang.Class type)
Gets an estimate of how well this type could represent objects of the given class.

Overrides:
getCompatibility in class TextType
Returns:
0.25, if the given type is assignable from String, otherwise 0.0. The compatibility estimate for strings is low, because it is difficult to determine whether a string is URL-encoded or not.
See Also:
getValueClass()

getFormat

public java.lang.String getFormat()
Gets the current type specification string.

The URL text type does not, however, support any constraints, so this method always returns a null string.

Overrides:
getFormat in class TextType
Returns:
type specification string (null)
See Also:
setFormat(java.lang.String)

setFormat

public void setFormat(java.lang.String format)
Sets the URL text specification.

The URL text type does not, however, support any constraints, so this method does nothing.

Overrides:
setFormat in class TextType
Parameters:
format - type specifications (may be null)
See Also:
getFormat()

getValueClass

public java.lang.Class getValueClass()
Gets value container class.

Overrides:
getValueClass in class TextType

toData

public DataValue toData(java.lang.String stringValue,
                        java.text.ParsePosition status)
                 throws InvalidDataException
Converts a string to a data value.

URL text type expects the given value to contain an URL encoded string value, and returns a corresponding URLTextData value.

Overrides:
toData in class TextType
Parameters:
stringValue - data string
status - parse status (may be null)
Returns:
a data value object corresponding given string value
Throws:
InvalidDataException - if given string value could not be parsed
See Also:
Type.toData(CallableStatement,int), Type.toData(Object), Type.toData(ResultSet,int), URLTextData


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.