ariba.util.fieldtype
Class PrimitiveTypeProvider

java.lang.Object
  extended by ariba.util.fieldtype.TypeProvider
      extended by ariba.util.fieldtype.PrimitiveTypeProvider
All Implemented Interfaces:
TypeRetriever

public class PrimitiveTypeProvider
extends TypeProvider


Method Summary
static ariba.util.fieldtype.PrimitiveTypeProvider.PrimitiveTypeInfo getBoxedTypeInfo(TypeInfo info)
           
static java.lang.Class getClassForType(java.lang.String name)
           
static TypeInfo getCoercedType(TypeInfo first, TypeInfo second)
          Given two numeric types first and second, this method returns a widened type that can contain both first and second.
 TypeInfo getTypeInfo(java.lang.String name)
          Retrieve the TypeInfo given the type name.
static TypeProvider instance()
           
static boolean isBoxedType(TypeInfo info)
           
static boolean isFloatingPointNumericType(TypeInfo info)
           
static boolean isNumericType(java.lang.String name)
           
static boolean isNumericType(TypeInfo info)
           
static boolean isSimplePrimitiveType(TypeInfo info)
           
static boolean isSupportedType(java.lang.String name)
           
static boolean isUnboxedPrimitiveType(TypeInfo info)
           
static boolean isWideningTypeOf(java.lang.String target, java.lang.String source)
          Check to see if source can be converted to type target, following the Java widening primitive conversion.
static boolean isWideningTypeOf(TypeInfo target, TypeInfo source)
          Check to see if source can be converted to type target, following the Java widening primitive conversion.
 
Methods inherited from class ariba.util.fieldtype.TypeProvider
equals, getProviderId
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static TypeProvider instance()

getTypeInfo

public TypeInfo getTypeInfo(java.lang.String name)
Description copied from interface: TypeRetriever
Retrieve the TypeInfo given the type name.

Parameters:
name - - fully qualified type name
Returns:
TypeInfo for the specified type name. If type is not found, return null;

isSupportedType

public static boolean isSupportedType(java.lang.String name)

isNumericType

public static boolean isNumericType(java.lang.String name)

getClassForType

public static java.lang.Class getClassForType(java.lang.String name)

isNumericType

public static boolean isNumericType(TypeInfo info)

isFloatingPointNumericType

public static boolean isFloatingPointNumericType(TypeInfo info)

isSimplePrimitiveType

public static boolean isSimplePrimitiveType(TypeInfo info)

isUnboxedPrimitiveType

public static boolean isUnboxedPrimitiveType(TypeInfo info)

getBoxedTypeInfo

public static ariba.util.fieldtype.PrimitiveTypeProvider.PrimitiveTypeInfo getBoxedTypeInfo(TypeInfo info)

isBoxedType

public static boolean isBoxedType(TypeInfo info)

getCoercedType

public static TypeInfo getCoercedType(TypeInfo first,
                                      TypeInfo second)
Given two numeric types first and second, this method returns a widened type that can contain both first and second. The input TypeInfo can be:
  1. A numeric primitive type
  2. A numeric boxed type
  3. BigDecimal or BigInteger
If the TypeInfo is not numeric, this method will return null.
The coercion rule is as follows:
  1. If both TypeInfo are whole numbers, return the larger of the two types.
  2. If both TypeInfo are real numbers, return the larger of the two types.
  3. If one of the TypeInfo is real number, then return this real number type unless (a) the other whole number type is BigInteger (return BigDecimal), (b) the other whole number type is Integer or Long (return the larger of Double and the real number type.

Parameters:
first - - A numeric type
second - - A numeric type
Returns:
A TypeInfo that is wide enough to contain both numeric types. If one of the types is not numeric, return null. If one of the types is a boxed type, then the returned result is also a boxed type.

isWideningTypeOf

public static boolean isWideningTypeOf(TypeInfo target,
                                       TypeInfo source)
Check to see if source can be converted to type target, following the Java widening primitive conversion. If target or source is a primitive type, it will first be converted to the equivalent primitive type (boxing) before the widening conversion applies. This method will also handle type widening if source or target is BigInteger and BigDecimal. This method does not support subtypes of boxed types, BigInteger and BigDecimal.
All primitive types can be converted to the Boolean. During runtime, non-zero number is covnerted to Boolean.True, and zero is converted to Boolean.False.
If either target or source is not a primitive type, this method returns false.

Parameters:
target - - a primitive type or boxed type to be converted to.
source - - a primitive type or boxed type
Returns:
true if source can be converted to target. Otherwise, return false.

isWideningTypeOf

public static boolean isWideningTypeOf(java.lang.String target,
                                       java.lang.String source)
Check to see if source can be converted to type target, following the Java widening primitive conversion.

Parameters:
target - - a primitive type or boxed type to be converted to.
source - - a primitive type or boxed type
Returns:
true if source can be converted to target. Otherwise, return false.


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.