Package java.io

Examples of java.io.PushbackReader


   {
      this.currentReader = new StackedReader();
      this.readers = new Stack();
      this.currentReader.lineReader = new LineNumberReader(reader);
      this.currentReader.pbReader
         = new PushbackReader(this.currentReader.lineReader, 2);
      this.currentReader.publicId = "";

      try {
         this.currentReader.systemId = new URL("file:.");
      } catch (MalformedURLException e) {
View Full Code Here


      Reader reader = this.stream2reader(stream, charsRead);
      this.currentReader = new StackedReader();
      this.readers = new Stack();
      this.currentReader.lineReader = new LineNumberReader(reader);
      this.currentReader.pbReader
         = new PushbackReader(this.currentReader.lineReader, 2);
      this.currentReader.publicId = "";

      try {
         this.currentReader.systemId = new URL("file:.");
      } catch (MalformedURLException e) {
View Full Code Here

      if (charsRead.length() == 0) {
         return reader;
      }

      String charsReadStr = charsRead.toString();
      PushbackReader pbreader = new PushbackReader(reader,
                                                   charsReadStr.length());

      for (int i = charsReadStr.length() - 1; i >= 0; i--) {
         pbreader.unread(charsReadStr.charAt(i));
      }

      return pbreader;
   }
View Full Code Here

      this.readers.push(this.currentReader);
      this.currentReader = new StackedReader();

      if (isInternalEntity) {
         this.currentReader.lineReader = null;
         this.currentReader.pbReader = new PushbackReader(reader, 2);
      } else {
         this.currentReader.lineReader = new LineNumberReader(reader);
         this.currentReader.pbReader
            = new PushbackReader(this.currentReader.lineReader, 2);
      }

      this.currentReader.systemId = oldReader.systemId;
      this.currentReader.publicId = oldReader.publicId;
   }
View Full Code Here

    {
        Reader old = m_in;

        if( in != null )
        {
            m_in = new PushbackReader( new BufferedReader( in ),
                                       PUSHBACK_BUFFER_SIZE );
        }

        return old;
    }
View Full Code Here

    public static JSONArtifact parse(Reader reader, boolean order, boolean strict) throws JSONException, NullPointerException {

        try {
            if (reader != null) {

                PushbackReader pReader = null;

                //Determine if we should buffer-wrap the reader before passing it on
                //to the appropriate parser.
                boolean bufferIt = false;

                Class readerClass = reader.getClass();

                if (!StringReader.class.isAssignableFrom(readerClass) &&
                    !CharArrayReader.class.isAssignableFrom(readerClass) &&
                    !PushbackReader.class.isAssignableFrom(readerClass) &&
                    !BufferedReader.class.isAssignableFrom(readerClass)) {
                    bufferIt = true;
                }

                if (PushbackReader.class.isAssignableFrom(readerClass)) {
                    pReader = (PushbackReader) reader;
                } else {
                    pReader = new PushbackReader(reader);
                }

                Reader rdr = pReader;
                int ch = pReader.read();
                while (ch != -1) {
                    switch (ch) {
                        case '{':
                            pReader.unread(ch);
                            if (bufferIt) {
                                rdr = new BufferedReader(pReader);
                            }
                            if (order) {
                                return new OrderedJSONObject(rdr, strict);
                            } else {
                                return new JSONObject(rdr,strict);
                            }
                        case '[':
                            pReader.unread(ch);
                            if (bufferIt) {
                                rdr = new BufferedReader(pReader);
                            }
                            return new JSONArray(rdr, strict);
                        case ' ':
                        case '\t':
                        case '\f':
                        case '\r':
                        case '\n':
                        case '\b':
                            ch = pReader.read();
                            break;
                        default:
                            throw new JSONException("Unexpected character: [" + (char)ch + "] while scanning JSON String for JSON type.  Invalid JSON.");
                    }
                }
View Full Code Here

     * so that input stream modifications may be handled transparently by our
     * {@link #doRead()} method.
     */
    public EspReader(Reader baseReader) {
        super(baseReader);
        this.input = new PushbackReader(baseReader, 100);
        this.stateStack = new Stack<Byte>();
        this.lineStart = true;
        this.verbatimChars = -1;
        this.quoteChar = 0;
        this.escape = false;
View Full Code Here

    }
   
    /** Creates a new instance of CsvRecordInput */
    public CsvRecordInput(InputStream in) {
      try {
      stream = new PushbackReader(new InputStreamReader(in, "UTF-8"));
      } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
      }
    }
View Full Code Here

    {
        Reader old = m_in;

        if( in != null )
        {
            m_in = new PushbackReader( new BufferedReader( in ),
                                       PUSHBACK_BUFFER_SIZE );
        }

        return old;
    }
View Full Code Here

     * @param config_str Configuration string
     * @return Vector of strings
     */
    private static List<String> parseProtocols(String config_str) throws IOException {
        List<String> retval=new LinkedList<String>();
        PushbackReader reader=new PushbackReader(new StringReader(config_str));
        int ch;
        StringBuilder sb;
        boolean running=true;

        while(running) {
            String protocol_name=readWord(reader);
            sb=new StringBuilder();
            sb.append(protocol_name);

            ch=read(reader);
            if(ch == -1) {
                retval.add(sb.toString());
                break;
            }

            if(ch == ':') {  // no attrs defined
                retval.add(sb.toString());
                continue;
            }

            if(ch == '(') { // more attrs defined
                reader.unread(ch);
                String attrs=readUntil(reader, ')');
                sb.append(attrs);
                retval.add(sb.toString());
            }
            else {
                retval.add(sb.toString());
            }

            while(true) {
                ch=read(reader);
                if(ch == ':') {
                    break;
                }
                if(ch == -1) {
                    running=false;
                    break;
                }
            }
        }
        reader.close();

        return retval;
    }
View Full Code Here

TOP

Related Classes of java.io.PushbackReader

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.