本文整理汇总了Java中com.drew.metadata.Directory.setInt方法的典型用法代码示例。如果您正苦于以下问题:Java Directory.setInt方法的具体用法?Java Directory.setInt怎么用?Java Directory.setInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.drew.metadata.Directory
的用法示例。
在下文中一共展示了Directory.setInt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void extract(@NotNull SequentialReader reader, @NotNull Metadata metadata)
{
Directory directory = new AdobeJpegDirectory();
metadata.addDirectory(directory);
try {
reader.setMotorolaByteOrder(false);
if (!reader.getString(PREAMBLE.length()).equals(PREAMBLE)) {
directory.addError("Invalid Adobe JPEG data header.");
return;
}
directory.setInt(AdobeJpegDirectory.TAG_DCT_ENCODE_VERSION, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS0, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS1, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_COLOR_TRANSFORM, reader.getInt8());
} catch (IOException ex) {
directory.addError("IO exception processing data: " + ex.getMessage());
}
}
示例2: extract
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void extract(@NotNull SequentialReader reader, @NotNull Metadata metadata)
{
final Directory directory = metadata.getOrCreateDirectory(AdobeJpegDirectory.class);
try {
reader.setMotorolaByteOrder(false);
if (!reader.getString(5).equals("Adobe")) {
directory.addError("Invalid Adobe JPEG data header.");
return;
}
directory.setInt(AdobeJpegDirectory.TAG_DCT_ENCODE_VERSION, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS0, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS1, reader.getUInt16());
directory.setInt(AdobeJpegDirectory.TAG_COLOR_TRANSFORM, reader.getInt8());
} catch (IOException ex) {
directory.addError("IO exception processing data: " + ex.getMessage());
}
}
示例3: extract
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void extract(@NotNull final BufferReader reader, @NotNull Metadata metadata)
{
final Directory directory = metadata.getOrCreateDirectory(AdobeJpegDirectory.class);
if (reader.getLength() != 12) {
directory.addError(String.format("Adobe JPEG data is expected to be 12 bytes long, not %d.", reader.getLength()));
return;
}
try {
reader.setMotorolaByteOrder(false);
if (!reader.getString(0, 5).equals("Adobe")) {
directory.addError("Invalid Adobe JPEG data header.");
return;
}
directory.setInt(AdobeJpegDirectory.TAG_DCT_ENCODE_VERSION, reader.getUInt16(5));
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS0, reader.getUInt16(7));
directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS1, reader.getUInt16(9));
directory.setInt(AdobeJpegDirectory.TAG_COLOR_TRANSFORM, reader.getInt8(11));
} catch (BufferBoundsException ex) {
directory.addError("Exif data segment ended prematurely");
}
}
示例4: testSetAndGetInt
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void testSetAndGetInt() throws Exception
{
Metadata metadata = new Metadata();
Directory directory = metadata.getDirectory(MockDirectory.class);
int value = 321;
int tagType = 123;
directory.setInt(tagType, value);
assertEquals(value, directory.getInt(tagType));
assertEquals(Integer.toString(value), directory.getString(tagType));
}
示例5: testSetAndGetSingleTag
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void testSetAndGetSingleTag() throws Exception
{
Metadata metadata = new Metadata();
Directory directory = metadata.getDirectory(ExifDirectory.class);
directory.setInt(ExifDirectory.TAG_APERTURE, 1);
assertEquals(1, directory.getInt(ExifDirectory.TAG_APERTURE));
}
示例6: testSetSameTagMultpleTimes
import com.drew.metadata.Directory; //导入方法依赖的package包/类
public void testSetSameTagMultpleTimes() throws Exception
{
Metadata metadata = new Metadata();
Directory directory = metadata.getDirectory(ExifDirectory.class);
directory.setInt(ExifDirectory.TAG_APERTURE, 1);
directory.setInt(ExifDirectory.TAG_APERTURE, 2);
assertEquals("setting the tag with a different value should override old value",
2, directory.getInt(ExifDirectory.TAG_APERTURE));
}
示例7: setInt32
import com.drew.metadata.Directory; //导入方法依赖的package包/类
private void setInt32(@NotNull Directory directory, int tagType, @NotNull RandomAccessReader reader) throws IOException
{
int i = reader.getInt32(tagType);
if (i != 0)
directory.setInt(tagType, i);
}
示例8: processTag
import com.drew.metadata.Directory; //导入方法依赖的package包/类
private void processTag(@NotNull SequentialReader reader, @NotNull Directory directory, int directoryType, int tagType, int tagByteCount) throws IOException
{
int tagIdentifier = tagType | (directoryType << 8);
String string = null;
switch (tagIdentifier) {
case IptcDirectory.TAG_APPLICATION_RECORD_VERSION:
// short
int shortValue = reader.getUInt16();
reader.skip(tagByteCount - 2);
directory.setInt(tagIdentifier, shortValue);
return;
case IptcDirectory.TAG_URGENCY:
// byte
directory.setInt(tagIdentifier, reader.getUInt8());
reader.skip(tagByteCount - 1);
return;
case IptcDirectory.TAG_RELEASE_DATE:
case IptcDirectory.TAG_DATE_CREATED:
// Date object
if (tagByteCount >= 8) {
string = reader.getString(tagByteCount);
try {
int year = Integer.parseInt(string.substring(0, 4));
int month = Integer.parseInt(string.substring(4, 6)) - 1;
int day = Integer.parseInt(string.substring(6, 8));
Date date = new java.util.GregorianCalendar(year, month, day).getTime();
directory.setDate(tagIdentifier, date);
return;
} catch (NumberFormatException e) {
// fall through and we'll process the 'string' value below
}
} else {
reader.skip(tagByteCount);
}
case IptcDirectory.TAG_RELEASE_TIME:
case IptcDirectory.TAG_TIME_CREATED:
// time...
default:
// fall through
}
// If we haven't returned yet, treat it as a string
// NOTE that there's a chance we've already loaded the value as a string above, but failed to parse the value
if (string == null) {
string = reader.getString(tagByteCount, System.getProperty("file.encoding")); // "ISO-8859-1"
}
if (directory.containsTag(tagIdentifier)) {
// this fancy string[] business avoids using an ArrayList for performance reasons
String[] oldStrings = directory.getStringArray(tagIdentifier);
String[] newStrings;
if (oldStrings == null) {
newStrings = new String[1];
} else {
newStrings = new String[oldStrings.length + 1];
System.arraycopy(oldStrings, 0, newStrings, 0, oldStrings.length);
}
newStrings[newStrings.length - 1] = string;
directory.setStringArray(tagIdentifier, newStrings);
} else {
directory.setString(tagIdentifier, string);
}
}
示例9: setInt32
import com.drew.metadata.Directory; //导入方法依赖的package包/类
private void setInt32(@NotNull Directory directory, int tagType, @NotNull BufferReader reader) throws BufferBoundsException
{
int i = reader.getInt32(tagType);
if (i != 0)
directory.setInt(tagType, i);
}
示例10: processTag
import com.drew.metadata.Directory; //导入方法依赖的package包/类
private void processTag(@NotNull BufferReader reader, @NotNull Directory directory, int directoryType, int tagType, int offset, int tagByteCount) throws BufferBoundsException
{
int tagIdentifier = tagType | (directoryType << 8);
switch (tagIdentifier) {
case IptcDirectory.TAG_APPLICATION_RECORD_VERSION:
// short
int shortValue = reader.getUInt16(offset);
directory.setInt(tagIdentifier, shortValue);
return;
case IptcDirectory.TAG_URGENCY:
// byte
directory.setInt(tagIdentifier, reader.getUInt8(offset));
return;
case IptcDirectory.TAG_RELEASE_DATE:
case IptcDirectory.TAG_DATE_CREATED:
// Date object
if (tagByteCount >= 8) {
String dateStr = reader.getString(offset, tagByteCount);
try {
int year = Integer.parseInt(dateStr.substring(0, 4));
int month = Integer.parseInt(dateStr.substring(4, 6)) - 1;
int day = Integer.parseInt(dateStr.substring(6, 8));
Date date = new java.util.GregorianCalendar(year, month, day).getTime();
directory.setDate(tagIdentifier, date);
return;
} catch (NumberFormatException e) {
// fall through and we'll store whatever was there as a String
}
}
case IptcDirectory.TAG_RELEASE_TIME:
case IptcDirectory.TAG_TIME_CREATED:
// time...
default:
// fall through
}
// If we haven't returned yet, treat it as a string
String str;
if (tagByteCount < 1) {
str = "";
} else {
str = reader.getString(offset, tagByteCount, System.getProperty("file.encoding")); // "ISO-8859-1"
}
if (directory.containsTag(tagIdentifier)) {
// this fancy string[] business avoids using an ArrayList for performance reasons
String[] oldStrings = directory.getStringArray(tagIdentifier);
String[] newStrings;
if (oldStrings == null) {
newStrings = new String[1];
} else {
newStrings = new String[oldStrings.length + 1];
System.arraycopy(oldStrings, 0, newStrings, 0, oldStrings.length);
}
newStrings[newStrings.length - 1] = str;
directory.setStringArray(tagIdentifier, newStrings);
} else {
directory.setString(tagIdentifier, str);
}
}