FileDocCategorySizeDatePackage
ObjectFormat.javaAPI DocAndroid 5.1 API4135Thu Mar 12 22:22:30 GMT 2015android.filterfw.format

ObjectFormat

public class ObjectFormat extends Object
hide

Fields Summary
Constructors Summary
Methods Summary
private static intbytesPerSampleForClass(java.lang.Class clazz, int target)

        // Native targets have objects manifested in a byte buffer. Thus it is important to
        // correctly determine the size of single element here.
        if (target == FrameFormat.TARGET_NATIVE) {
            if (!NativeBuffer.class.isAssignableFrom(clazz)) {
                throw new IllegalArgumentException("Native object-based formats must be of a " +
                    "NativeBuffer subclass! (Received class: " + clazz + ").");
            }
            try {
                return ((NativeBuffer)clazz.newInstance()).getElementSize();
            } catch (Exception e) {
                throw new RuntimeException("Could not determine the size of an element in a "
                    + "native object-based frame of type " + clazz + "! Perhaps it is missing a "
                    + "default constructor?");
            }
        } else {
            return FrameFormat.BYTES_PER_SAMPLE_UNSPECIFIED;
        }
    
public static android.filterfw.core.MutableFrameFormatfromClass(java.lang.Class clazz, int count, int target)

        // Create frame format
        MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target);
        result.setObjectClass(getBoxedClass(clazz));
        if (count != FrameFormat.SIZE_UNSPECIFIED) {
            result.setDimensions(count);
        }
        result.setBytesPerSample(bytesPerSampleForClass(clazz, target));
        return result;
    
public static android.filterfw.core.MutableFrameFormatfromClass(java.lang.Class clazz, int target)

        return fromClass(clazz, FrameFormat.SIZE_UNSPECIFIED, target);
    
public static android.filterfw.core.MutableFrameFormatfromObject(java.lang.Object object, int target)

        return object == null
            ? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
            : fromClass(object.getClass(), FrameFormat.SIZE_UNSPECIFIED, target);
    
public static android.filterfw.core.MutableFrameFormatfromObject(java.lang.Object object, int count, int target)

        return object == null
            ? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
            : fromClass(object.getClass(), count, target);
    
private static java.lang.ClassgetBoxedClass(java.lang.Class type)

        // Check if type is primitive
        if (type.isPrimitive()) {
            // Yes -> box it
            if (type == boolean.class) {
                return java.lang.Boolean.class;
            } else if (type == byte.class) {
                return java.lang.Byte.class;
            } else if (type == char.class) {
                return java.lang.Character.class;
            } else if (type == short.class) {
                return java.lang.Short.class;
            } else if (type == int.class) {
                return java.lang.Integer.class;
            } else if (type == long.class) {
                return java.lang.Long.class;
            } else if (type == float.class) {
                return java.lang.Float.class;
            } else if (type == double.class) {
                return java.lang.Double.class;
            } else {
                throw new IllegalArgumentException(
                    "Unknown primitive type: " + type.getSimpleName() + "!");
            }
        } else {
            // No -> return it
            return type;
        }