本文整理匯總了Java中com.drew.metadata.Directory.setString方法的典型用法代碼示例。如果您正苦於以下問題:Java Directory.setString方法的具體用法?Java Directory.setString怎麽用?Java Directory.setString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.drew.metadata.Directory
的用法示例。
在下文中一共展示了Directory.setString方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSetStringAndGetDate
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void testSetStringAndGetDate() throws Exception
{
Metadata metadata = new Metadata();
Directory directory = metadata.getDirectory(MockDirectory.class);
String date1 = "2002:01:30 24:59:59";
String date2 = "2002:01:30 24:59";
String date3 = "2002-01-30 24:59:59";
String date4 = "2002-01-30 24:59";
directory.setString(1, date1);
directory.setString(2, date2);
directory.setString(3, date3);
directory.setString(4, date4);
assertEquals(date1, directory.getString(1));
assertEquals(new GregorianCalendar(2002, GregorianCalendar.JANUARY, 30, 24, 59, 59).getTime(), directory.getDate(1));
assertEquals(new GregorianCalendar(2002, GregorianCalendar.JANUARY, 30, 24, 59, 0).getTime(), directory.getDate(2));
assertEquals(new GregorianCalendar(2002, GregorianCalendar.JANUARY, 30, 24, 59, 59).getTime(), directory.getDate(3));
assertEquals(new GregorianCalendar(2002, GregorianCalendar.JANUARY, 30, 24, 59, 0).getTime(), directory.getDate(4));
}
示例2: testSetStringGetInt
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void testSetStringGetInt() throws Exception
{
Metadata metadata = new Metadata();
Directory directory = metadata.getDirectory(MockDirectory.class);
byte[] bytes = { 0x01, 0x02, 0x03 };
directory.setString(1, new String(bytes));
assertEquals(0x010203, directory.getInt(1));
}
示例3: testSetAndGetMultipleTagsInSingleDirectory
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void testSetAndGetMultipleTagsInSingleDirectory() throws Exception
{
Metadata metadata = new Metadata();
Directory exifDir = metadata.getDirectory(ExifDirectory.class);
exifDir.setString(ExifDirectory.TAG_APERTURE, "Tag Value");
exifDir.setString(ExifDirectory.TAG_BATTERY_LEVEL, "Another tag");
assertEquals("Tag Value", exifDir.getString(ExifDirectory.TAG_APERTURE));
assertEquals("Another tag", exifDir.getString(ExifDirectory.TAG_BATTERY_LEVEL));
}
示例4: testSetAndGetMultipleTagsInMultilpeDirectories
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void testSetAndGetMultipleTagsInMultilpeDirectories() throws Exception
{
Metadata metadata = new Metadata();
Directory exifDir = metadata.getDirectory(ExifDirectory.class);
Directory gpsDir = metadata.getDirectory(GpsDirectory.class);
exifDir.setString(ExifDirectory.TAG_APERTURE, "ExifAperture");
exifDir.setString(ExifDirectory.TAG_BATTERY_LEVEL, "ExifBatteryLevel");
gpsDir.setString(GpsDirectory.TAG_GPS_ALTITUDE, "GpsAltitude");
gpsDir.setString(GpsDirectory.TAG_GPS_DEST_BEARING, "GpsDestBearing");
assertEquals("ExifAperture", exifDir.getString(ExifDirectory.TAG_APERTURE));
assertEquals("ExifBatteryLevel", exifDir.getString(ExifDirectory.TAG_BATTERY_LEVEL));
assertEquals("GpsAltitude", gpsDir.getString(GpsDirectory.TAG_GPS_ALTITUDE));
assertEquals("GpsDestBearing", gpsDir.getString(GpsDirectory.TAG_GPS_DEST_BEARING));
}
示例5: testContainsTag
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void testContainsTag() throws Exception
{
Metadata metadata = new Metadata();
Directory exifDir = metadata.getDirectory(ExifDirectory.class);
assertTrue(!exifDir.containsTag(ExifDirectory.TAG_APERTURE));
exifDir.setString(ExifDirectory.TAG_APERTURE, "Tag Value");
assertTrue(exifDir.containsTag(ExifDirectory.TAG_APERTURE));
}
示例6: set4ByteString
import com.drew.metadata.Directory; //導入方法依賴的package包/類
private void set4ByteString(@NotNull Directory directory, int tagType, @NotNull RandomAccessReader reader) throws IOException
{
int i = reader.getInt32(tagType);
if (i != 0)
directory.setString(tagType, getStringFromInt32(i));
}
示例7: setLookup
import com.drew.metadata.Directory; //導入方法依賴的package包/類
public static void setLookup(int scope, String lookup, Directory directory)
{
String results = lookup(scope, lookup);
directory.setString(scope, results);
}
示例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: set4ByteString
import com.drew.metadata.Directory; //導入方法依賴的package包/類
private void set4ByteString(@NotNull Directory directory, int tagType, @NotNull BufferReader reader) throws BufferBoundsException
{
int i = reader.getInt32(tagType);
if (i != 0)
directory.setString(tagType, getStringFromInt32(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);
}
}