6 * Some portions of this file have been modified by Robert Hanson hansonr.at.stolaf.edu 2012-2017
7 * for use in SwingJS via transpilation into JavaScript using Java2Script.
9 * Copyright (C) 2006 The Jmol Development Team
11 * Contact: jmol-developers@lists.sf.net
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 import java.io.BufferedInputStream;
33 import javajs.api.GenericZipTools;
38 public class ZipData {
39 boolean isEnabled = true;
44 public ZipData(int nBytes) {
48 public int addBytes(byte[] byteBuf, int nSectorBytes, int nBytesRemaining) {
50 if (!Rdr.isGzipB(byteBuf)) {
54 buf = new byte[nBytesRemaining];
56 int nToAdd = Math.min(nSectorBytes, nBytesRemaining);
57 System.arraycopy(byteBuf, 0, buf, pt, nToAdd);
59 return nBytesRemaining - nToAdd;
62 public void addTo(GenericZipTools jzt, SB data) {
63 data.append(getGzippedBytesAsString(jzt, buf));
66 static String getGzippedBytesAsString(GenericZipTools jzt, byte[] bytes) {
68 BufferedInputStream bis = jzt.getUnGzippedInputStream(bytes);
69 String s = ZipTools.getStreamAsString(bis);
72 } catch (Exception e) {