Examples of LineTokenizer


Examples of com.intellij.openapi.diff.LineTokenizer

    public LineBlocks(ComparisonPolicy comparisonPolicy) {
      myComparisonPolicy = comparisonPolicy;
    }

    public DiffFragment[] buildFragments(String text1, String text2) throws FilesTooBigForDiffException {
      String[] strings1 = new LineTokenizer(text1).execute();
      String[] strings2 = new LineTokenizer(text2).execute();
      return myComparisonPolicy.buildDiffFragmentsFromLines(strings1, strings2);
    }
View Full Code Here

Examples of com.intellij.openapi.diff.LineTokenizer

      if (!fragment.isEqual()) {
        if (myComparisonPolicy.isEqual(fragment))
          fragment = myComparisonPolicy.createFragment(fragment.getText1(), fragment.getText2());
        collector.add(fragment);
      } else {
        String[] lines1 = new LineTokenizer(fragment.getText1()).execute();
        String[] lines2 = new LineTokenizer(fragment.getText2()).execute();
        LOG.assertTrue(lines1.length == lines2.length);
        for (int i = 0; i < lines1.length; i++)
          collector.addAll(myDiffPolicy.buildFragments(lines1[i], lines2[i]));
      }
    }
View Full Code Here

Examples of com.intellij.openapi.diff.LineTokenizer

    verify(runResult, true, stdoutLines);
  }

  private static void verify(final RunResult runResult, final boolean sorted, final String... stdoutLines) {
    verify(runResult);
    final String[] lines = new LineTokenizer(runResult.stdOut).execute();
    if (sorted) {
      Arrays.sort(lines);
    }
    Assert.assertEquals(runResult.stdOut, stdoutLines.length, lines.length);
    for(int i=0; i<stdoutLines.length; i++) {
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

      byte[] b = new byte[1024];
      if (filterSets.hasFilters()) {
         InputStreamReader reader = new InputStreamReader(in, encoding);
         OutputStreamWriter writer = new OutputStreamWriter(out, encoding);
        
         LineTokenizer tok = new LineTokenizer();
         tok.setIncludeDelims(true);

         for (String l = tok.getToken(reader); l != null; l = tok.getToken(reader)) {
            writer.write(filterSets.replaceTokens(l));
         }
         writer.close();
         reader.close();
      } else {
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

            if (this.filterSets.hasFilters()) {
               // TODO this part doesn't look nice
               InputStreamReader reader = new InputStreamReader(
                                          new FileInputStream(file), this.encoding);
               ByteArrayOutputStream out = new ByteArrayOutputStream();
               LineTokenizer tok = new LineTokenizer();
               tok.setIncludeDelims(true);
              
               for (String l = tok.getToken(reader); l != null; l = tok.getToken(reader)) {
                  out.write(this.filterSets.replaceTokens(l).getBytes(this.encoding));
               }
               Utils.putFile(getHttpClient(), url,
                     new ByteArrayInputStream(out.toByteArray()),
                     contentType, this.locktoken);
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

     * @param in A Reader object providing the underlying stream.
     *           Must not be <code>null</code>.
     */
    public HeadFilter(final Reader in) {
        super(in);
        lineTokenizer = new LineTokenizer();
        lineTokenizer.setIncludeDelims(true);
    }
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

                            = new BufferedWriter(new OutputStreamWriter(fos, destEncoding));
                        FileInputStream fis = new FileInputStream(src);
                        BufferedReader in
                            = new BufferedReader(new InputStreamReader(fis, srcEncoding));
                        String line;
                        LineTokenizer lineTokenizer = new LineTokenizer();
                        lineTokenizer.setIncludeDelims(true);
                        line = lineTokenizer.getToken(in);
                        while ((line) != null) {
                            // 2003-02-21 new replace algorithm by tbee (tbee@tbee.org)
                            // because it wasn't able to replace something like "@aaa;@bbb;"

                            // is there a startToken
                            // and there is still stuff following the startToken
                            int startIndex = line.indexOf(startToken);
                            while (startIndex >= 0
                                && (startIndex + startToken.length()) <= line.length()) {
                                // the new value, this needs to be here
                                // because it is required to calculate the next position to
                                // search from at the end of the loop
                                String replace = null;

                                // we found a starttoken, is there an endtoken following?
                                // start at token+tokenlength because start and end
                                // token may be indentical
                                int endIndex = line.indexOf(
                                    endToken, startIndex + startToken.length());
                                if (endIndex < 0) {
                                    startIndex += 1;
                                } else {
                                    // grab the token
                                    String token = line.substring(
                                        startIndex + startToken.length(), endIndex);

                                    // If there is a white space or = or :, then
                                    // it isn't to be treated as a valid key.
                                    boolean validToken = true;
                                    for (int k = 0; k < token.length() && validToken; k++) {
                                        char c = token.charAt(k);
                                        if (c == ':' || c == '='
                                            || Character.isSpaceChar(c)) {
                                            validToken = false;
                                        }
                                    }
                                    if (!validToken) {
                                        startIndex += 1;
                                    } else {
                                        // find the replace string
                                        if (resourceMap.containsKey(token)) {
                                            replace = (String) resourceMap.get(token);
                                        } else {
                                            log("Replacement string missing for: "
                                                + token, Project.MSG_VERBOSE);
                                            replace = startToken + token + endToken;
                                        }


                                        // generate the new line
                                        line = line.substring(0, startIndex)
                                             + replace
                                             + line.substring(endIndex + endToken.length());

                                        // set start position for next search
                                        startIndex += replace.length();
                                    }
                                }

                                // find next starttoken
                                startIndex = line.indexOf(startToken, startIndex);
                            }
                            out.write(line);
                            line = lineTokenizer.getToken(in);
                        }
                        if (in != null) {
                            in.close();
                        }
                        if (out != null) {
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

        ResourceCollection rc = getResourceCollection();
        if (rc.size() == 0) {
            return Collections.EMPTY_SET;
        }
        if (tokenizer == null) {
            tokenizer = new LineTokenizer();
        }
        ConcatResourceInputStream cat = new ConcatResourceInputStream(rc);
        cat.setManagingComponent(this);

        InputStreamReader rdr = null;
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

                            = new BufferedWriter(new OutputStreamWriter(fos, destEncoding));
                        FileInputStream fis = new FileInputStream(src);
                        BufferedReader in
                            = new BufferedReader(new InputStreamReader(fis, srcEncoding));
                        String line;
                        LineTokenizer lineTokenizer = new LineTokenizer();
                        lineTokenizer.setIncludeDelims(true);
                        line = lineTokenizer.getToken(in);
                        while ((line) != null) {
                        // 2003-02-21 new replace algorithm by tbee (tbee@tbee.org)
                        // because it wasn't able to replace something like "@aaa;@bbb;"

                        // is there a startToken
                        // and there is still stuff following the startToken
                        int startIndex = line.indexOf(startToken);
                        while (startIndex >= 0
                            && (startIndex + startToken.length()) <= line.length()) {
                            // the new value, this needs to be here
                            // because it is required to calculate the next position to search from
                            // at the end of the loop
                            String replace = null;

                            // we found a starttoken, is there an endtoken following?
                            // start at token+tokenlength because start and end
                            // token may be indentical
                            int endIndex = line.indexOf(endToken, startIndex + startToken.length());
                            if (endIndex < 0) {
                                startIndex += 1;
                            } else {
                                // grab the token
                                String token
                                    = line.substring(startIndex + startToken.length(), endIndex);

                                // If there is a white space or = or :, then
                                // it isn't to be treated as a valid key.
                                boolean validToken = true;
                                for (int k = 0; k < token.length() && validToken; k++) {
                                    char c = token.charAt(k);
                                    if (c == ':' || c == '='
                                        || Character.isSpaceChar(c)) {
                                        validToken = false;
                                    }
                                }
                                if (!validToken) {
                                    startIndex += 1;
                                } else {
                                    // find the replace string
                                    if (resourceMap.containsKey(token)) {
                                        replace = (String) resourceMap.get(token);
                                    } else {
                                        replace = token;
                                    }


                                    // generate the new line
                                    line = line.substring(0, startIndex)
                                         + replace
                                         + line.substring(endIndex + endToken.length());

                                    // set start position for next search
                                    startIndex += replace.length();
                                }
                            }

                            // find next starttoken
                            startIndex = line.indexOf(startToken, startIndex);
                        }


                            out.write(line);
                            line = lineTokenizer.getToken(in);
                        }
                        if (in != null) {
                            in.close();
                        }
                        if (out != null) {
View Full Code Here

Examples of org.apache.tools.ant.util.LineTokenizer

     * during reading
     */

    public int read() throws IOException {
        if (tokenizer == null) {
            tokenizer = new LineTokenizer();
        }
        while (line == null || line.length() == 0) {
            line = tokenizer.getToken(in);
            if (line == null) {
                return -1;
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.