6 * Copyright (C) 2006 The Jmol Development Team
\r
8 * Contact: jmol-developers@lists.sf.net
\r
10 * This library is free software; you can redistribute it and/or
\r
11 * modify it under the terms of the GNU Lesser General Public
\r
12 * License as published by the Free Software Foundation; either
\r
13 * version 2.1 of the License, or (at your option) any later version.
\r
15 * This library is distributed in the hope that it will be useful,
\r
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
18 * Lesser General Public License for more details.
\r
20 * You should have received a copy of the GNU Lesser General Public
\r
21 * License along with this library; if not, write to the Free Software
\r
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
\r
26 package javajs.util;
\r
28 import java.io.BufferedInputStream;
\r
30 import javajs.api.GenericZipTools;
\r
35 public class ZipData {
\r
36 boolean isEnabled = true;
\r
41 public ZipData(int nBytes) {
\r
42 this.nBytes = nBytes;
\r
45 public int addBytes(byte[] byteBuf, int nSectorBytes, int nBytesRemaining) {
\r
47 if (!Rdr.isGzipB(byteBuf)) {
\r
51 buf = new byte[nBytesRemaining];
\r
53 int nToAdd = Math.min(nSectorBytes, nBytesRemaining);
\r
54 System.arraycopy(byteBuf, 0, buf, pt, nToAdd);
\r
56 return nBytesRemaining - nToAdd;
\r
59 public void addTo(GenericZipTools jzt, SB data) {
\r
60 data.append(getGzippedBytesAsString(jzt, buf));
\r
63 static String getGzippedBytesAsString(GenericZipTools jzt, byte[] bytes) {
\r
65 BufferedInputStream bis = jzt.getUnGzippedInputStream(bytes);
\r
66 String s = ZipTools.getStreamAsString(bis);
\r
69 } catch (Exception e) {
\r