Package java.io

Examples of java.io.PushbackReader


     *
     * @param reader
     *            the Reader for the Java source text
     */
    public Tokenizer(Reader reader) {
        this.reader = new PushbackReader(reader);
    }
View Full Code Here


    * {@inheritDoc}
    */
   public void parse(Reader reader, JsonHandler handler) throws JsonException
   {
      jsonHandler = handler;
      pushbackReader = new PushbackReader(reader);
      try
      {
         char c = 0;
         while ((c = next()) != 0)
         {
View Full Code Here

     * @param config_str Configuration string
     * @return Vector of strings
     */
    public static Vector<String> parseProtocols(String config_str) throws IOException {
        Vector<String> retval=new Vector<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

     * @param config_str Configuration string
     * @return Vector of strings
     */
    public static Vector<String> parseProtocols(String config_str) throws IOException {
        Vector<String> retval=new Vector<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

        internalBuffer = new char[LS_CHARS.length + 3];
        pos = internalBuffer.length;
        // Assumes input is at start of message
        atBeginning = true;
        eof = false;
        internalReader = new PushbackReader(reader);
    }
View Full Code Here

  private final static int BUFSIZE = 32;
  private char[] buf = new char[BUFSIZE];
 
  public PullReader(String data) {
    StringReader r = new StringReader(data);
    rdr = new PushbackReader(r, BUFSIZE);
  }
View Full Code Here

  }
 
  public PullReader(InputStream is) {
    try {
      InputStreamReader ir = new InputStreamReader(is,"UTF-8");
      rdr = new PushbackReader(ir, BUFSIZE);
    } catch(Exception e) { fail(e); }
  }
View Full Code Here


public class TextStoryParser implements StoryParser {
  public StoryDetails parseStory(Reader in) {
    try {
      Lexer lexer = new Lexer(new PushbackReader(in, 1024));
      Parser parser = new Parser(lexer);
      Start root = parser.parse();
      StoryDetailsBuilder builder = new StoryDetailsBuilder();
      root.apply(builder);
      return builder.getStoryDetails();
View Full Code Here

    public static PValue compileVal(String expression)
        throws CompilationException
    {
        try {
            // Create a Parser instance.
            Parser p = new Parser(new Lexer(new PushbackReader
                (new StringReader("[foo] = " + expression + ";"), 1024)));

            // Parse the input
            Start tree = p.parse();
View Full Code Here

      if (filename != null)
        defineDecls = (String) defineDeclarations.get(filename);

      try {
        CppFilterReader readIn = new CppFilterReader(in, defineDecls);
        Parser p = new Parser(new Lexer(new PushbackReader(readIn, 1024)));

        // Parse the file.
        Start tree = p.parse();

        // Apply the file loader.
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.