svn commit: r743269 - /commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java

2009-02-11 Thread dfabulich
Author: dfabulich
Date: Wed Feb 11 08:08:01 2009
New Revision: 743269

URL: http://svn.apache.org/viewvc?rev=743269view=rev
Log:
[DBUTILS-34] BasicRowProcessor loses any information on database field case
Submitted by: Julien Aymé

Modified:

commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java

Modified: 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java?rev=743269r1=743268r2=743269view=diff
==
--- 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
 (original)
+++ 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
 Wed Feb 11 08:08:01 2009
@@ -144,10 +144,36 @@
  * A Map that converts all keys to lowercase Strings for case insensitive
  * lookups.  This is needed for the toMap() implementation because 
  * databases don't consistenly handle the casing of column names. 
+ * 
+ * pThe keys are stored as they are given [BUG #DBUTILS-34], so we 
maintain
+ * an internal mapping from lowercase keys to the real keys in order to 
+ * achieve the case insensitive lookup.
+ * 
+ * pNote: This implementation does not allow ttnull/tt
+ * for key, whereas {...@link HashMap} does, because of the code:
+ * pre
+ * key.toString().toLowerCase()
+ * /pre
  */
 private static class CaseInsensitiveHashMap extends HashMap {
 
 /**
+ * The internal mapping from lowercase keys to the real keys.
+ * 
+ * p
+ * Any query operation using the key 
+ * ({...@link #get(Object)}, {...@link #containsKey(Object)})
+ * is done in three steps:
+ * ul
+ * liconvert the parameter key to lower case/li
+ * liget the actual key that corresponds to the lower case key/li
+ * liquery the map with the actual key/li
+ * /ul
+ * /p
+ */
+private Map lowerCaseMap = new HashMap();
+
+/**
  * Required for serialization support.
  * 
  * @see java.io.Serializable
@@ -158,21 +184,37 @@
  * @see java.util.Map#containsKey(java.lang.Object)
  */
 public boolean containsKey(Object key) {
-return super.containsKey(key.toString().toLowerCase());
+Object realKey = lowerCaseMap.get(key.toString().toLowerCase());
+return super.containsKey(realKey);
+// Possible optimisation here:
+// Since the lowerCaseMap contains a mapping for all the keys,
+// we could just do this:
+// return lowerCaseMap.containsKey(key.toString().toLowerCase());
 }
 
 /**
  * @see java.util.Map#get(java.lang.Object)
  */
 public Object get(Object key) {
-return super.get(key.toString().toLowerCase());
+Object realKey = lowerCaseMap.get(key.toString().toLowerCase());
+return super.get(realKey);
 }
 
 /**
  * @see java.util.Map#put(java.lang.Object, java.lang.Object)
  */
 public Object put(Object key, Object value) {
-return super.put(key.toString().toLowerCase(), value);
+/*
+ * In order to keep the map and lowerCaseMap synchronized,
+ * we have to remove the old mapping before putting the 
+ * new one. Indeed, oldKey and key are not necessaliry equals.
+ * (That's why we call super.remove(oldKey) and not just
+ * super.put(key, value))
+ */
+Object oldKey = lowerCaseMap.put(key.toString().toLowerCase(), 
key);
+Object oldValue = super.remove(oldKey);
+super.put(key, value);
+return oldValue;
 }
 
 /**
@@ -191,7 +233,8 @@
  * @see java.util.Map#remove(java.lang.Object)
  */
 public Object remove(Object key) {
-return super.remove(key.toString().toLowerCase());
+Object realKey = lowerCaseMap.remove(key.toString().toLowerCase());
+return super.remove(realKey);
 }
 }
 




svn commit: r743278 - /commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java

2009-02-11 Thread dfabulich
Author: dfabulich
Date: Wed Feb 11 09:18:45 2009
New Revision: 743278

URL: http://svn.apache.org/viewvc?rev=743278view=rev
Log:
Deprecating methods that will be eliminated in favor of varargs in java5 branch

Modified:

commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java

Modified: 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java?rev=743278r1=743277r2=743278view=diff
==
--- 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java
 (original)
+++ 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/QueryRunner.java
 Wed Feb 11 09:18:45 2009
@@ -335,11 +335,12 @@
  * @param rsh The handler that converts the results into an object.
  * @return The object returned by the handler.
  * @throws SQLException if a database access error occurs
+ * @deprecated Use {...@link 
#query(Connection,String,ResultSetHandler,Object[])} instead
  */
 public Object query(Connection conn, String sql, Object param,
 ResultSetHandler rsh) throws SQLException {
 
-return this.query(conn, sql, new Object[] { param }, rsh);
+return this.query(conn, sql, rsh, new Object[] { param });
 }
 
 /**
@@ -352,9 +353,26 @@
  * @param rsh The handler that converts the results into an object.
  * @return The object returned by the handler.
  * @throws SQLException if a database access error occurs
+ * @deprecated Use {...@link 
#query(Connection,String,ResultSetHandler,Object[])} instead
  */
 public Object query(Connection conn, String sql, Object[] params,
 ResultSetHandler rsh) throws SQLException {
+return query(conn, sql, rsh, params);
+}
+
+/**
+ * Execute an SQL SELECT query with replacement parameters.  The
+ * caller is responsible for closing the connection.
+ * 
+ * @param conn The connection to execute the query in.
+ * @param sql The query to execute.
+ * @param rsh The handler that converts the results into an object.
+ * @param params The replacement parameters.
+ * @return The object returned by the handler.
+ * @throws SQLException if a database access error occurs
+ */
+public Object query(Connection conn, String sql, ResultSetHandler rsh,
+Object[] params) throws SQLException {
 
 PreparedStatement stmt = null;
 ResultSet rs = null;
@@ -393,7 +411,7 @@
 public Object query(Connection conn, String sql, ResultSetHandler rsh)
 throws SQLException {
 
-return this.query(conn, sql, (Object[]) null, rsh);
+return this.query(conn, sql, rsh, (Object[]) null);
 }
 
 /**
@@ -408,11 +426,12 @@
  * 
  * @return An object generated by the handler.
  * @throws SQLException if a database access error occurs
+ * @deprecated Use {...@link #query(String,ResultSetHandler,Object[])} 
instead
  */
 public Object query(String sql, Object param, ResultSetHandler rsh)
 throws SQLException {
 
-return this.query(sql, new Object[] { param }, rsh);
+return this.query(sql, rsh, new Object[] { param });
 }
 
 /**
@@ -429,14 +448,33 @@
  * 
  * @return An object generated by the handler.
  * @throws SQLException if a database access error occurs
+ * @deprecated Use {...@link #query(String,ResultSetHandler,Object[])} 
instead
  */
 public Object query(String sql, Object[] params, ResultSetHandler rsh)
 throws SQLException {
+return query(sql, rsh, params);
+}
+
+/**
+ * Executes the given SELECT SQL query and returns a result object.
+ * The codeConnection/code is retrieved from the 
+ * codeDataSource/code set in the constructor.
+ * 
+ * @param sql The SQL statement to execute.
+ * @param rsh The handler used to create the result object from 
+ * the codeResultSet/code.
+ * @param params Initialize the PreparedStatement's IN parameters with 
+ * this array.
+ * @return An object generated by the handler.
+ * @throws SQLException if a database access error occurs
+ */
+public Object query(String sql, ResultSetHandler rsh, Object[] params)
+throws SQLException {
 
 Connection conn = this.prepareConnection();
 
 try {
-return this.query(conn, sql, params, rsh);
+return this.query(conn, sql, rsh, params);
 } finally {
 close(conn);
 }
@@ -455,7 +493,7 @@
  * @throws SQLException if a database access error occurs
  */
 public Object query(String sql, ResultSetHandler rsh) throws SQLException {
-return this.query(sql, (Object[]) null, rsh);
+

svn commit: r743292 - /commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java

2009-02-11 Thread dfabulich
Author: dfabulich
Date: Wed Feb 11 10:35:04 2009
New Revision: 743292

URL: http://svn.apache.org/viewvc?rev=743292view=rev
Log:
Incorporating a couple more of Julien's suggestions (especially to use an 
entrySet instead of a keySet0

Modified:

commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java

Modified: 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java?rev=743292r1=743291r2=743292view=diff
==
--- 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
 (original)
+++ 
commons/sandbox/dbutils/bugfixing/src/java/org/apache/commons/dbutils/BasicRowProcessor.java
 Wed Feb 11 10:35:04 2009
@@ -171,7 +171,7 @@
  * /ul
  * /p
  */
-private Map lowerCaseMap = new HashMap();
+private final Map lowerCaseMap = new HashMap();
 
 /**
  * Required for serialization support.
@@ -221,10 +221,11 @@
  * @see java.util.Map#putAll(java.util.Map)
  */
 public void putAll(Map m) {
-Iterator iter = m.keySet().iterator();
+Iterator iter = m.entrySet().iterator();
 while (iter.hasNext()) {
-Object key = iter.next();
-Object value = m.get(key);
+Map.Entry entry = (Map.Entry) iter.next();
+Object key = entry.getKey();
+Object value = entry.getValue();
 this.put(key, value);
 }
 }




svn commit: r743430 - /commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java

2009-02-11 Thread jukka
Author: jukka
Date: Wed Feb 11 17:59:25 2009
New Revision: 743430

URL: http://svn.apache.org/viewvc?rev=743430view=rev
Log:
xml: Added a TeeContentHandler based on the similar class in Apache Tika.

Added:

commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
  - copied, changed from r743413, 
lucene/tika/trunk/src/main/java/org/apache/tika/sax/TeeContentHandler.java

Copied: 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
 (from r743413, 
lucene/tika/trunk/src/main/java/org/apache/tika/sax/TeeContentHandler.java)
URL: 
http://svn.apache.org/viewvc/commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java?p2=commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.javap1=lucene/tika/trunk/src/main/java/org/apache/tika/sax/TeeContentHandler.javar1=743413r2=743430rev=743430view=diff
==
--- lucene/tika/trunk/src/main/java/org/apache/tika/sax/TeeContentHandler.java 
(original)
+++ 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
 Wed Feb 11 17:59:25 2009
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.tika.sax;
+package org.apache.commons.xml;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -23,17 +23,44 @@
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
- * Content handler proxy that forwards the received SAX events to zero or
- * more underlying content handlers.
+ * A multiplexing content handler proxy that copies all received SAX events to
+ * zero or more proxied content handlers. If a proxied content handler throws
+ * an exception when receiving an event, then the exception is passed directly
+ * to the caller without giving any of the remaining handlers a chance to
+ * process the event.
+ * p
+ * As a convenience this class inherits the {...@link DefaultHandler} class
+ * instead of just the {...@link ContentHandler} interface. This makes it
+ * possible to pass instances of this class to methods like
+ * {...@link javax.xml.parsers.SAXParser#parse(String, DefaultHandler)} that
+ * expect a DefaultHandler instance instead of a ContentHandler.
  */
 public class TeeContentHandler extends DefaultHandler {
 
+/**
+ * The proxied content handlers.
+ */
 private final ContentHandler[] handlers;
 
+/**
+ * Creates a multiplexing proxy that passes received SAX events to
+ * all the given content handlers.
+ *
+ * @param handlers content handlers to be proxied
+ */
 public TeeContentHandler(ContentHandler... handlers) {
 this.handlers = handlers;
 }
 
+//-- ContentHandler 
+
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @param prefix passed through
+ * @param uri passed through
+ * @throws SAXException if an error occurs
+ */
 @Override
 public void startPrefixMapping(String prefix, String uri)
 throws SAXException {
@@ -42,6 +69,12 @@
 }
 }
 
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @param prefix passed through
+ * @throws SAXException if an error occurs
+ */
 @Override
 public void endPrefixMapping(String prefix) throws SAXException {
 for (ContentHandler handler : handlers) {
@@ -49,6 +82,13 @@
 }
 }
 
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @param target passed through
+ * @param data passed through
+ * @throws SAXException if an error occurs
+ */
 @Override
 public void processingInstruction(String target, String data)
 throws SAXException {
@@ -57,6 +97,11 @@
 }
 }
 
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @param locator passed through
+ */
 @Override
 public void setDocumentLocator(Locator locator) {
 for (ContentHandler handler : handlers) {
@@ -64,6 +109,11 @@
 }
 }
 
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @throws SAXException if an error occurs
+ */
 @Override
 public void startDocument() throws SAXException {
 for (ContentHandler handler : handlers) {
@@ -71,6 +121,11 @@
 }
 }
 
+/**
+ * Delegated to the proxied {...@link #handlers}.
+ *
+ * @throws SAXException if an error occurs
+ */
 @Override
 public void endDocument() throws SAXException {
 for (ContentHandler 

svn commit: r743438 - /commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/ProxyContentHandler.java

2009-02-11 Thread jukka
Author: jukka
Date: Wed Feb 11 18:21:13 2009
New Revision: 743438

URL: http://svn.apache.org/viewvc?rev=743438view=rev
Log:
xml: No need for svn:mergeinfo here

Modified:

commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/ProxyContentHandler.java
   (props changed)

Propchange: 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/ProxyContentHandler.java
('svn:mergeinfo' removed)




svn commit: r743448 - /commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java

2009-02-11 Thread sebb
Author: sebb
Date: Wed Feb 11 18:46:17 2009
New Revision: 743448

URL: http://svn.apache.org/viewvc?rev=743448view=rev
Log:
Add missing AL header

Modified:

commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java

Modified: 
commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=743448r1=743447r2=743448view=diff
==
--- 
commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
 (original)
+++ 
commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
 Wed Feb 11 18:46:17 2009
@@ -1,3 +1,21 @@
+/*
+ * 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.commons.compress;
 
 import java.io.File;




svn commit: r743450 - in /commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml: SerializingContentHandler.java TeeContentHandler.java

2009-02-11 Thread sebb
Author: sebb
Date: Wed Feb 11 18:52:01 2009
New Revision: 743450

URL: http://svn.apache.org/viewvc?rev=743450view=rev
Log:
Javadoc corrections

Modified:

commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java

commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java

Modified: 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java?rev=743450r1=743449r2=743450view=diff
==
--- 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
 (original)
+++ 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
 Wed Feb 11 18:52:01 2009
@@ -63,7 +63,7 @@
  * The character encoding used for serialization (UTF-8).
  * The encoding is fixed to make the text/xml content type safer to use.
  *
- * @see https://issues.apache.org/jira/browse/JCR-1621
+ * @see https://issues.apache.org/jira/browse/JCR-1621;
  */
 public static final String ENCODING = UTF-8;
 
@@ -116,7 +116,7 @@
 /**
  * Creates a serializing content handler that writes to the given stream.
  *
- * @param stream serialization target
+ * @param output serialization target
  * @return serializing content handler
  * @throws SAXException if the content handler could not be initialized
  */

Modified: 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java?rev=743450r1=743449r2=743450view=diff
==
--- 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
 (original)
+++ 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/TeeContentHandler.java
 Wed Feb 11 18:52:01 2009
@@ -136,9 +136,9 @@
 /**
  * Delegated to the proxied {...@link #handlers}.
  *
- * @param namespaceURI passed through
+ * @param uri passed through
  * @param localName passed through
- * @param qName passed through
+ * @param name passed through
  * @param atts passed through
  * @throws SAXException if an error occurs
  */
@@ -154,9 +154,9 @@
 /**
  * Delegated to the proxied {...@link #handlers}.
  *
- * @param namespaceURI passed through
+ * @param uri passed through
  * @param localName passed through
- * @param qName passed through
+ * @param name passed through
  * @throws SAXException if an error occurs
  */
 @Override




svn commit: r743451 - /commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java

2009-02-11 Thread sebb
Author: sebb
Date: Wed Feb 11 18:52:56 2009
New Revision: 743451

URL: http://svn.apache.org/viewvc?rev=743451view=rev
Log:
Remove unnecessary casts

Modified:

commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java

Modified: 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java?rev=743451r1=743450r2=743451view=diff
==
--- 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
 (original)
+++ 
commons/sandbox/xml/trunk/src/main/java/org/apache/commons/xml/SerializingContentHandler.java
 Wed Feb 11 18:52:56 2009
@@ -325,8 +325,8 @@
 for (int mapping = 0; mapping  mappingCount; mapping++) {
 
 // Build infos for this namespace
-String uri = (String) this.uriList.get(mapping);
-String prefix = (String) this.prefixList.get(mapping);
+String uri = this.uriList.get(mapping);
+String prefix = this.prefixList.get(mapping);
 String qName = prefix.equals() ? xmlns : (xmlns: + 
prefix);
 
 // Search for the corresponding xmlns* attribute




svn commit: r743608 - in /commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar: TarArchiveInputStream.java TarArchiveOutputStream.java

2009-02-11 Thread bodewig
Author: bodewig
Date: Thu Feb 12 03:13:10 2009
New Revision: 743608

URL: http://svn.apache.org/viewvc?rev=743608view=rev
Log:
fix linefeeds, thanks to Sebb for spotting this

Modified:

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
   (contents, props changed)

commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
   (contents, props changed)

Modified: 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=743608r1=743607r2=743608view=diff
==
--- 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 (original)
+++ 
commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
 Thu Feb 12 03:13:10 2009
@@ -1,435 +1,435 @@
-/*
- *  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.
- *
- */
-
-/*
- * This package is based on the work done by Timothy Gerard Endres
- * (t...@ice.com) to whom the Ant project is very grateful for his great code.
- */
-
-package org.apache.commons.compress.archivers.tar;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.ArchiveInputStream;
-
-/**
- * The TarInputStream reads a UNIX tar archive as an InputStream.
- * methods are provided to position at each successive entry in
- * the archive, and the read each entry as a normal input stream
- * using read().
- *
- */
-public class TarArchiveInputStream extends ArchiveInputStream {
-private static final int SMALL_BUFFER_SIZE = 256;
-private static final int BUFFER_SIZE = 8 * 1024;
-private static final int LARGE_BUFFER_SIZE = 32 * 1024;
-private static final int BYTE_MASK = 0xFF;
-
-// CheckStyle:VisibilityModifier OFF - bc
-protected boolean debug;
-protected boolean hasHitEOF;
-protected long entrySize;
-protected long entryOffset;
-protected byte[] readBuf;
-protected TarBuffer buffer;
-protected TarArchiveEntry currEntry;
-
-/**
- * This contents of this array is not used at all in this class,
- * it is only here to avoid repreated object creation during calls
- * to the no-arg read method.
- */
-protected byte[] oneBuf;
-
-// CheckStyle:VisibilityModifier ON
-
-private final InputStream in;
-
-/**
- * Constructor for TarInputStream.
- * @param is the input stream to use
- */
-public TarArchiveInputStream(InputStream is) {
-this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE);
-}
-
-/**
- * Constructor for TarInputStream.
- * @param is the input stream to use
- * @param blockSize the block size to use
- */
-public TarArchiveInputStream(InputStream is, int blockSize) {
-this(is, blockSize, TarBuffer.DEFAULT_RCDSIZE);
-}
-
-/**
- * Constructor for TarInputStream.
- * @param is the input stream to use
- * @param blockSize the block size to use
- * @param recordSize the record size to use
- */
-public TarArchiveInputStream(InputStream is, int blockSize, int 
recordSize) {
-this.in = is;
-
-this.buffer = new TarBuffer(is, blockSize, recordSize);
-this.readBuf = null;
-this.oneBuf = new byte[1];
-this.debug = false;
-this.hasHitEOF = false;
-}
-
-/**
- * Sets the debugging flag.
- *
- * @param debug True to turn on debugging.
- */
-public void setDebug(boolean debug) {
-this.debug = debug;
-buffer.setDebug(debug);
-}
-
-/**
- * Closes this stream. Calls the TarBuffer's close() method.
- * @throws IOException on error
- */
-public void close() throws IOException {
-buffer.close();
-}
-
-/**
- *