Methods Summary |
---|
public static int | checkNativeType(int nativeType)Ensure that the {@code nativeType} is one of the native types supported
by {@link CameraMetadataNative}.
switch (nativeType) {
case TYPE_BYTE:
case TYPE_INT32:
case TYPE_FLOAT:
case TYPE_INT64:
case TYPE_DOUBLE:
case TYPE_RATIONAL:
return nativeType;
}
throw new UnsupportedOperationException("Unknown nativeType " + nativeType);
|
public static int | checkNativeTypeEquals(int expectedNativeType, int actualNativeType)Ensure that the expected and actual native types are equal.
if (expectedNativeType != actualNativeType) {
throw new UnsupportedOperationException(
String.format("Expected native type %d, but got %d",
expectedNativeType, actualNativeType));
}
return actualNativeType;
|
public static java.lang.Class | checkPrimitiveClass(java.lang.Class klass)Ensure that the {@code klass} is one of the metadata-primitive classes.
checkNotNull(klass, "klass must not be null");
if (isPrimitiveClass(klass)) {
return klass;
}
throw new UnsupportedOperationException("Unsupported class '" + klass +
"'; expected a metadata primitive class");
|
public static int | getPrimitiveTypeSize(int nativeType)Get the size in bytes for the native camera metadata type.
This used to determine how many bytes it would take to encode/decode a single value
of that {@link nativeType}.
switch (nativeType) {
case TYPE_BYTE:
return SIZEOF_BYTE;
case TYPE_INT32:
return SIZEOF_INT32;
case TYPE_FLOAT:
return SIZEOF_FLOAT;
case TYPE_INT64:
return SIZEOF_INT64;
case TYPE_DOUBLE:
return SIZEOF_DOUBLE;
case TYPE_RATIONAL:
return SIZEOF_RATIONAL;
}
throw new UnsupportedOperationException("Unknown type, can't get size for "
+ nativeType);
|
public static boolean | isPrimitiveClass(java.lang.Class klass)Checks whether or not {@code klass} is one of the metadata-primitive classes.
The following types (whether boxed or unboxed) are considered primitive:
- byte
- int
- float
- double
- Rational
This doesn't strictly follow the java understanding of primitive since
boxed objects are included, Rational is included, and other types such as char and
short are not included.
if (klass == null) {
return false;
}
if (klass == byte.class || klass == Byte.class) {
return true;
} else if (klass == int.class || klass == Integer.class) {
return true;
} else if (klass == float.class || klass == Float.class) {
return true;
} else if (klass == long.class || klass == Long.class) {
return true;
} else if (klass == double.class || klass == Double.class) {
return true;
} else if (klass == Rational.class) {
return true;
}
return false;
|
public static java.lang.String | toStringNativeType(int nativeType)Return a human-readable representation of the {@code nativeType}, e.g. "TYPE_INT32"
Out-of-range values return a string with "UNKNOWN" as the prefix.
switch (nativeType) {
case TYPE_BYTE:
return "TYPE_BYTE";
case TYPE_INT32:
return "TYPE_INT32";
case TYPE_FLOAT:
return "TYPE_FLOAT";
case TYPE_INT64:
return "TYPE_INT64";
case TYPE_DOUBLE:
return "TYPE_DOUBLE";
case TYPE_RATIONAL:
return "TYPE_RATIONAL";
}
return "UNKNOWN(" + nativeType + ")";
|
public static java.lang.Class | wrapClassIfPrimitive(java.lang.Class klass)Wrap {@code klass} with its wrapper variant if it was a {@code Class} corresponding
to a Java primitive.
Non-primitive classes are passed through as-is.
For example, for a primitive {@code int.class => Integer.class},
but for a non-primitive {@code Rational.class => Rational.class}.
if (klass == byte.class) {
return (Class<T>)Byte.class;
} else if (klass == int.class) {
return (Class<T>)Integer.class;
} else if (klass == float.class) {
return (Class<T>)Float.class;
} else if (klass == long.class) {
return (Class<T>)Long.class;
} else if (klass == double.class) {
return (Class<T>)Double.class;
}
return klass;
|