Commit c1b78910 authored by cdanger's avatar cdanger

Refactored 'new IllegalArgumentException(constant_string)' into

constants
parent 892a9f2f
......@@ -34,6 +34,8 @@ import org.ow2.authzforce.core.pdp.api.SingleCategoryAttributes;
*/
public class MutableIndividualDecisionRequest implements IndividualDecisionRequest
{
private static final IllegalArgumentException UNDEF_ATTRIBUTES_EXCEPTION = new IllegalArgumentException("Undefined attributes");
private static final IllegalArgumentException UNDEF_ATTRIBUTE_CATEGORY_EXCEPTION = new IllegalArgumentException("Undefined attribute category");
private final Map<AttributeGUID, Bag<?>> namedAttributes;
private final Map<String, XdmNode> extraContentsByCategory;
private final List<Attributes> attributesToIncludeInResult;
......@@ -86,12 +88,12 @@ public class MutableIndividualDecisionRequest implements IndividualDecisionReque
{
if (categoryName == null)
{
throw new IllegalArgumentException("Undefined attribute category");
throw UNDEF_ATTRIBUTE_CATEGORY_EXCEPTION;
}
if (categorySpecificAttributes == null)
{
throw new IllegalArgumentException("Undefined attributes");
throw UNDEF_ATTRIBUTES_EXCEPTION;
}
/*
......
......@@ -138,6 +138,8 @@ public class SchemaHandler
*/
private static class OASISCatalogManager
{
private static final IllegalArgumentException ERROR_CREATING_CATALOG_RESOLVER_EXCEPTION = new IllegalArgumentException("Error creating org.apache.xml.resolver.tools.CatalogResolver for OASIS CatalogManager");
private final static Logger _LOGGER = LoggerFactory.getLogger(OASISCatalogManager.class);
private final CatalogResolver resolver;
......@@ -149,7 +151,7 @@ public class SchemaHandler
resolver = getResolver();
if (resolver == null)
{
throw new IllegalArgumentException("Error creating org.apache.xml.resolver.tools.CatalogResolver for OASIS CatalogManager");
throw ERROR_CREATING_CATALOG_RESOLVER_EXCEPTION;
}
catalog = getCatalog(resolver);
......
......@@ -51,6 +51,8 @@ public class RulePepActionExpressionsEvaluator
*/
private static class ActionExpressionsParser implements PepActionExpressions
{
private static final IllegalArgumentException UNDEF_RULE_EFFECT_ILLEGAL_ARGUMENT_EXCEPTION = new IllegalArgumentException("Undefined Rule's Effect to which obligations/advice must apply");
private static final Logger LOGGER = LoggerFactory.getLogger(ActionExpressionsParser.class);
private final XPathCompiler xPathCompiler;
......@@ -71,7 +73,7 @@ public class RulePepActionExpressionsEvaluator
{
if (ruleEffect == null)
{
throw new IllegalArgumentException("Undefined Rule's Effect to which obligations/advice must apply");
throw UNDEF_RULE_EFFECT_ILLEGAL_ARGUMENT_EXCEPTION;
}
this.ruleEffectMatchingActionExpressions = new EffectSpecific(ruleEffect);
......
......@@ -27,6 +27,11 @@ import javax.xml.bind.DatatypeConverter;
*/
public final class IntegerValue extends NumericValue<BigInteger, IntegerValue> implements Comparable<IntegerValue>
{
private static final IllegalArgumentException TOO_BIGINTEGER_FOR_DOUBLE_ILLEGAL_ARGUMENT_EXCEPTION = new IllegalArgumentException(
"BigInteger argument outside the range which can be represented by a double");
private static final ArithmeticException TOO_BIGINTEGER_FOR_INT_ARITHMETIC_EXCEPTION = new ArithmeticException("BigInteger argument outside the range which can be represented by an int");
/**
* Official name of this type
*/
......@@ -164,22 +169,12 @@ public final class IntegerValue extends NumericValue<BigInteger, IntegerValue> i
if (Double.isInfinite(doubleVal) || Double.isNaN(doubleVal))
{
// this BigInteger has too great a magnitude to represent as a double
throw new IllegalArgumentException("integer argument outside the range which can be represented by a double");
throw TOO_BIGINTEGER_FOR_DOUBLE_ILLEGAL_ARGUMENT_EXCEPTION;
}
return doubleVal;
}
// public int intValueExact() throws ArithmeticException
// {
// if (value.compareTo(MAX_INT_AS_BIGINT) == 1 || value.compareTo(MIN_INT_AS_BIGINT) == -1)
// {
// throw new ArithmeticException("Integer overflow");
// }
//
// return value.intValue();
// }
/**
*
* Converts BigInteger to an int, checking for lost information. If the value of this BigInteger is out of the range of the int type, then an ArithmeticException is thrown.
......@@ -198,7 +193,7 @@ public final class IntegerValue extends NumericValue<BigInteger, IntegerValue> i
{
if (val.compareTo(MAX_INT_AS_BIGINT) == 1 || val.compareTo(MIN_INT_AS_BIGINT) == -1)
{
throw new ArithmeticException("Integer overflow");
throw TOO_BIGINTEGER_FOR_INT_ARITHMETIC_EXCEPTION;
}
return val.intValue();
......
......@@ -31,6 +31,8 @@ import javax.mail.internet.InternetAddress;
public final class RFC822NameValue extends SimpleValue<String>
{
private static final IllegalArgumentException INVALID_RFC822NAME_MATCH_ARG0_EXCEPTION = new IllegalArgumentException("Invalid first arg to function 'rfc822Name-match': empty string");
/**
* Official name of this type
*/
......@@ -182,7 +184,7 @@ public final class RFC822NameValue extends SimpleValue<String>
if (maybePartialRfc822Name.isEmpty())
{
throw new IllegalArgumentException("Invalid first arg to function 'rfc822Name-match': empty string");
throw INVALID_RFC822NAME_MATCH_ARG0_EXCEPTION;
}
if (maybePartialRfc822Name.charAt(0) == '.')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment