Author: rhauch
Date: 2008-08-19 17:24:05 -0400 (Tue, 19 Aug 2008)
New Revision: 450
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidValueFactory.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/UuidValueFactoryTest.java
Log:
DNA-96 - ValueFormatException should be replaced by existing JDK IllegalArgumentException
and UnsupportedOperationException in ValueFactories
http://jira.jboss.com/jira/browse/DNA-96
Changed to rely upon a ValueFormatException for all conversions, and the IoException only
on conversions that take (or might take) a Binary, InputStream, or Reader. Also added
methods to the ValueFactory that create from a DateTime and from a Binary (not sure why
these were never added).
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -63,10 +63,10 @@
*
* @param value the string from which the value is to be created
* @return the value, or null if the supplied string is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a string could not be
performed
* @see #create(String, TextDecoder)
*/
- T create( String value ) throws IoException;
+ T create( String value ) throws ValueFormatException;
/**
* Create a value from a string, using the supplied decoder.
@@ -74,148 +74,169 @@
* @param value the string from which the value is to be created
* @param decoder the decoder that should be used; if null, the {@link
#DEFAULT_DECODER default decoder} is used
* @return the value, or null if the supplied string is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a string could not be
performed
* @see #create(String)
*/
T create( String value,
- TextDecoder decoder ) throws IoException;
+ TextDecoder decoder ) throws ValueFormatException;
/**
* Create a value from an integer.
*
* @param value the integer from which the value is to be created
* @return the value; never null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an integer could not be
performed
*/
- T create( int value ) throws IoException;
+ T create( int value ) throws ValueFormatException;
/**
* Create a long from a string.
*
* @param value the string from which the long is to be created
* @return the value; never null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a long could not be performed
*/
- T create( long value ) throws IoException;
+ T create( long value ) throws ValueFormatException;
/**
* Create a boolean from a string.
*
* @param value the boolean from which the value is to be created
* @return the value; never null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a boolean could not be
performed
*/
- T create( boolean value ) throws IoException;
+ T create( boolean value ) throws ValueFormatException;
/**
* Create a value from a float.
*
* @param value the float from which the value is to be created
* @return the value; never null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a float could not be
performed
*/
- T create( float value ) throws IoException;
+ T create( float value ) throws ValueFormatException;
/**
* Create a value from a double.
*
* @param value the double from which the value is to be created
* @return the value; never null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a double could not be
performed
*/
- T create( double value ) throws IoException;
+ T create( double value ) throws ValueFormatException;
/**
* Create a value from a decimal.
*
* @param value the decimal from which the value is to be created
* @return the value, or null if the supplied decimal is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a decimal could not be
performed
*/
- T create( BigDecimal value ) throws IoException;
+ T create( BigDecimal value ) throws ValueFormatException;
/**
* Create a value from a Calendar instance.
*
* @param value the Calendar instance from which the value is to be created
* @return the value, or null if the supplied Calendar is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a Calendar could not be
performed
*/
- T create( Calendar value ) throws IoException;
+ T create( Calendar value ) throws ValueFormatException;
/**
* Create a value from a date.
*
* @param value the date from which the value is to be created
* @return the value, or null if the supplied date is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a Date could not be performed
*/
- T create( Date value ) throws IoException;
+ T create( Date value ) throws ValueFormatException;
/**
+ * Create a value from a date-time instant.
+ *
+ * @param value the date-time instant from which the value is to be created
+ * @return the value, or null if the supplied date is null
+ * @throws ValueFormatException if the conversion from a Date could not be performed
+ */
+ T create( DateTime value ) throws ValueFormatException;
+
+ /**
* Create a value from a name.
*
* @param value the name from which the value is to be created
* @return the value, or null if the supplied name is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a name could not be performed
*/
- T create( Name value ) throws IoException;
+ T create( Name value ) throws ValueFormatException;
/**
* Create a value from a path.
*
* @param value the path from which the value is to be created
* @return the value, or null if the supplied path is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a path could not be performed
*/
- T create( Path value ) throws IoException;
+ T create( Path value ) throws ValueFormatException;
/**
* Create a value from a reference.
*
* @param value the reference from which the value is to be created
* @return the value, or null if the supplied reference is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a reference could not be
performed
*/
- T create( Reference value ) throws IoException;
+ T create( Reference value ) throws ValueFormatException;
/**
* Create a value from a URI.
*
* @param value the URI from which the value is to be created
* @return the value, or null if the supplied URI is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a URI could not be performed
*/
- T create( URI value ) throws IoException;
+ T create( URI value ) throws ValueFormatException;
/**
* Create a value from a UUID.
*
* @param value the UUID from which the value is to be created
* @return the value, or null if the supplied URI is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a UUID could not be performed
*/
- T create( UUID value ) throws IoException;
+ T create( UUID value ) throws ValueFormatException;
/**
* Create a value from the binary content given by the supplied array.
*
* @param value the content to be used to create the value
* @return the value, or null if the supplied stream is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a byte array could not be
performed
*/
- T create( byte[] value ) throws IoException;
+ T create( byte[] value ) throws ValueFormatException;
/**
* Create a value from the binary content given by the supplied stream.
*
+ * @param value the binary object to be used to create the value
+ * @return the value, or null if the supplied stream is null
+ * @throws ValueFormatException if the conversion from the binary object could not be
performed
+ * @throws IoException If an unexpected problem occurs while accessing the supplied
binary value (such as an
+ * {@link IOException}).
+ */
+ T create( Binary value ) throws ValueFormatException, IoException;
+
+ /**
+ * Create a value from the binary content given by the supplied stream.
+ *
* @param stream the stream containing the content to be used to create the value
* @param approximateLength the approximate length of the content (in bytes)
* @return the value, or null if the supplied stream is null
- * @throws IoException If an unexpected problem occurs during the conversion (such as
an {@link IOException}).
+ * @throws ValueFormatException if the conversion from an input stream could not be
performed
+ * @throws IoException If an unexpected problem occurs while accessing the supplied
stream (such as an {@link IOException}).
*/
T create( InputStream stream,
- int approximateLength ) throws IoException;
+ long approximateLength ) throws ValueFormatException, IoException;
/**
* Create a value from a the binary content given by the supplied reader.
@@ -223,31 +244,34 @@
* @param reader the reader containing the content to be used to create the value
* @param approximateLength the approximate length of the content (in bytes)
* @return the value, or null if the supplied string is null
- * @throws IoException If an unexpected problem occurs during the conversion (such as
an {@link IOException}).
+ * @throws ValueFormatException if the conversion from a reader could not be
performed
+ * @throws IoException If an unexpected problem occurs while accessing the supplied
reader (such as an {@link IOException}).
*/
T create( Reader reader,
- int approximateLength ) throws IoException;
+ long approximateLength ) throws ValueFormatException, IoException;
/**
* Create a value from the specified information by determining which other
<code>create</code> method applies and delegating
* to that method. Note that this method only will call
<code>create</code> methods that take a single parameter; so this
- * excludes {@link #create(InputStream, int)}, {@link #create(Reader, int)} and
{@link #create(String, TextDecoder)}.
+ * excludes {@link #create(InputStream, long)}, {@link #create(Reader, long)} and
{@link #create(String, TextDecoder)}.
*
* @param value the value
* @return the new value, or null if the supplied parameter is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an object could not be
performed
+ * @throws IoException If an unexpected problem occurs while accessing the supplied
binary value (such as an
+ * {@link IOException}).
*/
- T create( Object value ) throws IoException;
+ T create( Object value ) throws ValueFormatException, IoException;
/**
* Create an array of values from an array of string values, using no decoding.
*
* @param values the values
* @return the values, or null if the supplied string is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a string array could not be
performed
* @see #create(String[], TextDecoder)
*/
- T[] create( String[] values ) throws IoException;
+ T[] create( String[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of strings, using the supplied decoder.
@@ -255,161 +279,183 @@
* @param values the string values from which the values are to be created
* @param decoder the decoder that should be used; if null, the {@link
#DEFAULT_DECODER default decoder} is used
* @return the value, or null if the supplied string is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from a string array could not be
performed
* @see #create(String)
*/
T[] create( String[] values,
- TextDecoder decoder ) throws IoException;
+ TextDecoder decoder ) throws ValueFormatException;
/**
* Create an array of values from an array of integers.
*
* @param values the integers from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an integer array could not be
performed
*/
- T[] create( int[] values ) throws IoException;
+ T[] create( int[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of longs.
*
* @param values the longs from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of longs could not be
performed
*/
- T[] create( long[] values ) throws IoException;
+ T[] create( long[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of booleans.
*
* @param values the booleans from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of booleans could not
be performed
*/
- T[] create( boolean[] values ) throws IoException;
+ T[] create( boolean[] values ) throws ValueFormatException;
/**
- * Create an array of values from an array of booleans.
+ * Create an array of values from an array of floats.
*
* @param values the floats from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of floats could not
be performed
*/
- T[] create( float[] values ) throws IoException;
+ T[] create( float[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of doubles.
*
* @param values the doubles from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of doubles could not
be performed
*/
- T[] create( double[] values ) throws IoException;
+ T[] create( double[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of decimal values.
*
* @param values the decimals from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of decimal values
could not be performed
*/
- T[] create( BigDecimal[] values ) throws IoException;
+ T[] create( BigDecimal[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of Calendar instances.
*
* @param values the Calendar instances from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of calendar instances
could not be performed
*/
- T[] create( Calendar[] values ) throws IoException;
+ T[] create( Calendar[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of dates.
*
* @param values the dates from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of date values could
not be performed
*/
- T[] create( Date[] values ) throws IoException;
+ T[] create( Date[] values ) throws ValueFormatException;
/**
+ * Create an array of values from an array of {@link DateTime} instants.
+ *
+ * @param values the instants from which the values are to be created
+ * @return the values, or null if the supplied array is null
+ * @throws ValueFormatException if the conversion from an array of date values could
not be performed
+ */
+ T[] create( DateTime[] values ) throws ValueFormatException;
+
+ /**
* Create an array of values from an array of names.
*
* @param values the names from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of names could not be
performed
*/
- T[] create( Name[] values ) throws IoException;
+ T[] create( Name[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of paths.
*
* @param values the paths from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of paths could not be
performed
*/
- T[] create( Path[] values ) throws IoException;
+ T[] create( Path[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of references.
*
* @param values the references from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of references could
not be performed
*/
- T[] create( Reference[] values ) throws IoException;
+ T[] create( Reference[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of URIs.
*
* @param values the URIs from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of URIs could not be
performed
*/
- T[] create( URI[] values ) throws IoException;
+ T[] create( URI[] values ) throws ValueFormatException;
/**
* Create an array of values from an array of UUIDs.
*
* @param values the UUIDs from which the values are to be created
* @return the values, or null if the supplied array is null
- * @throws IoException If an unexpected problem occurs during the conversion.
+ * @throws ValueFormatException if the conversion from an array of UUIDs could not be
performed
*/
- T[] create( UUID[] values ) throws IoException;
+ T[] create( UUID[] values ) throws ValueFormatException;
/**
* Create an array of values from the array of binary content.
*
* @param values the array of content to be used to create the values
* @return the value, or null if the supplied array is null
+ * @throws ValueFormatException if the conversion from an array of byte arrays could
not be performed
+ */
+ T[] create( byte[][] values ) throws ValueFormatException;
+
+ /**
+ * Create an array of values from the array of binary objects.
+ *
+ * @param values the values
+ * @return the new value, or null if the supplied parameter is null
+ * @throws ValueFormatException if the conversion from an array of objects could not
be performed
* @throws IoException If an unexpected problem occurs during the conversion.
*/
- T[] create( byte[][] values ) throws IoException;
+ T[] create( Binary[] values ) throws ValueFormatException, IoException;
/**
* Create an array of values from the specified information by determining which
other <code>create</code> method applies for
- * each object and then delegating to that method. Note that this method will not
consider {@link #create(InputStream, int)},
- * {@link #create(Reader, int)} and {@link #create(String, TextDecoder)}.
+ * each object and then delegating to that method. Note that this method will not
consider {@link #create(InputStream, long)},
+ * {@link #create(Reader, long)} and {@link #create(String, TextDecoder)}.
*
* @param values the values
* @return the new value, or null if the supplied parameter is null
+ * @throws ValueFormatException if the conversion from an array of objects could not
be performed
* @throws IoException If an unexpected problem occurs during the conversion.
*/
- T[] create( Object[] values ) throws IoException;
+ T[] create( Object[] values ) throws ValueFormatException, IoException;
/**
* Create an iterator over the values (of an unknown type). The factory converts any
values as required. Note that this method
- * will not consider {@link #create(InputStream, int)}, {@link #create(Reader, int)}
and {@link #create(String, TextDecoder)}.
+ * will not consider {@link #create(InputStream, long)}, {@link #create(Reader,
long)} and
+ * {@link #create(String, TextDecoder)}.
* <p>
* This is useful to use when iterating over the {@link Property#getValues() values}
of a {@link Property}.
* </p>
*
* @param values the values
* @return the iterator of type <code>T</code> over the values, or null
if the supplied parameter is null
+ * @throws ValueFormatException if the conversion from an iterator of objects could
not be performed
* @throws IoException If an unexpected problem occurs during the conversion.
* @see Property#getValues()
*/
- Iterator<T> create( Iterator<?> values ) throws IoException;
+ Iterator<T> create( Iterator<?> values ) throws ValueFormatException,
IoException;
}
Added: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
(rev 0)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.spi.graph;
+
+/**
+ * @author Randall Hauch
+ */
+public class ValueFormatException extends RuntimeException {
+
+ /**
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final Object value;
+ private final PropertyType targetType;
+
+ /**
+ * @param value the value that was not able to be converted
+ * @param targetType the {@link PropertyType} to which the value was being converted
+ */
+ public ValueFormatException( Object value,
+ PropertyType targetType ) {
+ this.value = value;
+ this.targetType = targetType;
+ }
+
+ /**
+ * @param value the value that was not able to be converted
+ * @param targetType the {@link PropertyType} to which the value was being converted
+ * @param message the message
+ */
+ public ValueFormatException( Object value,
+ PropertyType targetType,
+ String message ) {
+ super(message);
+ this.value = value;
+ this.targetType = targetType;
+ }
+
+ /**
+ * @param value the value that was not able to be converted
+ * @param targetType the {@link PropertyType} to which the value was being converted
+ * @param cause the cause of the exception
+ */
+ public ValueFormatException( Object value,
+ PropertyType targetType,
+ Throwable cause ) {
+ super(cause);
+ this.value = value;
+ this.targetType = targetType;
+ }
+
+ /**
+ * @param value the value that was not able to be converted
+ * @param targetType the {@link PropertyType} to which the value was being converted
+ * @param message the message
+ * @param cause the cause of the exception
+ */
+ public ValueFormatException( Object value,
+ PropertyType targetType,
+ String message,
+ Throwable cause ) {
+ super(message, cause);
+ this.value = value;
+ this.targetType = targetType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+
+ /**
+ * Get the {@link PropertyType} to which the {@link #getValue() value} was being
converted.
+ *
+ * @return the target type
+ */
+ public PropertyType getTargetType() {
+ return targetType;
+ }
+
+ /**
+ * Get the original value that was being converted.
+ *
+ * @return the value
+ */
+ public Object getValue() {
+ return value;
+ }
+}
Property changes on:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* Abstract {@link ValueFactory}.
@@ -188,7 +191,22 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime[])
*/
+ public T[] create( DateTime[] values ) throws ValueFormatException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public T[] create( double[] values ) {
if (values == null) return null;
final int length = values.length;
@@ -335,7 +353,7 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID[])
*/
- public T[] create( UUID[] values ) throws IoException {
+ public T[] create( UUID[] values ) {
if (values == null) return null;
final int length = values.length;
T[] result = createEmptyArray(length);
@@ -345,6 +363,21 @@
return result;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary[])
+ */
+ public T[] create( Binary[] values ) throws ValueFormatException, IoException {
+ if (values == null) return null;
+ final int length = values.length;
+ T[] result = createEmptyArray(length);
+ for (int i = 0; i != length; ++i) {
+ result[i] = create(values[i]);
+ }
+ return result;
+ }
+
protected static class ConvertingIterator<ValueType> implements
Iterator<ValueType> {
private final Iterator<?> delegate;
private final ValueFactory<ValueType> factory;
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#BOOLEAN} values.
@@ -74,18 +77,18 @@
* {@inheritDoc}
*/
public Boolean create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Integer.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Long.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
@@ -99,81 +102,94 @@
* {@inheritDoc}
*/
public Boolean create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Float.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Double.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
BigDecimal.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Boolean create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Calendar.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Boolean create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Boolean create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Name.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Path.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Boolean create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Boolean create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
URI.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -181,10 +197,10 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public Boolean create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ public Boolean create( UUID value ) {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -197,9 +213,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Boolean create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Boolean create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -208,7 +234,7 @@
* {@inheritDoc}
*/
public Boolean create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DECIMAL} values.
@@ -61,9 +64,10 @@
try {
return new BigDecimal(value.trim());
} catch (NumberFormatException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
BigDecimal.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
BigDecimal.class.getSimpleName(),
+ value),
err);
}
}
@@ -94,9 +98,9 @@
* {@inheritDoc}
*/
public BigDecimal create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Boolean.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
@@ -138,38 +142,49 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public BigDecimal create( DateTime value ) throws ValueFormatException {
+ if (value == null) return null;
+ return create(value.getMilliseconds());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public BigDecimal create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Name.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public BigDecimal create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Path.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public BigDecimal create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public BigDecimal create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
URI.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -178,9 +193,9 @@
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
public BigDecimal create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -193,9 +208,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public BigDecimal create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public BigDecimal create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -204,7 +229,7 @@
* {@inheritDoc}
*/
public BigDecimal create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DOUBLE} values.
@@ -61,9 +64,10 @@
try {
return Double.valueOf(value.trim());
} catch (NumberFormatException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Double.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Double.class.getSimpleName(),
+ value),
err);
}
}
@@ -94,9 +98,9 @@
* {@inheritDoc}
*/
public Double create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Double.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
@@ -120,9 +124,10 @@
if (value == null) return null;
double result = value.doubleValue();
if (result == Double.NEGATIVE_INFINITY || result == Double.POSITIVE_INFINITY) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(BigDecimal.class.getSimpleName(),
-
Double.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(BigDecimal.class.getSimpleName(),
+
Double.class.getSimpleName(),
+ value));
}
return result;
}
@@ -145,38 +150,49 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Double create( DateTime value ) throws ValueFormatException {
+ if (value == null) return null;
+ return create(value.getMilliseconds());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Double create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Name.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Double create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Path.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Double create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Double create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
URI.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -184,10 +200,10 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public Double create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ public Double create( UUID value ) {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -200,9 +216,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Double create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Double create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -211,7 +237,7 @@
* {@inheritDoc}
*/
public Double create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,12 +36,14 @@
import org.jboss.dna.common.util.IoUtil;
import org.jboss.dna.spi.SpiI18n;
import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* Teh standard {@link ValueFactory} for {@link PropertyType#BINARY} values.
@@ -67,9 +69,10 @@
try {
return create(value.getBytes(CHAR_SET_NAME));
} catch (UnsupportedEncodingException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Binary.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Binary.class.getSimpleName(),
+ value),
err);
}
}
@@ -148,7 +151,17 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Binary create( DateTime value ) throws ValueFormatException {
+ // Convert the value to a string, then to a binary ...
+ return create(this.getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Binary create( Name value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
@@ -183,7 +196,7 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public Binary create( UUID value ) throws IoException {
+ public Binary create( UUID value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -197,9 +210,18 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Binary create( Binary value ) throws ValueFormatException, IoException {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Binary create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
if (stream == null) return null;
try {
byte[] value = IoUtil.readBytes(stream);
@@ -215,7 +237,7 @@
* {@inheritDoc}
*/
public Binary create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
if (reader == null) return null;
// Convert the value to a string, then to a binary ...
try {
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,6 +32,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.DateTimeFactory;
import org.jboss.dna.spi.graph.IoException;
@@ -40,6 +41,7 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.joda.time.DateTimeZone;
/**
@@ -64,9 +66,10 @@
try {
return new JodaDateTime(value.trim());
} catch (IllegalArgumentException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
DateTime.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
DateTime.class.getSimpleName(),
+ value),
err);
}
}
@@ -97,9 +100,9 @@
* {@inheritDoc}
*/
public DateTime create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -142,38 +145,48 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public DateTime create( DateTime value ) throws ValueFormatException {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public DateTime create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Name.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public DateTime create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Path.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public DateTime create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public DateTime create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
URI.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -181,10 +194,10 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public DateTime create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ public DateTime create( UUID value ) {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -197,9 +210,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public DateTime create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public DateTime create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -208,7 +231,7 @@
* {@inheritDoc}
*/
public DateTime create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#LONG} values.
@@ -61,9 +64,10 @@
try {
return Long.valueOf(value.trim());
} catch (NumberFormatException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Long.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Long.class.getSimpleName(),
+ value),
err);
}
}
@@ -94,9 +98,9 @@
* {@inheritDoc}
*/
public Long create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Long.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
@@ -139,38 +143,49 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Long create( DateTime value ) throws ValueFormatException {
+ if (value == null) return null;
+ return value.getMilliseconds();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Long create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Name.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Long create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Path.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Long create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Long create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
URI.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -179,9 +194,9 @@
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
public Long create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -194,9 +209,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Long create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Long create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -205,7 +230,7 @@
* {@inheritDoc}
*/
public Long create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -35,6 +35,8 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NameFactory;
@@ -44,6 +46,7 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#NAME} values.
@@ -114,13 +117,14 @@
return new BasicName(namespaceUri, localName);
}
} catch (NamespaceException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Name.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Name.class.getSimpleName(),
+ value),
err);
}
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Name.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
@@ -148,77 +152,89 @@
* {@inheritDoc}
*/
public Name create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Name create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Name create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Name create( Name value ) {
return value;
}
@@ -232,18 +248,19 @@
// A relative name of length 1 is converted to a name
return value.getSegment(0).getName();
}
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(Path.class.getSimpleName(),
-
Name.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.errorConvertingType.text(Path.class.getSimpleName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Name create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
@@ -259,9 +276,9 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
-
Path.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
@@ -270,9 +287,9 @@
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
public Name create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -285,9 +302,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Name create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Name create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -296,7 +323,7 @@
* {@inheritDoc}
*/
public Name create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -33,12 +33,14 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#OBJECT} values.
@@ -139,7 +141,16 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Object create( DateTime value ) {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Object create( Name value ) {
return value;
}
@@ -203,9 +214,18 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Object create( Binary value ) throws ValueFormatException, IoException {
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Object create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) {
return getBinaryValueFactory().create(stream, approximateLength);
}
@@ -213,7 +233,7 @@
* {@inheritDoc}
*/
public Object create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) {
return getBinaryValueFactory().create(reader, approximateLength);
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -37,6 +37,8 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
@@ -44,6 +46,7 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.jboss.dna.spi.graph.Path.Segment;
/**
@@ -144,7 +147,7 @@
List<Segment> segments = new ArrayList<Segment>();
String[] pathSegments = DELIMITER_PATTERN.split(trimmedValue);
if (pathSegments.length == 0) {
- throw new
IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
if (decoder == null) decoder = getDecoder();
assert pathSegments.length != 0;
@@ -153,7 +156,7 @@
assert segment != null;
segment = segment.trim();
if (segment.length() == 0) {
- throw new
IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
// Create the name and add a segment with it ...
segments.add(createSegment(segment, decoder));
@@ -167,82 +170,98 @@
* {@inheritDoc}
*/
public Path create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Path create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Path create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Path create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Path create( Name value ) {
if (value == null) return null;
- List<Path.Segment> segments = new ArrayList<Path.Segment>(1);
- segments.add(new BasicPathSegment(value));
- return new BasicPath(segments, true);
+ try {
+ List<Path.Segment> segments = new ArrayList<Path.Segment>(1);
+ segments.add(new BasicPathSegment(value));
+ return new BasicPath(segments, true);
+ } catch (IllegalArgumentException e) {
+ throw new ValueFormatException(value, getPropertyType(), e);
+ }
}
/**
@@ -519,7 +538,8 @@
return new
BasicPathSegment(this.nameValueFactory.create(segmentName.substring(0, startBracketNdx),
decoder),
Integer.parseInt(ndx));
} catch (NumberFormatException err) {
- throw new
IllegalArgumentException(SpiI18n.invalidIndexInSegmentName.text(ndx, segmentName));
+ throw new ValueFormatException(segmentName, getPropertyType(),
SpiI18n.invalidIndexInSegmentName.text(ndx,
+
segmentName));
}
}
@@ -538,9 +558,10 @@
* {@inheritDoc}
*/
public Path create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
@@ -556,9 +577,9 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
-
Path.class.getSimpleName(),
- value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
@@ -566,10 +587,10 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public Path create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ public Path create( UUID value ) {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -582,9 +603,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Path create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Path create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -593,7 +624,7 @@
* {@inheritDoc}
*/
public Path create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,13 +36,17 @@
import org.jboss.dna.common.text.TextEncoder;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.IoUtil;
+import org.jboss.dna.common.util.Logger;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#STRING} values.
@@ -155,7 +159,17 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public String create( DateTime value ) throws ValueFormatException {
+ if (value == null) return null;
+ return value.getString(); // ISO representation
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String create( Name value ) {
if (value == null) return null;
return value.getString(getEncoder());
@@ -203,26 +217,52 @@
try {
return new String(value, "UTF-8");
} catch (UnsupportedEncodingException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(byte[].class.getSimpleName(),
-
String.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(byte[].class.getSimpleName(),
+
String.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public String create( Binary value ) throws ValueFormatException, IoException {
+ if (value == null) return null;
+ try {
+ value.acquire();
+ InputStream stream = value.getStream();
+ try {
+ return create(stream, value.getSize());
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ Logger.getLogger(getClass()).debug(e, "Error closing the stream
while converting from Binary to String");
+ }
+ }
+ } finally {
+ value.release();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
if (stream == null) return null;
byte[] value = null;
try {
value = IoUtil.readBytes(stream);
return new String(value, "UTF-8");
} catch (UnsupportedEncodingException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(InputStream.class.getSimpleName(),
-
String.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(InputStream.class.getSimpleName(),
+
String.class.getSimpleName(),
+ value),
err);
} catch (IOException err) {
throw new IoException(
SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
String.class.getSimpleName()),
@@ -234,7 +274,7 @@
* {@inheritDoc}
*/
public String create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
if (reader == null) return null;
try {
return IoUtil.read(reader);
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -34,6 +34,8 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NamespaceRegistry;
@@ -41,6 +43,7 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#URI} values.
@@ -69,9 +72,10 @@
try {
return new URI(value);
} catch (URISyntaxException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
URI.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
URI.class.getSimpleName(),
+ value),
err);
}
}
@@ -88,77 +92,89 @@
* {@inheritDoc}
*/
public URI create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public URI create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public URI create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public URI create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public URI create( Name value ) {
if (value == null) return null;
return create("./" + value.getString(this.namespaceRegistry));
@@ -179,9 +195,10 @@
* {@inheritDoc}
*/
public URI create( Reference value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
@@ -189,10 +206,10 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public URI create( UUID value ) throws IoException {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
UUID.class.getSimpleName(),
-
value));
+ public URI create( UUID value ) {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
UUID.class.getSimpleName(),
+
value));
}
/**
@@ -212,9 +229,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public URI create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public URI create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -223,7 +250,7 @@
* {@inheritDoc}
*/
public URI create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,12 +32,15 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#REFERENCE} values.
@@ -62,9 +65,10 @@
UUID uuid = UUID.fromString(value);
return new UuidReference(uuid);
} catch (IllegalArgumentException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
Reference.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Reference.class.getSimpleName(),
+ value),
err);
}
}
@@ -81,90 +85,102 @@
* {@inheritDoc}
*/
public Reference create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public Reference create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public Reference create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Reference create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public Reference create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
@@ -179,7 +195,8 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public Reference create( UUID value ) throws IoException {
+ public Reference create( UUID value ) {
+ if (value == null) return null;
return new UuidReference(value);
}
@@ -187,9 +204,9 @@
* {@inheritDoc}
*/
public Reference create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, getPropertyType(),
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -202,9 +219,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public Reference create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Reference create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -213,7 +240,7 @@
* {@inheritDoc}
*/
public Reference create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidValueFactory.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidValueFactory.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -32,6 +32,8 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.spi.SpiI18n;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
@@ -39,6 +41,7 @@
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.UuidFactory;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#URI} values.
@@ -72,9 +75,10 @@
try {
return UUID.fromString(value);
} catch (IllegalArgumentException err) {
- throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
-
URI.class.getSimpleName(),
- value),
err);
+ throw new ValueFormatException(value, PropertyType.UUID,
+
SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
URI.class.getSimpleName(),
+ value),
err);
}
}
@@ -91,90 +95,102 @@
* {@inheritDoc}
*/
public UUID create( int value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( long value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( boolean value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( float value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( double value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( BigDecimal value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public UUID create( Calendar value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( Date value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Date.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.DateTime)
*/
+ public UUID create( DateTime value ) throws ValueFormatException {
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
DateTime.class.getSimpleName(),
+
value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public UUID create( Name value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
public UUID create( Path value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
@@ -185,18 +201,19 @@
UuidReference ref = (UuidReference)value;
return ref.getUuid();
}
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
+
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
public UUID create( URI value ) {
- throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
-
Reference.class.getSimpleName(),
-
value));
+ throw new ValueFormatException(value, PropertyType.UUID,
SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
@@ -204,7 +221,7 @@
*
* @see org.jboss.dna.spi.graph.ValueFactory#create(java.util.UUID)
*/
- public UUID create( UUID value ) throws IoException {
+ public UUID create( UUID value ) {
return value;
}
@@ -218,9 +235,19 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.ValueFactory#create(org.jboss.dna.spi.graph.Binary)
*/
+ public UUID create( Binary value ) throws ValueFormatException, IoException {
+ // First create a string and then create the boolean from the string value ...
+ return create(getStringValueFactory().create(value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public UUID create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -229,7 +256,7 @@
* {@inheritDoc}
*/
public UUID create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) throws IoException {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,12 +36,15 @@
import java.util.UUID;
import org.jboss.dna.common.text.NoOpEncoder;
import org.jboss.dna.common.text.TextDecoder;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
import org.jboss.dna.spi.graph.IoException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -100,6 +103,10 @@
return null;
}
+ public String create( DateTime value ) throws ValueFormatException {
+ return null;
+ }
+
public String create( Name value ) {
return null;
}
@@ -124,13 +131,17 @@
return null;
}
+ public String create( Binary value ) throws ValueFormatException, IoException {
+ return null;
+ }
+
public String create( InputStream stream,
- int approximateLength ) {
+ long approximateLength ) {
return null;
}
public String create( Reader reader,
- int approximateLength ) {
+ long approximateLength ) {
return null;
}
Modified: trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java
===================================================================
--- trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import org.jboss.dna.spi.graph.InvalidPathException;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -179,12 +180,12 @@
assertThat(pathFactory.create("/").isRoot(), is(true));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotConstructPathWithSuccessiveDelimiters() {
pathFactory.create("///a/b///c//d//");
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotConstructPathWithOnlyDelimiters() {
pathFactory.create("///");
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -35,6 +35,7 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -86,57 +87,57 @@
assertThat(factory.create(" 1 "), is(false));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromIntegerValue() {
factory.create(1);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromLongValue() {
factory.create(1l);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromFloatValue() {
factory.create(1.0f);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromDoubleValue() {
factory.create(1.0d);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromBigDecimal() {
factory.create(1.0d);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromDate() {
factory.create(new Date());
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromCalendar() {
factory.create(Calendar.getInstance());
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromPath() {
factory.create(mock(Path.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromReference() {
factory.create(mock(Reference.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateBooleanFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -57,7 +58,7 @@
factory = new DecimalValueFactory(Path.URL_DECODER, stringFactory);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDecimalFromBooleanValue() {
factory.create(true);
}
@@ -114,22 +115,22 @@
assertThat(factory.create(value),
is(BigDecimal.valueOf(value.getTimeInMillis())));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDecimalFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDecimalFromPath() {
factory.create(mock(Path.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDecimalFromReference() {
factory.create(mock(Reference.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDecimalFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -155,18 +156,18 @@
assertThat(factory.create(new StringReader("100.000101")),
is(BigDecimal.valueOf(100.000101d)));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDecimalFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() {
factory.create(new StringReader("something"));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -57,7 +58,7 @@
factory = new DoubleValueFactory(Path.URL_DECODER, stringFactory);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -114,22 +115,22 @@
assertThat(factory.create(value), is(Double.valueOf(value.getTimeInMillis())));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromPath() {
factory.create(mock(Path.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromReference() {
factory.create(mock(Reference.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -158,17 +159,17 @@
assertThat(factory.create(new StringReader("1003044")),
is(1003044.d));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDoubleFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDouble()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDoubleFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDouble()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDoubleFromReaderContainingStringWithContentsOtherThanDouble() throws
Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +67,7 @@
factory = new JodaDateTimeValueFactory(Path.URL_DECODER, stringFactory);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromBoolean() {
factory.create(true);
}
@@ -83,7 +84,7 @@
assertThat(factory.create(" " + LAST_YEAR.getString() + "
"), is(LAST_YEAR));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromStringThatIsNotInTheStandardFormat() {
factory.create("something");
}
@@ -126,22 +127,22 @@
assertThat(factory.create(value), is((DateTime)new JodaDateTime(value)));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromPath() {
factory.create(mock(Path.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromReference() {
factory.create(mock(Reference.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDateFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -164,19 +165,19 @@
assertThat(factory.create(new StringReader(LAST_YEAR.getString())),
is(LAST_YEAR));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateDateFromReaderContainingStringWithContentThatIsNotWellFormedDate() throws
Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.Reference;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -57,7 +58,7 @@
factory = new LongValueFactory(Path.URL_DECODER, stringFactory);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -116,22 +117,22 @@
assertThat(factory.create(value), is(Long.valueOf(value.getTimeInMillis())));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateLongFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateLongFromPath() {
factory.create(mock(Path.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateLongFromReference() {
factory.create(mock(Reference.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateLongFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -160,17 +161,17 @@
assertThat(factory.create(new StringReader("1003044")), is(1003044l));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateLongFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanLong()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateLongFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanLong()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateLongFromReaderContainingStringWithContentsOtherThanLong()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
Modified:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/UuidValueFactoryTest.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/UuidValueFactoryTest.java 2008-08-19
19:34:42 UTC (rev 449)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/UuidValueFactoryTest.java 2008-08-19
21:24:05 UTC (rev 450)
@@ -36,6 +36,7 @@
import java.util.UUID;
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -59,7 +60,7 @@
uuid = UUID.randomUUID();
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -84,42 +85,42 @@
assertThat(factory.create(" " + uuid.toString() + " "),
is(uuid));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromIntegerValue() {
factory.create(1);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromLongValue() {
factory.create(1L);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromDoubleValue() {
factory.create(1.0d);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromFloatValue() {
factory.create(1.0f);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromBooleanValue() {
factory.create(true);
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromCalendarValue() {
factory.create(Calendar.getInstance());
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromName() {
factory.create(mock(Name.class));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromPath() {
factory.create(mock(Path.class));
}
@@ -130,7 +131,7 @@
assertThat(factory.create(ref), is(uuid));
}
- @Test( expected = UnsupportedOperationException.class )
+ @Test( expected = ValueFormatException.class )
public void shouldNotCreateUuidFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -150,17 +151,17 @@
assertThat(factory.create(new StringReader(uuid.toString())), is(uuid));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateUuidFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanUuid()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateUuuidFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanUuuid()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = IllegalArgumentException.class )
+ @Test( expected = ValueFormatException.class )
public void
shouldNotCreateUuuidFromReaderContainingStringWithContentsOtherThanUuuid() throws
Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}