uk.ac.starlink.plastic
Class ValueType

java.lang.Object
  extended byuk.ac.starlink.plastic.ValueType

public class ValueType
extends Object

Defines the type of a value which is passed through the PLASTIC messaging system. These types define what is legal for the arguments and return values of each particular message. The types defined are ones which can be transmitted and have the same meaning using both the Java RMI and the XML-RPC transport modes.

Since:
19 Jul 2006
Author:
Mark Taylor
See Also:
MessageDefinition

Field Summary
static ValueType ANY
          No constraints - any object is permissible.
static ValueType BOOLEAN
          Boolean type.
static ValueType DATE
          ISO-8601 date type.
static ValueType DOUBLE
          Double precision type.
static ValueType INT
          Integer type.
static ValueType LIST
          List/<array> type.
static ValueType LIST_INTS
          List/ type in which all elements must be integers.
static ValueType MAP
          Map/<struct> type.
static ValueType STRING
          String type.
static ValueType STRING_IVORN
          Type for a string which is required to be a legal IVORN.
static ValueType STRING_URI
          Type for a string which is required to be a legal URI.
static ValueType STRING_URL
          Type for a string which is required to be a legal URL.
static ValueType VOID
          Void type - the return type for methods with no return value.
 
Constructor Summary
ValueType(String name, Class jClazz, Object blank)
          Constructs a basic value type with a given symbolic name and a java class which all legal values of this type must instantiate.
 
Method Summary
 void checkJavaValue(Object jValue)
          Checks a value sent or received using Java-RMI.
 Object getBlankValue()
          Returns a neutral sort of value which is legal for this type.
static ValueType inferValueType(Object value)
          Guesses from a single value what type it might correspond to.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static ValueType ANY
No constraints - any object is permissible.


INT

public static ValueType INT
Integer type.


BOOLEAN

public static ValueType BOOLEAN
Boolean type.


STRING

public static ValueType STRING
String type.


DOUBLE

public static ValueType DOUBLE
Double precision type.


DATE

public static ValueType DATE
ISO-8601 date type.


MAP

public static ValueType MAP
Map/<struct> type.


LIST

public static ValueType LIST
List/<array> type.


VOID

public static ValueType VOID
Void type - the return type for methods with no return value.


STRING_URL

public static ValueType STRING_URL
Type for a string which is required to be a legal URL.


STRING_IVORN

public static ValueType STRING_IVORN
Type for a string which is required to be a legal IVORN.


STRING_URI

public static ValueType STRING_URI
Type for a string which is required to be a legal URI.


LIST_INTS

public static ValueType LIST_INTS
List/ type in which all elements must be integers.

Constructor Detail

ValueType

public ValueType(String name,
                 Class jClazz,
                 Object blank)
Constructs a basic value type with a given symbolic name and a java class which all legal values of this type must instantiate.

Parameters:
name - label for this type (for documentation purposes only)
jClazz - required assignable java class
blank - suitable blank value (see getBlankValue())
Method Detail

checkJavaValue

public void checkJavaValue(Object jValue)
                    throws ValueTypeException
Checks a value sent or received using Java-RMI. If the value has a type which is inconsistent with the constraints defined by this object, a ValueTypeException will be thrown.

Parameters:
jValue - value to check
Throws:
ValueTypeException

getBlankValue

public Object getBlankValue()
Returns a neutral sort of value which is legal for this type. This is not guaranteed to be suitable for any given use, but if you have to come up with a value for this type and don't have any other information, it's as good a guess as any.

Returns:
blank value compatible with this type

toString

public String toString()

inferValueType

public static ValueType inferValueType(Object value)
                                throws ValueTypeException
Guesses from a single value what type it might correspond to. Necessarily unreliable.

Parameters:
value - example value
Returns:
ValueType that value might be an instance of
Throws:
ValueTypeException


Copyright © 2006 \\ CLRC: Central Laboratory of the Research Councils. All Rights Reserved.