org.json.Kim

Here are the examples of the java api class org.json.Kim taken from open source projects.

1. TrieKeep#kim()

Project: JsonToJava
File: TrieKeep.java
/**
     * Get the kim associated with an integer.
     *
     * @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;
}

2. Compressor#writeName()

Project: JsonToJava
File: Compressor.java
/**
     * Write the name of an object property. Names have their own Keep and
     * Huffman encoder because they are expected to be a more restricted set.
     *
     * @param name
     * @throws JSONException
     */
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 {
        // Otherwise, emit the string with Huffman encoding, and register it.
        zero();
        write(kim, this.namehuff);
        write(end, namehuff);
        this.namekeep.register(kim);
    }
}

3. Decompressor#readString()

Project: JsonToJava
File: Decompressor.java
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();
}