com.davisor.data
Class URLType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.URLType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable

public class URLType
extends Type

URLType defines a data type that writes and reads URL address strings. URLType maintains also an URL context, that is used to fullfill URL fields missing from URL strings presented to this type.

Since:
JDK1.1
See Also:
getContext(), URLData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static URLType DEFAULT
          The default URL type.
static java.lang.String TYPENAME
          Type name ("URL").
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  URLType()
          Default constructor.
  URLType(java.lang.String dataName)
          Creates a new default type with no identity.
  URLType(java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.net.URL context)
          Creates a new URL text type.
  URLType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Creates a new URL text type.
protected URLType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.net.URL context)
          Creates a new URL text type.
  URLType(URLType ut)
          Copy constructor.
 
Method Summary
 java.lang.String check(java.lang.String value)
          Checks, and possibly fixes an URL string.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 boolean equals(java.lang.Object o)
          Tests if this object is equal with another object.
 java.net.URL getContext()
          Gets URL context that is used to resolve partial URL addresses.
 java.lang.String getFormat()
          Gets the current type specification string.
 java.lang.Class getValueClass()
          Gets value container class.
 int hashCode()
          Returns a hash code value for the object.
 void setFormat(java.lang.String format)
          Sets type URL context.
 DataValue toData(java.lang.Object objectValue)
          Converts an object to a data value.
 DataValue toData(java.lang.String stringValue, java.text.ParsePosition status)
          Converts a string to a data value.
 java.net.URL urlValue(java.lang.String stringValue, java.text.ParsePosition status)
          Converts a string to a URL address.
 DataValue zero()
          Gets zero data value for this type.
 
Methods inherited from class com.davisor.data.Type
ceil, check, compare, create, create, create, create, create, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, 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 URLType DEFAULT
The default URL type.


TYPENAME

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

See Also:
Constant Field Values
Constructor Detail

URLType

public URLType()
Default constructor.


URLType

public URLType(URLType ut)
Copy constructor.


URLType

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

Parameters:
dataName - data name (may be null)

URLType

public URLType(java.lang.String dataName,
               java.lang.String id,
               java.lang.String format)
Creates a new URL text type.

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 - context to resolve partial URL addresses
See Also:
setFormat(java.lang.String)

URLType

public URLType(java.lang.String dataName,
               java.lang.String id,
               java.util.Map metaData,
               java.net.URL context)
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)
context - context to resolve partial URL addresses

URLType

protected URLType(java.lang.String typeName,
                  java.lang.String dataName,
                  java.lang.String id,
                  java.util.Map metaData,
                  java.net.URL context)
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)
context - context to resolve partial URL addresses
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
Specified by:
dup in class Type

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal with another object.

URL types are equal if their super-classes and contexts are.

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class Type
See Also:
Compare.equals(Object,Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Type

getContext

public java.net.URL getContext()
Gets URL context that is used to resolve partial URL addresses.

See Also:
urlValue(java.lang.String, java.text.ParsePosition)

urlValue

public java.net.URL urlValue(java.lang.String stringValue,
                             java.text.ParsePosition status)
                      throws InvalidDataException
Converts a string to a URL address. If the string is null or empty, null is returned. If the URL address is only partially determined, any missing components are inherited from current type URL context.

Parameters:
stringValue - a URL string (may be null or empty)
status - parse status (may be null)
Returns:
A URL that corresponds to the given argument string (may be null)
Throws:
InvalidDataException - 'url' is invalid as a URL address.
See Also:
getContext()

check

public java.lang.String check(java.lang.String value)
                       throws InvalidDataException
Checks, and possibly fixes an URL string.

Overrides:
check in class Type
Parameters:
value - data string value to check
Returns:
checked and possibly fixed URL string
Throws:
InvalidDataException - if the value is invalid as an URL
See Also:
URLData.setValue(java.lang.String, java.text.ParsePosition), URLData.toString()

getFormat

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

URL type specification string contains current URL context. If no context has been defined, null is returned.

Overrides:
getFormat in class Type
Returns:
type specification string, as described above.
See Also:
getContext(), setFormat(java.lang.String)

setFormat

public void setFormat(java.lang.String format)
Sets type URL context. Invalid or missing URL string will set type URL context to null value.

Overrides:
setFormat in class Type
Parameters:
format - type specification, as specified above (may be null)
See Also:
getFormat()

getValueClass

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

Specified by:
getValueClass in class Type

toData

public DataValue toData(java.lang.Object objectValue)
                 throws InvalidDataException
Converts an object to a data value.

URL and URLData objects are converted directly, other objects are converted first to strings, then to URL data values.

Overrides:
toData in class Type
Parameters:
objectValue - data object
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
See Also:
toData(String,ParsePosition)

toData

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

URL type expects the given value to contain an URL address value, and returns a corresponding URLData value.

Specified by:
toData in class Type
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), toData(Object), Type.toData(ResultSet,int), DataValue.toString(), URLData

zero

public DataValue zero()
Gets zero data value for this type.

Specified by:
zero in class Type
Returns:
a new zero value data object sharing this type
Throws:
java.lang.Error - always since this operation is undefined
See Also:
DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue), DataValue.interpolate(double, com.davisor.data.DataValue)


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