protected char seekTo(String seek, Source source) { while (source.hasNext()) { char c=source.peek(); if (seek.indexOf(c)>=0) { return c; } if (!Character.isWhitespace(c)) throw new IllegalStateException("Unexpected '"+c+"' while seeking one of '"+seek+"'"); source.next(); } throw new IllegalStateException("Expected one of '"+seek+"'"); }
if (source.next()!='"') throw new IllegalStateException(); final char[] scratch=source.scratchBuffer(); while (source.hasNext()) char c=source.next(); break; case 'u': char uc=(char)((TypeUtil.convertHexDigit((byte)source.next())<<12)+ (TypeUtil.convertHexDigit((byte)source.next())<<8)+ (TypeUtil.convertHexDigit((byte)source.next())<<4)+ (TypeUtil.convertHexDigit((byte)source.next()))); scratch[i++]=uc; break; while (source.hasNext()) char c=source.next(); break; case 'u': char uc=(char)((TypeUtil.convertHexDigit((byte)source.next())<<12)+ (TypeUtil.convertHexDigit((byte)source.next())<<8)+ (TypeUtil.convertHexDigit((byte)source.next())<<4)+ (TypeUtil.convertHexDigit((byte)source.next()))); b.append(uc);
longLoop: while (source.hasNext()) char c=source.peek(); switch (c) case '9': number=number*10+(c-'0'); source.next(); break; throw new IllegalStateException("bad number"); minus=true; source.next(); break; buffer.append(number); buffer.append(c); source.next(); break longLoop; doubleLoop: while (source.hasNext()) char c=source.peek(); switch (c) case 'E': buffer.append(c); source.next(); break;
protected static void complete(String seek, Source source) { int i=0; while (source.hasNext()&&i<seek.length()) { char c=source.next(); if (c!=seek.charAt(i++)) throw new IllegalStateException("Unexpected '"+c+" while seeking \""+seek+"\""); } if (i<seek.length()) throw new IllegalStateException("Expected \""+seek+"\""); }
protected void seekTo(char seek, Source source) { while (source.hasNext()) { char c=source.peek(); if (c==seek) return; if (!Character.isWhitespace(c)) throw new IllegalStateException("Unexpected '"+c+" while seeking '"+seek+"'"); source.next(); } throw new IllegalStateException("Expected '"+seek+"'"); }