本文整理了Java中com.drew.metadata.Directory.getObject()
方法的一些代码示例,展示了Directory.getObject()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Directory.getObject()
方法的具体详情如下:
包路径:com.drew.metadata.Directory
类名称:Directory
方法名:getObject
[英]Returns the object hashed for the particular tag type specified, if available.
[中]返回指定的特定标记类型的哈希对象(如果可用)。
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
public StringValue getStringValue(int tagType)
{
Object o = getObject(tagType);
if (o instanceof StringValue)
return (StringValue)o;
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as an array of Rational. If the value is unset or cannot be converted, <code>null</code> is returned. */
@Nullable
public Rational[] getRationalArray(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof Rational[])
return (Rational[])o;
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a float. If the tag is not set or cannot be converted, <code>null</code> is returned. */
@Nullable
public Float getFloatObject(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof String || o instanceof StringValue) {
try {
return Float.parseFloat(o.toString());
} catch (NumberFormatException nfe) {
return null;
}
}
if (o instanceof Number)
return ((Number)o).floatValue();
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
/**
* Gets the specified tag's value as a StringValue array, if possible.
* Only succeeds if the tag is set as StringValue[], or StringValue.
*
* @param tagType the tag identifier
* @return the tag's value as an array of StringValues. If the value is unset or cannot be converted, <code>null</code> is returned.
*/
@Nullable
public StringValue[] getStringValueArray(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof StringValue[])
return (StringValue[])o;
if (o instanceof StringValue)
return new StringValue[] {(StringValue) o};
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a Double. If the tag is not set or cannot be converted, <code>null</code> is returned. */
@Nullable
public Double getDoubleObject(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof String || o instanceof StringValue) {
try {
return Double.parseDouble(o.toString());
} catch (NumberFormatException nfe) {
return null;
}
}
if (o instanceof Number)
return ((Number)o).doubleValue();
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a boolean. If the tag is not set or cannot be converted, <code>null</code> is returned. */
@Nullable
@SuppressWarnings(value = "NP_BOOLEAN_RETURN_NULL", justification = "keep API interface consistent")
public Boolean getBooleanObject(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof Boolean)
return (Boolean)o;
if (o instanceof String || o instanceof StringValue) {
try {
return Boolean.getBoolean(o.toString());
} catch (NumberFormatException nfe) {
return null;
}
}
if (o instanceof Number)
return (((Number)o).doubleValue() != 0);
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
public String getDescription(int tagType)
Object object = _directory.getObject(tagType);
代码示例来源:origin: drewnoakes/metadata-extractor
@Nullable
public String getReferenceBlackWhiteDescription()
{
// For some reason, sometimes this is read as a long[] and
// getIntArray isn't able to deal with it
int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE);
if (ints==null || ints.length < 6)
{
Object o = _directory.getObject(TAG_REFERENCE_BLACK_WHITE);
if (o != null && (o instanceof long[]))
{
long[] longs = (long[])o;
if (longs.length < 6)
return null;
ints = new int[longs.length];
for (int i = 0; i < longs.length; i++)
ints[i] = (int)longs[i];
}
else
return null;
}
int blackR = ints[0];
int whiteR = ints[1];
int blackG = ints[2];
int whiteG = ints[3];
int blackB = ints[4];
int whiteB = ints[5];
return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB);
}
代码示例来源:origin: drewnoakes/metadata-extractor
public Long getLongObject(int tagType)
Object o = getObject(tagType);
if (o == null)
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a long, if possible. */
public long getLong(int tagType) throws MetadataException
{
Long value = getLongObject(tagType);
if (value != null)
return value;
Object o = getObject(tagType);
if (o == null)
throw new MetadataException("Tag '" + getTagName(tagType) + "' has not been set -- check using containsTag() first");
throw new MetadataException("Tag '" + tagType + "' cannot be converted to a long. It is of type '" + o.getClass() + "'.");
}
代码示例来源:origin: drewnoakes/metadata-extractor
public Integer getInteger(int tagType)
Object o = getObject(tagType);
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a boolean, if possible. */
public boolean getBoolean(int tagType) throws MetadataException
{
Boolean value = getBooleanObject(tagType);
if (value != null)
return value;
Object o = getObject(tagType);
if (o == null)
throw new MetadataException("Tag '" + getTagName(tagType) + "' has not been set -- check using containsTag() first");
throw new MetadataException("Tag '" + tagType + "' cannot be converted to a boolean. It is of type '" + o.getClass() + "'.");
}
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a double, if possible. */
public double getDouble(int tagType) throws MetadataException
{
Double value = getDoubleObject(tagType);
if (value!=null)
return value;
Object o = getObject(tagType);
if (o == null)
throw new MetadataException("Tag '" + getTagName(tagType) + "' has not been set -- check using containsTag() first");
throw new MetadataException("Tag '" + tagType + "' cannot be converted to a double. It is of type '" + o.getClass() + "'.");
}
/** Returns the specified tag's value as a Double. If the tag is not set or cannot be converted, <code>null</code> is returned. */
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a float, if possible. */
public float getFloat(int tagType) throws MetadataException
{
Float value = getFloatObject(tagType);
if (value!=null)
return value;
Object o = getObject(tagType);
if (o == null)
throw new MetadataException("Tag '" + getTagName(tagType) + "' has not been set -- check using containsTag() first");
throw new MetadataException("Tag '" + tagType + "' cannot be converted to a float. It is of type '" + o.getClass() + "'.");
}
代码示例来源:origin: drewnoakes/metadata-extractor
public int[] getIntArray(int tagType)
Object o = getObject(tagType);
if (o == null)
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
public String getString(int tagType)
Object o = getObject(tagType);
if (o == null)
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
public byte[] getByteArray(int tagType)
Object o = getObject(tagType);
if (o == null) {
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
/** Returns the specified tag's value as a Rational. If the value is unset or cannot be converted, <code>null</code> is returned. */
@Nullable
public Rational getRational(int tagType)
{
Object o = getObject(tagType);
if (o == null)
return null;
if (o instanceof Rational)
return (Rational)o;
if (o instanceof Integer)
return new Rational((Integer)o, 1);
if (o instanceof Long)
return new Rational((Long)o, 1);
// NOTE not doing conversions for real number types
return null;
}
代码示例来源:origin: drewnoakes/metadata-extractor
public String[] getStringArray(int tagType)
Object o = getObject(tagType);
if (o == null)
return null;
代码示例来源:origin: drewnoakes/metadata-extractor
/**
* Returns the specified tag's value as an int, if possible. Every attempt to represent the tag's value as an int
* is taken. Here is a list of the action taken depending upon the tag's original type:
* <ul>
* <li> int - Return unchanged.
* <li> Number - Return an int value (real numbers are truncated).
* <li> Rational - Truncate any fractional part and returns remaining int.
* <li> String - Attempt to parse string as an int. If this fails, convert the char[] to an int (using shifts and OR).
* <li> Rational[] - Return int value of first item in array.
* <li> byte[] - Return int value of first item in array.
* <li> int[] - Return int value of first item in array.
* </ul>
*
* @throws MetadataException if no value exists for tagType or if it cannot be converted to an int.
*/
public int getInt(int tagType) throws MetadataException
{
Integer integer = getInteger(tagType);
if (integer!=null)
return integer;
Object o = getObject(tagType);
if (o == null)
throw new MetadataException("Tag '" + getTagName(tagType) + "' has not been set -- check using containsTag() first");
throw new MetadataException("Tag '" + tagType + "' cannot be converted to int. It is of type '" + o.getClass() + "'.");
}
内容来源于网络,如有侵权,请联系作者删除!