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