Examples of KVBundle


Examples of com.addthis.bundle.core.kvp.KVBundle

        }
    }

    @Override
    public Bundle createBundle() {
        return new KVBundle(format);
    }
View Full Code Here

Examples of com.addthis.bundle.core.kvp.KVBundle

     */
    public static KVBundle fromText(byte text[], KVBundleFormat format) {
        if (text.length == 0) {
            return null;
        }
        KVBundle bundle = new KVBundle(format);
        String s = Bytes.toString(text);
        int i = 0;
        int j = s.indexOf('&');
        while (j >= 0) {
            if (j > 0) {
                KVPair kv = KVPair.parsePair(s.substring(i, j));
                if (kv != null) {
                    bundle.setValue(format.getField(kv.getKey()), ValueFactory.create(kv.getValue()));
                }
            }
            i = j + 1;
            j = s.indexOf('&', i);
        }
        KVPair kv = KVPair.parsePair(s.substring(i));
        if (kv != null) {
            bundle.setValue(format.getField(kv.getKey()), ValueFactory.create(kv.getValue()));
        }
        return bundle;
    }
View Full Code Here

Examples of com.addthis.bundle.core.kvp.KVBundle

    /**
     * copied from KVPairs.class and modified
     */
    public static KVBundle fromBin(byte bin[], KVBundleFormat format) {
        KVBundle bundle = new KVBundle(format);
        int pos = 0;
        while (pos < bin.length) {
            String key = null;
            String val = null;
            for (int i = pos; i < bin.length; i++) {
                if (bin[i] == 0) {
                    key = new String(bin, pos, i - pos);
                    pos = i + 1;
                    break;
                }
                if (i == bin.length - 1) {
                    key = new String(bin, pos, i - pos + 1);
                    pos = i + 1;
                    break;
                }
            }
            for (int i = pos; i < bin.length; i++) {
                if (bin[i] == 0) {
                    val = new String(bin, pos, i - pos);
                    pos = i + 1;
                    break;
                }
                if (i == bin.length - 1) {
                    val = new String(bin, pos, i - pos + 1);
                    pos = i + 1;
                    break;
                }
            }
            bundle.setValue(format.getField(key), ValueFactory.create(val));
        }
        return bundle;
    }
View Full Code Here

Examples of com.addthis.bundle.core.kvp.KVBundle

        }
    }

    @Override
    public Bundle createBundle() {
        return new KVBundle(format);
    }
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.