Returns the next token on the stream, or null if there are no more JSON
tokens on the stream.
@return The next token, or null.
@throws JsonException If the next token is illegally formatted.
@throws IOException If unable to read from stream.
768256
@Nullable
    public JsonToken next() throws IOException, JsonException {
        if (unreadToken != null) {
            JsonToken tmp = unreadToken;
            unreadToken = null;
            return tmp;
        }

        while (lastChar >= 0) {
            if (lastChar == 0) {
                if (!readNextChar()) {
                    break;
                }
            }
            if (lastChar == JsonToken.kNewLine ||
                lastChar == JsonToken.kCarriageReturn ||
                lastChar == JsonToken.kSpace ||
                lastChar == JsonToken.kTab) {
                lastChar = 0;
                continue;
            }

            if (lastChar == JsonToken.kDoubleQuote) {
                return nextString();
            } else if (lastChar == '.' || lastChar == '-' || (lastChar >= '0' && lastChar <= '9')) {
                return nextNumber();
            } else if (lastChar == '_' ||
                       (lastChar >= 'a' && lastChar <= 'z') ||
                       (lastChar >= 'A' && lastChar <= 'Z')) {
                return nextToken();
            } else if (lastChar < 0x20 || lastChar >= 0x7F) {
                // UTF-8 characters are only allowed inside JSON string literals.
                throw newParseException("Illegal character in JSON structure: '\\u%04x'", lastChar);
            } else {
                return nextSymbol();
            }
        }

        return null;
    }
583321
public boolean next() throws IOException {
		boolean hasNext = true;
		try {
			oldId = stream.readInt();
			oldText = stream.readUTFAsArray();
		} catch (EOFException e) {
			hasNext = false;
		}
		return hasNext;
	}
807260
public T get(String json) throws IOException, JsonFormatException {
		JsonPullParser parser = JsonPullParser.newParser(json);
		return get(parser, null);
	}
1115248
public String next(int n) throws JSONException {
         if (n == 0) {
             return "";
         }

         char[] buffer = new char[n];
         int pos = 0;

         while (pos < n) {
             buffer[pos] = next();
             if (end()) {
                 throw syntaxError("Substring bounds error");                 
             }
             pos += 1;
         }
         return new String(buffer);
     }
1039757
private int get() throws IOException {
        int c = theLookahead;
        theLookahead = EOF;
        if (c == EOF) {
            c = inputStream.read();
        }
        if (c >= ' ' || c == '\n' || c == EOF) {
            return c;
        }
        if (c == '\r') {
            return '\n';
        }
        return ' ';
    }
1182953
public char next() throws JSONException {
        if (this.useLastChar) {
        	this.useLastChar = false;
            if (this.lastChar != 0) {
            	this.index += 1;
            }
            return this.lastChar;
        } 
        int c;
        try {
            c = this.reader.read();
        } catch (IOException exc) {
            throw new JSONException(exc);
        }

        if (c <= 0) { // End of stream
        	this.lastChar = 0;
            return 0;
        } 
    	this.index += 1;
    	this.lastChar = (char) c;
        return this.lastChar;
    }
822036
private JsonToken advance() throws IOException {
        peek();

        JsonToken result = token;
        token = null;
        value = null;
        name = null;
        return result;
    }
298952
private static void assertNextToken(
			final JsonParser p,
			final JsonToken requiredJsonToken) throws IOException {
		final JsonToken jsonToken = p.nextToken();
		if (jsonToken != requiredJsonToken) {
			throw new JsonMappingException(p, String.format("Expected token %s (was %s)", requiredJsonToken, jsonToken));
		}
	}
1095486
public boolean hasNextToken() {
    if (this.nextToken == null) {
      try {
        this.nextToken = this.jlexer.yylex();
      } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return this.nextToken != null;
  }
350091
private void getFirstToken(StreamTokenizer tokenizer) throws IOException {
        while (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
        }

        if ((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
            tokenizer.ttype = StreamTokenizer.TT_WORD;
        } else if ((tokenizer.ttype == StreamTokenizer.TT_WORD) && (tokenizer.sval.equals("?"))) {
            tokenizer.ttype = '?';
        }
    }
1360957
public JsonToken peek() throws IOException {
        if (token != null) {
            return token;
        }

        switch (peekStack()) {
            case EMPTY_DOCUMENT:
                replaceTop(JsonScope.NONEMPTY_DOCUMENT);
                JsonToken firstToken = nextValue();
                if (!lenient && token != JsonToken.BEGIN_ARRAY && token != JsonToken.BEGIN_OBJECT) {
                    throw new IOException(
                            "Expected JSON document to start with '[' or '{' but was " + token);
                }
                return firstToken;
            case EMPTY_ARRAY:
                return nextInArray(true);
            case NONEMPTY_ARRAY:
                return nextInArray(false);
            case EMPTY_OBJECT:
                return nextInObject(true);
            case DANGLING_NAME:
                return objectValue();
            case NONEMPTY_OBJECT:
                return nextInObject(false);
            case NONEMPTY_DOCUMENT:
                try {
                    JsonToken token = nextValue();
                    if (lenient) {
                        return token;
                    }
                    throw syntaxError("Expected EOF");
                } catch (EOFException e) {
                    return token = JsonToken.END_DOCUMENT; // TODO: avoid throwing here?
                }
            case CLOSED:
                throw new IllegalStateException("JsonReader is closed");
            default:
                throw new AssertionError();
        }
    }
1359074
@Override
    public Tuple getNext()
            throws IOException {
        Tuple tuple = null;
        try {
            if (isBuildingExample) {
                isBuildingExample = false; // Terminate on the next iteration
                return tupleFactory.newTuple(createPigExample());
            }

            boolean notDone = reader.nextKeyValue();
            if (!notDone) {
                return null;
            }

            ParsedRecord value = reader.getCurrentValue();

            if (value != null) {
                List<Object> values = new ArrayList<>();
                if (onlyWantListOfFields) {
                    values.add(value.getString(ApacheHttpdLogfileRecordReader.FIELDS));
                } else {
                    for (String fieldName : requestedFields) {
                        if (fieldName.endsWith(".*")) {
                            values.add(value.getStringSet(fieldName));
                            continue;
                        } else {
                            EnumSet<Casts> casts = reader.getParser().getCasts(fieldName);

                            if (casts != null) {
                                if (casts.contains(Casts.LONG)) {
                                    values.add(value.getLong(fieldName));
                                    continue;
                                }

                                if (casts.contains(Casts.DOUBLE)) {
                                    values.add(value.getDouble(fieldName));
                                    continue;
                                }
                            }
                        }
                        values.add(value.getString(fieldName));
                    }
                }
                tuple = tupleFactory.newTuple(values);
            }
        } catch (InvalidDissectorException | MissingDissectorsException e) {
            throw new IOException("Fatal error in the parser", e);
        }
        return tuple;
    }
978201
@Nullable
  private String _getNextLine () throws IOException
  {
    if (_isClosed ())
    {
      m_bHasNext = false;
      return null;
    }

    if (!m_bLinesSkiped)
    {
      // Perform skip of lines exactly once
      for (int i = 0; i < m_nSkipLines; i++)
        m_aLineReader.readLine ();
      m_bLinesSkiped = true;
    }

    if (!m_bHasNext)
      return null;

    final String sNextLine = m_aLineReader.readLine ();
    if (sNextLine == null)
      m_bHasNext = false;

    return sNextLine;
  }
184659
public Token read(Token t) throws IOException {
    if (t.e == EditsElement.OPCODE) {
      // read the offset first
      LongToken offsetToken = new LongToken(EditsElement.OFFSET);
      offsetToken.fromString(getNextElementsValue(EditsElement.OFFSET.name()));
      t.offset = offsetToken.value;
    }
    t.fromString(getNextElementsValue(t.getEditsElement().toString()));
    return t;
  }
707263
public Object nextValue() throws JSONException {
		int c = nextCleanInternal();
		switch (c) {
		case -1:
			throw syntaxError("End of input");

		case '{':
			return readObject();

		case '[':
			return readArray();

		case '\'':
		case '"':
			return nextString((char) c);

		default:
			this.pos--;
			return readLiteral();
		}
	}
933822
public char nextClean() throws JSONException {

        for (;;) {
            char c = next();
            if (c == '/') {
                switch (next()) {
                    case '/':
                        do {
                            c = next();
                        } while ((c != '\n') && (c != '\r') && (c != 0));
                        break;
                    case '*':
                        for (;;) {
                            c = next();
                            if (c == 0) {
                                throw syntaxError("Unclosed comment");
                            }
                            if (c == '*') {
                                if (next() == '/') {
                                    break;
                                }
                                back();
                            }
                        }
                        break;
                    default:
                        back();
                        return '/';
                }
            } else if (c == '#') {
                do {
                    c = next();
                } while ((c != '\n') && (c != '\r') && (c != 0));
            } else if ((c == 0) || (c > ' ')) {
                return c;
            }
        }
    }
618078
private int nextToken(StreamTokenizer tokeniser, Reader in, boolean ignoreEOF) throws IOException, ParserException {
        int token = tokeniser.nextToken();
        if (!ignoreEOF && token == StreamTokenizer.TT_EOF) {
            throw new ParserException("Unexpected end of file", getLineNumber(tokeniser, in));
        }
        return token;
    }