You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2020/03/31 18:12:57 UTC
svn commit: r1875953 - in
/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema:
DublinCoreSchema.java ExifSchema.java TiffSchema.java
XMPRightsManagementSchema.java XMPSchema.java
Author: tilman
Date: Tue Mar 31 18:12:57 2020
New Revision: 1875953
URL: http://svn.apache.org/viewvc?rev=1875953&view=rev
Log:
PDFBOX-4803: use BadFieldValueException where it makes sense, as suggested by Hao Zhong
Modified:
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/ExifSchema.java
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/TiffSchema.java
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java?rev=1875953&r1=1875952&r2=1875953&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/DublinCoreSchema.java Tue Mar 31 18:12:57 2020
@@ -26,6 +26,7 @@ import java.util.List;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.type.ArrayProperty;
+import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.type.Cardinality;
import org.apache.xmpbox.type.MIMEType;
import org.apache.xmpbox.type.PropertyType;
@@ -488,33 +489,37 @@ public class DublinCoreSchema extends XM
}
/**
- * Return a list of languages defined in description property
- *
- * @return get List of languages defined for description property
+ * Return a list of languages defined in the description property.
+ *
+ * @return The List of languages defined for the description property or null if it doesn't
+ * exist.
+ * @throws BadFieldValueException If the description property is not a multi-lingual property.
*/
- public List<String> getDescriptionLanguages()
+ public List<String> getDescriptionLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(DESCRIPTION);
}
/**
- * Return a language value for description property
- *
- * @param lang
- * The language wanted
- * @return Description value for specified language
+ * Return a language value for the description property.
+ *
+ * @param lang The language wanted.
+ * @return Description value for specified language or null if it doesn't exist.
+ * @throws BadFieldValueException BadFieldValueException If the description property is not a
+ * multi-lingual property.
*/
- public String getDescription(String lang)
+ public String getDescription(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(DESCRIPTION, lang);
}
/**
- * Get the default value for the description.
+ * Get the default value for the description property.
*
* @return The description of this resource.
+ * @throws BadFieldValueException If the description property is not a multi-lingual property.
*/
- public String getDescription()
+ public String getDescription() throws BadFieldValueException
{
return getDescription(null);
}
@@ -632,34 +637,36 @@ public class DublinCoreSchema extends XM
}
/**
- * Return a list of languages defined in Right property
+ * Return a list of languages defined in Right property.
*
* @return list of rights languages values defined
+ * @throws BadFieldValueException If the Rights property is not a multi-lingual property.
*/
- public List<String> getRightsLanguages()
+ public List<String> getRightsLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(RIGHTS);
}
/**
- * Return a language value for Right property
- *
- * @param lang
- * language concerned
- * @return the rights value for specified language
+ * Return a language value for the Rights property.
+ *
+ * @param lang language concerned.
+ * @return The rights value for specified language or null if it doesn't exist.
+ * @throws BadFieldValueException If the Rights property is not a multi-lingual property.
*/
- public String getRights(String lang)
+ public String getRights(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(RIGHTS, lang);
}
/**
- * Return the default value for Right property
- *
+ * Return the default value for the Rights property.
+ *
+ * @throws BadFieldValueException If the Rights property is not a multi-lingual property.
* @see DublinCoreSchema#getRights(String)
* @return the default rights value
*/
- public String getRights()
+ public String getRights() throws BadFieldValueException
{
return getRights(null);
}
@@ -716,33 +723,35 @@ public class DublinCoreSchema extends XM
}
/**
- * Return a list of languages defined in Title property
- *
+ * Return a list of languages defined in the Title property
+ *
* @return list of languages defined for title property
+ * @throws BadFieldValueException If the Title property is not a multi-lingual property.
*/
- public List<String> getTitleLanguages()
+ public List<String> getTitleLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(TITLE);
}
/**
- * Return a language value for Title property
- *
- * @param lang
- * the language concerned
+ * Return a language value for the Title property
+ *
+ * @param lang the language concerned
* @return the title value for specified language
+ * @throws BadFieldValueException If the Title property is not a multi-lingual property.
*/
- public String getTitle(String lang)
+ public String getTitle(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(TITLE, lang);
}
/**
* Get the default value for the title.
- *
+ *
* @return The default title of this resource.
+ * @throws BadFieldValueException If the Title property is not a multi-lingual property.
*/
- public String getTitle()
+ public String getTitle() throws BadFieldValueException
{
return getTitle(null);
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/ExifSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/ExifSchema.java?rev=1875953&r1=1875952&r2=1875953&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/ExifSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/ExifSchema.java Tue Mar 31 18:12:57 2020
@@ -25,13 +25,14 @@ import org.apache.xmpbox.XMPMetadata;
import java.util.List;
import org.apache.xmpbox.type.ArrayProperty;
+import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.type.Cardinality;
import org.apache.xmpbox.type.PropertyType;
import org.apache.xmpbox.type.StructuredType;
import org.apache.xmpbox.type.Types;
/**
- * Representation of a Exif Schema
+ * Representation of an Exif Schema
*
*/
@@ -298,33 +299,37 @@ public class ExifSchema extends XMPSchem
}
/**
- * Return a list of languages defined in UserComment property
+ * Return a list of languages defined in the UserComment property.
*
- * @return list of UserComment languages values defined
+ * @return list of UserComment languages values defined or null if it doesn't exist.
+ * @throws BadFieldValueException If the UserComment property is not a multi-lingual property.
*/
- public List<String> getUserCommentLanguages()
+ public List<String> getUserCommentLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(USER_COMMENT);
}
/**
- * Return a language value for UserComment property
+ * Return a language value for the UserComment property.
*
* @param lang
* language concerned
- * @return the UserComment value for specified language
+ * @return the UserComment value for specified language or null if it doesn't exist.
+ * @throws BadFieldValueException If the UserComment property is not a multi-lingual property.
*/
- public String getUserComment(String lang)
+ public String getUserComment(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(USER_COMMENT, lang);
}
/**
- * Return the default value for UserComment property
+ * Return the default value for the UserComment property.
*
+ * @return the default value for the UserComment property or null if it doesn't exist.
+ * @throws BadFieldValueException If the UserComment property is not a multi-lingual property.
* @see ExifSchema#getUserComment(String)
*/
- public String getUserComment()
+ public String getUserComment() throws BadFieldValueException
{
return getUserComment(null);
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/TiffSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/TiffSchema.java?rev=1875953&r1=1875952&r2=1875953&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/TiffSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/TiffSchema.java Tue Mar 31 18:12:57 2020
@@ -24,6 +24,7 @@ import org.apache.xmpbox.XMPMetadata;
import java.util.List;
import org.apache.xmpbox.type.ArrayProperty;
+import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.type.Cardinality;
import org.apache.xmpbox.type.ProperNameType;
import org.apache.xmpbox.type.PropertyType;
@@ -129,7 +130,8 @@ public class TiffSchema extends XMPSchem
}
/**
- * Return the artist property as String
+ * Return the Artist property as String
+ *
* @return string
*/
public String getArtist()
@@ -140,6 +142,7 @@ public class TiffSchema extends XMPSchem
/**
* Set the name of the artist
+ *
* @param text
*/
public void setArtist(String text)
@@ -147,10 +150,10 @@ public class TiffSchema extends XMPSchem
addProperty(createTextType(ARTIST, text));
}
-
/**
- * Return the image description property object
- * @return the image description property
+ * Return the ImageDescription property object.
+ *
+ * @return the ImageDescription property.
*/
public ArrayProperty getImageDescriptionProperty()
{
@@ -158,37 +161,46 @@ public class TiffSchema extends XMPSchem
}
/**
- * Return the list of language existing for image description
- * @return a list of languages
+ * Return the list of language existing for the ImageDescription property.
+ *
+ * @return a list of languages or null if it doesn't exist.
+ * @throws BadFieldValueException If the ImageDescription property is not a multi-lingual
+ * property.
*/
- public List<String> getImageDescriptionLanguages()
+ public List<String> getImageDescriptionLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(IMAGE_DESCRIPTION);
}
/**
- * Return the image description value as String in expected language
+ * Return the ImageDescription property value as String in a specified language.
*
- * @param lang expected language
- * @return image description value
+ * @param lang The expected language.
+ * @return The ImageDescription property value or null if it doesn't exist.
+ * @throws BadFieldValueException If the ImageDescription property is not a multi-lingual
+ * property.
*/
- public String getImageDescription(String lang)
+ public String getImageDescription(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(IMAGE_DESCRIPTION, lang);
}
/**
- * Return the image description as String in default language
- * @return image description value
+ * Return the ImageDescription property as String in the default language.
+ *
+ * @return the ImageDescription value or null if it doesn't exist.
+ * @throws BadFieldValueException If the ImageDescription property is not a multi-lingual
+ * property.
*/
- public String getImageDescription()
+ public String getImageDescription() throws BadFieldValueException
{
return getImageDescription(null);
}
/**
- * Add a image description value for a specified language
- * @param lang language of the image description
+ * Add an ImageDescription value for a specified language.
+ *
+ * @param lang language of the ImageDescription property.
* @param value image description text
*/
public void addImageDescription(String lang, String value)
@@ -197,8 +209,9 @@ public class TiffSchema extends XMPSchem
}
/**
- * Return the copyright property object
- * @return the copyright property
+ * Return the Copyright property object
+ *
+ * @return the Copyright property
*/
public ArrayProperty getCopyRightProperty()
{
@@ -206,36 +219,42 @@ public class TiffSchema extends XMPSchem
}
/**
- * Return the list of language existing for copyright
- * @return a list of languages
+ * Return the list of language existing for the Copyright property.
+ *
+ * @return a list of languages or null if it doesn't exist.
+ * @throws BadFieldValueException If the Copyright property is not a multi-lingual property
*/
- public List<String> getCopyRightLanguages()
+ public List<String> getCopyRightLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(COPYRIGHT);
}
/**
- * Return the copyright value as String in expected language
+ * Return the Copyright value as String in expected language
*
* @param lang expected language
- * @return copyright value
+ * @return copyright value or null if it doesn't exist.
+ * @throws BadFieldValueException If the Copyright property is not a multi-lingual property
*/
- public String getCopyRight(String lang)
+ public String getCopyRight(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(COPYRIGHT, lang);
}
/**
- * Return the copyright value as String in default language
- * @return copyright value
+ * Return the Copyright property value as String in default language
+ *
+ * @return The Copyright property value or null if it doesn't exist.
+ * @throws BadFieldValueException If the Copyright property is not a multi-lingual property
*/
- public String getCopyRight()
+ public String getCopyRight() throws BadFieldValueException
{
return getCopyRight(null);
}
/**
- * Add a copyright value for a specified language
+ * Add a Copyright property value for a specified language
+ *
* @param lang language of the copyright
* @param value copyright text
*/
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java?rev=1875953&r1=1875952&r2=1875953&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPRightsManagementSchema.java Tue Mar 31 18:12:57 2020
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.type.ArrayProperty;
+import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.type.BooleanType;
import org.apache.xmpbox.type.Cardinality;
import org.apache.xmpbox.type.PropertyType;
@@ -197,23 +198,25 @@ public class XMPRightsManagementSchema e
}
/**
- * Return a list of languages defined in description property
+ * Return a list of languages defined in the UsageTerms property
*
- * @return list of languages defined for usageterms
+ * @return list of languages defined for the UsageTerms property or null if it doesn't exist.
+ * @throws BadFieldValueException If the UsageTerms property is not a multi-lingual property.
*/
- public List<String> getUsageTermsLanguages()
+ public List<String> getUsageTermsLanguages() throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyLanguagesValue(USAGETERMS);
}
/**
- * Return a language value for description property
+ * Return a language value for the UsageTerms property
*
* @param lang
* concerned language
- * @return value of specified language
+ * @return value of specified language or null if it doesn't exist.
+ * @throws BadFieldValueException If the UsageTerms property is not a multi-lingual property.
*/
- public String getUsageTerms(String lang)
+ public String getUsageTerms(String lang) throws BadFieldValueException
{
return getUnqualifiedLanguagePropertyValue(USAGETERMS, lang);
}
@@ -221,9 +224,10 @@ public class XMPRightsManagementSchema e
/**
* Get the default usage terms for the document.
*
- * @return The terms for this resource.
+ * @return The terms for this resource or null if it doesn't exist.
+ * @throws BadFieldValueException If the UsageTerms property is not a multi-lingual property.
*/
- public String getUsageTerms()
+ public String getUsageTerms() throws BadFieldValueException
{
return getUsageTerms(null);
}
Modified: pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java?rev=1875953&r1=1875952&r2=1875953&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java (original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/schema/XMPSchema.java Tue Mar 31 18:12:57 2020
@@ -287,12 +287,13 @@ public class XMPSchema extends AbstractS
}
/**
- * Get a TextProperty Type from its name
+ * Get a TextProperty Type by its name
*
* @param name The property name.
- * @return The Text Type property wanted
+ * @return The Text Type property wanted or null if not found.
+ * @throws BadFieldValueException If the property is not a text property.
*/
- public TextType getUnqualifiedTextProperty(String name)
+ public TextType getUnqualifiedTextProperty(String name) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(name);
if (prop != null)
@@ -301,10 +302,7 @@ public class XMPSchema extends AbstractS
{
return (TextType) prop;
}
- else
- {
- throw new IllegalArgumentException("Property asked is not a Text Property");
- }
+ throw new BadFieldValueException("Property asked is not a Text Property");
}
return null;
}
@@ -314,23 +312,25 @@ public class XMPSchema extends AbstractS
*
* @param name The property name.
* @return The value of the text property or null if there is no value.
+ * @throws BadFieldValueException If the property is not a text property.
*
*/
- public String getUnqualifiedTextPropertyValue(String name)
+ public String getUnqualifiedTextPropertyValue(String name) throws BadFieldValueException
{
TextType tt = getUnqualifiedTextProperty(name);
return tt == null ? null : tt.getStringValue();
}
/**
- * Get the Date property with its name
+ * Get a Date property by its name
*
* @param qualifiedName
* The name of the property to get, it must include the namespace prefix, e.g. "pdf:Keywords".
* @return Date Type property
+ * @throws BadFieldValueException If the property is not a date property.
*
*/
- public DateType getDateProperty(String qualifiedName)
+ public DateType getDateProperty(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -339,10 +339,7 @@ public class XMPSchema extends AbstractS
{
return (DateType) prop;
}
- else
- {
- throw new IllegalArgumentException("Property asked is not a Date Property");
- }
+ throw new BadFieldValueException("Property asked is not a Date Property");
}
return null;
}
@@ -353,9 +350,10 @@ public class XMPSchema extends AbstractS
* @param simpleName
* the local name of the property to get
* @return The value of the property as a calendar.
+ * @throws BadFieldValueException If the property is not a date property.
*
*/
- public Calendar getDatePropertyValueAsSimple(String simpleName)
+ public Calendar getDatePropertyValueAsSimple(String simpleName) throws BadFieldValueException
{
return this.getDatePropertyValue(simpleName);
}
@@ -366,10 +364,11 @@ public class XMPSchema extends AbstractS
* @param qualifiedName
* The fully qualified property name for the date.
*
- * @return The value of the property as a date.
+ * @return The value of the property as a date or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not a date property.
*
*/
- public Calendar getDatePropertyValue(String qualifiedName)
+ public Calendar getDatePropertyValue(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -378,10 +377,7 @@ public class XMPSchema extends AbstractS
{
return ((DateType) prop).getValue();
}
- else
- {
- throw new IllegalArgumentException("Property asked is not a Date Property");
- }
+ throw new BadFieldValueException("Property asked is not a Date Property");
}
return null;
}
@@ -424,13 +420,14 @@ public class XMPSchema extends AbstractS
}
/**
- * Get a BooleanType property with its name
+ * Get a BooleanType property by its name.
*
* @param qualifiedName
* the full qualified name of property wanted
- * @return boolean Type property
+ * @return boolean Type property or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not a boolean property.
*/
- public BooleanType getBooleanProperty(String qualifiedName)
+ public BooleanType getBooleanProperty(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -441,7 +438,7 @@ public class XMPSchema extends AbstractS
}
else
{
- throw new IllegalArgumentException("Property asked is not a Boolean Property");
+ throw new BadFieldValueException("Property asked is not a Boolean Property");
}
}
return null;
@@ -453,8 +450,9 @@ public class XMPSchema extends AbstractS
* @param simpleName
* the local name of property wanted
* @return The value of the property as a boolean or null if the property does not exist.
+ * @throws BadFieldValueException If the property is not a boolean property.
*/
- public Boolean getBooleanPropertyValueAsSimple(String simpleName)
+ public Boolean getBooleanPropertyValueAsSimple(String simpleName) throws BadFieldValueException
{
return this.getBooleanPropertyValue(simpleName);
}
@@ -467,8 +465,9 @@ public class XMPSchema extends AbstractS
*
* @return The value of the property as a Boolean, or null if the property
* does not exist.
+ * @throws BadFieldValueException If the property is not a boolean property.
*/
- public Boolean getBooleanPropertyValue(String qualifiedName)
+ public Boolean getBooleanPropertyValue(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -479,7 +478,7 @@ public class XMPSchema extends AbstractS
}
else
{
- throw new IllegalArgumentException("Property asked is not a Boolean Property");
+ throw new BadFieldValueException("Property asked is not a Boolean Property");
}
}
return null;
@@ -523,13 +522,14 @@ public class XMPSchema extends AbstractS
}
/**
- * Get the Integer property with its name
+ * Get the Integer property by its name
*
* @param qualifiedName
* the full qualified name of property wanted
- * @return Integer Type property
+ * @return Integer Type property or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not an integer property.
*/
- public IntegerType getIntegerProperty(String qualifiedName)
+ public IntegerType getIntegerProperty(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -538,10 +538,7 @@ public class XMPSchema extends AbstractS
{
return ((IntegerType) prop);
}
- else
- {
- throw new IllegalArgumentException("Property asked is not an Integer Property");
- }
+ throw new BadFieldValueException("Property asked is not an Integer Property");
}
return null;
}
@@ -551,9 +548,10 @@ public class XMPSchema extends AbstractS
*
* @param simpleName
* the local name of property wanted
- * @return The value of the property as an integer.
+ * @return The value of the property as an integer or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not an integer property.
*/
- public Integer getIntegerPropertyValueAsSimple(String simpleName)
+ public Integer getIntegerPropertyValueAsSimple(String simpleName) throws BadFieldValueException
{
return this.getIntegerPropertyValue(simpleName);
}
@@ -564,9 +562,10 @@ public class XMPSchema extends AbstractS
* @param qualifiedName
* The fully qualified property name for the integer.
*
- * @return The value of the property as an integer.
+ * @return The value of the property as an integer or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not an integer property.
*/
- public Integer getIntegerPropertyValue(String qualifiedName)
+ public Integer getIntegerPropertyValue(String qualifiedName) throws BadFieldValueException
{
AbstractField prop = getAbstractProperty(qualifiedName);
if (prop != null)
@@ -575,10 +574,7 @@ public class XMPSchema extends AbstractS
{
return ((IntegerType) prop).getValue();
}
- else
- {
- throw new IllegalArgumentException("Property asked is not an Integer Property");
- }
+ throw new BadFieldValueException("Property asked is not an Integer Property");
}
return null;
}
@@ -1069,9 +1065,10 @@ public class XMPSchema extends AbstractS
* @param expectedLanguage
* The language code of the value. If null then "x-default" is assumed.
*
- * @return The value of the language property.
+ * @return The value of the language property or null if it doesn't exist.
+ * @throws BadFieldValueException If the property is not a multi-lingual property.
*/
- public String getUnqualifiedLanguagePropertyValue(String name, String expectedLanguage)
+ public String getUnqualifiedLanguagePropertyValue(String name, String expectedLanguage) throws BadFieldValueException
{
String language = (expectedLanguage != null) ? expectedLanguage : XmpConstants.X_DEFAULT;
AbstractField property = getAbstractProperty(name);
@@ -1090,10 +1087,7 @@ public class XMPSchema extends AbstractS
}
return null;
}
- else
- {
- throw new IllegalArgumentException("The property '" + name + "' is not of Lang Alt type");
- }
+ throw new BadFieldValueException("The property '" + name + "' is not of Lang Alt type");
}
return null;
}
@@ -1107,8 +1101,9 @@ public class XMPSchema extends AbstractS
*
* @return A list of all languages, this will return an non-null empty list
* if none have been defined, and null if the property doesn't exist.
+ * @throws BadFieldValueException If the property is not a multi-lingual property.
*/
- public List<String> getUnqualifiedLanguagePropertyLanguagesValue(String name)
+ public List<String> getUnqualifiedLanguagePropertyLanguagesValue(String name) throws BadFieldValueException
{
AbstractField property = getAbstractProperty(name);
if (property != null)
@@ -1131,10 +1126,7 @@ public class XMPSchema extends AbstractS
}
return retval;
}
- else
- {
- throw new IllegalArgumentException("The property '" + name + "' is not of Lang Alt type");
- }
+ throw new BadFieldValueException("The property '" + name + "' is not of Lang Alt type");
}
// no property with that name
return null;