本文整理匯總了Java中com.drew.metadata.Directory.setStringArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Directory.setStringArray方法的具體用法?Java Directory.setStringArray怎麽用?Java Directory.setStringArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.drew.metadata.Directory
的用法示例。
在下文中一共展示了Directory.setStringArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例2: 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);
}
}