Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 12814 invoked from network); 29 Jul 2009 15:45:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Jul 2009 15:45:51 -0000 Received: (qmail 9557 invoked by uid 500); 29 Jul 2009 15:45:52 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 9510 invoked by uid 500); 29 Jul 2009 15:45:52 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 9501 invoked by uid 99); 29 Jul 2009 15:45:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2009 15:45:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2009 15:45:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8E1FE23888E5; Wed, 29 Jul 2009 15:45:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798958 - in /jackrabbit/trunk: jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/ Date: Wed, 29 Jul 2009 15:45:28 -0000 To: commits@jackrabbit.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090729154529.8E1FE23888E5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stefan Date: Wed Jul 29 15:45:28 2009 New Revision: 798958 URL: http://svn.apache.org/viewvc?rev=798958&view=rev Log: JCR-2234: changed behavior of javax.jcr.Value get* methods JCR-2085: test case (TCK) maintenance for JCR 2.0 Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BaseValue.java Wed Jul 29 15:45:28 2009 @@ -51,12 +51,6 @@ protected static final String DEFAULT_ENCODING = "UTF-8"; - private static final short STATE_UNDEFINED = 0; - private static final short STATE_VALUE_CONSUMED = 1; - private static final short STATE_STREAM_CONSUMED = 2; - - private short state = STATE_UNDEFINED; - protected final int type; protected InputStream stream = null; @@ -71,39 +65,6 @@ } /** - * Checks if the non-stream value of this instance has already been - * consumed (if any getter methods except {@link #getStream()} and - * {@link #getType()} have been previously called at least once) and - * sets the state to STATE_STREAM_CONSUMED. - * - * @throws IllegalStateException if any getter methods other than - * getStream() and - * getType() have been - * previously called at least once. - */ - protected void setStreamConsumed() throws IllegalStateException { - if (state == STATE_VALUE_CONSUMED) { - throw new IllegalStateException("non-stream value has already been consumed"); - } - state = STATE_STREAM_CONSUMED; - } - - /** - * Checks if the stream value of this instance has already been - * consumed (if {@link #getStream()} has been previously called - * at least once) and sets the state to STATE_VALUE_CONSUMED. - * - * @throws IllegalStateException if getStream() has been - * previously called at least once. - */ - protected void setValueConsumed() throws IllegalStateException { - if (state == STATE_STREAM_CONSUMED) { - throw new IllegalStateException("stream value has already been consumed"); - } - state = STATE_VALUE_CONSUMED; - } - - /** * Returns the internal string representation of this value without modifying * the value state. * @@ -130,8 +91,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - Calendar cal = ISO8601.parse(getInternalString()); if (cal == null) { throw new ValueFormatException("not a valid date format"); @@ -146,8 +105,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - try { return Long.parseLong(getInternalString()); } catch (NumberFormatException e) { @@ -161,9 +118,7 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - - return Boolean.valueOf(getInternalString()).booleanValue(); + return Boolean.valueOf(getInternalString()); } /** @@ -172,8 +127,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - try { return Double.parseDouble(getInternalString()); } catch (NumberFormatException e) { @@ -187,8 +140,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - try { return new BigDecimal(getInternalString()); } catch (NumberFormatException e) { @@ -201,8 +152,6 @@ */ public InputStream getStream() throws IllegalStateException, RepositoryException { - setStreamConsumed(); - if (stream != null) { return stream; } @@ -240,8 +189,6 @@ public String getString() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - return getInternalString(); } } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BinaryValue.java Wed Jul 29 15:45:28 2009 @@ -152,8 +152,6 @@ */ public InputStream getStream() throws IllegalStateException, RepositoryException { - setStreamConsumed(); - if (stream == null) { if (bin != null) { stream = bin.getStream(); Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/BooleanValue.java Wed Jul 29 15:45:28 2009 @@ -49,7 +49,7 @@ */ public BooleanValue(boolean bool) { super(TYPE); - this.bool = Boolean.valueOf(bool); + this.bool = bool; } /** @@ -120,8 +120,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -131,8 +129,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -142,10 +138,8 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (bool != null) { - return bool.booleanValue(); + return bool; } else { throw new ValueFormatException("empty value"); } @@ -157,8 +151,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -168,8 +160,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DateValue.java Wed Jul 29 15:45:28 2009 @@ -135,8 +135,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (date != null) { return (Calendar) date.clone(); } else { @@ -150,8 +148,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (date != null) { return date.getTimeInMillis(); } else { @@ -165,8 +161,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (date != null) { throw new ValueFormatException("cannot convert date to boolean"); } else { @@ -180,8 +174,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (date != null) { long ms = date.getTimeInMillis(); if (ms <= Double.MAX_VALUE) { @@ -199,8 +191,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (date != null) { return new BigDecimal(date.getTimeInMillis()); } else { Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DecimalValue.java Wed Jul 29 15:45:28 2009 @@ -117,8 +117,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (number != null) { // loosing timezone information... Calendar cal = Calendar.getInstance(); @@ -135,8 +133,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (number != null) { return number.longValue(); } else { @@ -150,8 +146,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -161,8 +155,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (number != null) { return number.doubleValue(); } else { @@ -176,8 +168,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (number != null) { return number; } else { Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/DoubleValue.java Wed Jul 29 15:45:28 2009 @@ -50,7 +50,7 @@ */ public DoubleValue(double dbl) { super(TYPE); - this.dblNumber = new Double(dbl); + this.dblNumber = dbl; } /** @@ -127,8 +127,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (dblNumber != null) { // loosing timezone information... Calendar cal = Calendar.getInstance(); @@ -145,8 +143,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (dblNumber != null) { return dblNumber.longValue(); } else { @@ -160,8 +156,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -171,10 +165,8 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (dblNumber != null) { - return dblNumber.doubleValue(); + return dblNumber; } else { throw new ValueFormatException("empty value"); } @@ -186,10 +178,8 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (dblNumber != null) { - return new BigDecimal(dblNumber.doubleValue()); + return new BigDecimal(dblNumber); } else { throw new ValueFormatException("empty value"); } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/LongValue.java Wed Jul 29 15:45:28 2009 @@ -50,7 +50,7 @@ */ public LongValue(long l) { super(TYPE); - this.lNumber = new Long(l); + this.lNumber = l; } /** @@ -127,12 +127,10 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (lNumber != null) { // loosing timezone information... Calendar cal = Calendar.getInstance(); - cal.setTime(new Date(lNumber.longValue())); + cal.setTime(new Date(lNumber)); return cal; } else { throw new ValueFormatException("empty value"); @@ -145,10 +143,8 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (lNumber != null) { - return lNumber.longValue(); + return lNumber; } else { throw new ValueFormatException("empty value"); } @@ -160,8 +156,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -171,8 +165,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (lNumber != null) { return lNumber.doubleValue(); } else { @@ -186,10 +178,8 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - if (lNumber != null) { - return new BigDecimal(lNumber.longValue()); + return new BigDecimal(lNumber); } else { throw new ValueFormatException("empty value"); } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/NameValue.java Wed Jul 29 15:45:28 2009 @@ -122,8 +122,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -133,8 +131,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -144,8 +140,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -155,8 +149,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -166,8 +158,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/PathValue.java Wed Jul 29 15:45:28 2009 @@ -122,8 +122,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -133,8 +131,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -144,8 +140,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -155,8 +149,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -166,8 +158,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/ReferenceValue.java Wed Jul 29 15:45:28 2009 @@ -147,8 +147,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -158,8 +156,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -169,8 +165,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -180,8 +174,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -191,8 +183,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/URIValue.java Wed Jul 29 15:45:28 2009 @@ -126,8 +126,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -137,8 +135,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -148,8 +144,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -159,8 +153,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -170,8 +162,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } \ No newline at end of file Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/value/WeakReferenceValue.java Wed Jul 29 15:45:28 2009 @@ -147,8 +147,6 @@ public Calendar getDate() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to date failed: inconvertible types"); } @@ -158,8 +156,6 @@ public long getLong() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to long failed: inconvertible types"); } @@ -169,8 +165,6 @@ public boolean getBoolean() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to boolean failed: inconvertible types"); } @@ -180,8 +174,6 @@ public double getDouble() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to double failed: inconvertible types"); } @@ -191,8 +183,6 @@ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); - throw new ValueFormatException("conversion to Decimal failed: inconvertible types"); } } \ No newline at end of file Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/BooleanPropertyTest.java Wed Jul 29 15:45:28 2009 @@ -137,17 +137,15 @@ } try { val.getBoolean(); - fail("Non stream method call after stream method call " + - "should throw an IllegalStateException"); } catch (IllegalStateException ise) { - //ok + fail("Non stream method call after stream method call " + + "should not throw an IllegalStateException"); } try { ins = otherVal.getStream(); - fail("Stream method call after a non stream method call " + - "should throw an IllegalStateException"); } catch (IllegalStateException ise) { - // ok + fail("Stream method call after a non stream method call " + + "should not throw an IllegalStateException"); } finally { if (in != null) { in.close(); Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DatePropertyTest.java Wed Jul 29 15:45:28 2009 @@ -146,17 +146,15 @@ } try { val.getDate(); - fail("Non stream method call after stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - //ok + fail("Non stream method call after stream method call " + + "should not throw an IllegalStateException."); } try { ins = otherVal.getStream(); - fail("Stream method call after a non stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - // ok + fail("Stream method call after a non stream method call " + + "should not throw an IllegalStateException."); } finally { if (in != null) { in.close(); Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/DoublePropertyTest.java Wed Jul 29 15:45:28 2009 @@ -130,17 +130,15 @@ } try { val.getDouble(); - fail("Non stream method call after stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - //ok + fail("Non stream method call after stream method call " + + "should not throw an IllegalStateException."); } try { ins = otherVal.getStream(); - fail("Stream method call after a non stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - // ok + fail("Stream method call after a non stream method call " + + "should not throw an IllegalStateException."); } finally { if (in != null) { in.close(); Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/LongPropertyTest.java Wed Jul 29 15:45:28 2009 @@ -128,17 +128,15 @@ } try { val.getLong(); - fail("Non stream method call after stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - //ok + fail("Non stream method call after stream method call " + + "should not throw an IllegalStateException."); } try { ins = otherVal.getStream(); - fail("Stream method call after a non stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - // ok + fail("Stream method call after a non stream method call " + + "should not throw an IllegalStateException."); } finally { if (in != null) { in.close(); Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java Wed Jul 29 15:45:28 2009 @@ -122,9 +122,7 @@ Property prop; - // create an extra value for BINARY property to avoid IllegalStateException - Value stringValueForBinary = NodeTypeUtil.getValueOfType(superuser, PropertyType.STRING); - prop = testNode.setProperty(testPropName, stringValueForBinary, PropertyType.BINARY); + prop = testNode.setProperty(testPropName, binaryValue, PropertyType.BINARY); assertEquals("setProperty(String, Value, int) of a property of type undefined " + "must assume the property type of the type parameter.", PropertyType.BINARY, @@ -186,10 +184,7 @@ Property prop; - // create an extra value for BINARY property to avoid IllegalStateException - Value stringValuesForBinary[] = - new Value[] {NodeTypeUtil.getValueOfType(superuser, PropertyType.STRING)}; - prop = testNode.setProperty(testPropName, stringValuesForBinary, PropertyType.BINARY); + prop = testNode.setProperty(testPropName, binaryValues, PropertyType.BINARY); assertEquals("setProperty(String, Value, int) of a property of type undefined " + "must assume the property type of the type parameter.", PropertyType.BINARY, Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/StringPropertyTest.java Wed Jul 29 15:45:28 2009 @@ -193,17 +193,15 @@ } try { val.getString(); - fail("Non stream method call after stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - //ok + fail("Non stream method call after stream method call " + + "should not throw an IllegalStateException."); } try { otherVal.getStream(); - fail("Stream method call after a non stream method call " + - "should throw an IllegalStateException."); } catch (IllegalStateException ise) { - // ok + fail("Stream method call after a non stream method call " + + "should not throw an IllegalStateException."); } in.close(); } Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=798958&r1=798957&r2=798958&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java (original) +++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java Wed Jul 29 15:45:28 2009 @@ -38,15 +38,6 @@ */ public final class QValueValue implements Value { - private static final short STATE_UNDEFINED = 0; - - private static final short STATE_VALUE_CONSUMED = 1; - - private static final short STATE_STREAM_CONSUMED = 2; - - // the state of this value instance - private short state = STATE_UNDEFINED; - // wrapped QValue private final QValue qvalue; @@ -82,7 +73,6 @@ * @see javax.jcr.Value#getBoolean() */ public boolean getBoolean() throws RepositoryException { - setValueConsumed(); if (getType() == PropertyType.STRING || getType() == PropertyType.BINARY || getType() == PropertyType.BOOLEAN) { return Boolean.valueOf(qvalue.getString()).booleanValue(); } else { @@ -94,7 +84,6 @@ * @see javax.jcr.Value#getDecimal() */ public BigDecimal getDecimal() throws ValueFormatException, IllegalStateException, RepositoryException { - setValueConsumed(); switch (getType()) { case PropertyType.DECIMAL: case PropertyType.DOUBLE: @@ -118,7 +107,6 @@ * @see javax.jcr.Value#getDate() */ public Calendar getDate() throws RepositoryException { - setValueConsumed(); return qvalue.getCalendar(); } @@ -126,7 +114,6 @@ * @see javax.jcr.Value#getDouble() */ public double getDouble() throws RepositoryException { - setValueConsumed(); return qvalue.getDouble(); } @@ -134,7 +121,6 @@ * @see javax.jcr.Value#getLong() */ public long getLong() throws RepositoryException { - setValueConsumed(); return qvalue.getLong(); } @@ -142,7 +128,6 @@ * @see javax.jcr.Value#getStream() */ public InputStream getStream() throws IllegalStateException, RepositoryException { - setStreamConsumed(); if (stream == null) { if (getType() == PropertyType.NAME || getType() == PropertyType.PATH) { // needs namespace mapping @@ -165,7 +150,6 @@ * @see javax.jcr.Value#getString() */ public String getString() throws RepositoryException { - setValueConsumed(); if (getType() == PropertyType.NAME) { // needs formatting return resolver.getJCRName(qvalue.getName()); @@ -202,38 +186,4 @@ public int hashCode() { return qvalue.hashCode(); } - - //-------------------------------------------------------------------------- - /** - * Checks if the non-stream value of this instance has already been - * consumed (if any getter methods except {@link #getStream()} and - * {@link #getType()} have been previously called at least once) and - * sets the state to STATE_STREAM_CONSUMED. - * - * @throws IllegalStateException if any getter methods other than - * getStream() and - * getType() have been - * previously called at least once. - */ - private void setStreamConsumed() throws IllegalStateException { - if (state == STATE_VALUE_CONSUMED) { - throw new IllegalStateException("non-stream value has already been consumed"); - } - state = STATE_STREAM_CONSUMED; - } - - /** - * Checks if the stream value of this instance has already been - * consumed (if {@link #getStream()} has been previously called - * at least once) and sets the state to STATE_VALUE_CONSUMED. - * - * @throws IllegalStateException if getStream() has been - * previously called at least once. - */ - private void setValueConsumed() throws IllegalStateException { - if (state == STATE_STREAM_CONSUMED) { - throw new IllegalStateException("stream value has already been consumed"); - } - state = STATE_VALUE_CONSUMED; - } }