Return-Path: Delivered-To: apmail-incubator-jackrabbit-commits-archive@www.apache.org Received: (qmail 94648 invoked from network); 1 Apr 2005 13:40:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Apr 2005 13:40:11 -0000 Received: (qmail 93274 invoked by uid 500); 1 Apr 2005 13:40:10 -0000 Mailing-List: contact jackrabbit-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-commits@incubator.apache.org Received: (qmail 93260 invoked by uid 500); 1 Apr 2005 13:40:10 -0000 Delivered-To: apmail-incubator-jackrabbit-cvs@incubator.apache.org Received: (qmail 93254 invoked by uid 99); 1 Apr 2005 13:40:10 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 01 Apr 2005 05:40:09 -0800 Received: (qmail 94644 invoked by uid 65534); 1 Apr 2005 13:40:08 -0000 Message-ID: <20050401134008.94641.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Fri, 01 Apr 2005 13:40:08 -0000 Subject: svn commit: r159686 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: util/Base64.java util/ValueHelper.java xml/DocViewSAXEventGenerator.java xml/SysViewImportHandler.java xml/SysViewSAXEventGenerator.java To: jackrabbit-cvs@incubator.apache.org From: stefan@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: stefan Date: Fri Apr 1 05:40:06 2005 New Revision: 159686 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D159686 Log: consolidated Value de-/serialization code in static methods of ValueHelper = class Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Bas= e64.java incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Val= ueHelper.java incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocV= iewSAXEventGenerator.java incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewImportHandler.java incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewSAXEventGenerator.java Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ut= il/Base64.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/= apache/jackrabbit/core/util/Base64.java?view=3Ddiff&r1=3D159685&r2=3D159686 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Bas= e64.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Bas= e64.java Fri Apr 1 05:40:06 2005 @@ -35,7 +35,8 @@ private static final char[] BASE64CHARS =3D "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678= 9+/".toCharArray(); =20 - // decoding table (used to lookup original 6-bit with base64 character= as table index) + // decoding table (used to lookup original 6-bit with base64 character + // as table index) private static final byte[] DECODETABLE =3D new byte[128]; =20 static { @@ -72,8 +73,9 @@ } =20 /** - * Pessimistically guesses the size (i.e. number of bytes) of the deco= ded output - * given the length (i.e. number of bytes) of the base64 encoded data. + * Pessimistically guesses the size (i.e. number of bytes) of the deco= ded + * output given the length (i.e. number of bytes) of the base64 encoded + * data. * * @param encLength length (i.e. number of bytes) of the base64 encode= d data * @return size (i.e. number of bytes) of the decoded output @@ -84,10 +86,12 @@ } =20 /** - * Outputs base64 representation of the specified stream data to an OutputStream. + * Outputs base64 representation of the specified stream data to a + * Writer. * * @param in stream data to be encoded * @param writer writer to output the encoded data + * @throws IOException if an i/o error occurs */ public static void encode(InputStream in, Writer writer) throws IOException { @@ -95,17 +99,19 @@ // chunksize must be a multiple of 3 in order // to avoid padding within output byte[] buffer =3D new byte[9 * 1024]; - int read =3D 0; + int read; while ((read =3D in.read(buffer)) > 0) { encode(buffer, 0, read, writer); } } =20 /** - * Outputs base64 representation of the specified stream data to an OutputStream. + * Outputs base64 representation of the specified stream data to an + * OutputStream. * * @param in stream data to be encoded * @param out stream where the encoded data should be written to + * @throws IOException if an i/o error occurs */ public static void encode(InputStream in, OutputStream out) throws IOException { @@ -114,12 +120,14 @@ } =20 /** - * Outputs base64 representation of the specified data to an Out= putStream. + * Outputs base64 representation of the specified data to a + * Writer. * * @param data data to be encoded * @param off offset within data at which to start encoding * @param len length of data to encode * @param writer writer to output the encoded data + * @throws IOException if an i/o error occurs */ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException { @@ -166,8 +174,10 @@ * * @param reader reader for the base64 encoded data to be decoded * @param out stream where the decoded data should be written to + * @throws IOException if an i/o error occurs */ - public static void decode(Reader reader, OutputStream out) throws IOEx= ception { + public static void decode(Reader reader, OutputStream out) + throws IOException { char[] chunk =3D new char[8192]; int read; while ((read =3D reader.read(chunk)) > -1) { @@ -181,8 +191,10 @@ * * @param in inputstream of the base64 encoded data to be decoded * @param out stream where the decoded data should be written to + * @throws IOException if an i/o error occurs */ - public static void decode(InputStream in, OutputStream out) throws IOE= xception { + public static void decode(InputStream in, OutputStream out) + throws IOException { decode(new InputStreamReader(in, CHARSET), out); } =20 @@ -191,8 +203,10 @@ * * @param data the base64 encoded data to be decoded * @param out stream where the decoded data should be written to + * @throws IOException if an i/o error occurs */ - public static void decode(String data, OutputStream out) throws IOExce= ption { + public static void decode(String data, OutputStream out) + throws IOException { char[] chars =3D data.toCharArray(); decode(chars, 0, chars.length, out); } @@ -202,8 +216,10 @@ * * @param chars the base64 encoded data to be decoded * @param out stream where the decoded data should be written to + * @throws IOException if an i/o error occurs */ - public static void decode(char[] chars, OutputStream out) throws IOExc= eption { + public static void decode(char[] chars, OutputStream out) + throws IOException { decode(chars, 0, chars.length, out); } =20 @@ -214,8 +230,10 @@ * @param off offset within data at which to start decoding * @param len length of data to decode * @param out stream where the decoded data should be written to + * @throws IOException if an i/o error occurs */ - public static void decode(char[] chars, int off, int len, OutputStream= out) throws IOException { + public static void decode(char[] chars, int off, int len, OutputStream= out) + throws IOException { if (len =3D=3D 0) { return; } Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ut= il/ValueHelper.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/= apache/jackrabbit/core/util/ValueHelper.java?view=3Ddiff&r1=3D159685&r2=3D1= 59686 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Val= ueHelper.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/Val= ueHelper.java Fri Apr 1 05:40:06 2005 @@ -34,6 +34,12 @@ import javax.jcr.StringValue; import javax.jcr.Value; import javax.jcr.ValueFormatException; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; =20 /** * The ValueHelper class provides several Value @@ -52,11 +58,10 @@ * @param targetType * @return * @throws ValueFormatException - * @throws IllegalStateException * @throws IllegalArgumentException */ public static Value convert(String srcValue, int targetType) - throws ValueFormatException, IllegalStateException, IllegalArg= umentException { + throws ValueFormatException, IllegalArgumentException { return convert(new StringValue(srcValue), targetType); } =20 @@ -69,7 +74,8 @@ * @throws IllegalArgumentException */ public static Value convert(Value srcValue, int targetType) - throws ValueFormatException, IllegalStateException, IllegalArg= umentException { + throws ValueFormatException, IllegalStateException, + IllegalArgumentException { Value val; int srcType =3D srcValue.getType(); =20 @@ -163,13 +169,15 @@ path =3D srcValue.getString(); } catch (RepositoryException re) { // should never happen - throw new ValueFormatException("failed to conv= ert source value to PATH value", re); + throw new ValueFormatException("failed to conv= ert source value to PATH value", + re); } try { // check path format Path.checkFormat(path); } catch (MalformedPathException mpe) { - throw new ValueFormatException("source value "= + path + " does not represent a valid path", mpe); + throw new ValueFormatException("source value "= + path + + " does not represent a valid path", = mpe); } val =3D PathValue.valueOf(path); break; @@ -198,7 +206,7 @@ =20 case PropertyType.BINARY: case PropertyType.STRING: - case PropertyType.PATH: // path might be a name (relat= ive, onle element long path) + case PropertyType.PATH: // path might be a name (relat= ive path of length 1) // try conversion via string String name; try { @@ -206,13 +214,16 @@ name =3D srcValue.getString(); } catch (RepositoryException re) { // should never happen - throw new ValueFormatException("failed to conv= ert source value to NAME value", re); + throw new ValueFormatException("failed to conv= ert source value to NAME value", + re); } try { // check name format QName.checkFormat(name); } catch (IllegalNameException ine) { - throw new ValueFormatException("source value "= + name + " does not represent a valid name", ine); + throw new ValueFormatException("source value " + + name + + " does not represent a valid name", = ine); } val =3D NameValue.valueOf(name); break; @@ -248,7 +259,8 @@ uuid =3D srcValue.getString(); } catch (RepositoryException re) { // should never happen - throw new ValueFormatException("failed to conv= ert source value to REFERENCE value", re); + throw new ValueFormatException("failed to conv= ert source value to REFERENCE value", + re); } val =3D ReferenceValue.valueOf(uuid); break; @@ -340,5 +352,159 @@ newVal[i] =3D copy(srcVal[i]); } return newVal; + } + + /** + * Serializes the given value to a String. The serializat= ion + * format is the same as used by Document & System View XML, i.e. + * binary values will be Base64-encoded whereas for all others + * {@link javax.jcr.Value#getString()} will be used. + * + * @param value the value to be serialized + * @param encodeBlanks if true space characters will be e= ncoded + * as "_x0020_" within he output stri= ng. + * @return a string representation of the given value. + * @throws IllegalStateException if the given value is in an illegal s= tate + * @throws RepositoryException if an error occured during the serial= ization. + */ + public static String serialize(Value value, boolean encodeBlanks) + throws IllegalStateException, RepositoryException { + StringWriter writer =3D new StringWriter(); + try { + serialize(value, encodeBlanks, writer); + } catch (IOException ioe) { + throw new RepositoryException("failed to serialize value", + ioe); + } + return writer.toString(); + } + + /** + * Outputs the serialized value to a Writer. The serializ= ation + * format is the same as used by Document & System View XML, i.e. + * binary values will be Base64-encoded whereas for all others + * {@link javax.jcr.Value#getString()} will be used for + * serialization. + * + * @param value the value to be serialized + * @param encodeBlanks if true space characters will be e= ncoded + * as "_x0020_" within he output stri= ng. + * @param writer writer to output the encoded data + * @throws IllegalStateException if the given value is in an illegal s= tate + * @throws IOException if an i/o error occured during the + * serialization + * @throws RepositoryException if an error occured during the serial= ization. + */ + public static void serialize(Value value, boolean encodeBlanks, + Writer writer) + throws IllegalStateException, IOException, RepositoryException= { + if (value.getType() =3D=3D PropertyType.BINARY) { + // binary data, base64 encoding required; + // the encodeBlanks flag can be ignored since base64-encoded + // data cannot contain space characters + InputStream in =3D value.getStream(); + try { + Base64.encode(in, writer); + // no need to close StringWriter + //writer.close(); + } finally { + try { + in.close(); + } catch (IOException e) { + // ignore + } + } + } else { + String textVal =3D value.getString(); + if (encodeBlanks) { + // enocde blanks in string + textVal =3D Text.replace(textVal, " ", "_x0020_"); + } + writer.write(textVal); + } + } + + /** + * Deserializes the given string to a Value of the given = type. + * + * @param value string to be deserialized + * @param type type of value + * @param decodeBlanks if true "_x0020_" + * character sequences will be decoded to single s= pace + * characters each. + * @return the deserialized Value + * @throws ValueFormatException if the string data is not of the requi= red + * format + * @throws RepositoryException if an error occured during the + * deserialization. + */ + public static Value deserialize(String value, int type, + boolean decodeBlanks) + throws RepositoryException { + if (type =3D=3D PropertyType.BINARY) { + // base64 encoded binary value; + // the encodeBlanks flag can be ignored since base64-encoded + // data cannot contain encoded space characters + ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); + try { + Base64.decode(value, baos); + // no need to close ByteArrayOutputStream + //baos.close(); + } catch (IOException ioe) { + throw new RepositoryException("failed to decode binary val= ue", + ioe); + } + return new BinaryValue(baos.toByteArray()); + } else { + if (decodeBlanks) { + // decode encoded blanks in value + value =3D Text.replace(value, "_x0020_", " "); + } + return convert(value, type); + } + } + + /** + * Deserializes the string data read from the given reader to a + * Value of the given type. + * + * @param reader reader for the string data to be deserialized + * @param type type of value + * @param decodeBlanks if true "_x0020_" + * character sequences will be decoded to single s= pace characters each. + * @return the deserialized Value + * @throws IOException if an i/o error occured during the + * serialization + * @throws ValueFormatException if the string data is not of the requi= red + * format + * @throws RepositoryException if an error occured during the + * deserialization. + */ + public static Value deserialize(Reader reader, int type, + boolean decodeBlanks) + throws IOException, ValueFormatException, RepositoryException { + if (type =3D=3D PropertyType.BINARY) { + // base64 encoded binary value; + // the encodeBlanks flag can be ignored since base64-encoded + // data cannot contain encoded space characters + ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); + Base64.decode(reader, baos); + // no need to close ByteArrayOutputStream + //baos.close(); + return new BinaryValue(baos.toByteArray()); + } else { + char[] chunk =3D new char[8192]; + int read; + StringBuffer buf =3D new StringBuffer(); + while ((read =3D reader.read(chunk)) > -1) { + buf.append(chunk, 0, read); + } + String value =3D buf.toString(); + if (decodeBlanks) { + // decode encoded blanks in value + value =3D Text.replace(value, "_x0020_", " "); + } + return convert(value, type); + } } } Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xm= l/DocViewSAXEventGenerator.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/= apache/jackrabbit/core/xml/DocViewSAXEventGenerator.java?view=3Ddiff&r1=3D1= 59685&r2=3D159686 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocV= iewSAXEventGenerator.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/DocV= iewSAXEventGenerator.java Fri Apr 1 05:40:06 2005 @@ -21,9 +21,8 @@ import org.apache.jackrabbit.core.PropertyImpl; import org.apache.jackrabbit.core.QName; import org.apache.jackrabbit.core.SessionImpl; -import org.apache.jackrabbit.core.util.Base64; import org.apache.jackrabbit.core.util.ISO9075; -import org.apache.jackrabbit.core.util.Text; +import org.apache.jackrabbit.core.util.ValueHelper; import org.apache.log4j.Logger; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; @@ -32,9 +31,6 @@ import javax.jcr.PropertyType; import javax.jcr.RepositoryException; import javax.jcr.Value; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -56,11 +52,13 @@ * Constructor * * @param node the node state which should be serialized - * @param noRecurse if true, only node and its prope= rties will - * be serialized; otherwise the entire hierarchy= starting with - * node will be serialized. - * @param skipBinary flag governing whether binary properties are = to be serialized. - * @param session the session to be used for resolving namespac= e mappings + * @param noRecurse if true, only node and its prope= rties + * will be serialized; otherwise the entire hier= archy + * starting with node will be seria= lized. + * @param skipBinary flag governing whether binary properties are = to be + * serialized. + * @param session the session to be used for resolving namespace + * mappings * @param contentHandler the content handler to feed the SAX events to */ public DocViewSAXEventGenerator(NodeImpl node, boolean noRecurse, @@ -145,7 +143,8 @@ attrName =3D propName.toJCRName(session.getNamespaceRe= solver()); } catch (NoPrefixDeclaredException npde) { // should never get here... - String msg =3D "internal error: encountered unregister= ed namespace"; + String msg =3D + "internal error: encountered unregistered name= space"; log.debug(msg); throw new RepositoryException(msg, npde); } @@ -164,43 +163,15 @@ // use space as delimiter for multi-valued propert= ies attrValue.append(" "); } - Value val =3D vals[i]; - String textVal; - if (prop.getType() =3D=3D PropertyType.BINARY) { - // binary data, base64 encoding required - InputStream in =3D val.getStream(); - StringWriter writer =3D new StringWriter(); - try { - Base64.encode(in, writer); - // no need to close StringWriter - //writer.close(); - } catch (IOException ioe) { - // check if the exception wraps a SAXException - Throwable t =3D ioe.getCause(); - if (t !=3D null && t instanceof SAXException) { - throw (SAXException) t; - } else { - throw new SAXException(ioe); - } - } finally { - try { - in.close(); - } catch (IOException e) { - // ignore - } - } - textVal =3D writer.toString(); - } else { - textVal =3D val.getString(); - } - // enocde blanks in value - textVal =3D Text.replace(textVal, " ", "_x0020_"); - attrValue.append(textVal); + attrValue.append(ValueHelper.serialize(vals[i], true)); } - attrs.addAttribute(propName.getNamespaceURI(), propName.ge= tLocalName(), attrName, CDATA_TYPE, attrValue.toString()); + attrs.addAttribute(propName.getNamespaceURI(), + propName.getLocalName(), attrName, CDATA_TYPE, + attrValue.toString()); } // start element (node) - contentHandler.startElement(name.getNamespaceURI(), name.getLo= calName(), elemName, attrs); + contentHandler.startElement(name.getNamespaceURI(), + name.getLocalName(), elemName, attrs); } } =20 @@ -232,7 +203,8 @@ } =20 // end element (node) - contentHandler.endElement(name.getNamespaceURI(), name.getLocalNam= e(), elemName); + contentHandler.endElement(name.getNamespaceURI(), name.getLocalNam= e(), + elemName); } =20 /** Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xm= l/SysViewImportHandler.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/= apache/jackrabbit/core/xml/SysViewImportHandler.java?view=3Ddiff&r1=3D15968= 5&r2=3D159686 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewImportHandler.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewImportHandler.java Fri Apr 1 05:40:06 2005 @@ -23,7 +23,7 @@ import org.apache.jackrabbit.core.NamespaceResolver; import org.apache.jackrabbit.core.QName; import org.apache.jackrabbit.core.UnknownPrefixException; -import org.apache.jackrabbit.core.util.Base64; +import org.apache.jackrabbit.core.util.ValueHelper; import org.apache.log4j.Logger; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -32,9 +32,6 @@ import javax.jcr.InvalidSerializedDataException; import javax.jcr.PropertyType; import javax.jcr.RepositoryException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.Stack; =20 @@ -285,20 +282,9 @@ InternalValue[] vals =3D new InternalValue[currentProp= Values.size()]; for (int i =3D 0; i < currentPropValues.size(); i++) { String value =3D (String) currentPropValues.get(i); - if (currentPropType =3D=3D PropertyType.BINARY) { - // base64 encoded binary value - ByteArrayOutputStream baos =3D new ByteArrayOu= tputStream(); - try { - Base64.decode(value, baos); - baos.close(); - vals[i] =3D InternalValue.create(new ByteA= rrayInputStream(baos.toByteArray())); - } catch (IOException ioe) { - throw new SAXException("failed to decode b= inary value", ioe); - } - } else { - vals[i] =3D InternalValue.create(value, - currentPropType, nsContext); - } + vals[i] =3D InternalValue.create( + ValueHelper.deserialize(value, currentProp= Type, + false), nsContext); } Importer.PropInfo prop =3D new Importer.PropInfo(); prop.setName(currentPropName); Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xm= l/SysViewSAXEventGenerator.java URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/= apache/jackrabbit/core/xml/SysViewSAXEventGenerator.java?view=3Ddiff&r1=3D1= 59685&r2=3D159686 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewSAXEventGenerator.java (original) +++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/xml/SysV= iewSAXEventGenerator.java Fri Apr 1 05:40:06 2005 @@ -21,7 +21,7 @@ import org.apache.jackrabbit.core.PropertyImpl; import org.apache.jackrabbit.core.QName; import org.apache.jackrabbit.core.SessionImpl; -import org.apache.jackrabbit.core.util.Base64; +import org.apache.jackrabbit.core.util.ValueHelper; import org.apache.log4j.Logger; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; @@ -31,7 +31,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; import java.io.IOException; -import java.io.InputStream; import java.io.Writer; =20 /** @@ -197,47 +196,36 @@ PREFIXED_VALUE_ELEMENT, new AttributesImpl()); =20 // characters - if (prop.getType() =3D=3D PropertyType.BINARY) { - // binary data, base64 encoding required - InputStream in =3D val.getStream(); - Writer writer =3D new Writer() { - public void close() /*throws IOException*/ { - } + Writer writer =3D new Writer() { + public void close() /*throws IOException*/ { + } =20 - public void flush() /*throws IOException*/ { - } + public void flush() /*throws IOException*/ { + } =20 - public void write(char[] cbuf, int off, int len) throw= s IOException { - try { - contentHandler.characters(cbuf, off, len); - } catch (SAXException se) { - throw new IOException(se.toString()); - } - } - }; - try { - Base64.encode(in, writer); - // no need to close our Writer implementation - //writer.close(); - } catch (IOException ioe) { - // check if the exception wraps a SAXException - Throwable t =3D ioe.getCause(); - if (t !=3D null && t instanceof SAXException) { - throw (SAXException) t; - } else { - throw new SAXException(ioe); - } - } finally { + public void write(char[] cbuf, int off, int len) throws IO= Exception { try { - in.close(); - } catch (IOException e) { - // ignore + contentHandler.characters(cbuf, off, len); + } catch (SAXException se) { + throw new IOException(se.toString()); } } - } else { - char[] chars =3D val.getString().toCharArray(); - contentHandler.characters(chars, 0, chars.length); + }; + try { + ValueHelper.serialize(val, false, writer); + // no need to close our Writer implementation + //writer.close(); + } catch (IOException ioe) { + // check if the exception wraps a SAXException + // (see Writer.write(char[], int, int) above) + Throwable t =3D ioe.getCause(); + if (t !=3D null && t instanceof SAXException) { + throw (SAXException) t; + } else { + throw new SAXException(ioe); + } } + // end value element contentHandler.endElement(NS_SV_URI, VALUE_ELEMENT, PREFIXED_VALUE_ELEMENT);