Package net.yacy.kelondro.util.BDecoder

Examples of net.yacy.kelondro.util.BDecoder.BObject


        m.put("s", "222".getBytes());
        Map<String, BObject> t = transcode(m);
        byte[] b = encode(t);
        System.out.println(UTF8.String(b));
        BDecoder d = new BDecoder(b);
        BObject o = d.parse();
        System.out.println(o.toString());
    }
View Full Code Here


            b = FileUtils.read(source);
        } catch (IOException e1) {
            throw new Parser.Failure(e1.toString(), location);
        }
        final BDecoder bd = new BDecoder(b);
        final BObject bo = bd.parse();
        if (bo == null) throw new Parser.Failure("BDecoder.parse returned null", location);
        if (bo.getType() != BType.dictionary) throw new Parser.Failure("BDecoder object is not a dictionary", location);
        final Map<String, BObject> map = bo.getMap();
        final BObject commento = map.get("comment");
        final String comment = (commento == null) ? "" : UTF8.String(commento.getString());
        //Date creation = new Date(map.get("creation date").getInteger());
        final BObject infoo = map.get("info");
        final StringBuilder filenames = new StringBuilder(80);
        String title = "";
        if (infoo != null) {
            final Map<String, BObject> info = infoo.getMap();
            final BObject fileso = info.get("files");
            if (fileso != null) {
                final List<BObject> filelist = fileso.getList();
                for (final BObject fo: filelist) {
                    final BObject patho = fo.getMap().get("path");
                    if (patho != null) {
                        final List<BObject> l = patho.getList(); // one file may have several names
                        for (final BObject fl: l) {
                            filenames.append(fl.toString()).append(" ");
                        }
                    }
                }
            }
            final BObject nameo = info.get("name");
            if (nameo != null) title = UTF8.String(nameo.getString());
        }
        if (title == null || title.length() == 0) title = MultiProtocolURI.unescape(location.getFileName());
        try {
            return new Document[]{new Document(
                    location,
View Full Code Here

   
    private static Map<String, byte[]> b2m(byte[] b) {
        if (b == null) return null;
        //System.out.println("b = " + UTF8.String(b));
        BDecoder decoder = new BDecoder(b);
        BObject bobj = decoder.parse();
        if (bobj.getType() != BDecoder.BType.dictionary) return null;
        Map<String, BDecoder.BObject> map = bobj.getMap();
        Map<String, byte[]> m = new HashMap<String, byte[]>();
        for (Map.Entry<String, BDecoder.BObject> entry: map.entrySet()) {
            if (entry.getValue().getType() != BDecoder.BType.string) continue;
            m.put(entry.getKey(), entry.getValue().getString());
        }
View Full Code Here

            b = FileUtils.read(source);
        } catch (IOException e1) {
            throw new Parser.Failure(e1.toString(), location);
        }
        final BDecoder bd = new BDecoder(b);
        final BObject bo = bd.parse();
        if (bo == null) throw new Parser.Failure("BDecoder.parse returned null", location);
        if (bo.getType() != BType.dictionary) throw new Parser.Failure("BDecoder object is not a dictionary", location);
        final Map<String, BObject> map = bo.getMap();
        final BObject commento = map.get("comment");
        final String comment = (commento == null) ? "" : UTF8.String(commento.getString());
        //Date creation = new Date(map.get("creation date").getInteger());
        final BObject infoo = map.get("info");
        final StringBuilder filenames = new StringBuilder(80);
        String title = "";
        if (infoo != null) {
            final Map<String, BObject> info = infoo.getMap();
            final BObject fileso = info.get("files");
            if (fileso != null) {
                final List<BObject> filelist = fileso.getList();
                for (final BObject fo: filelist) {
                    final BObject patho = fo.getMap().get("path");
                    if (patho != null) {
                        final List<BObject> l = patho.getList(); // one file may have several names
                        for (final BObject fl: l) {
                            filenames.append(fl.toString()).append(" ");
                        }
                    }
                }
            }
            final BObject nameo = info.get("name");
            if (nameo != null) title = UTF8.String(nameo.getString());
        }
        if (title == null || title.length() == 0) title = MultiProtocolURI.unescape(location.getFileName());
        try {
            return new Document[]{new Document(
                    location,
View Full Code Here

    private static Map<String, byte[]> b2m(final byte[] b) {
        if (b == null) return null;
        //System.out.println("b = " + UTF8.String(b));
        final BDecoder decoder = new BDecoder(b);
        final BObject bobj = decoder.parse();
        if (bobj.getType() != BDecoder.BType.dictionary) return null;
        final Map<String, BDecoder.BObject> map = bobj.getMap();
        final Map<String, byte[]> m = new HashMap<String, byte[]>();
        for (final Map.Entry<String, BDecoder.BObject> entry: map.entrySet()) {
            if (entry.getValue().getType() != BDecoder.BType.string) continue;
            m.put(entry.getKey(), entry.getValue().getString());
        }
View Full Code Here

        m.put("s", "222".getBytes());
        Map<String, BObject> t = transcode(m);
        byte[] b = encode(t);
        System.out.println(UTF8.String(b));
        BDecoder d = new BDecoder(b);
        BObject o = d.parse();
        System.out.println(o.toString());
    }
View Full Code Here

TOP

Related Classes of net.yacy.kelondro.util.BDecoder.BObject

Copyright © 2018 www.massapicom. 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.