Repository: empire-db Updated Branches: refs/heads/master b5e25f76d -> a5cb2785e
EMPIREDB-261 reset of reader for clob before use Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/a5cb2785 Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/a5cb2785 Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/a5cb2785 Branch: refs/heads/master Commit: a5cb2785ec2a9976db215e599d1cc326b602210d Parents: b5e25f7 Author: Rainer Döbele <[email protected]> Authored: Mon Jul 17 11:51:44 2017 +0200 Committer: Rainer Döbele <[email protected]> Committed: Mon Jul 17 11:51:44 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/empire/db/DBClobData.java | 229 ++++++++++--------- 1 file changed, 120 insertions(+), 109 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/empire-db/blob/a5cb2785/empire-db/src/main/java/org/apache/empire/db/DBClobData.java ---------------------------------------------------------------------- diff --git a/empire-db/src/main/java/org/apache/empire/db/DBClobData.java b/empire-db/src/main/java/org/apache/empire/db/DBClobData.java index 03a7d1d..aedd06d 100644 --- a/empire-db/src/main/java/org/apache/empire/db/DBClobData.java +++ b/empire-db/src/main/java/org/apache/empire/db/DBClobData.java @@ -1,110 +1,121 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.empire.db; - -import java.io.Reader; -import java.io.StringReader; - -/** - * This class allocates methods to store binary character objects in the database. - * - * - */ -public class DBClobData -{ - /** - * The reader associated with this object - */ - private Reader reader = null; - - /** - * The length of the data in the <code>reader</code> - */ - private int length = 0; - - /** - * Constructor to pass LOB data to the setValue methods of - * a record, consisting of the input stream where the data can be - * loaded from and the length of the data. - * - * @param reader The reader where the character data will be read from - * @param length The number of characters to read from the reader - * @throws IllegalArgumentException If the reader is null - */ - public DBClobData(Reader reader, int length) - throws IllegalArgumentException - { - if (reader == null) - { - throw new IllegalArgumentException("reader was null"); - - } - this.reader = reader; - this.length = length; - } - - /** - * Constructor for LobData from a string. - * - * @param text The string to be used as data - * @throws IllegalArgumentException If the text is null - */ - public DBClobData(String text) - throws IllegalArgumentException - { - if (text == null) - { - throw new IllegalArgumentException("text was null"); - } - reader = new StringReader(text); - this.length = text.length(); - } - - /** - * Set the defaultEncoding used in a constructor. - * - * @return Returns the reader with the character data for the CLOB - */ - public Reader getReader() - { - return reader; - } - - /** - * Returns the length of the CLOB data in characters. - * - * @return Returns the length of the CLOB data in characters - */ - public int getLength() - { - return length; - } - - /** - * Returns a CLOB String. - * - * @return Returns CLOB String - */ - @Override - public String toString() - { - // WARNING: String contained in reader is NOT supplied. - return super.toString(); - } +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.empire.db; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import org.apache.empire.exceptions.InternalException; + +/** + * This class allocates methods to store binary character objects in the database. + * + * + */ +public class DBClobData +{ + /** + * The reader associated with this object + */ + private Reader reader = null; + + /** + * The length of the data in the <code>reader</code> + */ + private int length = 0; + + /** + * Constructor to pass LOB data to the setValue methods of + * a record, consisting of the input stream where the data can be + * loaded from and the length of the data. + * + * @param reader The reader where the character data will be read from + * @param length The number of characters to read from the reader + * @throws IllegalArgumentException If the reader is null + */ + public DBClobData(Reader reader, int length) + throws IllegalArgumentException + { + if (reader == null) + { + throw new IllegalArgumentException("reader must not be null"); + + } + this.reader = reader; + this.length = length; + } + + /** + * Constructor for LobData from a string. + * + * @param text The string to be used as data + * @throws IllegalArgumentException If the text is null + */ + public DBClobData(String text) + throws IllegalArgumentException + { + if (text == null) + { + throw new IllegalArgumentException("text must not be null"); + } + reader = new StringReader(text); + this.length = text.length(); + } + + /** + * Get the Reader for the large string + * + * @return Returns the reader with the character data for the CLOB + */ + public Reader getReader() + { + try + { + reader.reset(); + return reader; + } + catch (IOException e) + { + throw new InternalException(e); + } + } + + /** + * Returns the length of the CLOB data in characters. + * + * @return Returns the length of the CLOB data in characters + */ + public int getLength() + { + return length; + } + + /** + * Returns a CLOB String. + * + * @return Returns CLOB String + */ + @Override + public String toString() + { + // WARNING: String contained in reader is NOT supplied. + return super.toString(); + } } \ No newline at end of file
