Package com.dropbox.core.json

Examples of com.dropbox.core.json.JsonExtractionException


                    case FM_icon: icon = JsonExtractor.StringExtractor.extractField(parser, fieldName, icon); break;
                    case FM_modified: modified = JsonDateExtractor.Dropbox.extractField(parser, fieldName, modified); break;
                    case FM_client_mtime: client_mtime = JsonDateExtractor.Dropbox.extractField(parser, fieldName, client_mtime); break;
                    case FM_mime_type: mime_type = JsonExtractor.StringExtractor.extractField(parser, fieldName, mime_type); break;
                    case FM_hash:
                        if (collector == null) throw new JsonExtractionException("not expecting \"hash\" field, since we didn't ask for children", parser.getCurrentLocation());
                        hash = JsonExtractor.StringExtractor.extractField(parser, fieldName, hash); break;
                    case FM_contents:
                        if (collector == null) throw new JsonExtractionException("not expecting \"contents\" field, since we didn't ask for children", parser.getCurrentLocation());
                        contents = JsonArrayExtractor.mk(Extractor, collector).extractField(parser, fieldName, contents); break;
                    default:
                        throw new AssertionError("bad index: " + fi + ", field = \"" + fieldName + "\"");
                }
            }
            catch (JsonExtractionException ex) {
                throw ex.addFieldContext(fieldName);
            }
        }

        JsonExtractor.expectObjectEnd(parser);

        if (path == null) throw new JsonExtractionException("missing field \"path\"", top);
        if (icon == null) throw new JsonExtractionException("missing field \"icon\"", top);
        if (is_deleted == null) is_deleted = Boolean.FALSE;
        if (is_dir == null) is_dir = Boolean.FALSE;
        if (thumb_exists == null) thumb_exists = Boolean.FALSE;

        if (is_dir && (contents != null || hash != null)) {
            if (hash == null) throw new JsonExtractionException("missing \"hash\", when we asked for children", top);
            if (contents == null) throw new JsonExtractionException("missing \"contents\", when we asked for children", top);
        }

        DbxEntry e;
        if (is_dir) {
            e = new Folder(path, icon, thumb_exists);
        }
        else {
            // Normal File
            if (size == null) throw new JsonExtractionException("missing \"size\" for a file entry", top);
            if (bytes == -1) throw new JsonExtractionException("missing \"bytes\" for a file entry", top);
            if (modified == null) throw new JsonExtractionException("missing \"modified\" for a file entry", top);
            if (client_mtime == null) throw new JsonExtractionException("missing \"client_mtime\" for a file entry", top);
            if (mime_type == null) throw new JsonExtractionException("missing \"mime_type\" for a file entry", top);
            if (rev == null) throw new JsonExtractionException("missing \"rev\" for a file entry", top);
            e = new File(path, icon, thumb_exists, bytes, size, modified, client_mtime, mime_type, rev);
        }

        if (is_deleted) return null;
        return new WithChildrenC<C>(e, hash, contents);
View Full Code Here


                }
            }

            JsonExtractor.expectObjectEnd(parser);

            if (reset == null) throw new JsonExtractionException("missing field \"path\"", top);
            if (entries == null) throw new JsonExtractionException("missing field \"entries\"", top);
            if (cursor == null) throw new JsonExtractionException("missing field \"cursor\"", top);
            if (has_more == null) throw new JsonExtractionException("missing field \"has_more\"", top);

            return new DbxDeltaC<C,MD>(reset, entries, cursor, has_more);
        }
View Full Code Here

                throws IOException, JsonExtractionException
            {
                JsonLocation arrayStart = JsonExtractor.expectArrayStart(parser);

                if (JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found a zero-element array", arrayStart);
                }

                String lcPath;
                try {
                    lcPath = JsonExtractor.StringExtractor.extract(parser);
                }
                catch (JsonExtractionException ex) {
                    throw ex.addArrayContext(0);
                }

                if (JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found a one-element array", arrayStart);
                }

                MD metadata;
                try {
                    metadata = metadataExtractor.extractOptional(parser);
                }
                catch (JsonExtractionException ex) {
                    throw ex.addArrayContext(1);
                }

                if (!JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found more than two elements", arrayStart);
                }

                parser.nextToken();

                return new Entry<MD>(lcPath, metadata);
View Full Code Here

                }
            }

            JsonExtractor.expectObjectEnd(parser);

            if (reset == null) throw new JsonExtractionException("missing field \"path\"", top);
            if (entries == null) throw new JsonExtractionException("missing field \"entries\"", top);
            if (cursor == null) throw new JsonExtractionException("missing field \"cursor\"", top);
            if (has_more == null) throw new JsonExtractionException("missing field \"has_more\"", top);

            return new DbxDelta<MD>(reset, entries, cursor, has_more);
        }
View Full Code Here

                throws IOException, JsonExtractionException
            {
                JsonLocation arrayStart = JsonExtractor.expectArrayStart(parser);

                if (JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found a zero-element array", arrayStart);
                }

                String lcPath;
                try {
                    lcPath = JsonExtractor.StringExtractor.extract(parser);
                }
                catch (JsonExtractionException ex) {
                    throw ex.addArrayContext(0);
                }

                if (JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found a one-element array: " + jq(lcPath), arrayStart);
                }

                MD metadata;
                try {
                    metadata = metadataExtractor.extractOptional(parser);
                }
                catch (JsonExtractionException ex) {
                    throw ex.addArrayContext(1);
                }

                if (!JsonExtractor.isArrayEnd(parser)) {
                    throw new JsonExtractionException("expecting a two-element array of [path, metadata], found non \"]\" token after the two elements: " + parser.getCurrentToken(), arrayStart);
                }

                parser.nextToken();

                return new Entry<MD>(lcPath, metadata);
View Full Code Here

TOP

Related Classes of com.dropbox.core.json.JsonExtractionException

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.