com.davisor.data
Class URLData

java.lang.Object
  extended bycom.davisor.data.VoidData
      extended bycom.davisor.data.VoidValue
          extended bycom.davisor.data.GenericValue
              extended bycom.davisor.data.URLData
All Implemented Interfaces:
java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.io.Serializable, SerializableData

public class URLData
extends GenericValue

A URLData object represents a URL address. The address may also be null, indicating a missing or undetermined address.

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

Field Summary
 
Fields inherited from class com.davisor.data.VoidData
M_type
 
Constructor Summary
URLData()
          Default constructor.
URLData(URLData data, boolean deep)
          Deep or shallow copy constructor.
URLData(URLType type, java.lang.String stringValue, java.text.ParsePosition status)
          Creates a URL data value from a string value.
URLData(URLType type, java.net.URL value)
          Creates a new URL data object with the given URL type and value.
 
Method Summary
 DataValue add(DataValue value)
          Adds data values.
 int compareTo(java.lang.Object o)
          Compares this data with other data objects.
 double deinterpolate(DataValue min, DataValue max)
          De-interpolates the current data value to a scalar value, in respect, with the given data value range.
 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.lang.String getFormat()
          Gets the type specification optimal for this particular value.
 java.net.URL getValue()
          Gets the URL value.
 int hashCode()
          Returns a hash code value for the object.
 DataValue interpolate(double value, DataValue max)
          Interpolates the given scalar value to data value, in respect, with the range defined by this value and the given maximum value.
 boolean isNull()
          Tests if this data object value is undetermined.
 void setValue(java.lang.String stringValue, java.text.ParsePosition status)
          Sets data value from a string value.
 void setValue(java.net.URL value)
          Sets the URL value.
 DataValue sub(DataValue value)
          Substracts a data value.
 java.lang.String toString()
          Gets the string representation of current URL value.
 DataValue unit(DataValue targetValue, double maxSteps)
          Gets the largest suitable unit step to represent a value change between this value and the given target value.
 
Methods inherited from class com.davisor.data.GenericValue
max, min, toStatement, toXML
 
Methods inherited from class com.davisor.data.VoidValue
abs, ceil, div, floor, mul, negate
 
Methods inherited from class com.davisor.data.VoidData
getDataValue, getType, setType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.davisor.data.Data
getType
 

Constructor Detail

URLData

public URLData()
Default constructor. Creates a new URL data object with the default URLType.DEFAULT type.

See Also:
URLType

URLData

public URLData(URLData data,
               boolean deep)
Deep or shallow copy constructor. If is is shallow, then the new object shares an underlying type with the original object. If it is deep, then the type is dupped.

Parameters:
data - source data (may be null)
deep - determines if the copying is deep or shallow
See Also:
VoidData.getType(), Type.dup()

URLData

public URLData(URLType type,
               java.net.URL value)
Creates a new URL data object with the given URL type and value.

Parameters:
type - url type
value - url value (may be null)

URLData

public URLData(URLType type,
               java.lang.String stringValue,
               java.text.ParsePosition status)
        throws InvalidDataException
Creates a URL data value from a string value.

Parameters:
stringValue - string value to be parsed
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
setValue(String,ParsePosition)
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Compares this data with other data objects.

Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class GenericValue
See Also:
GenericValue.max(com.davisor.data.DataValue), GenericValue.min(com.davisor.data.DataValue), Compare.compareTo(Object,Object)

isNull

public boolean isNull()
Tests if this data object value is undetermined.

Specified by:
isNull in interface SerializableData
Overrides:
isNull in class VoidValue
Returns:
always true

add

public DataValue add(DataValue value)
              throws InvalidDataException
Adds data values.

Specified by:
add in interface DataValue
Overrides:
add in class VoidValue
Parameters:
value - a data value to be added to this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if the data values cannot be added.

deinterpolate

public double deinterpolate(DataValue min,
                            DataValue max)
                     throws InvalidDataException
De-interpolates the current data value to a scalar value, in respect, with the given data value range. This gives scalar values between [0,1], when the current data value is within the range, negative scalar values when the data value falls below the range and scalar values greater than 1.0 otherwise.

URL values do not support this operation, but they always throw an InvalidDataException instead.

Specified by:
deinterpolate in interface DataValue
Overrides:
deinterpolate in class VoidValue
Parameters:
min - a data value representing a range's lower limit
max - a data value representing a range's higher limit
Returns:
de-interpolated scalar value
Throws:
InvalidDataException - if the de-interpolation fails

getFormat

public java.lang.String getFormat()
Gets the type specification optimal for this particular value. The specification returned may differ from the current type specification. If so, setting the current type specification equal to the value returned by this method will ensure optimal value formatting and parsing for values of the same magnitude as this value.

The URL data optimal specification string is always null.

Specified by:
getFormat in interface DataValue
Overrides:
getFormat in class VoidValue
See Also:
Data.getType(), FormatType.getFormat(), FormatType.setFormat(java.util.Locale, java.lang.String)

interpolate

public DataValue interpolate(double value,
                             DataValue max)
                      throws InvalidDataException
Interpolates the given scalar value to data value, in respect, with the range defined by this value and the given maximum value. Scalar values between [0,1] result in data values between the current value and the given maximum value. Negative scalar values result in values smaller than this value and scalar values higher than 1.0 return data values above the given maximum.

URL values do not support this operation, but they always throw an InvalidDataException instead.

Specified by:
interpolate in interface DataValue
Overrides:
interpolate in class VoidValue
Parameters:
value - the scalar value to be interpolated
max - a data value representing a range's higher limit
Returns:
a new data object containing the result
Throws:
InvalidDataException - if interpolation fails

setValue

public void setValue(java.lang.String stringValue,
                     java.text.ParsePosition status)
              throws InvalidDataException
Sets data value from a string value.

Specified by:
setValue in interface DataValue
Overrides:
setValue in class VoidValue
Parameters:
stringValue - string value to be parsed (may be null)
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
URLType.urlValue(String,ParsePosition)

sub

public DataValue sub(DataValue value)
              throws InvalidDataException
Substracts a data value.

Specified by:
sub in interface DataValue
Overrides:
sub in class VoidValue
Parameters:
value - a data value to be substracted from this data value
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if the value cannot be substracted.

toString

public java.lang.String toString()
Gets the string representation of current URL value.

Specified by:
toString in interface DataValue
Overrides:
toString in class VoidData

unit

public DataValue unit(DataValue targetValue,
                      double maxSteps)
               throws InvalidDataException
Gets the largest suitable unit step to represent a value change between this value and the given target value. If the values are equal, then a type specific default unit step is returned. If the values are not equal, the given target value must be reached from this value by adding the returned unit step to this value once or more.

URL data does not support the concept of unit values. Calling this method raises a runtime error.

Specified by:
unit in interface DataValue
Overrides:
unit in class VoidValue
Parameters:
targetValue - target value to be reached (may be null)
maxSteps - maximum number of steps (zero leaves the choise open)
Returns:
a new data object, sharing the current type of this object
Throws:
InvalidDataException - if target value is unsuitable

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 VoidValue

equals

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

URL data objects are equal if their super-classes and URL values are.

Overrides:
equals in class VoidData
See Also:
Compare.equals(Object,Object)

hashCode

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

Overrides:
hashCode in class VoidData

getValue

public java.net.URL getValue()
Gets the URL value.

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

setValue

public void setValue(java.net.URL value)
Sets the URL value.

Parameters:
value - url value (may be null)
See Also:
getValue()


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