本文整理匯總了Java中org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType類的典型用法代碼示例。如果您正苦於以下問題:Java FieldType類的具體用法?Java FieldType怎麽用?Java FieldType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FieldType類屬於org.apache.commons.imaging.formats.tiff.fieldtypes包,在下文中一共展示了FieldType類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFieldValue
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public int[] getFieldValue(final TagInfoShortOrLong tag, final boolean mustExist)
throws ImageReadException {
final TiffField field = findField(tag);
if (field == null) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" is missing");
} else {
return null;
}
}
if (!tag.dataTypes.contains(field.getFieldType())) {
if (mustExist) {
throw new ImageReadException("Required field \"" + tag.name
+ "\" has incorrect type " + field.getFieldType().getName());
} else {
return null;
}
}
final byte[] bytes = field.getByteArrayValue();
if (field.getFieldType() == FieldType.SHORT) {
return ByteConversions.toUInt16s(bytes, field.getByteOrder());
} else {
return ByteConversions.toInts(bytes, field.getByteOrder());
}
}
示例2: TiffOutputField
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public TiffOutputField(final int tag, final TagInfo tagInfo, final FieldType fieldType,
final int count, final byte[] bytes) {
this.tag = tag;
this.tagInfo = tagInfo;
this.fieldType = fieldType;
this.count = count;
this.bytes = bytes;
if (isLocalValue()) {
separateValueItem = null;
} else {
final String name = "Field Seperate value (" + tagInfo.getDescription()
+ ")";
separateValueItem = new TiffOutputItem.Value(name, bytes);
}
}
示例3: encodeValue
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
@Override
public byte[] encodeValue(final FieldType fieldType, final Object value, final ByteOrder byteOrder)
throws ImageWriteException {
if (!(value instanceof String)) {
throw new ImageWriteException("Text value not String", value);
}
final String s = (String) value;
try {
return s.getBytes("UTF-16LE");
} catch (final UnsupportedEncodingException cannotHappen) {
return null;
}
}
示例4: getValue
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
@Override
public String getValue(final TiffField entry) throws ImageReadException {
if (entry.getFieldType() != FieldType.BYTE) {
throw new ImageReadException("Text field not encoded as bytes.");
}
try {
return new String(entry.getByteArrayValue(), "UTF-16LE");
} catch (final UnsupportedEncodingException cannotHappen) {
return null;
}
}
示例5: TagInfo
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public TagInfo(final String name, final int tag, final List<FieldType> dataTypes, final int length,
final TiffDirectoryType exifDirectory, final boolean isOffset) {
this.name = name;
this.tag = tag;
this.dataTypes = Collections.unmodifiableList(new ArrayList<FieldType>(
dataTypes));
this.length = length;
this.directoryType = exifDirectory;
this.isOffset = isOffset;
}
示例6: add
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public void add(final TagInfoByte tagInfo, final byte... values)
throws ImageWriteException {
if (tagInfo.length > 0 && tagInfo.length != values.length) {
throw new ImageWriteException("Tag expects " + tagInfo.length
+ " value(s), not " + values.length);
}
final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
tagInfo, FieldType.BYTE, values.length,
bytes);
add(tiffOutputField);
}
示例7: TiffField
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public TiffField(final int tag, final int directoryType, final FieldType fieldType,
final long count, final long offset, final byte[] value,
final ByteOrder byteOrder, final int sortHint) {
this.tag = tag;
this.directoryType = directoryType;
this.fieldType = fieldType;
this.count = count;
this.offset = offset;
this.value = value;
this.byteOrder = byteOrder;
this.sortHint = sortHint;
tagInfo = getTag(directoryType, tag);
}
示例8: encodeValue
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
@Override
public byte[] encodeValue(final FieldType fieldType, final Object value, final ByteOrder byteOrder)
throws ImageWriteException {
if (!(value instanceof String)) {
throw new ImageWriteException("Text value not String", value);
}
final String s = (String) value;
final byte[] bytes = s.getBytes(StandardCharsets.UTF_16LE);
final byte[] paddedBytes = new byte[bytes.length + 2];
System.arraycopy(bytes, 0, paddedBytes, 0, bytes.length);
return paddedBytes;
}
示例9: getValue
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
@Override
public String getValue(final TiffField entry) throws ImageReadException {
if (entry.getFieldType() != FieldType.BYTE) {
throw new ImageReadException("Text field not encoded as bytes.");
}
final byte[] bytes = entry.getByteArrayValue();
final int length;
if (bytes.length >= 2 && bytes[bytes.length - 1] == 0 && bytes[bytes.length - 2] == 0) {
length = bytes.length - 2;
} else {
length = bytes.length;
}
return new String(bytes, 0, length, StandardCharsets.UTF_16LE);
}
示例10: TagInfo
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public TagInfo(final String name, final int tag, final List<FieldType> dataTypes, final int length,
final TiffDirectoryType exifDirectory, final boolean isOffset) {
this.name = name;
this.tag = tag;
this.dataTypes = Collections.unmodifiableList(new ArrayList<>(
dataTypes));
this.length = length;
this.directoryType = exifDirectory;
this.isOffset = isOffset;
}
示例11: add
import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; //導入依賴的package包/類
public void add(final TagInfoByte tagInfo, final byte value)
throws ImageWriteException {
if (tagInfo.length != 1) {
throw new ImageWriteException("Tag expects " + tagInfo.length
+ " value(s), not 1");
}
final byte[] bytes = tagInfo.encodeValue(byteOrder, value);
final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
tagInfo, FieldType.BYTE, bytes.length, bytes);
add(tiffOutputField);
}