Examples of Kim


Examples of org.json.Kim

   * @return The string that was read.
   * @throws JSONException
   */
  private String read(final Huff huff, final Huff ext, final Keep keep)
      throws JSONException {
    Kim kim;
    int at = 0;
    int allocation = 256;
    byte[] bytes = new byte[allocation];
    if (bit()) {
      return getAndTick(keep, this.bitreader).toString();
    }
    while (true) {
      if (at >= allocation) {
        allocation *= 2;
        bytes = java.util.Arrays.copyOf(bytes, allocation);
      }
      int c = huff.read(this.bitreader);
      if (c == end) {
        break;
      }
      while ((c & 128) == 128) {
        bytes[at] = (byte) c;
        at += 1;
        c = ext.read(this.bitreader);
      }
      bytes[at] = (byte) c;
      at += 1;
    }
    if (at == 0) {
      return "";
    }
    kim = new Kim(bytes, at);
    keep.register(kim);
    return kim.toString();
  }
View Full Code Here

Examples of org.json.Kim

  private void writeName(final String name) throws JSONException {

    // If this name has already been registered, then emit its integer and
    // increment its usage count.

    final Kim kim = new Kim(name);
    final int integer = this.namekeep.find(kim);
    if (integer != none) {
      one();
      write(integer, this.namekeep);
    } else {
View Full Code Here

Examples of org.json.Kim

    if (string.length() == 0) {
      zero();
      write(end, this.stringhuff);
    } else {
      final Kim kim = new Kim(string);

      // Look for the string in the strings keep. If it is found, emit its
      // integer and count that as a use.

      final int integer = this.stringkeep.find(kim);
View Full Code Here

Examples of org.json.Kim

    private void writeName(String name) throws JSONException {

// If this name has already been registered, then emit its integer and
// increment its usage count.

        Kim kim = new Kim(name);
        int integer = this.namekeep.find(kim);
        if (integer != none) {
            one();
            writeAndTick(integer, this.namekeep);
        } else {
View Full Code Here

Examples of org.json.Kim

            zero();
            zero();
            write(end, this.substringhuff);
            zero();
        } else {
            Kim kim = new Kim(string);

// Look for the string in the strings keep. If it is found, emit its
// integer and count that as a use.

            int integer = this.stringkeep.find(kim);
View Full Code Here

Examples of org.json.Kim

                length += 1;
            }
            if (length == 0) {
                return "";
            }
            Kim kim = new Kim(bytes, length);
            this.namekeep.register(kim);
            return kim.toString();
        }
        return getAndTick(this.namekeep, this.bitreader).toString();
    }
View Full Code Here

Examples of org.json.Kim

            }
        }
    }

    private String readString() throws JSONException {
        Kim kim;
        int from = 0;
        int thru = 0;
        int previousFrom = none;
        int previousThru = 0;
        if (bit()) {
            return getAndTick(this.stringkeep, this.bitreader).toString();
        }
        byte[] bytes = new byte[65536];
        boolean one = bit();
        this.substringkeep.reserve();
        while (true) {
            if (one) {
                from = thru;
                kim = (Kim) getAndTick(this.substringkeep, this.bitreader);
                thru = kim.copy(bytes, from);
                if (previousFrom != none) {
                    this.substringkeep.registerOne(new Kim(bytes, previousFrom,
                            previousThru + 1));
                }
                previousFrom = from;
                previousThru = thru;
                one = bit();
            } else {
                from = none;
                while (true) {
                    int c = this.substringhuff.read(this.bitreader);
                    if (c == end) {
                        break;
                    }
                    bytes[thru] = (byte) c;
                    thru += 1;
                    if (previousFrom != none) {
                        this.substringkeep.registerOne(new Kim(bytes,
                                previousFrom, previousThru + 1));
                        previousFrom = none;
                    }
                }
                if (!bit()) {
                    break;
                }
                one = true;
            }
        }
        if (thru == 0) {
            return "";
        }
        kim = new Kim(bytes, thru);
        this.stringkeep.register(kim);
        this.substringkeep.registerMany(kim);
        return kim.toString();
    }
View Full Code Here

Examples of org.json.Kim

     *
     * @param integer
     * @return
     */
    public Kim kim(int integer) {
        Kim kim = this.kims[integer];
        int from = this.froms[integer];
        int thru = this.thrus[integer];
        if (from != 0 || thru != kim.length) {
            kim = new Kim(kim, from, thru);
            this.froms[integer] = 0;
            this.thrus[integer] = kim.length;
            this.kims[integer] = kim;
        }
        return kim;
View Full Code Here

Examples of org.json.Kim

            JSONzip.log("\nCapacity " + this.capacity + " <> " +
                    that.capacity);
            return false;
        }
        for (int i = 0; i < this.length; i += 1) {
            Kim thiskim = this.kim(i);
            Kim thatkim = that.kim(i);
            if (!thiskim.equals(thatkim)) {
                JSONzip.log("\n[" + i + "] " + thiskim + " <> " + thatkim);
                result = false;
            }
        }
View Full Code Here

Examples of org.json.Kim

                    this.froms[this.length] = from;
                    this.thrus[this.length] = at + 1;
                    if (JSONzip.probe) {
                        try {
                            JSONzip.log("<<" + this.length + " "
                                    + new Kim(kim, from, at + 1) + ">> ");
                        } catch (Throwable ignore) {
                        }
                    }
                    this.length += 1;
                    limit -= 1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.