/** * Indicates whether any errors were reported during the reading of metadata values. * This value will be true if Directory.hasErrors() is true for one of the contained {@link Directory} objects. * * @return whether one of the contained directories has an error */ public boolean hasErrors() { for (Directory directory : getDirectories()) { if (directory.hasErrors()) return true; } return false; }
/** * Sets an <code>int</code> value for the specified tag. * * @param tagType the tag's value as an int * @param value the value for the specified tag as an int */ public void setInt(int tagType, int value) { setObject(tagType, value); }
/** * Get whether this tag has a name. * * If <code>true</code>, it may be accessed via {@link #getTagName}. * If <code>false</code>, {@link #getTagName} will return a string resembling <code>"Unknown tag (0x1234)"</code>. * * @return whether this tag has a name */ public boolean hasTagName() { return _directory.hasTagName(_tagType); }
/** 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() + "'."); }
/** 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. */
/** 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() + "'."); }
/** 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() + "'."); }
protected void addError(@NotNull String errorMessage, final @NotNull Metadata metadata) { ErrorDirectory directory = metadata.getFirstDirectoryOfType(ErrorDirectory.class); if (directory == null) { metadata.addDirectory(new ErrorDirectory(errorMessage)); } else { directory.addError(errorMessage); } } }
@Nullable protected String getVersionBytesDescription(final int tagType, int majorDigits) { int[] values = _directory.getIntArray(tagType); return values == null ? null : convertBytesToVersionString(values, majorDigits); }
@Override public String toString() { return toString(_charset); }
public void setInt16s(int tagId, int int16s) { // TODO create and use a proper setter for int16u? _currentDirectory.setInt(tagId, int16s); }
public void setDouble(int tagId, double double64) { _currentDirectory.setDouble(tagId, double64); }
public ErrorDirectory(String error) { super.addError(error); }
/** * Sets a <code>double</code> value for the specified tag. * * @param tagType the tag's value as an int * @param value the value for the specified tag as a double */ public void setDouble(int tagType, double value) { setObject(tagType, value); }
public void setInt8s(int tagId, byte int8s) { // NOTE Directory stores all integral types as int32s, except for int32u and long _currentDirectory.setInt(tagId, int8s); }
/** * Sets a <code>boolean</code> value for the specified tag. * * @param tagType the tag's value as an int * @param value the value for the specified tag as a boolean */ public void setBoolean(int tagType, boolean value) { setObject(tagType, value); }
public void setInt16u(int tagId, int int16u) { // TODO create and use a proper setter for _currentDirectory.setInt(tagId, int16u); }
/** * Sets a <code>float</code> value for the specified tag. * * @param tagType the tag's value as an int * @param value the value for the specified tag as a float */ public void setFloat(int tagType, float value) { setObject(tagType, value); }
public void setInt8u(int tagId, short int8u) { // NOTE Directory stores all integral types as int32s, except for int32u and long _currentDirectory.setInt(tagId, int8u); }
/** * Sets a <code>long</code> value for the specified tag. * * @param tagType the tag's value as an int * @param value the value for the specified tag as a long */ public void setLong(int tagType, long value) { setObject(tagType, value); }