Author: jverhaeg(a)redhat.com
Date: 2008-06-09 10:44:48 -0400 (Mon, 09 Jun 2008)
New Revision: 250
Added:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java
Removed:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
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/resources/org/jboss/dna/spi/SpiI18n.properties
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
Log:
DNA-96: Replaced ValueFormatException with IllegalArgumentException,
UnsupportedOperationException, and a new IoException (a runtime exception that replaces
IOException), and changed exceptions thrown to be more consistent across value factory
implementations.
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-06-08 20:47:13 UTC
(rev 249)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/SpiI18n.java 2008-06-09 14:44:48 UTC
(rev 250)
@@ -32,29 +32,28 @@
*/
public final class SpiI18n {
- public static I18n errorConvertingBinaryValueToString;
- public static I18n errorCreatingValue;
+ public static I18n closedConnectionMayNotBeUsed;
+ public static I18n errorConvertingIo;
+ public static I18n errorConvertingType;
public static I18n errorReadingPropertyValueBytes;
- public static I18n invalidIndexInSegmentName;
- public static I18n invalidQualifiedNameString;
- public static I18n missingEndBracketInSegmentName;
+ public static I18n invalidIndexInSegmentName;
+ public static I18n invalidQualifiedNameString;
+ public static I18n maximumPoolSizeMayNotBeSmallerThanCorePoolSize;
+ public static I18n missingEndBracketInSegmentName;
public static I18n noNamespaceRegisteredForPrefix;
public static I18n pathAncestorDegreeIsInvalid;
public static I18n pathCannotBeNormalized;
public static I18n pathIsAlreadyAbsolute;
public static I18n pathIsNotAbsolute;
public static I18n pathIsNotRelative;
+ public static I18n repositoryConnectionPoolIsNotRunning;
public static I18n unableToCreateSubpathBeginIndexGreaterThanOrEqualToEndingIndex;
public static I18n unableToCreateSubpathBeginIndexGreaterThanOrEqualToSize;
public static I18n unableToCreateValue;
- public static I18n unableToDiscoverPropertyTypeForNullValue;
- public static I18n validPathMayNotContainEmptySegment;
- public static I18n valueJavaTypeNotCompatibleWithPropertyType;
-
- public static I18n maximumPoolSizeMayNotBeSmallerThanCorePoolSize;
- public static I18n repositoryConnectionPoolIsNotRunning;
+ public static I18n unableToDiscoverPropertyTypeForNullValue;
public static I18n unableToObtainValidRepositoryAfterAttempts;
- public static I18n closedConnectionMayNotBeUsed;
+ public static I18n validPathMayNotContainEmptySegment;
+ public static I18n valueJavaTypeNotCompatibleWithPropertyType;
static {
try {
Copied: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java (from rev
249, trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java)
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java
(rev 0)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/IoException.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -0,0 +1,69 @@
+/*
+ * 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
+ * @author John Verhaeg
+ */
+public class IoException extends RuntimeException {
+
+ /**
+ *
+ */
+ public IoException() {
+ }
+
+ /**
+ * @param message
+ */
+ public IoException( String message ) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public IoException( Throwable cause ) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public IoException( String message,
+ Throwable cause ) {
+ super(message, cause);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+}
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-08
20:47:13 UTC (rev 249)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/PropertyType.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -30,6 +30,7 @@
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public enum PropertyType {
@@ -51,7 +52,9 @@
private final Comparator comparator;
private final Class valueClass;
- private PropertyType( String name, Comparator comparator, Class valueClass ) {
+ private PropertyType( String name,
+ Comparator comparator,
+ Class valueClass ) {
this.name = name;
this.comparator = comparator;
this.valueClass = valueClass;
@@ -90,7 +93,7 @@
public static PropertyType discoverType( Object value ) {
if (value == null) {
- throw new
ValueFormatException(SpiI18n.unableToDiscoverPropertyTypeForNullValue.text());
+ throw new
IllegalArgumentException(SpiI18n.unableToDiscoverPropertyTypeForNullValue.text());
}
for (PropertyType type : PropertyType.values()) {
if (type == OBJECT) continue;
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-08
20:47:13 UTC (rev 249)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueComparators.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -116,7 +116,7 @@
if (numRead1 < 0) break;
int numRead2 = stream2.read(buffer2);
if (numRead1 != numRead2) {
- throw new
ValueFormatException(SpiI18n.errorReadingPropertyValueBytes.text());
+ throw new
IoException(SpiI18n.errorReadingPropertyValueBytes.text());
}
for (int i = 0; i != numRead1; ++i) {
int diff = buffer1[i] - buffer2[i];
@@ -125,7 +125,7 @@
}
return 0;
} catch (IOException e) {
- throw new
ValueFormatException(SpiI18n.errorReadingPropertyValueBytes.text());
+ throw new
IoException(SpiI18n.errorReadingPropertyValueBytes.text());
} finally {
if (stream1 != null) {
try {
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-06-08
20:47:13 UTC (rev 249)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -32,10 +32,16 @@
import org.jboss.dna.common.text.TextEncoder;
/**
- * A factory for {@link Property} values. Some of the methods may throw a {@link
ValueFormatException} if the parameter supplied
- * to the <code>create(...)</code> method cannot be converted to the {@link
#getPropertyType() factory's type}.
+ * A factory for {@link Property} values. Each create method may throw one of these
exceptions when attempting to convert a
+ * supplied value to the {@link #getPropertyType() factory's type}:
+ * <ul>
+ * <li>{@link IllegalArgumentException} - If the supplied value is invalid in
respect to the conversion being attempted.</li>
+ * <li>{@link UnsupportedOperationException} - If a conversion from the supplied
value is not supported.</li>
+ * <li>{@link IoException} - If an unexpected problem occurs during the conversion
(such as an {@link IOException}).</li>
+ * </ul>
*
* @author Randall Hauch
+ * @author John Verhaeg
* @param <T> the type of value to create
*/
public interface ValueFactory<T> {
@@ -55,10 +61,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 ValueFormatException if the value could not be created from the supplied
string
+ * @throws IoException If an unexpected problem occurs during the conversion.
* @see #create(String, TextDecoder)
*/
- T create( String value ) throws ValueFormatException;
+ T create( String value ) throws IoException;
/**
* Create a value from a string, using the supplied decoder.
@@ -66,127 +72,128 @@
* @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 ValueFormatException if the value could not be created from the supplied
string
+ * @throws IoException If an unexpected problem occurs during the conversion.
* @see #create(String)
*/
- T create( String value, TextDecoder decoder ) throws ValueFormatException;
+ T create( String value,
+ TextDecoder decoder ) throws IoException;
/**
* Create a value from an integer.
*
* @param value the integer from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied
integer
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( int value ) throws ValueFormatException;
+ T create( int value ) throws IoException;
/**
* Create a long from a string.
*
* @param value the string from which the long is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied
long
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( long value ) throws ValueFormatException;
+ T create( long value ) throws IoException;
/**
* Create a boolean from a string.
*
* @param value the boolean from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied
boolean
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( boolean value ) throws ValueFormatException;
+ T create( boolean value ) throws IoException;
/**
* Create a value from a float.
*
* @param value the float from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied
float
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( float value ) throws ValueFormatException;
+ T create( float value ) throws IoException;
/**
* Create a value from a double.
*
* @param value the double from which the value is to be created
* @return the value; never null
- * @throws ValueFormatException if the value could not be created from the supplied
double
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( double value ) throws ValueFormatException;
+ T create( double value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
decimal
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( BigDecimal value ) throws ValueFormatException;
+ T create( BigDecimal value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
Calendar object
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Calendar value ) throws ValueFormatException;
+ T create( Calendar value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
date
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Date value ) throws ValueFormatException;
+ T create( Date value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
name
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Name value ) throws ValueFormatException;
+ T create( Name value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
path
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Path value ) throws ValueFormatException;
+ T create( Path value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
reference
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Reference value ) throws ValueFormatException;
+ T create( Reference value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
URI
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( URI value ) throws ValueFormatException;
+ T create( URI value ) throws IoException;
/**
* 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 ValueFormatException if the value could not be created from the supplied
byte array
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( byte[] value ) throws ValueFormatException;
+ T create( byte[] value ) throws IoException;
/**
* Create a value from the binary content given by the supplied stream.
@@ -194,10 +201,10 @@
* @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 ValueFormatException if the value could not be created from the supplied
stream
- * @throws IOException if there is a problem reading the stream
+ * @throws IoException If an unexpected problem occurs during the conversion (such as
an {@link IOException}).
*/
- T create( InputStream stream, int approximateLength ) throws ValueFormatException,
IOException;
+ T create( InputStream stream,
+ int approximateLength ) throws IoException;
/**
* Create a value from a the binary content given by the supplied reader.
@@ -205,10 +212,10 @@
* @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 ValueFormatException if the value could not be created from the supplied
reader
- * @throws IOException if there is a problem reading the stream
+ * @throws IoException If an unexpected problem occurs during the conversion (such as
an {@link IOException}).
*/
- T create( Reader reader, int approximateLength ) throws ValueFormatException,
IOException;
+ T create( Reader reader,
+ int approximateLength ) throws IoException;
/**
* Create a value from the specified information by determining which other
<code>create</code> method applies and
@@ -217,8 +224,8 @@
*
* @param value the value
* @return the new value, or null if the supplied parameter is null
- * @throws ValueFormatException if the value could not be created from the supplied
stream
+ * @throws IoException If an unexpected problem occurs during the conversion.
*/
- T create( Object value ) throws ValueFormatException;
+ T create( Object value ) throws IoException;
}
Deleted: 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 2008-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFormatException.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -1,67 +0,0 @@
-/*
- * 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 {
-
- /**
- *
- */
- public ValueFormatException() {
- }
-
- /**
- * @param message
- */
- public ValueFormatException( String message ) {
- super(message);
-
- }
-
- /**
- * @param cause
- */
- public ValueFormatException( Throwable cause ) {
- super(cause);
-
- }
-
- /**
- * @param message
- * @param cause
- */
- public ValueFormatException( String message, Throwable cause ) {
- super(message, cause);
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return super.toString();
- }
-}
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,12 +35,12 @@
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}.
*
* @author Randall Hauch
+ * @author John Verhaeg
* @param <T> the property type
*/
@Immutable
@@ -51,7 +50,9 @@
private final PropertyType propertyType;
private final ValueFactory<String> stringValueFactory;
- protected AbstractValueFactory( PropertyType type, TextDecoder decoder,
ValueFactory<String> stringValueFactory ) {
+ protected AbstractValueFactory( PropertyType type,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
ArgCheck.isNotNull(type, "type");
this.propertyType = type;
this.decoder = decoder != null ? decoder : DEFAULT_DECODER;
@@ -94,7 +95,7 @@
/**
* {@inheritDoc}
*/
- public T create( Object value ) throws ValueFormatException {
+ public T create( Object value ) {
if (value == null) return null;
if (value instanceof String) return create((String)value);
if (value instanceof Integer) return create(((Integer)value).intValue());
@@ -110,20 +111,8 @@
if (value instanceof Reference) return create((Reference)value);
if (value instanceof URI) return create((URI)value);
if (value instanceof byte[]) return create((byte[])value);
- if (value instanceof InputStream) {
- try {
- return create((InputStream)value, 0);
- } catch (IOException e) {
- throw new ValueFormatException(e);
- }
- }
- if (value instanceof Reader) {
- try {
- return create((Reader)value, 0);
- } catch (IOException e) {
- throw new ValueFormatException(e);
- }
- }
+ if (value instanceof InputStream) return create((InputStream)value, 0);
+ if (value instanceof Reader) return create((Reader)value, 0);
return create(value.toString());
}
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/BooleanValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,17 +35,18 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class BooleanValueFactory extends AbstractValueFactory<Boolean> {
- public BooleanValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public BooleanValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.BOOLEAN, decoder, stringValueFactory);
}
@@ -61,7 +61,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( String value, TextDecoder decoder ) {
+ public Boolean create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -69,15 +70,19 @@
/**
* {@inheritDoc}
*/
- public Boolean create( int value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Integer.class.getSimpleName(), value));
+ public Boolean create( int value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Integer.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( long value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Long.class.getSimpleName(), value));
+ public Boolean create( long value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
@@ -90,70 +95,88 @@
/**
* {@inheritDoc}
*/
- public Boolean create( float value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Float.class.getSimpleName(), value));
+ public Boolean create( float value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Float.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( double value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Double.class.getSimpleName(), value));
+ public Boolean create( double value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( BigDecimal value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
BigDecimal.class.getSimpleName(), value));
+ public Boolean create( BigDecimal value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
BigDecimal.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Calendar value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Calendar.class.getSimpleName(), value));
+ public Boolean create( Calendar value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Calendar.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Date value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Boolean create( Date value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Name.class.getSimpleName(), value));
+ public Boolean create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ public Boolean create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public Boolean create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
URI.class.getSimpleName(), value));
+ public Boolean create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Boolean create( byte[] value ) throws ValueFormatException {
+ public Boolean create( byte[] value ) {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(value));
}
@@ -161,7 +184,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( InputStream stream, int approximateLength ) throws
IOException, ValueFormatException {
+ public Boolean create( InputStream stream,
+ int approximateLength ) {
// First create a string and then create the boolean from the string value ...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -169,7 +193,8 @@
/**
* {@inheritDoc}
*/
- public Boolean create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Boolean create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DecimalValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -2,7 +2,7 @@
* 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.
+ * 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
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class DecimalValueFactory extends AbstractValueFactory<BigDecimal> {
- public DecimalValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public DecimalValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DECIMAL, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( String value ) throws ValueFormatException {
+ public BigDecimal create( String value ) {
if (value == null) return null;
try {
return new BigDecimal(value.trim());
- } catch (NumberFormatException e) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
BigDecimal.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( String value, TextDecoder decoder ) {
+ public BigDecimal create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value.trim()));
}
@@ -87,8 +90,10 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Boolean.class.getSimpleName(), value));
+ public BigDecimal create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Boolean.class.getSimpleName(),
+
value));
}
/**
@@ -131,35 +136,43 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Name.class.getSimpleName(), value));
+ public BigDecimal create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ public BigDecimal create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public BigDecimal create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
URI.class.getSimpleName(), value));
+ public BigDecimal create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public BigDecimal create( byte[] value ) throws ValueFormatException {
+ public BigDecimal create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -167,7 +180,8 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( InputStream stream, int approximateLength ) throws
IOException, ValueFormatException {
+ public BigDecimal create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -175,7 +189,8 @@
/**
* {@inheritDoc}
*/
- public BigDecimal create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public BigDecimal create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/DoubleValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class DoubleValueFactory extends AbstractValueFactory<Double> {
- public DoubleValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public DoubleValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DOUBLE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Double create( String value ) throws ValueFormatException {
+ public Double create( String value ) {
if (value == null) return null;
try {
return Double.valueOf(value.trim());
- } catch (NumberFormatException e) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Double.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public Double create( String value, TextDecoder decoder ) {
+ public Double create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -87,8 +90,10 @@
/**
* {@inheritDoc}
*/
- public Double create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Double.class.getSimpleName(), value));
+ public Double create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Double.class.getSimpleName(),
+
value));
}
/**
@@ -108,11 +113,13 @@
/**
* {@inheritDoc}
*/
- public Double create( BigDecimal value ) throws ValueFormatException {
+ public Double create( BigDecimal value ) {
if (value == null) return null;
double result = value.doubleValue();
if (result == Double.NEGATIVE_INFINITY || result == Double.POSITIVE_INFINITY) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value));
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(BigDecimal.class.getSimpleName(),
+
Double.class.getSimpleName(),
+ value));
}
return result;
}
@@ -136,35 +143,43 @@
/**
* {@inheritDoc}
*/
- public Double create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Name.class.getSimpleName(), value));
+ public Double create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Double create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ public Double create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Double create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public Double create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Double create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
URI.class.getSimpleName(), value));
+ public Double create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Double create( byte[] value ) throws ValueFormatException {
+ public Double create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -172,7 +187,8 @@
/**
* {@inheritDoc}
*/
- public Double create( InputStream stream, int approximateLength ) throws IOException,
ValueFormatException {
+ public Double create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -180,7 +196,8 @@
/**
* {@inheritDoc}
*/
- public Double create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Double create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/InMemoryBinaryValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -39,38 +39,43 @@
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.IoException;
/**
* Teh standard {@link ValueFactory} for {@link PropertyType#BINARY} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class InMemoryBinaryValueFactory extends AbstractValueFactory<Binary> {
private static final String CHAR_SET_NAME = "UTF-8";
- public InMemoryBinaryValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public InMemoryBinaryValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.BINARY, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Binary create( String value ) throws ValueFormatException {
+ public Binary create( String value ) {
if (value == null) return null;
try {
return create(value.getBytes(CHAR_SET_NAME));
- } catch (UnsupportedEncodingException e) {
- throw new
ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Binary.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public Binary create( String value, TextDecoder decoder ) throws ValueFormatException
{
+ public Binary create( String value,
+ TextDecoder decoder ) {
if (value == null) return null;
return create(getDecoder(decoder).decode(value));
}
@@ -78,7 +83,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( int value ) throws ValueFormatException {
+ public Binary create( int value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -86,7 +91,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( long value ) throws ValueFormatException {
+ public Binary create( long value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -94,7 +99,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( boolean value ) throws ValueFormatException {
+ public Binary create( boolean value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -102,7 +107,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( float value ) throws ValueFormatException {
+ public Binary create( float value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -110,7 +115,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( double value ) throws ValueFormatException {
+ public Binary create( double value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -118,7 +123,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( BigDecimal value ) throws ValueFormatException {
+ public Binary create( BigDecimal value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -126,7 +131,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Calendar value ) throws ValueFormatException {
+ public Binary create( Calendar value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -134,7 +139,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Date value ) throws ValueFormatException {
+ public Binary create( Date value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -142,7 +147,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Name value ) throws ValueFormatException {
+ public Binary create( Name value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -150,7 +155,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Path value ) throws ValueFormatException {
+ public Binary create( Path value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -158,7 +163,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( Reference value ) throws ValueFormatException {
+ public Binary create( Reference value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -166,7 +171,7 @@
/**
* {@inheritDoc}
*/
- public Binary create( URI value ) throws ValueFormatException {
+ public Binary create( URI value ) {
// Convert the value to a string, then to a binary ...
return create(this.getStringValueFactory().create(value));
}
@@ -174,27 +179,38 @@
/**
* {@inheritDoc}
*/
- public Binary create( byte[] value ) throws ValueFormatException {
+ public Binary create( byte[] value ) {
return new InMemoryBinary(value);
}
/**
* {@inheritDoc}
*/
- public Binary create( InputStream stream, int approximateLength ) throws IOException
{
+ public Binary create( InputStream stream,
+ int approximateLength ) {
if (stream == null) return null;
- byte[] value = IoUtil.readBytes(stream);
- return create(value);
+ try {
+ byte[] value = IoUtil.readBytes(stream);
+ return create(value);
+ } catch (IOException err) {
+ throw new
IoException(SpiI18n.errorConvertingIo.text(InputStream.class.getSimpleName(),
+
Binary.class.getSimpleName()), err);
+ }
}
/**
* {@inheritDoc}
*/
- public Binary create( Reader reader, int approximateLength ) throws IOException {
+ public Binary create( Reader reader,
+ int approximateLength ) {
if (reader == null) return null;
// Convert the value to a string, then to a binary ...
- String value = IoUtil.read(reader);
- return create(this.getStringValueFactory().create(value));
+ try {
+ String value = IoUtil.read(reader);
+ return create(this.getStringValueFactory().create(value));
+ } catch (IOException err) {
+ throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
+
Binary.class.getSimpleName()), err);
+ }
}
-
}
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -38,36 +37,40 @@
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#DATE} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class JodaDateTimeValueFactory extends AbstractValueFactory<DateTime>
implements DateTimeFactory {
- public JodaDateTimeValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public JodaDateTimeValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.DATE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public DateTime create( String value ) throws ValueFormatException {
+ public DateTime create( String value ) {
if (value == null) return null;
try {
return new JodaDateTime(value.trim());
- } catch (IllegalArgumentException e) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), e);
+ } catch (IllegalArgumentException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
DateTime.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public DateTime create( String value, TextDecoder decoder ) {
+ public DateTime create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -89,28 +92,30 @@
/**
* {@inheritDoc}
*/
- public DateTime create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public DateTime create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( float value ) throws ValueFormatException {
+ public DateTime create( float value ) {
return create((long)value);
}
/**
* {@inheritDoc}
*/
- public DateTime create( double value ) throws ValueFormatException {
+ public DateTime create( double value ) {
return create((long)value);
}
/**
* {@inheritDoc}
*/
- public DateTime create( BigDecimal value ) throws ValueFormatException {
+ public DateTime create( BigDecimal value ) {
if (value == null) return null;
return create(value.longValue());
}
@@ -118,7 +123,7 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Calendar value ) throws ValueFormatException {
+ public DateTime create( Calendar value ) {
if (value == null) return null;
return new JodaDateTime(value);
}
@@ -126,7 +131,7 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Date value ) throws ValueFormatException {
+ public DateTime create( Date value ) {
if (value == null) return null;
return new JodaDateTime(value);
}
@@ -134,35 +139,43 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Name.class.getSimpleName(), value));
+ public DateTime create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ public DateTime create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public DateTime create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
URI.class.getSimpleName(), value));
+ public DateTime create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public DateTime create( byte[] value ) throws ValueFormatException {
+ public DateTime create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -170,7 +183,8 @@
/**
* {@inheritDoc}
*/
- public DateTime create( InputStream stream, int approximateLength ) throws
IOException, ValueFormatException {
+ public DateTime create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -178,7 +192,8 @@
/**
* {@inheritDoc}
*/
- public DateTime create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public DateTime create( Reader reader,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(reader, approximateLength));
}
@@ -193,22 +208,43 @@
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond ) {
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond ) {
return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond);
}
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond, int timeZoneOffsetHours ) {
- return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond, timeZoneOffsetHours);
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ int timeZoneOffsetHours ) {
+ return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond,
+ timeZoneOffsetHours);
}
/**
* {@inheritDoc}
*/
- public DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond, String timeZoneId ) {
- return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond, timeZoneId);
+ public DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ String timeZoneId ) {
+ return new JodaDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour,
secondOfMinute, millisecondsOfSecond,
+ timeZoneId);
}
-
}
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/LongValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -36,36 +35,40 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class LongValueFactory extends AbstractValueFactory<Long> {
- public LongValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public LongValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.LONG, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Long create( String value ) throws ValueFormatException {
+ public Long create( String value ) {
if (value == null) return null;
try {
return Long.valueOf(value.trim());
- } catch (NumberFormatException e) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), e);
+ } catch (NumberFormatException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Long.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public Long create( String value, TextDecoder decoder ) {
+ public Long create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -87,28 +90,30 @@
/**
* {@inheritDoc}
*/
- public Long create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Long.class.getSimpleName(), value));
+ public Long create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Long.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Long create( float value ) throws ValueFormatException {
+ public Long create( float value ) {
return (long)value;
}
/**
* {@inheritDoc}
*/
- public Long create( double value ) throws ValueFormatException {
+ public Long create( double value ) {
return (long)value;
}
/**
* {@inheritDoc}
*/
- public Long create( BigDecimal value ) throws ValueFormatException {
+ public Long create( BigDecimal value ) {
if (value == null) return null;
return value.longValue();
}
@@ -116,7 +121,7 @@
/**
* {@inheritDoc}
*/
- public Long create( Calendar value ) throws ValueFormatException {
+ public Long create( Calendar value ) {
if (value == null) return null;
return value.getTimeInMillis();
}
@@ -124,7 +129,7 @@
/**
* {@inheritDoc}
*/
- public Long create( Date value ) throws ValueFormatException {
+ public Long create( Date value ) {
if (value == null) return null;
return value.getTime();
}
@@ -132,35 +137,43 @@
/**
* {@inheritDoc}
*/
- public Long create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Name.class.getSimpleName(), value));
+ public Long create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Name.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Long create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ public Long create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Path.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Long create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public Long create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Long create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
URI.class.getSimpleName(), value));
+ public Long create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
URI.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Long create( byte[] value ) throws ValueFormatException {
+ public Long create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -168,7 +181,8 @@
/**
* {@inheritDoc}
*/
- public Long create( InputStream stream, int approximateLength ) throws IOException,
ValueFormatException {
+ public Long create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -176,7 +190,8 @@
/**
* {@inheritDoc}
*/
- public Long create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Long create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/NameValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -42,12 +41,12 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class NameValueFactory extends AbstractValueFactory<Name> implements
NameFactory {
@@ -62,7 +61,9 @@
private final NamespaceRegistry namespaceRegistry;
- public NameValueFactory( NamespaceRegistry namespaceRegistry, TextDecoder decoder,
ValueFactory<String> stringValueFactory ) {
+ public NameValueFactory( NamespaceRegistry namespaceRegistry,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.NAME, decoder, stringValueFactory);
ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
this.namespaceRegistry = namespaceRegistry;
@@ -78,7 +79,8 @@
/**
* {@inheritDoc}
*/
- public Name create( String value, TextDecoder decoder ) throws ValueFormatException
{
+ public Name create( String value,
+ TextDecoder decoder ) {
if (value == null) return null;
if (decoder == null) decoder = getDecoder();
try {
@@ -108,23 +110,30 @@
}
return new BasicName(namespaceUri, localName);
}
- } catch (Throwable t) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), t);
+ } catch (NamespaceException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Name.class.getSimpleName(),
+ value),
err);
}
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value));
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( String namespaceUri, String localName ) {
+ public Name create( String namespaceUri,
+ String localName ) {
return create(namespaceUri, localName, getDecoder());
}
/**
* {@inheritDoc}
*/
- public Name create( String namespaceUri, String localName, TextDecoder decoder ) {
+ public Name create( String namespaceUri,
+ String localName,
+ TextDecoder decoder ) {
ArgCheck.isNotEmpty(localName, "localName");
if (decoder == null) decoder = getDecoder();
namespaceUri = namespaceUri != null ? decoder.decode(namespaceUri.trim()) :
null;
@@ -135,57 +144,73 @@
/**
* {@inheritDoc}
*/
- public Name create( int value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( int value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( long value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( long value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( float value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( float value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( double value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( double value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( BigDecimal value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( BigDecimal value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( Calendar value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( Calendar value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( Date value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Name create( Date value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -198,26 +223,30 @@
/**
* {@inheritDoc}
*/
- public Name create( Path value ) throws ValueFormatException {
+ public Name create( Path value ) {
if (value == null) return null;
if (!value.isAbsolute() && value.size() == 1) {
// A relative name of length 1 is converted to a name
return value.getSegment(0).getName();
}
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(Path.class.getSimpleName(),
+
Name.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public Name create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Name create( URI value ) throws ValueFormatException {
+ public Name create( URI value ) {
if (value == null) return null;
String asciiString = value.toASCIIString();
// Remove any leading "./" ...
@@ -227,13 +256,15 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+
Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Name create( byte[] value ) throws ValueFormatException {
+ public Name create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -241,7 +272,8 @@
/**
* {@inheritDoc}
*/
- public Name create( InputStream stream, int approximateLength ) throws IOException,
ValueFormatException {
+ public Name create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -249,7 +281,8 @@
/**
* {@inheritDoc}
*/
- public Name create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Name create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/ObjectValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -37,19 +36,21 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class ObjectValueFactory extends AbstractValueFactory<Object> {
private final ValueFactory<Binary> binaryValueFactory;
- public ObjectValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory, ValueFactory<Binary> binaryValueFactory ) {
+ public ObjectValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory,
+ ValueFactory<Binary> binaryValueFactory ) {
super(PropertyType.OBJECT, decoder, stringValueFactory);
ArgCheck.isNotNull(binaryValueFactory, "binaryValueFactory");
this.binaryValueFactory = binaryValueFactory;
@@ -72,7 +73,8 @@
/**
* {@inheritDoc}
*/
- public Object create( String value, TextDecoder decoder ) {
+ public Object create( String value,
+ TextDecoder decoder ) {
return this.getStringValueFactory().create(value, decoder);
}
@@ -163,21 +165,23 @@
/**
* {@inheritDoc}
*/
- public Object create( byte[] value ) throws ValueFormatException {
+ public Object create( byte[] value ) {
return getBinaryValueFactory().create(value);
}
/**
* {@inheritDoc}
*/
- public Object create( InputStream stream, int approximateLength ) throws IOException
{
+ public Object create( InputStream stream,
+ int approximateLength ) {
return getBinaryValueFactory().create(stream, approximateLength);
}
/**
* {@inheritDoc}
*/
- public Object create( Reader reader, int approximateLength ) throws IOException {
+ public Object create( Reader reader,
+ int 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/PathValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -41,7 +40,6 @@
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;
/**
@@ -77,7 +75,9 @@
private final ValueFactory<Name> nameValueFactory;
- public PathValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory, ValueFactory<Name> nameValueFactory ) {
+ public PathValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory,
+ ValueFactory<Name> nameValueFactory ) {
super(PropertyType.PATH, decoder, stringValueFactory);
ArgCheck.isNotNull(nameValueFactory, "nameValueFactory");
this.nameValueFactory = nameValueFactory;
@@ -111,7 +111,8 @@
/**
* {@inheritDoc}
*/
- public Path create( final String value, TextDecoder decoder ) throws
ValueFormatException {
+ public Path create( final String value,
+ TextDecoder decoder ) {
if (value == null) return null;
String trimmedValue = value.trim();
int length = trimmedValue.length();
@@ -139,7 +140,7 @@
List<Segment> segments = new ArrayList<Segment>();
String[] pathSegments = DELIMITER_PATTERN.split(trimmedValue);
if (pathSegments.length == 0) {
- throw new
ValueFormatException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new
IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
if (decoder == null) decoder = getDecoder();
assert pathSegments.length != 0;
@@ -148,7 +149,7 @@
assert segment != null;
segment = segment.trim();
if (segment.length() == 0) {
- throw new
ValueFormatException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
+ throw new
IllegalArgumentException(SpiI18n.validPathMayNotContainEmptySegment.text(value));
}
// Create the name and add a segment with it ...
segments.add(createSegment(segment, decoder));
@@ -161,57 +162,73 @@
/**
* {@inheritDoc}
*/
- public Path create( int value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( int value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( long value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( long value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( float value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( float value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( double value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( double value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( BigDecimal value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( BigDecimal value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( Calendar value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( Calendar value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( Date value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Path create( Date value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -227,7 +244,7 @@
/**
* {@inheritDoc}
*/
- public Path create( Path value ) throws ValueFormatException {
+ public Path create( Path value ) {
return value;
}
@@ -305,7 +322,9 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Name segmentName, int index ) {
+ public Path create( Path parentPath,
+ Name segmentName,
+ int index ) {
ArgCheck.isNotNull(parentPath, "parent path");
ArgCheck.isNotNull(segmentName, "segment name");
List<Segment> segments = new ArrayList<Segment>(parentPath.size() +
1);
@@ -317,7 +336,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Name... segmentNames ) {
+ public Path create( Path parentPath,
+ Name... segmentNames ) {
ArgCheck.isNotNull(parentPath, "parent path");
if (segmentNames == null || segmentNames.length == 0) return parentPath;
@@ -335,7 +355,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Path parentPath, Segment... segments ) {
+ public Path create( Path parentPath,
+ Segment... segments ) {
ArgCheck.isNotNull(parentPath, "parent path");
if (segments == null || segments.length == 0) return BasicPath.ROOT;
@@ -363,7 +384,8 @@
/**
* {@inheritDoc}
*/
- public Segment createSegment( Name segmentName, int index ) {
+ public Segment createSegment( Name segmentName,
+ int index ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF_NAME.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT_NAME.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -386,7 +408,8 @@
*
* @see org.jboss.dna.spi.graph.PathFactory#createSegment(java.lang.String,
org.jboss.dna.common.text.TextDecoder)
*/
- public Segment createSegment( String segmentName, TextDecoder decoder ) {
+ public Segment createSegment( String segmentName,
+ TextDecoder decoder ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -400,7 +423,8 @@
}
String ndx = segmentName.substring(startBracketNdx + 1, endBracketNdx);
try {
- return new
BasicPathSegment(this.nameValueFactory.create(segmentName.substring(0, startBracketNdx),
decoder), Integer.parseInt(ndx));
+ 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));
}
@@ -409,7 +433,8 @@
/**
* {@inheritDoc}
*/
- public Segment createSegment( String segmentName, int index ) {
+ public Segment createSegment( String segmentName,
+ int index ) {
ArgCheck.isNotNull(segmentName, "segment name");
if (Path.SELF.equals(segmentName)) return Path.SELF_SEGMENT;
if (Path.PARENT.equals(segmentName)) return Path.PARENT_SEGMENT;
@@ -419,14 +444,16 @@
/**
* {@inheritDoc}
*/
- public Path create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public Path create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Path create( URI value ) throws ValueFormatException {
+ public Path create( URI value ) {
if (value == null) return null;
String asciiString = value.toASCIIString();
// Remove any leading "./" ...
@@ -436,13 +463,15 @@
if (asciiString.indexOf('/') == -1) {
return create(asciiString);
}
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
Path.class.getSimpleName(), value));
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(URI.class.getSimpleName(),
+
Path.class.getSimpleName(),
+ value));
}
/**
* {@inheritDoc}
*/
- public Path create( byte[] value ) throws ValueFormatException {
+ public Path create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -450,7 +479,8 @@
/**
* {@inheritDoc}
*/
- public Path create( InputStream stream, int approximateLength ) throws IOException,
ValueFormatException {
+ public Path create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -458,7 +488,8 @@
/**
* {@inheritDoc}
*/
- public Path create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Path create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/StringValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -40,19 +40,21 @@
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.IoException;
/**
* The standard {@link ValueFactory} for {@link PropertyType#STRING} values.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class StringValueFactory extends AbstractValueFactory<String> {
private final TextEncoder encoder;
- public StringValueFactory( TextDecoder decoder, TextEncoder encoder ) {
+ public StringValueFactory( TextDecoder decoder,
+ TextEncoder encoder ) {
super(PropertyType.STRING, decoder, null);
ArgCheck.isNotNull(encoder, "encoder");
this.encoder = encoder;
@@ -83,7 +85,8 @@
/**
* {@inheritDoc}
*/
- public String create( String value, TextDecoder decoder ) {
+ public String create( String value,
+ TextDecoder decoder ) {
if (value == null) return value;
if (decoder == null) decoder = getDecoder();
return decoder.decode(value);
@@ -183,34 +186,49 @@
/**
* {@inheritDoc}
*/
- public String create( byte[] value ) throws ValueFormatException {
+ public String create( byte[] value ) {
if (value == null) return null;
try {
return new String(value, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new
ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(byte[].class.getSimpleName(),
+
String.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public String create( InputStream stream, int approximateLength ) throws IOException
{
+ public String create( InputStream stream,
+ int approximateLength ) {
if (stream == null) return null;
- byte[] value = IoUtil.readBytes(stream);
+ byte[] value = null;
try {
+ value = IoUtil.readBytes(stream);
return new String(value, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new
ValueFormatException(SpiI18n.errorConvertingBinaryValueToString.text());
+ } catch (UnsupportedEncodingException err) {
+ throw new
IllegalArgumentException(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()), err);
}
}
/**
* {@inheritDoc}
*/
- public String create( Reader reader, int approximateLength ) throws IOException {
+ public String create( Reader reader,
+ int approximateLength ) {
if (reader == null) return null;
- return IoUtil.read(reader);
+ try {
+ return IoUtil.read(reader);
+ } catch (IOException err) {
+ throw new
IoException(SpiI18n.errorConvertingIo.text(Reader.class.getSimpleName(),
+
String.class.getSimpleName()), err);
+ }
}
}
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UriValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -39,19 +38,21 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class UriValueFactory extends AbstractValueFactory<URI> {
private final NamespaceRegistry namespaceRegistry;
- public UriValueFactory( NamespaceRegistry namespaceRegistry, TextDecoder decoder,
ValueFactory<String> stringValueFactory ) {
+ public UriValueFactory( NamespaceRegistry namespaceRegistry,
+ TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.URI, decoder, stringValueFactory);
ArgCheck.isNotNull(namespaceRegistry, "namespaceRegistry");
this.namespaceRegistry = namespaceRegistry;
@@ -60,19 +61,22 @@
/**
* {@inheritDoc}
*/
- public URI create( String value ) throws ValueFormatException {
+ public URI create( String value ) {
if (value == null) return null;
try {
return new URI(value);
- } catch (URISyntaxException t) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), t);
+ } catch (URISyntaxException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
URI.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public URI create( String value, TextDecoder decoder ) {
+ public URI create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -80,57 +84,73 @@
/**
* {@inheritDoc}
*/
- public URI create( int value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( int value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( long value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( long value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( float value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( float value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( double value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( double value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( BigDecimal value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( BigDecimal value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( Calendar value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( Calendar value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public URI create( Date value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public URI create( Date value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -144,7 +164,7 @@
/**
* {@inheritDoc}
*/
- public URI create( Path value ) throws ValueFormatException {
+ public URI create( Path value ) {
if (value == null) return null;
if (value.isAbsolute()) {
return create("/" + value.getString(this.namespaceRegistry));
@@ -155,8 +175,10 @@
/**
* {@inheritDoc}
*/
- public URI create( Reference value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Reference.class.getSimpleName(), value));
+ public URI create( Reference value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Reference.class.getSimpleName(),
+
value));
}
/**
@@ -169,7 +191,7 @@
/**
* {@inheritDoc}
*/
- public URI create( byte[] value ) throws ValueFormatException {
+ public URI create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -177,7 +199,8 @@
/**
* {@inheritDoc}
*/
- public URI create( InputStream stream, int approximateLength ) throws IOException,
ValueFormatException {
+ public URI create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -185,7 +208,8 @@
/**
* {@inheritDoc}
*/
- public URI create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public URI create( Reader reader,
+ int approximateLength ) {
// 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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/UuidReferenceValueFactory.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -21,7 +21,6 @@
*/
package org.jboss.dna.spi.graph.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
@@ -37,37 +36,41 @@
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.
*
* @author Randall Hauch
+ * @author John Verhaeg
*/
@Immutable
public class UuidReferenceValueFactory extends AbstractValueFactory<Reference> {
- public UuidReferenceValueFactory( TextDecoder decoder, ValueFactory<String>
stringValueFactory ) {
+ public UuidReferenceValueFactory( TextDecoder decoder,
+ ValueFactory<String> stringValueFactory ) {
super(PropertyType.REFERENCE, decoder, stringValueFactory);
}
/**
* {@inheritDoc}
*/
- public Reference create( String value ) throws ValueFormatException {
+ public Reference create( String value ) {
if (value == null) return null;
try {
UUID uuid = UUID.fromString(value);
return new UuidReference(uuid);
- } catch (IllegalArgumentException t) {
- throw new
ValueFormatException(SpiI18n.errorCreatingValue.text(getPropertyType().getName(),
String.class.getSimpleName(), value), t);
+ } catch (IllegalArgumentException err) {
+ throw new
IllegalArgumentException(SpiI18n.errorConvertingType.text(String.class.getSimpleName(),
+
Reference.class.getSimpleName(),
+ value),
err);
}
}
/**
* {@inheritDoc}
*/
- public Reference create( String value, TextDecoder decoder ) {
+ public Reference create( String value,
+ TextDecoder decoder ) {
// this probably doesn't really need to call the decoder, but by doing so
then we don't care at all what the decoder does
return create(getDecoder(decoder).decode(value));
}
@@ -75,71 +78,91 @@
/**
* {@inheritDoc}
*/
- public Reference create( int value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( int value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( long value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( long value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( boolean value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( boolean value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( float value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( float value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( double value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( double value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( BigDecimal value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( BigDecimal value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Calendar value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( Calendar value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Date value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( Date value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Name value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( Name value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( Path value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( Path value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
@@ -152,14 +175,16 @@
/**
* {@inheritDoc}
*/
- public Reference create( URI value ) throws ValueFormatException {
- throw new
ValueFormatException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
Date.class.getSimpleName(), value));
+ public Reference create( URI value ) {
+ throw new
UnsupportedOperationException(SpiI18n.unableToCreateValue.text(getPropertyType().getName(),
+
Date.class.getSimpleName(),
+
value));
}
/**
* {@inheritDoc}
*/
- public Reference create( byte[] value ) throws ValueFormatException {
+ public Reference create( byte[] value ) {
// First attempt to create a string from the value, then a long from the string
...
return create(getStringValueFactory().create(value));
}
@@ -167,7 +192,8 @@
/**
* {@inheritDoc}
*/
- public Reference create( InputStream stream, int approximateLength ) throws
IOException, ValueFormatException {
+ public Reference create( InputStream stream,
+ int approximateLength ) {
// First attempt to create a string from the value, then a double from the string
...
return create(getStringValueFactory().create(stream, approximateLength));
}
@@ -175,7 +201,8 @@
/**
* {@inheritDoc}
*/
- public Reference create( Reader reader, int approximateLength ) throws IOException,
ValueFormatException {
+ public Reference create( Reader reader,
+ int approximateLength ) {
// 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/resources/org/jboss/dna/spi/SpiI18n.properties
===================================================================
--- trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-06-08
20:47:13 UTC (rev 249)
+++ trunk/dna-spi/src/main/resources/org/jboss/dna/spi/SpiI18n.properties 2008-06-09
14:44:48 UTC (rev 250)
@@ -20,8 +20,8 @@
# 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
#
closedConnectionMayNotBeUsed = The connection has been closed an may not be used
-errorConvertingBinaryValueToString = Error while interpreting binary value as a UTF-8
string
-errorCreatingValue = Error creating {0} value from {1} "{2}"
+errorConvertingIo = Error converting {0} to a {1}
+errorConvertingType = Error converting {0} to a {1}: {2}
errorReadingPropertyValueBytes = Error reading bytes
invalidIndexInSegmentName = Invalid index, "{0}", in segment name: {1}
invalidQualifiedNameString = Unable to parse qualified name from "{0}"
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/AbstractValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -39,7 +39,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.IoException;
import org.junit.Before;
import org.junit.Test;
@@ -56,71 +56,71 @@
super(PropertyType.STRING, decoder, stringValueFactory);
}
- public String create( String value ) throws ValueFormatException {
+ public String create( String value ) throws IoException {
return null;
}
- public String create( String value, TextDecoder decoder ) throws
ValueFormatException {
+ public String create( String value, TextDecoder decoder ) throws IoException {
return null;
}
- public String create( int value ) throws ValueFormatException {
+ public String create( int value ) throws IoException {
return null;
}
- public String create( long value ) throws ValueFormatException {
+ public String create( long value ) throws IoException {
return null;
}
- public String create( boolean value ) throws ValueFormatException {
+ public String create( boolean value ) throws IoException {
return null;
}
- public String create( float value ) throws ValueFormatException {
+ public String create( float value ) throws IoException {
return null;
}
- public String create( double value ) throws ValueFormatException {
+ public String create( double value ) throws IoException {
return null;
}
- public String create( BigDecimal value ) throws ValueFormatException {
+ public String create( BigDecimal value ) throws IoException {
return null;
}
- public String create( Calendar value ) throws ValueFormatException {
+ public String create( Calendar value ) throws IoException {
return null;
}
- public String create( Date value ) throws ValueFormatException {
+ public String create( Date value ) throws IoException {
return null;
}
- public String create( Name value ) throws ValueFormatException {
+ public String create( Name value ) throws IoException {
return null;
}
- public String create( Path value ) throws ValueFormatException {
+ public String create( Path value ) throws IoException {
return null;
}
- public String create( Reference value ) throws ValueFormatException {
+ public String create( Reference value ) throws IoException {
return null;
}
- public String create( URI value ) throws ValueFormatException {
+ public String create( URI value ) throws IoException {
return null;
}
- public String create( byte[] value ) throws ValueFormatException {
+ public String create( byte[] value ) throws IoException {
return null;
}
- public String create( InputStream stream, int approximateLength ) throws
ValueFormatException {
+ public String create( InputStream stream, int approximateLength ) throws
IoException {
return null;
}
- public String create( Reader reader, int approximateLength ) throws
ValueFormatException {
+ public String create( Reader reader, int approximateLength ) throws IoException
{
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-06-08
20:47:13 UTC (rev 249)
+++ trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BasicPathTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -36,7 +36,6 @@
import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathNotFoundException;
-import org.jboss.dna.spi.graph.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -63,8 +62,10 @@
public void beforeEach() throws Exception {
validNamespacePrefix = "dna";
validNamespaceUri = "http://www.jboss.org/dna";
- validSegmentNames = new Name[] {new BasicName(validNamespaceUri, "a"),
new BasicName(validNamespaceUri, "b"), new BasicName(validNamespaceUri,
"c")};
- validSegments = new Path.Segment[] {new BasicPathSegment(validSegmentNames[0]),
new BasicPathSegment(validSegmentNames[1]), new BasicPathSegment(validSegmentNames[1])};
+ validSegmentNames = new Name[] {new BasicName(validNamespaceUri, "a"),
new BasicName(validNamespaceUri, "b"),
+ new BasicName(validNamespaceUri, "c")};
+ validSegments = new Path.Segment[] {new BasicPathSegment(validSegmentNames[0]),
+ new BasicPathSegment(validSegmentNames[1]), new
BasicPathSegment(validSegmentNames[1])};
validSegmentsList = new ArrayList<Path.Segment>();
for (Path.Segment segment : validSegments) {
validSegmentsList.add(segment);
@@ -178,12 +179,12 @@
assertThat(pathFactory.create("/").isRoot(), is(true));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotConstructPathWithSuccessiveDelimiters() {
pathFactory.create("///a/b///c//d//");
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotConstructPathWithOnlyDelimiters() {
pathFactory.create("///");
}
@@ -525,7 +526,8 @@
testSegmentsByIteratorAndListAndArray(ROOT.getString());
}
- public void testSegmentsByIteratorAndListAndArray( String pathStr, String...
expectedSegmentStrings ) {
+ public void testSegmentsByIteratorAndListAndArray( String pathStr,
+ String... expectedSegmentStrings )
{
path = pathFactory.create(pathStr);
assertThat(expectedSegmentStrings.length, is(path.size()));
Path.Segment[] segmentArray = path.getSegmentsArray();
@@ -549,7 +551,8 @@
@Test
public void shouldGetStringWithNamespaceUrisIfNoNamespaceRegistryIsProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
- assertThat(path.getString(NO_OP_ENCODER),
is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../...);
+ assertThat(path.getString(NO_OP_ENCODER),
+
is("/{http://www.jboss.org/dna}a/{}b/{http://www.jboss.org/dna}c/../...);
}
@Test
@@ -628,7 +631,16 @@
@Test
public void shouldReturnSubpathIfValidStartingIndexAndEndingIndexAreProvided() {
path = pathFactory.create("/dna:a/b/dna:c/../d/./dna:e/../..");
- assertThat(path.subpath(0, path.size()), hasSegments(pathFactory,
"dna:a", "b", "dna:c", "..", "d",
".", "dna:e", "..", ".."));
+ assertThat(path.subpath(0, path.size()), hasSegments(pathFactory,
+ "dna:a",
+ "b",
+ "dna:c",
+ "..",
+ "d",
+ ".",
+ "dna:e",
+ "..",
+ ".."));
assertThat(path.subpath(0, path.size()), is(path));
assertThat(path.subpath(0, path.size()), is(sameInstance(path)));
assertThat(path.subpath(1, path.size()), hasSegments(pathFactory, "b",
"dna:c", "..", "d", ".", "dna:e",
"..", ".."));
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/BooleanValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -31,13 +31,13 @@
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.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class BooleanValueFactoryTest {
@@ -85,57 +85,57 @@
assertThat(factory.create(" 1 "), is(false));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromIntegerValue() {
factory.create(1);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromLongValue() {
factory.create(1l);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromFloatValue() {
factory.create(1.0f);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromDoubleValue() {
factory.create(1.0d);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromBigDecimal() {
factory.create(1.0d);
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromDate() {
factory.create(new Date());
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromCalendar() {
factory.create(Calendar.getInstance());
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromName() {
factory.create(context.mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromPath() {
factory.create(context.mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateBooleanFromReference() {
factory.create(context.mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DecimalValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -32,13 +32,13 @@
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.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class DecimalValueFactoryTest {
@@ -56,7 +56,7 @@
context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromBooleanValue() {
factory.create(true);
}
@@ -113,22 +113,22 @@
assertThat(factory.create(value),
is(BigDecimal.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromName() {
factory.create(context.mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromPath() {
factory.create(context.mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromReference() {
factory.create(context.mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDecimalFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -154,17 +154,18 @@
assertThat(factory.create(new StringReader("100.000101")),
is(BigDecimal.valueOf(100.000101d)));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateDecimalFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
- public void
shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void
shouldNotCreateDecimalFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDecimal()
+ throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateDecimalFromReaderContainingStringWithContentsOtherThanDecimal() throws
Exception {
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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/DoubleValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -32,13 +32,13 @@
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.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class DoubleValueFactoryTest {
@@ -56,7 +56,7 @@
context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -113,22 +113,22 @@
assertThat(factory.create(value), is(Double.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromName() {
factory.create(context.mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromPath() {
factory.create(context.mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromReference() {
factory.create(context.mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -157,17 +157,17 @@
assertThat(factory.create(new StringReader("1003044")),
is(1003044.d));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateDoubleFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanDouble()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateDoubleFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanDouble()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -32,13 +32,13 @@
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.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class JodaDateTimeValueFactoryTest {
@@ -65,7 +65,7 @@
context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromBoolean() {
factory.create(true);
}
@@ -82,7 +82,7 @@
assertThat(factory.create(" " + LAST_YEAR.getString() + "
"), is(LAST_YEAR));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateDateFromStringThatIsNotInTheStandardFormat() {
factory.create("something");
}
@@ -125,22 +125,22 @@
assertThat(factory.create(value), is((DateTime)new JodaDateTime(value)));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromName() {
factory.create(context.mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromPath() {
factory.create(context.mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromReference() {
factory.create(context.mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDateFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -163,17 +163,19 @@
assertThat(factory.create(new StringReader(LAST_YEAR.getString())),
is(LAST_YEAR));
}
- @Test( expected = ValueFormatException.class )
- public void
shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void
shouldNotCreateDateFromByteArrayContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
- public void
shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
throws Exception {
+ @Test( expected = IllegalArgumentException.class )
+ public void
shouldNotCreateDateFromInputStreamContainingUtf8EncodingOfStringWithContentThatIsNotWellFormedDate()
+ throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.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-06-08
20:47:13 UTC (rev 249)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/graph/impl/LongValueFactoryTest.java 2008-06-09
14:44:48 UTC (rev 250)
@@ -32,13 +32,13 @@
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.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
/**
* @author Randall Hauch
+ * @author John Verhaeg
*/
public class LongValueFactoryTest {
@@ -56,7 +56,7 @@
context = new Mockery();
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateDoubleFromBooleanValue() {
factory.create(true);
}
@@ -115,22 +115,22 @@
assertThat(factory.create(value), is(Long.valueOf(value.getTimeInMillis())));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromName() {
factory.create(context.mock(Name.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromPath() {
factory.create(context.mock(Path.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromReference() {
factory.create(context.mock(Reference.class));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = UnsupportedOperationException.class )
public void shouldNotCreateLongFromUri() throws Exception {
factory.create(new URI("http://www.jboss.org"));
}
@@ -159,17 +159,17 @@
assertThat(factory.create(new StringReader("1003044")), is(1003044l));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateLongFromByteArrayContainingUtf8EncodingOfStringWithContentsOtherThanLong()
throws Exception {
factory.create("something".getBytes("UTF-8"));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void
shouldNotCreateLongFromInputStreamContainingUtf8EncodingOfStringWithContentsOtherThanLong()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}
- @Test( expected = ValueFormatException.class )
+ @Test( expected = IllegalArgumentException.class )
public void shouldNotCreateLongFromReaderContainingStringWithContentsOtherThanLong()
throws Exception {
factory.create(new
ByteArrayInputStream("something".getBytes("UTF-8")));
}