Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1)

E10653-04

oracle.jbo.domain
Class TypeFactory

java.lang.Object
  extended by oracle.jbo.domain.TypeFactory

public class TypeFactory
extends java.lang.Object

Internal: Applications should not extend this class or invoke its methods.

A utility for creating immutable Domain objects.

Create a Domain object by passing a fully qualified classname and a compatable data value to a getInstance method. The classname may be a expressed as a Class or as a String.

. The data value may be an Object or a value of any of the primitive data types.

Note that for non-String data types that do not have String constructors or that throw exceptions for empty strings ("") from their constructor or valueOf() methods, this factory assumes the value to be NULL value. So for example if an attribute is of type Number and setAttribute() is called for that attribute with a "" (empty string), the value for the attribute will be set to NULL. This helps all thin-clients to share the same logic of setting NULL values and provide similar behaviour without special-casing for "" strings. This behavior can be overruled by creating a domain for the desired data-type that has a string constructor or a valueOf(String) method that could accept "" (empty string) and convert that to some default value;

Since:
JDevloper 3.0

Constructor Summary
TypeFactory()
           
 
Method Summary
static void addCustomConverter(java.lang.Class domainClass, java.lang.Class paramClass, TypeConvMapEntry mth)
           
static void addStaticConverter(java.lang.Class domainClass, java.lang.Class paramClass, int opId)
           
static void addStaticConverterByName(java.lang.String toClassName, java.lang.String fromClassName, int opId)
           
static void addStaticConverterByName(java.lang.String toClassName, java.lang.String fromClassName, int opId, java.lang.String fromPattern)
           
static boolean checkEquals(java.lang.Object srcValue, java.lang.Object targetValue)
           
static java.lang.Object convertAttributeValue(AttributeDef adef, java.lang.Object value, int defType, java.lang.String defFullName)
          Deprecated. since 10.1.3 use convertAttributeValueToType();
static java.lang.Object convertAttributeValueToType(AttributeDef adef, java.lang.Class type, java.lang.Object value, int defType, java.lang.String defFullName)
           
static java.lang.Object getInstance(java.lang.Class clazz, boolean val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, byte val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, char val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class domainClass, java.lang.Class param, java.lang.Object val)
          Incase, a constructor in the class of type domainClass does not take one argument of type same as val, use the class given by param to find the constructor, assuming that val is convertible to an object of param class.
static java.lang.Object getInstance(java.lang.Class clazz, double val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, float val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, int val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, long val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, java.lang.Object val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.Class clazz, java.lang.Object val, boolean anotherInstance)
          Creates an object of type clazz from the value val.
static java.lang.Object getInstance(java.lang.Class clazz, short val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, boolean val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, byte val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, char val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, double val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, float val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, int val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, long val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String clazz, java.lang.Object val)
          Creates an object of type clazz having the value
static java.lang.Object getInstance(java.lang.String clazz, short val)
          Creates an object of type clazz having the value val.
static java.lang.Object getInstance(java.lang.String domainClass, java.lang.String param, java.lang.Object val)
          Incase, a constructor in the class of type domainClass does not take one argument of type same as val, use the class given by param to find the constructor, assuming that val is convertible to an object of param class.
static TypeSQLNative getTypeSQLNative(java.lang.Class theJavaType, int sqlType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeFactory

public TypeFactory()
Method Detail

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           java.lang.Object val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - An object.
Returns:
An object consisting of val converted to clazz. If val is null or already of type clazz then val itself is returned.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           java.lang.Object val,
                                           boolean anotherInstance)
Creates an object of type clazz from the value val. If the value is an instance of the class, try to create a copy of the val and return the copy.

Parameters:
clazz - A fully qualified classname.
val - An object.
anotherInstance - If the value matches the required type, create a copy if this parameter is true.
Returns:
An object consisting of val converted to clazz. If val is null or already of type clazz then val itself is returned.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String domainClass,
                                           java.lang.String param,
                                           java.lang.Object val)
Incase, a constructor in the class of type domainClass does not take one argument of type same as val, use the class given by param to find the constructor, assuming that val is convertible to an object of param class.

Parameters:
domainClass - full qualified classname of the target object
param - full qualified classname of the parameter
val - value to convert into the domainClass type.

getInstance

public static java.lang.Object getInstance(java.lang.Class domainClass,
                                           java.lang.Class param,
                                           java.lang.Object val)
Incase, a constructor in the class of type domainClass does not take one argument of type same as val, use the class given by param to find the constructor, assuming that val is convertible to an object of param class.

Parameters:
domainClass - Preferred Class type of the target object
param - Class type of the parameter
val - value to convert into the domainClass type.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           int val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 32-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           short val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 32-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           long val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 64-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           float val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 32-bit floating-point value.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           double val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 64-bit floating-point value.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           byte val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - An 8-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           boolean val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - true or false.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.Class clazz,
                                           char val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A unicode character.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           java.lang.Object val)
Creates an object of type clazz having the value

Parameters:
clazz - A fully qualified classname. val.
val - An object.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           int val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 32-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           short val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 16-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           long val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 64-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           float val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 32-bit floating-point value.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           double val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A 64-bit floating-point value.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           byte val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - An 8-bit signed integer.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           boolean val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - true or false.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getInstance

public static java.lang.Object getInstance(java.lang.String clazz,
                                           char val)
Creates an object of type clazz having the value val.

Parameters:
clazz - A fully qualified classname.
val - A unicode character.
Returns:
An object consisting of val converted to clazz.
Throws:
DataCreationException - if val is incompatable with clazz.

getTypeSQLNative

public static TypeSQLNative getTypeSQLNative(java.lang.Class theJavaType,
                                             int sqlType)

checkEquals

public static boolean checkEquals(java.lang.Object srcValue,
                                  java.lang.Object targetValue)

addStaticConverter

public static void addStaticConverter(java.lang.Class domainClass,
                                      java.lang.Class paramClass,
                                      int opId)

addStaticConverterByName

public static void addStaticConverterByName(java.lang.String toClassName,
                                            java.lang.String fromClassName,
                                            int opId)

addStaticConverterByName

public static void addStaticConverterByName(java.lang.String toClassName,
                                            java.lang.String fromClassName,
                                            int opId,
                                            java.lang.String fromPattern)

addCustomConverter

public static void addCustomConverter(java.lang.Class domainClass,
                                      java.lang.Class paramClass,
                                      TypeConvMapEntry mth)

convertAttributeValueToType

public static java.lang.Object convertAttributeValueToType(AttributeDef adef,
                                                           java.lang.Class type,
                                                           java.lang.Object value,
                                                           int defType,
                                                           java.lang.String defFullName)

convertAttributeValue

public static java.lang.Object convertAttributeValue(AttributeDef adef,
                                                     java.lang.Object value,
                                                     int defType,
                                                     java.lang.String defFullName)
Deprecated. since 10.1.3 use convertAttributeValueToType();


Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 1 (11.1.1)

E10653-04

Copyright © 1997, 2010, Oracle. All rights reserved.