Fields Summary |
---|
public static final Object | errorTypeRepresents the internal error type. |
public static final Object | booleanTypeRepresents the primitive type boolean. |
public static final Object | byteTypeRepresents the primitive type byte. |
public static final Object | shortTypeRepresents the primitive type short. |
public static final Object | charTypeRepresents the primitive type char. |
public static final Object | intTypeRepresents the primitive type int. |
public static final Object | longTypeRepresents the primitive type long. |
public static final Object | floatTypeRepresents the primitive type float. |
public static final Object | doubleTypeRepresents the primitive type double. |
public static final Object | booleanClassTypeRepresents the wrapper class type boolean. |
public static final Object | byteClassTypeRepresents the wrapper class type byte. |
public static final Object | shortClassTypeRepresents the wrapper class type short. |
public static final Object | characterClassTypeRepresents the wrapper class type char. |
public static final Object | integerClassTypeRepresents the wrapper class type int. |
public static final Object | longClassTypeRepresents the wrapper class type long. |
public static final Object | floatClassTypeRepresents the wrapper class type float. |
public static final Object | doubleClassTypeRepresents the wrapper class type double. |
public static final Object | stringTypeRepresents the type java.lang.String. |
public static final Object | bigDecimalTypeRepresents the type java.math.BigDecimal. |
public static final Object | bigIntegerTypeRepresents the type java.math.BigInteger. |
protected static final Set | numericTypesSet of names of numeric types. |
protected static final Set | numericWrapperTypesSet of names of numeric wrapper classes. |
protected static final Set | dateTimeTypesSet of names of date and time types. |
protected com.sun.jdo.api.persistence.model.Model | modelMeta data access. |
protected com.sun.jdo.spi.persistence.support.ejb.model.util.NameMapper | nameMapperName mapping EJB <-> JDO. |
protected static final ResourceBundle | msgsI18N support. |
Methods Summary |
---|
public static java.lang.Object | binaryNumericPromotion(java.lang.Object left, java.lang.Object right)Implements binary numeric promotion as defined in the
Java Language Specification section 5.6.2
if (isNumericType(left) && isNumericType(right)) {
if (left.equals(doubleType) || right.equals(doubleType))
return doubleType;
else if (left.equals(floatType) || right.equals(floatType))
return floatType;
else if (left.equals(longType) || right.equals(longType))
return longType;
else
return intType;
}
return errorType;
|
public java.lang.String | getAbstractSchemaForTypeInfo(java.lang.Object typeInfo)Returns the typeInfo (the ejb name) for the specified abstract schema.
String typeName = getTypeName(typeInfo);
return nameMapper.isEjbName(typeName) ?
nameMapper.getAbstractSchemaForEjbName(typeName) :
typeName;
|
public java.lang.Object | getAvgReturnType(java.lang.Object type)Return JDO QL return type for Avg function for a given type.
if (isNumericType(type) || isNumericWrapperType(type)) {
return doubleClassType;
} else {
return type;
}
|
public java.lang.Object | getElementType(java.lang.Object fieldInfo)Returns the type info of the element type if the specified field info
denotes a collection relationship. Otherwise it returns null .
if ((fieldInfo != null) && (fieldInfo instanceof RelationshipElement)) {
String elementClass = ((RelationshipElement)fieldInfo).getElementClass();
return nameMapper.getEjbNameForPersistenceClass(elementClass);
}
else
return null;
|
public java.lang.Object | getFieldInfo(java.lang.Object typeInfo, java.lang.String fieldName)Returns the field info for the specified field of the specified type.
The field info is opaque for the caller. Methods {@link #isRelationship}
and {@link #getElementType} allow to get details for a given field info.
Object fieldInfo = null;
String typeName = getTypeName(typeInfo);
if (!nameMapper.isEjbName(typeName)) {
ErrorMsg.fatal(I18NHelper.getMessage(
msgs, "ERR__EjbNameExpected", //NOI18N
"TypeSupport.getFieldInfo", typeName)); //NOI18N
}
String pcClassName = nameMapper.getPersistenceClassForEjbName(typeName);
String pcFieldName = nameMapper.getPersistenceFieldForEjbField(
typeName, fieldName);
PersistenceClassElement pce = model.getPersistenceClass(pcClassName);
if (pce != null) {
fieldInfo = pce.getField(pcFieldName);
}
return fieldInfo;
|
public java.lang.Object | getFieldType(java.lang.Object typeInfo, java.lang.String fieldName)Returns the type info for the type of the given field.
String typeName = getTypeName(typeInfo);
if (!nameMapper.isEjbName(typeName)) {
ErrorMsg.fatal(I18NHelper.getMessage(
msgs, "ERR_EjbNameExpected", //NOI18N
"TypeSupport.getFieldType", typeName)); //NOI18N
}
String fieldType = model.getFieldType(typeName, fieldName);
// check for local or remote interface, map to ejb name
if (nameMapper.isLocalInterface(fieldType)) {
fieldType = nameMapper.getEjbNameForLocalInterface(
typeName, fieldName, fieldType);
}
else if (nameMapper.isRemoteInterface(fieldType)) {
fieldType = nameMapper.getEjbNameForRemoteInterface(
typeName, fieldName, fieldType);
}
return getTypeInfo(fieldType);
|
public java.lang.Object | getMinMaxReturnType(java.lang.Object type)Return JDO QL return type for Min/Max function for a given type.
if (isFloatingPointType(type)) {
return doubleClassType;
} else if (isCharType(type)) {
return characterClassType;
} else if (isNumericType(type) || isNumericWrapperType(type)) {
return longClassType;
} else {
return type;
}
|
public java.lang.String | getPCForTypeInfo(java.lang.Object typeInfo)Gets the name of the persistence-capable class which corresponds to
the specified typeInfo (assuming an ejb name). The method returs the
type name of the specified typeInfo, it the typeInfo does not denote
an ejb-name (e.g. a local or remote interface).
String typeName = getTypeName(typeInfo);
String pcClassName =
nameMapper.getPersistenceClassForEjbName(typeName);
return (pcClassName != null) ? pcClassName : typeName;
|
public static java.lang.Object | getPrimitiveType(java.lang.Object type)Returns the type info for a primitive type. The method returns
{@link #errorType} if the specified type is not a primitive type.
Object result = errorType;
if (type.equals(booleanClassType))
result = booleanType;
else if (type.equals(integerClassType))
result = intType;
else if (type.equals(longClassType))
result = longType;
else if (type.equals(floatClassType))
result = floatType;
else if (type.equals(doubleClassType))
result = doubleType;
else if (type.equals(byteClassType))
result = byteType;
else if (type.equals(shortClassType))
result = shortType;
else if (type.equals(characterClassType))
result = charType;
return result;
|
public java.lang.Object | getSumReturnType(java.lang.Object type)Return JDO QL return type for Sum function for a given type.
if (isFloatingPointType(type)) {
return doubleClassType;
} else if (isNumericType(type) || isNumericWrapperType(type)) {
return longClassType;
} else {
return type;
}
|
public java.lang.Object | getTypeInfo(java.lang.String name)The method returns a type info by type name.
If the type name denotes a class the name should be fully qualified.
The method uses the type name as type info.
return name;
|
public java.lang.Object | getTypeInfo(java.lang.Class clazz)The method returns a type info by type name by class object.
return getTypeInfo(clazz.getName());
|
public java.lang.Object | getTypeInfoForAbstractSchema(java.lang.String abstractSchema)Returns the typeInfo (the ejb name) for the specified abstract schema.
return nameMapper.getEjbNameForAbstractSchema(abstractSchema);
|
public static java.lang.String | getTypeName(java.lang.Object type)Returns the type name for a specified type info.
return (String)type;
|
public static java.lang.Object | getWrapperType(java.lang.Object type)Returns the type info for a wrapper class type. The method returns
{@link #errorType} if the specified type is not a wrapper class type.
Object result = errorType;
if (type.equals(booleanType))
result = booleanClassType;
else if (type.equals(intType))
result = integerClassType;
else if (type.equals(longType))
result = longClassType;
else if (type.equals(floatType))
result = floatClassType;
else if (type.equals(doubleType))
result = doubleClassType;
else if (type.equals(byteType))
result = byteClassType;
else if (type.equals(shortType))
result = shortClassType;
else if (type.equals(charType))
result = characterClassType;
return result;
|
public boolean | hasLocalInterface(java.lang.Object typeInfo)Returns true if the bean with the specified ejb name
has a local interface.
return nameMapper.getLocalInterfaceForEjbName(
getTypeName(typeInfo)) != null;
|
public boolean | hasRemoteInterface(java.lang.Object typeInfo)Returns true if the bean with the specified ejb name
has a remote interface.
return nameMapper.getRemoteInterfaceForEjbName(
getTypeName(typeInfo)) != null;
|
public static boolean | isBooleanType(java.lang.Object type)Returns true if type is boolean or java.lang.Boolean
return type.equals(booleanType) ||
type.equals(booleanClassType);
|
public static boolean | isCharType(java.lang.Object type)Returns true if type is char or java.lang.Character
return type.equals(charType) ||
type.equals(characterClassType);
|
public boolean | isCollectionType(java.lang.Object type)Returns true if type is a collection type.
return model.isCollection((String)type);
|
public boolean | isCompatibleWith(java.lang.Object left, java.lang.Object right)Implements type compatibility. The method returns true
if left is compatible with right. This is equivalent to
rightClass.isAssignableFrom(leftClass).
Note, the method does not support inheritance.
String leftTypeName = getTypeName(left);
String rightTypeName = getTypeName(right);
if (nameMapper.isLocalInterface(leftTypeName) &&
nameMapper.isEjbName(rightTypeName))
rightTypeName = nameMapper.getLocalInterfaceForEjbName(rightTypeName);
else if (nameMapper.isRemoteInterface(leftTypeName) &&
nameMapper.isEjbName(rightTypeName))
rightTypeName = nameMapper.getRemoteInterfaceForEjbName(rightTypeName);
else if (nameMapper.isLocalInterface(rightTypeName) &&
nameMapper.isEjbName(leftTypeName))
leftTypeName = nameMapper.getLocalInterfaceForEjbName(leftTypeName);
else if (nameMapper.isRemoteInterface(rightTypeName) &&
nameMapper.isEjbName(leftTypeName))
leftTypeName = nameMapper.getRemoteInterfaceForEjbName(leftTypeName);
// does not handle inheritance!
return leftTypeName.equals(rightTypeName);
|
public boolean | isDateTimeType(java.lang.Object type)Returns true if type is a date or time type
return dateTimeTypes.contains(getTypeName(type));
|
public static boolean | isDoubleType(java.lang.Object type)Returns true if type is double or java.lang.Double.
return type.equals(doubleType) ||
type.equals(doubleClassType);
|
public boolean | isEjbName(java.lang.Object typeInfo)Returns true if the specified type info denotes an ejb name.
return nameMapper.isEjbName(getTypeName(typeInfo));
|
public boolean | isEjbOrInterfaceName(java.lang.Object typeInfo)Returns true if the specified type info denotes an ejb name
or the name of a local interface or the name of a remote interface.
String typeName = getTypeName(typeInfo);
return nameMapper.isEjbName(typeName) ||
nameMapper.isLocalInterface(typeName) ||
nameMapper.isRemoteInterface(typeName);
|
public static boolean | isErrorType(java.lang.Object type)Returns true if type denotes the error type.
return type.equals(errorType);
|
public static boolean | isFloatingPointType(java.lang.Object type)Returns true if type is a floating point type or
wrapper class of a floating point type.
return doubleType.equals(type) ||
doubleClassType.equals(type) ||
floatType.equals(type) ||
floatClassType.equals(type);
|
public static boolean | isIntType(java.lang.Object type)Returns true if type is int or java.lang.Integer
return type.equals(intType) ||
type.equals(integerClassType);
|
public boolean | isLocalInterface(java.lang.Object typeInfo)Returns true if the specified type info denotes
a local interface.
return nameMapper.isLocalInterface(getTypeName(typeInfo));
|
public boolean | isLocalInterfaceOfEjb(java.lang.Object typeInfo, java.lang.String ejbName)Returns true if the specified type info denotes the
local interface of the bean with the specified ejb name.
String typeName = getTypeName(typeInfo);
String localInterface = nameMapper.getLocalInterfaceForEjbName(ejbName);
return (localInterface != null) && localInterface.equals(typeName);
|
public static boolean | isNumberType(java.lang.Object type)Returns true if type is a NumerType, which means it is either
a numeric primitive or a numeric wrapper class.
return isNumericType(type) ||
isNumericWrapperType(type) ||
bigDecimalType.equals(type) ||
bigIntegerType.equals(type);
|
public static boolean | isNumericType(java.lang.Object type)Returns true if type is a primitive numeric type such as
byte, int etc.
return numericTypes.contains(type);
|
public static boolean | isNumericWrapperType(java.lang.Object type)Returns true if type is a wrapper class of a primitive
numeric type such as java.lang.Byte, java.lang.Integer etc.
return numericWrapperTypes.contains(type);
|
public boolean | isOrderableType(java.lang.Object type)Returns true if type is an orderable type
return isNumberType(type) || isDateTimeType(type) || isStringType(type);
|
public boolean | isRelationship(java.lang.Object fieldInfo)Returns true if the specified field info denotes a
relationship field.
return (fieldInfo != null) && (fieldInfo instanceof RelationshipElement);
|
public boolean | isRemoteInterface(java.lang.Object typeInfo)Returns true if the specified type info denotes
a remote interface.
return nameMapper.isRemoteInterface(getTypeName(typeInfo));
|
public boolean | isRemoteInterfaceOfEjb(java.lang.Object typeInfo, java.lang.String ejbName)Returns true if the specified type info denotes the
remote interface of the bean with the specified ejb name.
String typeName = getTypeName(typeInfo);
String remoteInterface = nameMapper.getRemoteInterfaceForEjbName(ejbName);
return (remoteInterface != null) && remoteInterface.equals(typeName);
|
public static boolean | isStringType(java.lang.Object type)Returns true if type denotes java.lang.String.
return type.equals(stringType);
|
public static java.lang.Object | unaryNumericPromotion(java.lang.Object type)Implements unray numeric promotion as defined in the
Java Language Specification section 5.6.1
if (isNumericType(type)) {
if (type.equals(byteType) || type.equals(shortType) ||
type.equals(charType)) {
return intType;
}
else {
return type;
}
}
return errorType;
|