Ugly parsing of Exec output into some Elements. Gets called from StreamPumper.

@param line the line of output to parse
554028
public synchronized void consumeLine(final String line) {

        // check if the output contains the error string
        if (StringUtils.isNotEmpty(errorStr)) {
            // YES: set error flag
            if (StringUtils.equalsIgnoreCase(line.trim(), errorStr)) {
                foundError = true;
            }
        }
    }
320938
public static Stream<Quad> parseQuad(final String line) {
        final List<Token> tokens = new ArrayList<>();
        makeTokenizerString(line).forEachRemaining(tokens::add);

        final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull)
            .collect(toList());

        if (nodes.size() == 3) {
            return of(rdf.asQuad(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2))));
        } else if (nodes.size() == 4) {
            return of(rdf.asQuad(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2))));
        } else {
            LOGGER.warn("Skipping invalid data value: {}", line);
            return empty();
        }
    }
1338644
public static void exec(ProcessBuilder pb) throws IOException
    {
        Process p = pb.start();
        try
        {
            int errCode = p.waitFor();
            if (errCode != 0)
            {
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
                StringBuilder sb = new StringBuilder();
                String str;
                while ((str = in.readLine()) != null)
                    sb.append(str).append(System.getProperty("line.separator"));
                while ((str = err.readLine()) != null)
                    sb.append(str).append(System.getProperty("line.separator"));
                throw new IOException("Exception while executing the command: "+ StringUtils.join(pb.command(), " ") +
                                      ", command error Code: " + errCode +
                                      ", command output: "+ sb.toString());
            }
        }
        catch (InterruptedException e)
        {
            throw new AssertionError(e);
        }
    }
1006847
public void parse( String line, File sourceFile, int lineNumber ) {

		// Reset
		this.rawNameToVariables.clear();
		this.errors.clear();
		this.cursor = 0;

		// Parse
		while( this.cursor < line.length()) {

			char c = line.charAt( this.cursor );
			if( Character.isWhitespace( c ) || c == ',' )
				this.cursor ++;

			recognizeVariable( line, sourceFile, lineNumber );
		}
	}
936669
private boolean parseLine(final String line, final StringBuilder sql) {
        String trimmedLine = trimLine(line);
        sql.append(trimmedLine).append(LINE_SEPARATOR);

        return isFullCommand(trimmedLine);
    }
1374357
private String trim(String line) {
        char[] chars = line.toCharArray();
        int len = chars.length;

        while (len > 0) {
            if (!Character.isWhitespace(chars[len - 1])) {
                break;
            }
            len--;
        }

        return line.substring(0, len);
    }
1150576
protected boolean processLine(final CommandLine line, final Options options)
            throws Exception {
        if (line.hasOption("version")) {
            System.out.println("version " + getVersion());
            return false;
        }
        if (line.hasOption("help")) {
            produceHelp(options);
            return false;
        }
        if (line.hasOption("config")) {
            setConfigFile(line.getOptionValue("config").trim());
        }
        if (line.hasOption("input")) {
            setInput(line.getOptionValue("input").trim());
        }
        if (line.hasOption("inputEncoding")) {
            setInputEncoding(line.getOptionValue("inputEncoding").trim());
        }
        if (line.hasOption("output")) {
            setOutput(line.getOptionValue("output").trim());
        }
        if (line.hasOption("targetNamespacePrefix")) {
            setTargetNamespacePrefix(line.getOptionValue(
                    "targetNamespacePrefix").trim());
        }
        if (line.hasOption("xsltFileName")) {
            setXsltFileName(line.getOptionValue(
                    "xsltFileName").trim());
        }

        return true;
    }
482490
protected void writeln (BufferedWriter bout, String line)
        throws IOException
    {
        bout.write(line);
        bout.newLine();
    }
723721
public static String uncommentLine( String line ) {

		String result = line;
		if( ! Utils.isEmptyOrWhitespaces( line )
				&& line.trim().startsWith( ParsingConstants.COMMENT_DELIMITER ))
			result = line.replaceFirst( "^(\\s*)" + ParsingConstants.COMMENT_DELIMITER + "+", "$1" );

		return result;
	}
315560
private void nullPrintln(PrintStream out, String line)
    {
        if (out != null)
        {
            out.println(line);
        }
    }
646764
@Override
    public AbstractPipelineOutput execute(final AbstractPipelineInput input)
            throws DITAOTException {
        final Collection<FileInfo> fis = job.getFileInfo(fileInfoFilter);
        for (final FileInfo f: fis) {
            final URI file = job.tempDirURI.resolve(f.uri);
            logger.info("Processing " + file);
            try {
                xmlUtils.transform(file, getProcessingPipe(f));
            } catch (final DITAOTException e) {
                logger.error("Failed to process XML filter: " + e.getMessage(), e);
            }
        }
        return null;
    }
816795
public static String[] parseLine(String line) {
        boolean insideQuote = false;
        List<String> result = new ArrayList<>();
        StringBuilder builder = new StringBuilder();
        int quoteCount = 0;

        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);

            if (c == QUOTE) {
                insideQuote = !insideQuote;
                quoteCount++;
            }

            if (c == COMMA && !insideQuote) {
                String value = builder.toString();
                value = unescape(value);

                result.add(value);
                builder = new StringBuilder();
                continue;
            }

            builder.append(c);
        }

        result.add(builder.toString());

        if (quoteCount % 2 != 0) {
            throw new RuntimeException("Unmatched quote in entry: " + line);
        }

        return result.toArray(new String[result.size()]);
    }
1072800
public void run() {

        String line = null;
        try {


            int c;
            StringBuilder buf = new StringBuilder();
            while ((c = this.stderr.read()) != -1){

                String s = String.valueOf((char) c);

                if ((char)c == '\n'){
                    line = buf.toString();

                    buf = new StringBuilder();
                    logger.info("*\t" + line);
                }
                else {
                    buf.append(s);
                }
            }

        } catch (final IOException e) {
            logger.error("error handling output streams", e);
        }
    }
746737
void parseLine(String line) throws UnsupportedEncodingException {
    String[] splits = line.split(" ");

    boolean isDir = "dir".equals(splits[1]) ? true: false;
    if (!isDir && splits.length >= 6) {
      String name = URLDecoder.decode(splits[0], "UTF-8");
      String partName = URLDecoder.decode(splits[2], "UTF-8");
      long startIndex = Long.parseLong(splits[3]);
      long length = Long.parseLong(splits[4]);
      String[] newsplits = URLDecoder.decode(splits[5],"UTF-8").split(" ");
      if (newsplits != null && newsplits.length >= 5) {
        long mtime = Long.parseLong(newsplits[0]);
        IndexEntry entry = new IndexEntry(
          name, startIndex, length, mtime, partName);
        entries.add(entry);
      }
    }
  }
180517
private static void parseAEJava(String line,
            IteratorWithPrevious<String> it, Pipeline pipeline)
            throws ParseException {
        LOG.info("+-parsing line '{}'", line);

        Interpreter i = new Interpreter(); // Construct an interpreter

        // Eval a statement and get the result
        try {
            String script = line.replaceFirst("ae_java: ", "").trim();
            i.eval("aed = " + script + ";");
            AnalysisEngineDescription aed = (AnalysisEngineDescription) i
                    .get("aed");
            pipeline.addAe(aed);
        } catch (EvalError e) {
            e.fillInStackTrace();
            throw new ParseException(
                    "cannot compile and run 'ae_java' command, " + e.toString(),
                    -1);
        }
    }
96509
function (line) {
    line = line.toString().trim();
    if (!line) { return; }

    var match = sectionReg.exec(line);
    if (match) {
      osuSection = match[1].toLowerCase();
      return;
    }

    switch (osuSection) {
    case 'timingpoints':
      timingLines.push(line);
      break;
    case 'hitobjects':
      objectLines.push(line);
      break;
    case 'events':
      eventsLines.push(line);
      break;
    default:
      if (!osuSection) {
        match = /^osu file format (v[0-9]+)$/.exec(line);
        if (match) {
          beatmap.fileFormat = match[1];
          return;
        }
      }

      /**
       * Apart from events, timingpoints and hitobjects sections, lines are "key: value"
       */
      match = keyValReg.exec(line);
      if (match) { beatmap[match[1]] = match[2]; }
    }
  }
844314
@Override
  public void execute() {
    super.execute();
    if (output == null) {
      System.err.println(
          "Please add an <output> for the <" + getTaskName() + "> at " + this.getLocation());
      return;
    }

    // Gather output in a buffer rather than generating a bad file with a valid timestamp.
    StringBuilder sb = new StringBuilder();

    // Output the source files that use the helper functions first, so we get the appropriate file
    // overviews and copyright headers.
    for (FileRef input : inputs) {
      try {
        boolean inGeneratedCode = false;
        for (String line : Files.readLines(input.file, Charsets.UTF_8)) {
          // Skip code between generated code markers so that this transformation is idempotent.
          // We can run an old output through this class, and get the latest version out.
          if (inGeneratedCode) {
            if (GENERATED_CODE_END_MARKER.equals(line.trim())) {
              inGeneratedCode = false;
            }
          } else if (GENERATED_CODE_START_MARKER.equals(line.trim())) {
            inGeneratedCode = true;
          } else {
            sb.append(line).append('\n');
          }
        }
      } catch (IOException ex) {
        System.err.println("Failed to read " + input.file);
        ex.printStackTrace();
        return;
      }
    }

    // Generate helper functions for escape directives.
    generateCode(availableIdentifiers, sb);

    // Output a file now that we know generation hasn't failed.
    try {
      Files.asCharSink(output.file, Charsets.UTF_8).write(sb);
    } catch (IOException ex) {
      // Make sure an abortive write does not leave a file w
      output.file.delete();
    }
  }