當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldType類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:27,代碼來源:TiffDirectory.java

示例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);
    }
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:17,代碼來源:TiffOutputField.java

示例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;
    }
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:14,代碼來源:TagInfoXpString.java

示例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;
    }
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:12,代碼來源:TagInfoXpString.java

示例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;
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:11,代碼來源:TagInfo.java

示例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);
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:13,代碼來源:TiffOutputDirectory.java

示例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);
}
 
開發者ID:windwardadmin,項目名稱:android-awt,代碼行數:16,代碼來源:TiffField.java

示例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;
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:13,代碼來源:TagInfoXpString.java

示例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);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:15,代碼來源:TagInfoXpString.java

示例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;
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:11,代碼來源:TagInfo.java

示例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);
}
 
開發者ID:apache,項目名稱:commons-imaging,代碼行數:12,代碼來源:TiffOutputDirectory.java


注:本文中的org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。