Examples of PushbackReader


Examples of java.io.PushbackReader

      }
   }

   public List<TemplateSection> parse(Reader tmp) throws IOException
   {
      PushbackReader reader = new PushbackReader(tmp);


      //
      ArrayList<TemplateSection> sections = new ArrayList<TemplateSection>();
      StringBuilder accumulator = new StringBuilder();

      //
      int lineNumber = 1;
      int colNumber = 1;
      Position pos = new Position(1, 1);
      Status status = Status.TEXT;
      int i;
      while ((i = reader.read()) != -1)
      {
         char c = (char)i;
        
         //
         if (c == '\r')
         {
            // On Windows, "\r\n" is a new line
            int j = reader.read();
            if (j != -1)
            {
               char c2 = (char)j;
               if (c2 == '\n')
               {
                  c = '\n';
               }
               else
               {
                  reader.unread(j);
               }
            }
         }

         // Update current position
View Full Code Here

Examples of java.io.PushbackReader

        reader = null;
    }

    public CharacterInputStream(InputStream in)
    {
        reader = new PushbackReader(
            new BufferedReader(new InputStreamReader(in)),
            2);
    }
View Full Code Here

Examples of java.io.PushbackReader

        sb.append(",,").append("\n"); // empty elements
        sb.append("a,\"PO Box 123,\nKippax,ACT. 2615.\nAustralia\",d.\n");
        sb.append("\"Glen \"\"The Man\"\" Smith\",Athlete,Developer\n"); // Test
        sb.append("\"\"\"\"\"\",\"test\"\n"); // """""","test" representing:
        sb.append("\"a\nb\",b,\"\nd\",e\n");
        PushbackReader reader = new PushbackReader(new StringReader(sb.toString()));

        // test normal case               
        String line = CsvUtils.readLine(reader, CsvUtils.DEFAULT_QUOTE_CHARACTER);
        String[] fields = CsvUtils.parseLine(line, ',', CsvUtils.DEFAULT_QUOTE_CHARACTER);
        org.junit.Assert.assertEquals("a", fields[0]);
View Full Code Here

Examples of java.io.PushbackReader

    protected void process(final String expression) throws IOException
    {
        ExceptionUtils.checkEmpty("expression", expression);
        try
        {
            Lexer lexer = new Lexer(new PushbackReader(new StringReader(expression)));
            OclParser parser = new OclParser(lexer);
            Start startNode = parser.parse();
            this.translatedExpression = new Expression(expression);
            startNode.apply(this);
        }
View Full Code Here

Examples of java.io.PushbackReader

    lineReader = new LineNumberReader(reader);
    // Start counting lines at 1:
    lineReader.setLineNumber(1);

    // Allow at most 2 characters to be pushed back:
    this.reader = new PushbackReader(lineReader, 2);

    // Store normalized base URI
    setBaseURI(baseURI);

    reportLocation();
View Full Code Here

Examples of java.io.PushbackReader

            if (url == null)
            {
                TestCase.fail("Could not load resource '" + VALID_SYNTAX + "'");
            }
            DepthFirstAdapter adapter = new DepthFirstAdapter();
            Lexer lexer = new Lexer(new PushbackReader(new FileReader(url.getFile())));
            OclParser parser = new OclParser(lexer);
            Start startNode = parser.parse();
            startNode.apply(adapter);
        }
        catch (Throwable th)
View Full Code Here

Examples of java.io.PushbackReader

        if (in == null)
        {
            throw new NullPointerException();
        }

        _in = new PushbackReader(in);
    }
View Full Code Here

Examples of java.io.PushbackReader

      throw new NullPointerException();
    }
    if (Globals.prefs == null) {
      Globals.prefs = JabRefPreferences.getInstance();
    }
    _in = new PushbackReader(in, LOOKAHEAD);
  }
View Full Code Here

Examples of java.io.PushbackReader

            }

            AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws Exception {
                    ConfigurationAdmin configAdmin = null;
                    PushbackReader reader = null;
                    try {
                        configAdmin = getCA();

                        CMDataReader cmDataReader = new CMDataReader();
                        reader = new PushbackReader(new BufferedReader(
                                new InputStreamReader(url.openStream(),
                                        CMDataReader.ENCODING), 8192), 8);
                        Hashtable[] configs = cmDataReader.readCMDatas(reader);

                        for (int i = 0; i < configs.length; i++) {
                            String pid = (String) configs[i]
                                    .get(CMDataReader.SERVICE_PID);
                            String fpid = (String) configs[i]
                                    .get(CMDataReader.FACTORY_PID);
                            Configuration config;
                            if (fpid == null) {
                                config = configAdmin
                                        .getConfiguration(pid, null);
                            } else {
                                config = configAdmin
                                        .createFactoryConfiguration(fpid, null);
                            }
                            if (config.getBundleLocation() != null) {
                                config.setBundleLocation(null);
                            }
                            if (configs[i].get("service.bundleLocation") != null) {
                                configs[i].remove("service.bundleLocation");
                            }
                            config.update(configs[i]);
                        }
                    } finally {
                        if (reader != null) {
                            reader.close();
                        }
                        if (configAdmin != null) {
                            bc.ungetService(refCA);
                        }
                    }
View Full Code Here

Examples of java.io.PushbackReader

        File f = new File(storeDir, fileName);
        if (!f.exists()) {
            return null;
        }

        PushbackReader r = new PushbackReader(new BufferedReader(
                new InputStreamReader(new FileInputStream(f),
                        CMDataReader.ENCODING), 8192), 8);

        Hashtable h = null;
        try {
            h = cmDataReader.readCMData(r);
        } catch (Exception e) {
            Activator.log.error("Failed reading file " + f.toString(), e);
            h = null;
        }

        if (r != null) {
            r.close();
        }

        return h;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.