Package de.zalando.typemapper.parser.exception

Examples of de.zalando.typemapper.parser.exception.HStoreParseException


                            position++;
                            continue;
                        }
                    }

                    throw new HStoreParseException("Backslash without following backslash or quote at position "
                            + position, position);

                } else if (ch == QUOTE) {

                    // it was a closing quote as we either ware are at the end of the rawValue string
                    // or we could not find the next quote
                    insideQuote = false;
                    break;
                } else {
                    if (sb != null) {
                        sb.append(ch);
                    }
                }
            }

            if (insideQuote) {
                throw new HStoreParseException("Quote at string position " + firstQuotePosition + " is not closed",
                    position);
            }

            if (sb == null) {
View Full Code Here


        private String advanceWord(final char stopAtChar) throws HStoreParseException {
            final int firstWordPosition = position;
            while (position < length) {
                final char ch = value.charAt(position);
                if (ch == QUOTE) {
                    throw new HStoreParseException("Unexpected quote in word", position);
                } else if (Character.isWhitespace(ch) || ch == stopAtChar) {
                    break;
                }

                position++;
View Full Code Here

                        if (ch == EQUALS) {
                            state = ParseState.WaitingForGreater;
                            continue;
                        } else {
                            throw new HStoreParseException("Expected '=>' key-value separator", position);
                        }

                    case WaitingForGreater :
                        if (ch == GREATER) {
                            state = ParseState.WaitingForValue;
                            continue;
                        } else {
                            throw new HStoreParseException("Expected '=>' key-value separator", position);
                        }

                    case WaitingForValue :
                        if (Character.isWhitespace(ch)) {
                            continue;
                        }

                        if (ch == QUOTE) {
                            elementValue = advanceQuoted();
                        } else {

                            // we have non-quote char, so start loading the key
                            elementValue = advanceWord(COMMA);

                            // hstore supports NULL values, so if unquoted NULL is there, it is rewritten to null
                            if (NULL.equalsIgnoreCase(elementValue)) {
                                elementValue = null;
                            }
                        }

                        state = ParseState.WaitingForComma;
                        continue;

                    case WaitingForComma :
                        if (Character.isWhitespace(ch)) {
                            continue;
                        }

                        if (ch == COMMA) {

                            // we are done
                            break loop;
                        } else {
                            throw new HStoreParseException("Cannot find comma as an end of the value: '" + value + "'",
                                position);
                        }

                    default :
                        throw new IllegalStateException("Unknown HStoreParser state");
                }
            } // loop

            // here we either consumed whole string or we found a comma
            if (state == ParseState.WaitingForKey) {

                // string was consumed when waiting for key, so we are done with processing
                nextEntry = null;
                return;
            }

            if (state != ParseState.WaitingForComma) {
                throw new HStoreParseException("Unexpected end of string", position);
            }

            if (elementKey == null) {
                throw new HStoreParseException("Internal parsing error", position);
            }

            // init nextValue
            nextEntry = new HStoreEntry(elementKey, elementValue);
        }
View Full Code Here

TOP

Related Classes of de.zalando.typemapper.parser.exception.HStoreParseException

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.