当前位置: 首页>>代码示例>>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;未经允许,请勿转载。