diff --git a/exist-core/pom.xml b/exist-core/pom.xml index c1f50335fc..86238d272e 100644 --- a/exist-core/pom.xml +++ b/exist-core/pom.xml @@ -2711,6 +2711,7 @@ The BaseX Team. The original license statement is also included below.]]>org.exist.xmldb.ShutdownTest + org.exist.xmldb.concurrent.ConcurrentResource2Test org.exist.xmlrpc.MoveResourceTest diff --git a/exist-core/src/main/java/org/exist/dom/persistent/DocumentImpl.java b/exist-core/src/main/java/org/exist/dom/persistent/DocumentImpl.java index e5a0f919b8..f8f55beffe 100644 --- a/exist-core/src/main/java/org/exist/dom/persistent/DocumentImpl.java +++ b/exist-core/src/main/java/org/exist/dom/persistent/DocumentImpl.java @@ -504,6 +504,8 @@ public String getMimeType() { /** * Set the Internet Media Type of the document. * + * @param mimeType the mime type. + * * @deprecated Use {@link #setMediaType(String)} instead. */ @Deprecated @@ -522,6 +524,8 @@ public String getMediaType() { /** * Set the Internet Media Type of the document. + * + * @param mediaType the Internet Media Type. */ public void setMediaType(final String mediaType) { this.mediaType = mediaType; diff --git a/exist-core/src/main/java/org/exist/storage/io/VariableByteInput.java b/exist-core/src/main/java/org/exist/storage/io/VariableByteInput.java index 78edbeb820..6fa8c796d5 100644 --- a/exist-core/src/main/java/org/exist/storage/io/VariableByteInput.java +++ b/exist-core/src/main/java/org/exist/storage/io/VariableByteInput.java @@ -65,27 +65,42 @@ public interface VariableByteInput { * Read a single byte and return as an int value. * * @return the byte value as int or -1 if no more bytes are available. - * @throws IOException in case of an I/O error + * + * @throws IOException in case of an I/O error. */ int read() throws IOException; /** * Fill the provided byte array with data from the input. * - * @param data the buffer to read + * @param data the buffer to write data to. + * + * @return the number of bytes written to the buffer. + * * @throws IOException in case of an I/O error - * @return the number of bytes read */ int read(byte[] data) throws IOException; - - int read(byte b[], int off, int len) throws IOException; + + /** + * Fill the provided byte array with data from the input. + * + * @param data the buffer to write data to. + * @param off the offset in the buffer to start writing at. + * @param len the maximum number of bytes to write into the buffer. + * + * @return the number of bytes written to the buffer. + * + * @throws IOException in case of an I/O error. + */ + int read(byte data[], int off, int len) throws IOException; /** * Returns a value > 0 if more bytes can be read * from the input. * - * @throws IOException in case of an I/O error - * @return the number of bytes available + * @return the number of bytes available. + * + * @throws IOException in case of an I/O error. */ int available() throws IOException; @@ -93,16 +108,18 @@ public interface VariableByteInput { * Read a single byte. Throws EOFException if no * more bytes are available. * - * @throws IOException in case of an I/O error - * @return the byte read + * @return the byte read. + * + * @throws IOException in case of an I/O error. */ byte readByte() throws IOException; /** * Read a short value in variable byte encoding. * - * @throws IOException in case of an I/O error - * @return the short read + * @return the short read. + * + * @throws IOException in case of an I/O error. */ short readShort() throws IOException; @@ -112,14 +129,17 @@ public interface VariableByteInput { * Requires 2 bytes. * * @return the short. + * + * @throws IOException in case of an I/O error. */ short readFixedShort() throws IOException; /** * Read an integer value in variable byte encoding. * - * @throws IOException in case of an I/O error - * @return the int read + * @return the int read. + * + * @throws IOException in case of an I/O error. */ int readInt() throws IOException; @@ -129,14 +149,17 @@ public interface VariableByteInput { * Requires 4 bytes. * * @return the int. + * + * @throws IOException in case of an I/O error. */ int readFixedInt() throws IOException; /** * Read a long value in variable byte encoding. * - * @throws IOException in case of an I/O error - * @return the long read + * @return the long read. + * + * @throws IOException in case of an I/O error. */ long readLong() throws IOException; @@ -146,42 +169,44 @@ public interface VariableByteInput { * Requires 8 bytes. * * @return the long. + * + * @throws IOException in case of an I/O error. */ long readFixedLong() throws IOException; /** * Read a big integer in variable byte encoding. * - * @throws IOException in case of an I/O error + * @return the big integer read. * - * @return the big integer read + * @throws IOException in case of an I/O error. */ BigInteger readBigInteger() throws IOException; /** * Read a fixed size big integer from input. * - * @throws IOException in case of an I/O error + * @return the big integer read. * - * @return the big integer read + * @throws IOException in case of an I/O error. */ BigInteger readFixedBigInteger() throws IOException; /** * Read a big decimal in variable byte encoding. * - * @throws IOException in case of an I/O error + * @return the big decimal read. * - * @return the big decimal read + * @throws IOException in case of an I/O error. */ BigDecimal readBigDecimal() throws IOException; /** * Read a fixed size big decimal from input. * - * @throws IOException in case of an I/O error + * @return the big decimal read. * - * @return the big decimal read + * @throws IOException in case of an I/O error. */ BigDecimal readFixedBigDecimal() throws IOException; @@ -189,26 +214,36 @@ public interface VariableByteInput { * Read a string as UTF-8 encoded bytes from the input. * * @return the string. + * + * @throws IOException in case of an I/O error. */ String readUTF() throws IOException; /** - * Read the following count numeric values from the input - * and drop them. + * Skip over a number of numeric values from. * - * @param count the number of bytes to skip - * @throws IOException in case of an I/O error + * @param count the number of numeric values to skip. + * + * @throws IOException in case of an I/O error. */ void skip(int count) throws IOException; + /** + * Skip over a number of bytes. + * + * @param count the number of bytes to skip. + * + * @throws IOException in case of an I/O error. + */ void skipBytes(long count) throws IOException; /** * Copy the next numeric value from the input to the * specified output stream. * - * @param output the output destination to copy the data to - * @throws IOException in case of an I/O error + * @param output the output destination to copy the data to. + * + * @throws IOException in case of an I/O error. */ void copyTo(VariableByteOutput output) throws IOException; @@ -216,13 +251,22 @@ public interface VariableByteInput { * Copy the count next numeric values from the input to * the specified output stream. * - * @param os the output destination to copy the data to - * @param count the number of bytes to copy - * @throws IOException in case of an I/O error + * @param os the output destination to copy the data to. + * @param count the number of bytes to copy. + * + * @throws IOException in case of an I/O error. */ void copyTo(VariableByteOutput os, int count) throws IOException; - + + /** + * Copy bytes from the input to the specified output stream. + * + * @param os the output destination to copy the data to. + * @param bytes the number of bytes to copy. + * + * @throws IOException in case of an I/O error. + */ void copyRaw(VariableByteOutput os, int bytes) throws IOException; } \ No newline at end of file diff --git a/exist-core/src/main/java/org/exist/storage/io/VariableByteOutput.java b/exist-core/src/main/java/org/exist/storage/io/VariableByteOutput.java index d959439a67..66ec1820d6 100644 --- a/exist-core/src/main/java/org/exist/storage/io/VariableByteOutput.java +++ b/exist-core/src/main/java/org/exist/storage/io/VariableByteOutput.java @@ -35,6 +35,8 @@ public interface VariableByteOutput { * Write a byte to the output. * * @param b the byte to write. + * + * @throws IOException in case of an I/O error. */ void write(final int b) throws IOException; @@ -42,6 +44,8 @@ public interface VariableByteOutput { * Write a byte to the output. * * @param b the byte to write. + * + * @throws IOException in case of an I/O error. */ void writeByte(final byte b) throws IOException; @@ -49,6 +53,8 @@ public interface VariableByteOutput { * Write bytes to the output. * * @param buf the bytes to write. + * + * @throws IOException in case of an I/O error. */ void write(final byte[] buf) throws IOException; @@ -58,6 +64,8 @@ public interface VariableByteOutput { * @param buf the bytes to write. * @param off the offset to read the bytes from. * @param len the length of bytes to read. + * + * @throws IOException in case of an I/O error. */ void write(final byte[] buf, final int off, final int len) throws IOException; @@ -72,7 +80,9 @@ public interface VariableByteOutput { * 128 and 16383, 2 bytes * 16384 and {@link Short#MAX_VALUE}, 3 bytes * - * @param s the short to write. + * @param s the short to write. + * + * @throws IOException in case of an I/O error. */ void writeShort(int s) throws IOException; @@ -82,6 +92,8 @@ public interface VariableByteOutput { * Requires 2 bytes. * * @param s the short to write. + * + * @throws IOException in case of an I/O error. */ void writeFixedShort(final short s) throws IOException; @@ -98,7 +110,9 @@ public interface VariableByteOutput { * 2097152 and 268435455, is 4 bytes * 268435456 and {@link Integer#MAX_VALUE}, 5 bytes * - * @param i the integer to write. + * @param i the integer to write. + * + * @throws IOException in case of an I/O error. */ void writeInt(int i) throws IOException; @@ -108,6 +122,8 @@ public interface VariableByteOutput { * Requires 4 bytes. * * @param i the integer to write. + * + * @throws IOException in case of an I/O error. */ void writeFixedInt(final int i) throws IOException; @@ -130,6 +146,8 @@ public interface VariableByteOutput { * 9223372036854775808 and {@link Long#MAX_VALUE}, 10 bytes * * @param l the long to write. + * + * @throws IOException in case of an I/O error. */ void writeLong(long l) throws IOException; @@ -139,6 +157,8 @@ public interface VariableByteOutput { * Requires 8 bytes. * * @param l the long to write. + * + * @throws IOException in case of an I/O error. */ void writeFixedLong(final long l) throws IOException; @@ -149,7 +169,9 @@ public interface VariableByteOutput { * VBE int - data length * byte[] - data * - * @param bi the big integer to write + * @param bi the big integer to write. + * + * @throws IOException in case of an I/O error. */ void writeBigInteger(final BigInteger bi) throws IOException; @@ -160,7 +182,9 @@ public interface VariableByteOutput { * int - data length * byte[] - data * - * @param bi the big integer to write + * @param bi the big integer to write. + * + * @throws IOException in case of an I/O error. */ void writeFixedBigInteger(final BigInteger bi) throws IOException; @@ -174,6 +198,8 @@ public interface VariableByteOutput { * byte[] - data * * @param bd the big decimal to write. + * + * @throws IOException in case of an I/O error. */ void writeBigDecimal(final BigDecimal bd) throws IOException; @@ -187,6 +213,8 @@ public interface VariableByteOutput { * byte[] - data * * @param bd the big decimal to write. + * + * @throws IOException in case of an I/O error. */ void writeFixedBigDecimal(final BigDecimal bd) throws IOException; @@ -194,6 +222,8 @@ public interface VariableByteOutput { * Write a string as UTF-8 encoded bytes to the output. * * @param s the string to write. + * + * @throws IOException in case of an I/O error. */ void writeUTF(final String s) throws IOException; } diff --git a/exist-core/src/main/java/org/exist/util/CodePointString.java b/exist-core/src/main/java/org/exist/util/CodePointString.java index f2083d1c1b..9b3df11160 100644 --- a/exist-core/src/main/java/org/exist/util/CodePointString.java +++ b/exist-core/src/main/java/org/exist/util/CodePointString.java @@ -359,6 +359,10 @@ public CodePointString removeFirst(final int codePoint) { /** * Removes the codepoint at the specified index. + * + * @param idx the index within the codepoint string of the codepoint to remove. + * + * @return this. */ public CodePointString removeChar(final int idx) { if (idx > -1) { diff --git a/exist-core/src/main/java/org/exist/xmldb/EXistResource.java b/exist-core/src/main/java/org/exist/xmldb/EXistResource.java index 7f3f05c7f3..e659865446 100644 --- a/exist-core/src/main/java/org/exist/xmldb/EXistResource.java +++ b/exist-core/src/main/java/org/exist/xmldb/EXistResource.java @@ -64,6 +64,13 @@ */ public interface EXistResource extends Resource, AutoCloseable { + /** + * Get the permissions of the resource. + * + * @return the permissions of the resource. + * + * @throws XMLDBException if an error occurs whilst getting the permissions. + */ Permission getPermissions() throws XMLDBException; /** @@ -75,6 +82,11 @@ public interface EXistResource extends Resource, AutoCloseable { */ long getContentLength() throws XMLDBException; + /** + * Set the SAX Lexical Handler. + * + * @param handler the lexical handler. + */ void setLexicalHandler(LexicalHandler handler); /** @@ -99,6 +111,8 @@ public interface EXistResource extends Resource, AutoCloseable { * * @return the Internet Media Type. * + * @throws XMLDBException if an error occurs whilst getting the mime type. + * * @deprecated Use {@link #getMediaType()} instead. */ @Deprecated @@ -108,25 +122,78 @@ public interface EXistResource extends Resource, AutoCloseable { * Get the Internet Media Type of the resource. * * @return the Internet Media Type. + * + * @throws XMLDBException if an error occurs whilst getting the media type. */ String getMediaType() throws XMLDBException; + /** + * Get the Document Type of the resource. + * + * @return the Document Type. + * + * @throws XMLDBException if an error occurs whilst getting the document type. + */ DocumentType getDocType() throws XMLDBException; + /** + * Set the Document Type of the resource. + * + * @param doctype the Document Type. + * + * @throws XMLDBException if an error occurs whilst setting the document type. + */ void setDocType(DocumentType doctype) throws XMLDBException; + /** + * Set the Last Modification Time of the resource. + * + * @param lastModificationTime the Last Modification Time. + * + * @throws XMLDBException if an error occurs whilst setting the last modification time. + */ void setLastModificationTime(Instant lastModificationTime) throws XMLDBException; + /** + * Free any other resources associated with accessing this resource. + * + * @throws XMLDBException if an error occurs whilst freeing resources. + */ void freeResources() throws XMLDBException; + /** + * Set the Properties of the resource. + * + * @param properties the properties. + */ void setProperties(Properties properties); + /** + * Get the Properties of the resource. + * + * @return the properties. + */ @Nullable Properties getProperties(); + /** + * Get the type name of the resource. + * + * @return the type name. + */ String getTypeName(); + /** + * Determine if the resource is closed. + * + * @return true if the resource is closed, false otherwise. + */ boolean isClosed(); + /** + * Close the resource. + * + * @throws XMLDBException if an error occurs whilst closing the resource. + */ @Override void close() throws XMLDBException; } diff --git a/exist-core/src/main/java/org/exist/xquery/value/AnyURIValue.java b/exist-core/src/main/java/org/exist/xquery/value/AnyURIValue.java index 9d01928532..46ecc1042f 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/AnyURIValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/AnyURIValue.java @@ -284,9 +284,7 @@ public static String escape(String uri) { // } } - /* (non-Javadoc) - * @see org.exist.xquery.value.AtomicValue#getType() - */ + @Override public int getType() { return Type.ANY_URI; } @@ -296,12 +294,14 @@ public String getStringValue() { return uri; } + @Override public boolean effectiveBooleanValue() throws XPathException { // If its operand is a singleton value of type xs:string, xs:anyURI, xs:untypedAtomic, //or a type derived from one of these, fn:boolean returns false if the operand value has zero length; otherwise it returns true. return !uri.isEmpty(); } + @Override public AtomicValue convertTo(final int requiredType) throws XPathException { switch (requiredType) { case Type.ITEM: @@ -352,9 +352,7 @@ public boolean compareTo(Collator collator, Comparison operator, AtomicValue oth } } - /* (non-Javadoc) - * @see org.exist.xquery.value.AtomicValue#compareTo(org.exist.xquery.value.AtomicValue) - */ + @Override public int compareTo(Collator collator, AtomicValue other) throws XPathException { if (other.getType() == Type.ANY_URI) { final String otherURI = other.getStringValue(); @@ -364,23 +362,17 @@ public int compareTo(Collator collator, AtomicValue other) throws XPathException } } - /* (non-Javadoc) - * @see org.exist.xquery.value.AtomicValue#max(org.exist.xquery.value.AtomicValue) - */ + @Override public AtomicValue max(Collator collator, AtomicValue other) throws XPathException { throw new XPathException(getExpression(), "max is not supported for values of type xs:anyURI"); } - /* (non-Javadoc) - * @see org.exist.xquery.value.AtomicValue#min(org.exist.xquery.value.AtomicValue) - */ + @Override public AtomicValue min(Collator collator, AtomicValue other) throws XPathException { throw new XPathException(getExpression(), "min is not supported for values of type xs:anyURI"); } - /* (non-Javadoc) - * @see org.exist.xquery.value.Item#conversionPreference(java.lang.Class) - */ + @Override public int conversionPreference(Class javaClass) { if (javaClass.isAssignableFrom(AnyURIValue.class)) { return 0; @@ -403,9 +395,6 @@ public int conversionPreference(Class javaClass) { return Integer.MAX_VALUE; } - /* (non-Javadoc) - * @see org.exist.xquery.value.Item#toJavaObject(java.lang.Class) - */ @Override public T toJavaObject(final Class target) throws XPathException { Throwable throwable = null; @@ -498,6 +487,8 @@ private String normalizeEscaped(String in) { * Serializes to a byte array. * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream()) { @@ -510,6 +501,8 @@ public byte[] serialize() throws IOException { * Serializes to a ByteBuffer. * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -523,6 +516,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the AnyURIValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing an AnyURIValue. */ public static AnyURIValue deserialize(@Nullable Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/BinaryValue.java b/exist-core/src/main/java/org/exist/xquery/value/BinaryValue.java index 3520d3d94a..4e192e3fd6 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/BinaryValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/BinaryValue.java @@ -341,6 +341,8 @@ public int hashCode() { * Serializes to a byte array. * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ private byte[] serializeRaw() throws IOException { try (final UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream()) { @@ -357,6 +359,8 @@ private byte[] serializeRaw() throws IOException { * byte[4..] the data * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final byte[] serialized; @@ -384,9 +388,12 @@ public byte[] serialize() throws IOException { * Deserializes from a ByteBuffer. * * @param expression the expression that creates the IntegerValue object. + * @param binaryValueType the type of the binary value to deserialize to. * @param buf the ByteBuffer to deserialize from. * * @return the IntegerValue. + * + * @throws XPathException if an error occurs constructing a BinaryValue. */ public static BinaryValue deserialize(@Nullable final Expression expression, final BinaryValueType binaryValueType, final ByteBuffer buf) throws XPathException { final int dataLen = ByteConversion.byteToIntH(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/BooleanValue.java b/exist-core/src/main/java/org/exist/xquery/value/BooleanValue.java index 94ed5b6f44..07f6c70abd 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/BooleanValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/BooleanValue.java @@ -291,6 +291,8 @@ public boolean equals(Object obj) { * 1 byte. * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -316,6 +318,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the BooleanValue. + * + * @throws XPathException if an error occurs constructing a BooleanValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final byte b = buf.get(); diff --git a/exist-core/src/main/java/org/exist/xquery/value/DateTimeValue.java b/exist-core/src/main/java/org/exist/xquery/value/DateTimeValue.java index 1c87052679..13e982e7d4 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/DateTimeValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/DateTimeValue.java @@ -243,6 +243,8 @@ public T toJavaObject(final Class target) throws XPathException { * 13 bytes where: [0-3 (Year), 4 (Month), 5 (Day), 6 (Hour), 7 (Minute), 8 (Second), 9-10 (Milliseconds), 11-12 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -285,6 +287,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the DateTimeValue. + * + * @throws XPathException if an error occurs constructing a DateTimeValue. */ public static AtomicValue deserialize(final @Nullable Expression expression, final ByteBuffer buf) throws XPathException { return deserialize(expression, buf, DateTimeValue::new); @@ -295,8 +299,11 @@ public static AtomicValue deserialize(final @Nullable Expression expression, fin * * @param expression the expression that creates the DateTimeValue object. * @param buf the ByteBuffer to deserialize from. + * @param cstr a function that constructs a subclass of DateTimeValue. * * @return the DateTimeValue. + * + * @throws XPathException if an error occurs constructing a DateTimeValue. */ protected static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf, final BiFunctionE cstr) throws XPathException { final int year = ByteConversion.byteToIntH(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/DateValue.java b/exist-core/src/main/java/org/exist/xquery/value/DateValue.java index a364dfd053..262895c217 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/DateValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/DateValue.java @@ -202,6 +202,14 @@ public void serialize(final ByteBuffer buf) { ByteConversion.shortToByteH((short) (timezone == DatatypeConstants.FIELD_UNDEFINED ? Short.MAX_VALUE : timezone), buf); } + /** + * Deserializes a DateValue that has been bit-packed into a ByteBuffer. + * + * @param expression the expression that creates the DateValue object. + * @param buf the serialized value. + * + * @return the DateValue + */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) { final int year = ByteConversion.byteToIntH(buf); final int month = buf.get(); @@ -241,6 +249,9 @@ public long serializeToLong() { /** * Deserializes a DateValue that has been bit-packed into a long (64 bits) * + * @param expression the expression that creates the DateValue object. + * @param l the long value. + * * @return the DateValue */ public static DateValue deserialize(@Nullable final Expression expression, final long l) { diff --git a/exist-core/src/main/java/org/exist/xquery/value/DayTimeDurationValue.java b/exist-core/src/main/java/org/exist/xquery/value/DayTimeDurationValue.java index 8f34cd65b5..edf30aab58 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/DayTimeDurationValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/DayTimeDurationValue.java @@ -325,7 +325,10 @@ public boolean effectiveBooleanValue() throws XPathException { * byte[...] VBE BigDecimal encoded seconds * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ + @Override public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream(37)) { @@ -350,7 +353,10 @@ public byte[] serialize() throws IOException { * byte[...] VBE BigDecimal encoded seconds * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ + @Override public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -369,6 +375,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the DayTimeDurationValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a DayTimeDurationValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/DecimalValue.java b/exist-core/src/main/java/org/exist/xquery/value/DecimalValue.java index 38c455b9a4..ee2b0ebd4c 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/DecimalValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/DecimalValue.java @@ -629,6 +629,8 @@ public T toJavaObject(final Class target) throws XPathException { * byte[...] the big decimal byte[] value * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final byte[] data = value.unscaledValue().toByteArray(); @@ -651,6 +653,8 @@ public byte[] serialize() throws IOException { * byte[...] the big decimal byte[] value * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -664,6 +668,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the DecimalValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a DecimalValue. */ public static DecimalValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/DurationValue.java b/exist-core/src/main/java/org/exist/xquery/value/DurationValue.java index f7147d5257..db4c6188ca 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/DurationValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/DurationValue.java @@ -478,6 +478,8 @@ public boolean equals(Object obj) { * byte[...] VBE BigDecimal encoded seconds * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream(37)) { @@ -523,6 +525,8 @@ protected void serializeBigDecimalField(final VariableByteOutput vbo, final Data * byte[...] VBE BigDecimal encoded seconds * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -543,6 +547,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the DurationValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a DurationValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/GDayValue.java b/exist-core/src/main/java/org/exist/xquery/value/GDayValue.java index 3a3ef9be89..51899ca08d 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/GDayValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/GDayValue.java @@ -203,6 +203,8 @@ public T toJavaObject(final Class target) throws XPathException { * 3 bytes where: [0 (Day), 1-2 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -232,6 +234,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the GDayValue. + * + * @throws XPathException if an error occurs constructing a GDayValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final int day = buf.get(); diff --git a/exist-core/src/main/java/org/exist/xquery/value/GMonthDayValue.java b/exist-core/src/main/java/org/exist/xquery/value/GMonthDayValue.java index 1ce504090e..5fa8095c4d 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/GMonthDayValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/GMonthDayValue.java @@ -168,6 +168,8 @@ public T toJavaObject(final Class target) throws XPathException { * 4 bytes where: [0 (Month), 1 (Day), 2-3 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -198,6 +200,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the GMonthDayValue. + * + * @throws XPathException if an error occurs constructing a GDayMonthValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final int month = buf.get(); diff --git a/exist-core/src/main/java/org/exist/xquery/value/GMonthValue.java b/exist-core/src/main/java/org/exist/xquery/value/GMonthValue.java index 6907aef205..4f673d0d83 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/GMonthValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/GMonthValue.java @@ -247,6 +247,8 @@ public T toJavaObject(final Class target) throws XPathException { * 3 bytes where: [0 (Month), 1-2 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -276,6 +278,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the GMonthValue. + * + * @throws XPathException if an error occurs constructing a GMonthValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final int month = buf.get(); diff --git a/exist-core/src/main/java/org/exist/xquery/value/GYearMonthValue.java b/exist-core/src/main/java/org/exist/xquery/value/GYearMonthValue.java index 6780f58820..2b19c81556 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/GYearMonthValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/GYearMonthValue.java @@ -206,6 +206,8 @@ public T toJavaObject(final Class target) throws XPathException { * 7 bytes where: [0-3 (Year), 4 (Month), 5-6 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -236,6 +238,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the GYearMonthValue. + * + * @throws XPathException if an error occurs constructing a GYearMonthValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final int year = ByteConversion.byteToIntH(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/GYearValue.java b/exist-core/src/main/java/org/exist/xquery/value/GYearValue.java index 8039fa130d..4b8aafa5c2 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/GYearValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/GYearValue.java @@ -169,6 +169,8 @@ public T toJavaObject(final Class target) throws XPathException { * 6 bytes where: [0-3 (Year), 4-5 (Timezone)] * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { final ByteBuffer buf = ByteBuffer.allocate(SERIALIZED_SIZE); @@ -198,6 +200,8 @@ public void serialize(final ByteBuffer buf) { * @param buf the ByteBuffer to deserialize from. * * @return the GYearValue. + * + * @throws XPathException if an error occurs constructing a GYearValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws XPathException { final int year = ByteConversion.byteToIntH(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java b/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java index e1f5867982..dc54793ef4 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java @@ -616,6 +616,8 @@ public int hashCode() { * byte[...] the big integer byte[] value * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream(6)) { @@ -634,6 +636,8 @@ public byte[] serialize() throws IOException { * byte[...] the big integer byte[] value * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -648,6 +652,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the IntegerValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing an IntegerValue. */ public static IntegerValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { return deserialize(expression, buf, null); @@ -661,6 +668,9 @@ public static IntegerValue deserialize(@Nullable final Expression expression, fi * @param checkType an XDM type to check that matches against the deserialized IntegerValue type. * * @return the IntegerValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing an IntegerValue. */ public static IntegerValue deserialize(@Nullable Expression expression, final ByteBuffer buf, @Nullable final Integer checkType) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/QNameValue.java b/exist-core/src/main/java/org/exist/xquery/value/QNameValue.java index 812312890d..df321f4068 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/QNameValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/QNameValue.java @@ -301,6 +301,8 @@ public int hashCode() { * Serializes to a byte array. * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream()) { @@ -313,6 +315,8 @@ public byte[] serialize() throws IOException { * Serializes to a ByteBuffer. * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -326,6 +330,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the AnyURIValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a QNameValue. */ public static QNameValue deserialize(@Nullable Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/StringValue.java b/exist-core/src/main/java/org/exist/xquery/value/StringValue.java index c82ce586c0..dd709917b2 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/StringValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/StringValue.java @@ -856,6 +856,8 @@ public boolean equals(Object obj) { * byte[...] the string as UTF-8 * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream(6)) { @@ -874,6 +876,8 @@ public byte[] serialize() throws IOException { * byte[...] the string as UTF-8 * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -888,6 +892,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the StringValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a StringValue. */ public static StringValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { return deserialize(expression, buf, false); @@ -901,6 +908,9 @@ public static StringValue deserialize(@Nullable final Expression expression, fin * @param expand if entities need to be expanded * * @return the StringValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a StringValue. */ public static StringValue deserialize(@Nullable final Expression expression, final ByteBuffer buf, final boolean expand) throws IOException, XPathException { return deserialize(expression, buf, null, expand); @@ -914,6 +924,9 @@ public static StringValue deserialize(@Nullable final Expression expression, fin * @param checkType an XDM type to check that matches against the deserialized StringValue type. * * @return the StringValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a StringValue. */ public static StringValue deserialize(@Nullable Expression expression, final ByteBuffer buf, @Nullable final Integer checkType) throws IOException, XPathException { return deserialize(expression, buf, checkType, false); @@ -928,6 +941,9 @@ public static StringValue deserialize(@Nullable Expression expression, final Byt * @param expand if entities need to be expanded * * @return the StringValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a StringValue. */ public static StringValue deserialize(@Nullable Expression expression, final ByteBuffer buf, @Nullable final Integer checkType, final boolean expand) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/main/java/org/exist/xquery/value/TimeValue.java b/exist-core/src/main/java/org/exist/xquery/value/TimeValue.java index dc09293273..faaf239789 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/TimeValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/TimeValue.java @@ -202,6 +202,14 @@ public void serialize(final ByteBuffer buf) { ByteConversion.shortToByteH((short) (timezone == DatatypeConstants.FIELD_UNDEFINED ? Short.MAX_VALUE : timezone), buf); } + /** + * Deserializes a TimeValue that has been bit-packed into a Byte Buffer. + * + * @param expression the expression that creates the TimeValue object. + * @param buf the buffer holding the value to deserialize. + * + * @return the TimeValue + */ public static TimeValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) { final int hour = buf.get(); final int minute = buf.get(); @@ -249,6 +257,9 @@ public long serializeToLong() { /** * Deserializes a TimeValue that has been bit-packed into a long (64 bits) * + * @param expression the expression that creates the TimeValue object. + * @param l the long value to deserialize. + * * @return the TimeValue */ public static TimeValue deserialize(@Nullable final Expression expression, final long l) { diff --git a/exist-core/src/main/java/org/exist/xquery/value/YearMonthDurationValue.java b/exist-core/src/main/java/org/exist/xquery/value/YearMonthDurationValue.java index 3095a4e4c9..3d0f333711 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/YearMonthDurationValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/YearMonthDurationValue.java @@ -271,7 +271,10 @@ public boolean effectiveBooleanValue() throws XPathException { * byte[...] VBE BigInteger encoded month * * @return the serialized data. + * + * @throws IOException if an I/O error occurs during serialization. */ + @Override public byte[] serialize() throws IOException { try (final VariableByteArrayOutputStream vbos = new VariableByteArrayOutputStream(37)) { @@ -292,7 +295,10 @@ public byte[] serialize() throws IOException { * byte[...] VBE BigInteger encoded month * * @param buf the ByteBuffer to serialize to. + * + * @throws IOException if an I/O error occurs during serialization. */ + @Override public void serialize(final ByteBuffer buf) throws IOException { final VariableByteBufferOutput vbb = new VariableByteBufferOutput(buf); @@ -308,6 +314,9 @@ public void serialize(final ByteBuffer buf) throws IOException { * @param buf the ByteBuffer to deserialize from. * * @return the YearMonthDurationValue. + * + * @throws IOException if an I/O error occurs during deserialization. + * @throws XPathException if an error occurs constructing a YearMonthDurationValue. */ public static AtomicValue deserialize(@Nullable final Expression expression, final ByteBuffer buf) throws IOException, XPathException { final VariableByteBufferInput vbbi = new VariableByteBufferInput(buf); diff --git a/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java b/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java index 988e792224..3ae22c7ca7 100644 --- a/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java +++ b/exist-core/src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java @@ -81,7 +81,7 @@ public class DbStore2Test { true, getConfig()); private static final int BUFFER_SIZE = 1024 * 1024 * 4; // 4MiB buffer - private static final long FILE_SIZE = 3l * 1024l * 1024l * 1024l; //3GiB file. + private static final long FILE_SIZE = 1024l * 1024l * 1024l; // 1GiB file. private static final String TEST_COLLECTION = "testAnyUri2"; private static Path largeFileLocation = null; diff --git a/extensions/modules/sql-oracle/pom.xml b/extensions/modules/sql-oracle/pom.xml index a5e5872b7d..e5c1205ef2 100644 --- a/extensions/modules/sql-oracle/pom.xml +++ b/extensions/modules/sql-oracle/pom.xml @@ -139,6 +139,11 @@ ${project.version} + + com.evolvedbinary.thirdparty.xml-apis + xml-apis + + com.oracle.database.jdbc ojdbc17 diff --git a/extensions/modules/sql-oracle/src/main/java/org/exist/xquery/modules/oracle/ExecuteFunction.java b/extensions/modules/sql-oracle/src/main/java/org/exist/xquery/modules/oracle/ExecuteFunction.java index 0978c47796..1cbd8fbc63 100644 --- a/extensions/modules/sql-oracle/src/main/java/org/exist/xquery/modules/oracle/ExecuteFunction.java +++ b/extensions/modules/sql-oracle/src/main/java/org/exist/xquery/modules/oracle/ExecuteFunction.java @@ -45,6 +45,7 @@ */ package org.exist.xquery.modules.oracle; +import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.sql.CallableStatement; import java.sql.Connection; @@ -67,7 +68,6 @@ import org.apache.logging.log4j.LogManager; import org.exist.Namespaces; import org.exist.dom.QName; -import org.apache.commons.io.output.ByteArrayOutputStream; import org.exist.dom.memtree.MemTreeBuilder; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality;