Examples of JsonParsingException


Examples of com.datasift.client.examples.JsonParsingException

                    try {
                        result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
                    } catch (IOException e) {
                        result.failed(e);
                        if (config.isAllowedToRaiseExceptions()) {
                            throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
                        }
                    }
                }
                result.setResponse(new com.datasift.client.Response(s, response));
                if (config.isAllowedToRaiseExceptions() && response.getStatus().code() == 401) {
View Full Code Here

Examples of com.datasift.client.exceptions.JsonParsingException

                    try {
                        result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
                    } catch (IOException e) {
                        result.failed(e);
                        if (config.isAllowedToRaiseExceptions()) {
                            throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
                        }
                    }
                }
                result.setResponse(new com.datasift.client.Response(s, response));
                if (config.isAllowedToRaiseExceptions() && response.getStatus().code() == 401) {
View Full Code Here

Examples of com.datasift.client.exceptions.JsonParsingException

                } else {
                    try {
                        result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
                    } catch (IOException e) {
                        result.failed(e);
                        throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
                    }
                }
                result.setResponse(new com.datasift.client.Response(s, response));
                if (response.getStatus().code() == 401) {
                    throw new AuthException("Please provide a valid username and API key", response);
View Full Code Here

Examples of com.datasift.client.exceptions.JsonParsingException

                    try {
                        result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
                    } catch (IOException e) {
                        result.failed(e);
                        if (config.isAllowedToRaiseExceptions()) {
                            throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
                        }
                    }
                }
                result.setResponse(new com.datasift.client.Response(s, response));
                if (config.isAllowedToRaiseExceptions() && response.getStatus().code() == 401) {
View Full Code Here

Examples of com.datasift.client.exceptions.JsonParsingException

                } else {
                    try {
                        result = (T) DataSiftClient.MAPPER.readValue(s, instance.getClass());
                    } catch (IOException e) {
                        result.failed(e);
                        throw new JsonParsingException("Unable to decode JSON from DataSift response", e, response);
                    }
                }
                result.setResponse(new com.datasift.client.Response(s, response));
                if (response.getStatus().code() == 401) {
                    throw new AuthException("Please provide a valid username and API key", response);
View Full Code Here

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

Examples of javax.json.stream.JsonParsingException

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

Examples of javax.json.stream.JsonParsingException

            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

Examples of javax.json.stream.JsonParsingException

        }
    }

    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

Examples of javax.json.stream.JsonParsingException

        }
    }

    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
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.