/** 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 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() + "'."); }
/** 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 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() + "'."); }
/** 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 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 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 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() + "'."); }
/** * 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() + "'."); }