/** * Constructs a new <code>Type</code> with the given type name. * * @param typeName the name of this type; must not be <code>null</code>. */ public Type(String typeName) { if (typeName.startsWith("[]")) { _typeName = typeName; _typeClass = TypeClass.SEQUENCE; return; } for (int i = 0; i < __typeClassToTypeName.length; ++i) { if (__typeClassToTypeName[i].equals(typeName)) { _typeName = typeName; _typeClass = TypeClass.fromInt(i); return; } } int i = typeName.indexOf('<'); try { init( typeName, Class.forName(i < 0 ? typeName : typeName.substring(0, i)), false, i >= 0); } catch (ClassNotFoundException e) { throw new RuntimeException(e.toString()); } }
private static boolean __isTypeClassPrimitive(TypeClass typeClass) { return typeClass.getValue() < __typeClassToTypeName.length; }
private static boolean __isTypeClassPrimitive(TypeClass typeClass) { return typeClass.getValue() < __typeClassToTypeName.length; }
/** * Constructs a new <code>Type</code> with the given type name. * * @param typeName the name of this type; must not be <code>null</code>. */ public Type(String typeName) { if (typeName.startsWith("[]")) { _typeName = typeName; _typeClass = TypeClass.SEQUENCE; return; } for (int i = 0; i < __typeClassToTypeName.length; ++i) { if (__typeClassToTypeName[i].equals(typeName)) { _typeName = typeName; _typeClass = TypeClass.fromInt(i); return; } } int i = typeName.indexOf('<'); try { init( typeName, Class.forName(i < 0 ? typeName : typeName.substring(0, i)), false, i >= 0, false); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
public static boolean isUnsigned(ITypeDescription desc) { switch (getElementTypeClass(desc).getValue()) { case TypeClass.UNSIGNED_SHORT_value: case TypeClass.UNSIGNED_LONG_value: case TypeClass.UNSIGNED_HYPER_value: return true; default: return false; } }
public TypeDescription readType() { int b = read8Bit(); TypeClass typeClass = TypeClass.fromInt(b & 0x7F); if (typeClass == null) { throw new RuntimeException(
/** Examines the argument <em>object</em> if is correspond to the type in argument <em>what</em>. <em>object</em> is either matched directly against the type or if it is an any then the contained object is matched against the type. */ static private boolean containsType( TypeClass what, Object object){ return (getType(object).getTypeClass().getValue() == what.getValue()); }
public TypeDescription readType() { int b = read8Bit(); TypeClass typeClass = TypeClass.fromInt(b & 0x7F); if (TypeDescription.isTypeClassSimple(typeClass)) { return TypeDescription.getTypeDescription(typeClass); } else { int index = read16Bit(); TypeDescription type = null; if ((b & 0x80) != 0) { try { type = TypeDescription.getTypeDescription( readStringValue()); } catch (ClassNotFoundException e) { throw new RuntimeException(e.toString()); } } if (index != 0xFFFF) { if ((b & 0x80) == 0) { type = typeCache[index]; } else { typeCache[index] = type; } } return type; } }
public static boolean isUnsigned(TypeDescription desc) { switch (getElementTypeClass(desc).getValue()) { case TypeClass.UNSIGNED_SHORT_value: case TypeClass.UNSIGNED_LONG_value: case TypeClass.UNSIGNED_HYPER_value: return true; default: return false; } }
/** * Examines the argument <em>object</em> if is correspond to the type in * argument <em>what</em>. * * <p><em>object</em> is either matched directly against the type or if it is * an any then the contained object is matched against the type.</p> */ private static boolean containsType( TypeClass what, Object object){ return (getType(object).getTypeClass().getValue() == what.getValue()); }
/** * Constructs a new <code>Type</code> with the given type class. * * @param typeClass the type class of this type; must not be * <code>null</code>. Only type classes for simple types are allowed * here. * * @throws IllegalArgumentException if the given <code>typeClass</code> is * not simple (for example, a struct or an interface type). This * constructor could not find out the type name in such a case. */ public Type(TypeClass typeClass) { if(__isTypeClassPrimitive(typeClass)) { _typeClass = typeClass; _typeName = __typeClassToTypeName[typeClass.getValue()]; } else throw new IllegalArgumentException(typeClass + " is not primitive"); }
/** * Constructs a new <code>Type</code> with the given type class. * * @param typeClass the type class of this type; must not be * <code>null</code>. Only type classes for simple types are allowed * here. * * @throws IllegalArgumentException if the given <code>typeClass</code> is * not simple (for example, a struct or an interface type). This * constructor could not find out the type name in such a case. */ public Type(TypeClass typeClass) { if(__isTypeClassPrimitive(typeClass)) { _typeClass = typeClass; _typeName = __typeClassToTypeName[typeClass.getValue()]; } else throw new IllegalArgumentException(typeClass + " is not primitive"); }
/** checks if the any contains an interface, struct, exception, sequence or enum. If <em>object</em> is an any with an interface type, then true is also returned if the any contains a null reference. This is because interfaces are allowed to have a null value contrary to other UNO types. @param object the object to check @return true if the any contains an object */ static public boolean isObject(Object object) { int tc = getType(object).getTypeClass().getValue(); return (TypeClass.INTERFACE_value == tc || TypeClass.STRUCT_value == tc || TypeClass.EXCEPTION_value == tc || TypeClass.SEQUENCE_value == tc || TypeClass.ENUM_value == tc); }
/** * Checks if the any contains an interface, struct, exception, sequence or enum. * * <p>If <em>object</em> is an any with an interface type, then true is also * returned if the any contains a null reference. This is because interfaces * are allowed to have a null value contrary to other UNO types.</p> * * @param object the object to check. * @return true if the any contains an object. */ public static boolean isObject(Object object) { int tc = getType(object).getTypeClass().getValue(); return (TypeClass.INTERFACE_value == tc || TypeClass.STRUCT_value == tc || TypeClass.EXCEPTION_value == tc || TypeClass.SEQUENCE_value == tc || TypeClass.ENUM_value == tc); }
return false; switch (_typeClass.getValue()) { case TypeClass.SEQUENCE_value: case TypeClass.ENUM_value:
return false; switch (_typeClass.getValue()) { case TypeClass.SEQUENCE_value: case TypeClass.ENUM_value:
_typeName = _typeClass == TypeClass.INTERFACE ? XInterface.class.getName() : __typeClassToTypeName[_typeClass.getValue()];
_typeName = _typeClass == TypeClass.INTERFACE ? XInterface.class.getName() : __typeClassToTypeName[_typeClass.getValue()];
return value; switch (type.getTypeClass().getValue()) { case TypeClass.BOOLEAN_value: return Boolean.FALSE;
return value; switch (type.getTypeClass().getValue()) { case TypeClass.BOOLEAN_value: return Boolean.FALSE;