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


Java Directory.setString方法代碼示例

本文整理匯總了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));
}
 
開發者ID:ecologylab,項目名稱:BigSemanticsJava,代碼行數:19,代碼來源:DirectoryTest.java

示例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));
}
 
開發者ID:ecologylab,項目名稱:BigSemanticsJava,代碼行數:9,代碼來源:DirectoryTest.java

示例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));
}
 
開發者ID:ecologylab,項目名稱:BigSemanticsJava,代碼行數:10,代碼來源:MetadataTest.java

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

示例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));
}
 
開發者ID:ecologylab,項目名稱:BigSemanticsJava,代碼行數:9,代碼來源:MetadataTest.java

示例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));
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:7,代碼來源:IccReader.java

示例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);
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:6,代碼來源:QuickTimeDictionary.java

示例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);
    }
}
 
開發者ID:byronb92,項目名稱:ImageEXIFExtraction,代碼行數:66,代碼來源:IptcReader.java

示例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));
}
 
開發者ID:mxbossard,項目名稱:metadata-extractor-osgi,代碼行數:7,代碼來源:IccReader.java

示例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);
    }
}
 
開發者ID:mxbossard,項目名稱:metadata-extractor-osgi,代碼行數:62,代碼來源:IptcReader.java


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