public boolean isLob() { Class clazz = mPropertyType.toClass(); return clazz != null && Lob.class.isAssignableFrom(clazz); }
public boolean isLob() { Class clazz = mPropertyType.toClass(); return clazz != null && Lob.class.isAssignableFrom(clazz); }
/** * Returns true if the type of the given property type is supported. The * types currently supported are primitives, primitive wrapper objects, * Strings, byte arrays and Lobs. */ public boolean isSupported(TypeDesc propertyType) { if (propertyType.toPrimitiveType() != null) { return true; } if (propertyType == TypeDesc.STRING || propertyType == TypeDesc.forClass(byte[].class)) { return true; } Class clazz = propertyType.toClass(); if (clazz != null) { return Lob.class.isAssignableFrom(clazz) || BigInteger.class.isAssignableFrom(clazz) || BigDecimal.class.isAssignableFrom(clazz); } return false; }
/** * Returns true if the type of the given property type is supported. The * types currently supported are primitives, primitive wrapper objects, * Strings, byte arrays and Lobs. */ public boolean isSupported(TypeDesc propertyType) { if (propertyType.toPrimitiveType() != null) { return true; } if (propertyType == TypeDesc.STRING || propertyType == TypeDesc.forClass(byte[].class)) { return true; } Class clazz = propertyType.toClass(); if (clazz != null) { return Lob.class.isAssignableFrom(clazz) || BigInteger.class.isAssignableFrom(clazz) || BigDecimal.class.isAssignableFrom(clazz); } return false; }
/** * Generates code to get a Lob from a locator from RawSupport. RawSupport * instance, Storable instance, property name and long locator must be on * the stack. Result is a Lob on the stack, which may be null. */ private void getLobFromLocator(CodeAssembler a, StorablePropertyInfo info) { if (!info.isLob()) { throw new IllegalArgumentException(); } TypeDesc type = info.getStorageType(); String name; if (Blob.class.isAssignableFrom(type.toClass())) { name = "getBlob"; } else if (Clob.class.isAssignableFrom(type.toClass())) { name = "getClob"; } else { throw new IllegalArgumentException(); } a.invokeInterface(TypeDesc.forClass(RawSupport.class), name, type, new TypeDesc[] {TypeDesc.forClass(Storable.class), TypeDesc.STRING, TypeDesc.LONG}); }
/** * Generates code to get a Lob from a locator from RawSupport. RawSupport * instance, Storable instance, property name and long locator must be on * the stack. Result is a Lob on the stack, which may be null. */ private void getLobFromLocator(CodeAssembler a, StorablePropertyInfo info) { if (!info.isLob()) { throw new IllegalArgumentException(); } TypeDesc type = info.getStorageType(); String name; if (Blob.class.isAssignableFrom(type.toClass())) { name = "getBlob"; } else if (Clob.class.isAssignableFrom(type.toClass())) { name = "getClob"; } else { throw new IllegalArgumentException(); } a.invokeInterface(TypeDesc.forClass(RawSupport.class), name, type, new TypeDesc[] {TypeDesc.forClass(Storable.class), TypeDesc.STRING, TypeDesc.LONG}); }
if (fromPrimitiveType == null) { if (!toType.isPrimitive()) { Class fromClass = fromType.toClass(); if (fromClass != null) { Class toClass = toType.toClass(); if (toClass != null && toClass.isAssignableFrom(fromClass)) { return; if (toType.toClass() == Number.class) { switch (fromTypeCode) { case TypeDesc.INT_CODE:
/** * Returns the type of the ChainedProperty property, boxed into an object * if primitive. */ public Class<?> getBoxedType() { if (mBoxedType == null) { mBoxedType = TypeDesc.forClass(getType()).toObjectType().toClass(); } return mBoxedType; }
/** * Returns the type of the ChainedProperty property, boxed into an object * if primitive. */ public Class<?> getBoxedType() { if (mBoxedType == null) { mBoxedType = TypeDesc.forClass(getType()).toObjectType().toClass(); } return mBoxedType; }
public void addInvokeReadMethod(CodeAssembler a, TypeDesc instanceType) { Class clazz = instanceType.toClass(); if (clazz == null) { // Can't know if instance should be invoked as an interface or as a // virtual method. throw new IllegalArgumentException("Instance type has no known class"); } if (clazz.isInterface()) { a.invokeInterface(instanceType, getReadMethodName(), getPropertyType(), null); } else { a.invokeVirtual(instanceType, getReadMethodName(), getPropertyType(), null); } }
public void addInvokeReadMethod(CodeAssembler a, TypeDesc instanceType) { Class clazz = instanceType.toClass(); if (clazz == null) { // Can't know if instance should be invoked as an interface or as a // virtual method. throw new IllegalArgumentException("Instance type has no known class"); } if (clazz.isInterface()) { a.invokeInterface(instanceType, getReadMethodName(), getPropertyType(), null); } else { a.invokeVirtual(instanceType, getReadMethodName(), getPropertyType(), null); } }
public void addInvokeWriteMethod(CodeAssembler a, TypeDesc instanceType) { Class clazz = instanceType.toClass(); if (clazz == null) { // Can't know if instance should be invoked as an interface or as a // virtual method. throw new IllegalArgumentException("Instance type has no known class"); } if (clazz.isInterface()) { a.invokeInterface(instanceType, getWriteMethodName(), null, new TypeDesc[] {getPropertyType()}); } else { a.invokeVirtual(instanceType, getWriteMethodName(), null, new TypeDesc[] {getPropertyType()}); } }
public void addInvokeWriteMethod(CodeAssembler a, TypeDesc instanceType) { Class clazz = instanceType.toClass(); if (clazz == null) { // Can't know if instance should be invoked as an interface or as a // virtual method. throw new IllegalArgumentException("Instance type has no known class"); } if (clazz.isInterface()) { a.invokeInterface(instanceType, getWriteMethodName(), null, new TypeDesc[] {getPropertyType()}); } else { a.invokeVirtual(instanceType, getWriteMethodName(), null, new TypeDesc[] {getPropertyType()}); } }
/** * @param fieldType must be an object type * @return null if compareTo should not be called */ private static TypeDesc compareToType(TypeDesc fieldType) { if (fieldType.toPrimitiveType() == TypeDesc.FLOAT) { // Special treatment to handle NaN. return TypeDesc.FLOAT.toObjectType(); } else if (fieldType.toPrimitiveType() == TypeDesc.DOUBLE) { // Special treatment to handle NaN. return TypeDesc.DOUBLE.toObjectType(); } else if (BigDecimal.class.isAssignableFrom(fieldType.toClass())) { // Call compareTo to disregard scale. return TypeDesc.forClass(BigDecimal.class); } else { return null; } }
/** * @param fieldType must be an object type * @return null if compareTo should not be called */ private static TypeDesc compareToType(TypeDesc fieldType) { if (fieldType.toPrimitiveType() == TypeDesc.FLOAT) { // Special treatment to handle NaN. return TypeDesc.FLOAT.toObjectType(); } else if (fieldType.toPrimitiveType() == TypeDesc.DOUBLE) { // Special treatment to handle NaN. return TypeDesc.DOUBLE.toObjectType(); } else if (BigDecimal.class.isAssignableFrom(fieldType.toClass())) { // Call compareTo to disregard scale. return TypeDesc.forClass(BigDecimal.class); } else { return null; } }
public Class getPropertyType(ClassLoader loader) throws SupportException { TypeDesc type = TypeDesc.forDescriptor(getPropertyTypeDescriptor()); Class propClass = type.toClass(loader); if (propClass == null) { throw new SupportException ("Unable to find class \"" + type.getRootName() + "\" for property \"" + getPropertyName() + '"'); } return propClass; }
public Class getPropertyType(ClassLoader loader) throws SupportException { TypeDesc type = TypeDesc.forDescriptor(getPropertyTypeDescriptor()); Class propClass = type.toClass(loader); if (propClass == null) { throw new SupportException ("Unable to find class \"" + type.getRootName() + "\" for property \"" + getPropertyName() + '"'); } return propClass; }