Package javax.json.stream

Examples of javax.json.stream.JsonParsingException


        return attrs;
    }

    public void readDatasets(Callback callback) {
        if (next() != Event.START_ARRAY) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected array of Data Set objects", location);
        }
        Attributes attrs;
        for (;;) {
            switch (next()) {
            case END_ARRAY:
                return;
            case START_OBJECT:
                fmi = null;
                attrs = new Attributes();
                doReadDataset(attrs);
                callback.onDataset(fmi, attrs);
                break;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected Data Set object", location);
            }
        }
    }
View Full Code Here


                break;
            case END_OBJECT:
                attrs.trimToSize();
                return;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected Tag value", location);
            }
        }
    }
View Full Code Here

            if (fmi == null)
                fmi = new Attributes();
            attrs = fmi;
        }
        if (next() != Event.START_OBJECT) {
            throw new JsonParsingException("Unexpected " + event
                    + " expected attribute object", location);
        }
        if (next() != Event.KEY_NAME) {
            throw new JsonParsingException("Unexpected " + event
                    + "\", expected \"vr\"", location);
        }
        key = getString();
        if (!"vr".equals(key)) {
            throw new JsonParsingException("Unexpected \"" + key
                    + "\", expected: \"vr\"", location);
        }
        if (next() != Event.VALUE_STRING) {
            throw new JsonParsingException("Unexpected " + event
                    + " expected vr value", location);
        }
        VR vr = VR.valueOf(parser.getString());
        switch (next()) {
        case END_OBJECT:
            attrs.setNull(tag, vr);
            break;
        case KEY_NAME:
            key = getString();
            if ("Value".equals(key)) {
                switch (vr) {
                case AE:
                case AS:
                case AT:
                case CS:
                case DA:
                case DT:
                case LO:
                case LT:
                case SH:
                case ST:
                case TM:
                case UI:
                case UT:
                    readStringValues(attrs, tag, vr);
                    break;
                case DS:
                case FL:
                case FD:
                case IS:
                case SL:
                case SS:
                case UL:
                case US:
                    readNumberValues(attrs, tag, vr);
                    break;
                case PN:
                    readPersonNames(attrs, tag);
                    break;
                case SQ:
                    readSequence(attrs, tag);
                    break;
                case OB:
                case OF:
                case OW:
                case UN:
                    throw new JsonParsingException("Unexpected \"Value\""
                            + "\", expected \"InlineBinary\""
                            + " or \"BulkDataURI\" or  \"DataFragment\"", location);
                }
            } else if ("InlineBinary".equals(key)) {
                attrs.setBytes(tag, vr, readInlineBinary());
            } else if ("BulkDataURI".equals(key)) {
                attrs.setValue(tag, vr, readBulkData(attrs.bigEndian()));
            } else if ("DataFragment".equals(key)) {
                readDataFragment(attrs, tag, vr);
            } else {
                throw new JsonParsingException("Unexpected \"" + key
                        + "\", expected \"Value\" or \"InlineBinary\""
                        + " or \"BulkDataURI\" or  \"DataFragment\"", location);
            }
            if (next() != Event.END_OBJECT) {
                throw new JsonParsingException("Unexpected " + event
                        + " expected end of attribute object", location);
            }
            break;
        default:
            throw new JsonParsingException("Unexpected " + event
                    + "\", expected \"Value\" or \"InlineBinary\""
                    + " or \"BulkDataURI\"", location);
        }
    }
View Full Code Here

        }
    }

    private void readStringValues(Attributes attrs, int tag, VR vr) {
        if (next() != Event.START_ARRAY) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected array of values", location);
        }
        for (;;) {
            switch (next()) {
            case END_ARRAY:
                attrs.setString(tag, vr,
                        stringValues.toArray(new String[stringValues.size()]));
                stringValues.clear();
                return;
            case VALUE_NULL:
                stringValues.add(null);
                break;
            case VALUE_STRING:
                stringValues.add(parser.getString());
                break;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected string value", location);
            }
        }
    }
View Full Code Here

        }
    }

    private void readNumberValues(Attributes attrs, int tag, VR vr) {
        if (next() != Event.START_ARRAY) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected array of values", location);
        }
        for (;;) {
            switch (next()) {
            case END_ARRAY:
                switch(vr) {
                case DS:
                case FL:
                case FD:
                    attrs.setDouble(tag, vr, toDoubles(numberValues));
                    break;
                case IS:
                case SL:
                case SS:
                case UL:
                case US:
                    attrs.setInt(tag, vr, toInts(numberValues));
                    break;
                default:
                    assert true;
                }
                numberValues.clear();
                return;
            case VALUE_NUMBER:
                numberValues.add(parser.getBigDecimal());
                break;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected number value", location);
            }
        }
    }
View Full Code Here

        return is;
    }

    private void readPersonNames(Attributes attrs, int tag) {
        if (next() != Event.START_ARRAY) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected array of person name objects", location);
        }
        for (;;) {
            switch (next()) {
            case END_ARRAY:
                attrs.setString(tag, VR.PN,
                        stringValues.toArray(new String[stringValues.size()]));
                stringValues.clear();
                return;
            case VALUE_NULL:
                stringValues.add(null);
                break;
            case START_OBJECT:
                stringValues.add(readPersonName());
                break;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected person name object", location);
            }
        }
    }
View Full Code Here

                return retval;
            case KEY_NAME:
                try {
                    key = PersonName.Group.valueOf(getString());
                } catch (IllegalArgumentException e) {
                    throw new JsonParsingException("Unexpected \"" + e.getMessage()
                            + "\", expected \"Alphabetic\" or \"Ideographic\""
                            + " or \"Phonetic\"", location);
                }
                if (next() != Event.VALUE_STRING) {
                    throw new JsonParsingException("Unexpected " + event
                            + "\", expected person name value", location);
                }
                personNameGroups.put(key, parser.getString());
                break;
            default:
                 throw new JsonParsingException("Unexpected " + event
                         + ", expected \"Alphabetic\" or \"Ideographic\""
                         + " or \"Phonetic\"", location);
            }
        }
    }
View Full Code Here

        seq.trimToSize();
    }

    private byte[] readInlineBinary() {
        if (next() != Event.VALUE_STRING) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected bulk data URI", location);
        }
        char[] base64 = parser.getString().toCharArray();
        bout.reset();
        try {
View Full Code Here

        return bout.toByteArray();
    }

    private BulkData readBulkData(boolean bigEndian) {
        if (next() != Event.VALUE_STRING) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected bulk data URI", location);
        }
        String uri = parser.getString();
        return new BulkData(null, uri, bigEndian);
    }
View Full Code Here

        return new BulkData(null, uri, bigEndian);
    }

    private void readDataFragment(Attributes attrs, int tag, VR vr) {
        if (next() != Event.START_ARRAY) {
            throw new JsonParsingException("Unexpected " + event
                    + ", expected array of data fragment objects", location);
        }
        Fragments frags = attrs.newFragments(tag, vr, 10);
        for (;;) {
            switch (next()) {
            case END_ARRAY:
                frags.trimToSize();
                return;
            case VALUE_NULL:
                frags.add(null);
                break;
            case START_OBJECT:
                frags.add(readDataFragment(attrs.bigEndian()));
                break;
            default:
                throw new JsonParsingException("Unexpected " + event
                        + ", expected data fragment object", location);
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.json.stream.JsonParsingException

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.