MCPcopy Index your code
hub / github.com/apache/groovy / processReader

Method processReader

src/main/java/groovy/ui/GroovyMain.java:664–699  ·  view source on GitHub ↗

Process a script against a single input file. @param s script to execute. @param reader input file. @param pw output sink.

(Script s, BufferedReader reader, PrintWriter pw)

Source from the content-addressed store, hash-verified

662 * @param pw output sink.
663 */
664 private void processReader(Script s, BufferedReader reader, PrintWriter pw) throws IOException {
665 String line;
666 String lineCountName = "count";
667 s.setProperty(lineCountName, BigInteger.ZERO);
668 String autoSplitName = "split";
669 s.setProperty("out", pw);
670
671 try {
672 InvokerHelper.invokeMethod(s, "begin", null);
673 } catch (MissingMethodException mme) {
674 // ignore the missing method exception
675 // as it means no begin() method is present
676 }
677
678 while ((line = reader.readLine()) != null) {
679 s.setProperty("line", line);
680 s.setProperty(lineCountName, ((BigInteger)s.getProperty(lineCountName)).add(BigInteger.ONE));
681
682 if(autoSplit) {
683 s.setProperty(autoSplitName, line.split(splitPattern));
684 }
685
686 Object o = s.run();
687
688 if (autoOutput && o != null) {
689 pw.println(o);
690 }
691 }
692
693 try {
694 InvokerHelper.invokeMethod(s, "end", null);
695 } catch (MissingMethodException mme) {
696 // ignore the missing method exception
697 // as it means no end() method is present
698 }
699 }
700
701 /**
702 * Process the standard, single script with args.

Callers 2

processFilesMethod · 0.95
processFileMethod · 0.95

Calls 8

invokeMethodMethod · 0.95
setPropertyMethod · 0.65
addMethod · 0.65
getPropertyMethod · 0.65
splitMethod · 0.65
runMethod · 0.65
readLineMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected