Parse a string into a stream of Quads.
@param line the line of text
@return the Quad
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();
        }
    }
781898
public Vertex get(int line, int length)
    {
        for (Vertex vertex : vertexes[line])
        {
            if (vertex.realWord.length() == length)
            {
                return vertex;
            }
        }

        return null;
    }
498743
public static String[] disectCommandLine(String line) {
		return StringSupport.split(line, "() ,;", "\"", false, false, false).toArray(new String[0]);
	}
848902
public static CharSequence concat(CharSequence... lines) {
		return new CharSequence() {

			private final StringBuilder content = new StringBuilder();

			private int next;

			private int length = -1;

			@Override
			public String toString() {
				ensure(length());
				return this.content.toString();
			}

			private void ensure(int index) {
				while (this.next < lines.length && index >= this.content.length()) {
					if (lines[this.next] != null) {
						this.content.append(lines[this.next]).append("\n"); //$NON-NLS-1$
					}
					++this.next;
				}
			}

			@Override
			public CharSequence subSequence(int start, int end) {
				ensure(end - 1);
				return this.content.subSequence(start, end);
			}

			@Override
			public int length() {
				if (this.length < 0) {
					int len = 0;
					for (final CharSequence seq : lines) {
						len += seq.length() + 1;
					}
					len = Math.max(0, len - 1);
					this.length = len;
				}
				return this.length;
			}

			@Override
			public char charAt(int index) {
				ensure(index);
				return this.content.charAt(index);
			}
		};
	}
1110093
public static StringValueMap fromString(String line) {
		StringValueMap result = new StringValueMap();
		if (line == null || line.length() == 0)
			return result;

		// Todo: User tokenizer / decoder
		String[] tokens = line.split(";", -1);

		for (String token : tokens) {
			if (token.length() == 0)
				continue;
			int index = token.indexOf('=');
			String key = index > 0 ? token.substring(0, index).trim() : token.trim();
			String val = index > 0 ? token.substring(index + 1).trim() : null;
			result.put(key, val);
		}

		return result;
	}
729916
protected String[] getLineParts(final String line) {
		String[] parts = line.split(" ");
		List<String> ans = new ArrayList<>();
		int idx = 0;
		int len = parts.length;
		while (idx < len) {
			if (parts[idx].contains("='") && !parts[idx].endsWith("'")) {
				StringBuilder builder = new StringBuilder(parts[idx++]);
				while (idx < len) {
					builder.append(" ").append(parts[idx]);
					if (parts[idx++].endsWith("'")) {
						break;
					}
				}
				ans.add(builder.toString());
			} else if (parts[idx].contains("=[") && !parts[idx].endsWith("]")) {
				StringBuilder builder = new StringBuilder(parts[idx++]);
				while (idx < len) {
					builder.append(" ").append(parts[idx]);
					if (parts[idx++].endsWith("]")) {
						break;
					}
				}
				ans.add(builder.toString());
			} else {
				String part = parts[idx++];
				if (StringUtils.isNotEmpty(part)) {
					ans.add(part);
				}
			}
		}
		return ans.toArray(new String[ans.size()]);
	}
830867
public static String buildStringFromLines(String... lines) {
		int numChars = lines.length;
		for (String line : lines) {
			numChars += line.length();
		}
		StringBuilder builder = new StringBuilder(numChars);
		for (String line : lines) {
			builder.append(line);
			builder.append('\n');
		}
		return builder.toString();
	}
954418
private static void parseLine(String line, int num) throws ParseException {
        StringTokenizer st = new StringTokenizer(line, ";");
        while (st.hasMoreTokens()) {
            String deviationElement = st.nextToken();
            int offsetIndex = deviationElement.indexOf(':');
            if (offsetIndex != -1) {
                String offsetString = deviationElement.substring(
                        offsetIndex + 1, deviationElement.length());
                int offset;
                try {
                    offset = Integer.parseInt(offsetString);
                } catch (NumberFormatException ex) {
                    throw new ParseException(
                            "Offset is not properly set at line " + num + ".",
                            num);
                }
                int separatorIndex = deviationElement.indexOf('-');
                if (separatorIndex != -1) {
                    String startDateStg = deviationElement.substring(0,
                            separatorIndex);
                    String endDateStg = deviationElement.substring(
                            separatorIndex + 1, offsetIndex);
                    int startDateYearSepIndex = startDateStg.indexOf('/');
                    int endDateYearSepIndex = endDateStg.indexOf('/');
                    int startYear = -1;
                    int endYear = -1;
                    int startMonth = -1;
                    int endMonth = -1;
                    if (startDateYearSepIndex != -1) {
                        String startYearStg = startDateStg.substring(0,
                                startDateYearSepIndex);
                        String startMonthStg = startDateStg.substring(
                                startDateYearSepIndex + 1, startDateStg
                                        .length());
                        try {
                            startYear = Integer.parseInt(startYearStg);
                        } catch (NumberFormatException ex) {
                            throw new ParseException(
                                    "Start year is not properly set at line "
                                            + num + ".", num);
                        }
                        try {
                            startMonth = Integer.parseInt(startMonthStg);
                        } catch (NumberFormatException ex) {
                            throw new ParseException(
                                    "Start month is not properly set at line "
                                            + num + ".", num);
                        }
                    } else {
                        throw new ParseException(
                                "Start year/month has incorrect format at line "
                                        + num + ".", num);
                    }
                    if (endDateYearSepIndex != -1) {
                        String endYearStg = endDateStg.substring(0,
                                endDateYearSepIndex);
                        String endMonthStg = endDateStg.substring(
                                endDateYearSepIndex + 1, endDateStg.length());
                        try {
                            endYear = Integer.parseInt(endYearStg);
                        } catch (NumberFormatException ex) {
                            throw new ParseException(
                                    "End year is not properly set at line "
                                            + num + ".", num);
                        }
                        try {
                            endMonth = Integer.parseInt(endMonthStg);
                        } catch (NumberFormatException ex) {
                            throw new ParseException(
                                    "End month is not properly set at line "
                                            + num + ".", num);
                        }
                    } else {
                        throw new ParseException(
                                "End year/month has incorrect format at line "
                                        + num + ".", num);
                    }
                    if (startYear != -1 && startMonth != -1 && endYear != -1
                            && endMonth != -1) {
                        addDeviationAsHijrah(startYear, startMonth, endYear,
                                endMonth, offset);
                    } else {
                        throw new ParseException("Unknown error at line " + num
                                + ".", num);
                    }
                } else {
                    throw new ParseException(
                            "Start and end year/month has incorrect format at line "
                                    + num + ".", num);
                }
            } else {
                throw new ParseException("Offset has incorrect format at line "
                        + num + ".", num);
            }
        }
    }
1123018
private String[] parseLine(String nextLine, boolean multi) throws IOException {

        if (!multi && pending != null) {
            pending = null;
        }

        if (nextLine == null) {
            if (pending != null) {
                String s = pending;
                pending = null;
                return new String[]{s};
            } else {
                return null;
            }
        }

        List<String> tokensOnThisLine = new ArrayList<String>();
        StringBuilder sb = new StringBuilder(INITIAL_READ_SIZE);
        boolean inQuotes = false;
        if (pending != null) {
            sb.append(pending);
            pending = null;
            inQuotes = true;
        }
        for (int i = 0; i < nextLine.length(); i++) {

            char c = nextLine.charAt(i);
            if (c == this.escape) {
                if (isNextCharacterEscapable(nextLine, inQuotes || inField, i)) {
                    sb.append(nextLine.charAt(i + 1));
                    i++;
                }
            } else if (c == quotechar) {
                if (isNextCharacterEscapedQuote(nextLine, inQuotes || inField, i)) {
                    sb.append(nextLine.charAt(i + 1));
                    i++;
                } else {
                    //inQuotes = !inQuotes;

                    // the tricky case of an embedded quote in the middle: a,bc"d"ef,g
                    if (!strictQuotes) {
                        if (i > 2 //not on the beginning of the line
                                && nextLine.charAt(i - 1) != this.separator //not at the beginning of an escape sequence
                                && nextLine.length() > (i + 1) &&
                                nextLine.charAt(i + 1) != this.separator //not at the	end of an escape sequence
                                ) {

                            if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) {
                                sb.setLength(0);  //discard white space leading up to quote
                            } else {
                                sb.append(c);
                                //continue;
                            }

                        }
                    }

                    inQuotes = !inQuotes;
                }
                inField = !inField;
            } else if (c == separator && !inQuotes) {
                tokensOnThisLine.add(sb.toString());
                sb.setLength(0); // start work on next token
                inField = false;
            } else {
                if (!strictQuotes || inQuotes) {
                    sb.append(c);
                    inField = true;
                }
            }
        }
        // line is done - check status
        if (inQuotes) {
            if (multi) {
                // continuing a quoted section, re-append newline
                sb.append("\n");
                pending = sb.toString();
                sb = null; // this partial content is not to be added to field list yet
            } else {
                throw new IOException("Un-terminated quoted field at end of CSV line");
            }
        }
        if (sb != null) {
            tokensOnThisLine.add(sb.toString());
        }
        return tokensOnThisLine.toArray(new String[tokensOnThisLine.size()]);

    }
842523
public List<String> parse(String line) throws ParseException {
    List<String> cols = new ArrayList<>();
    boolean afterQuote = false;
    boolean afterEscape = false;
    boolean afterSeparator = false;
    boolean outerQuote = false;
    boolean afterEndField = false;
    StringBuilder sb = new StringBuilder();

    for (int i = 0; ; ++i) {
      char c = (i == line.length()) ? EOT : line.charAt(i);
      if (afterEndField && c != separator && c != EOT) {
        if (!trim || c != ' ') {
          throw new ParseException("Extraneous character after end of quoted field", i);
        }
      } else if (afterEscape) {
        if (c == EOT) {
          // [abc\^]
          throw new ParseException("Escape not followed by a character", i);
        } else {
          // [abc\x...] => abcx...
          afterEscape = false;
          sb.append(c);
        }
      } else if (c == separator) {
        if (outerQuote && !afterQuote) {
          // ["abc,...] => abc,...
          sb.append(c);
          afterSeparator = false;
        } else {
          // [abc,...] => {abc, ...}
          endCol(cols, sb, i, outerQuote, afterQuote);
          afterQuote = afterEscape = afterEndField = outerQuote = false;
          afterSeparator = true;
        }
      } else if (c == EOT) {
        if (sb.length() != 0 || afterSeparator || outerQuote) {
          // [...,abc^] => {..., abc}
          // [...,^] => {..., ""}
          endCol(cols, sb, i, outerQuote, afterQuote);
        }
        return cols;
      } else if (c == escape) {
        // [...\...]
        afterEscape = true;
        afterSeparator = false;
      } else if (c == quote) {
        if (afterQuote && outerQuote) {
          // Two consecutive quotes inside quoted string, so the pair has to be internal
          // (the second quote cannot be terminating the field).
          sb.append(quote);
          afterQuote = false;
        } else if (sb.length() == 0 && !outerQuote) {
          outerQuote = true;
        } else if (sb.length() != 0 && !outerQuote) {
          // Fields that are not quote-delimited cannot have any internal quotes,
          // unless they are escaped which was already handled.
          throw new ParseException(escape == NUL
              ? "Unescaped quote inside non-quote-delimited field"
              : "Quote inside non-quote-delimited field",
              i);
        } else {
          afterQuote = true;
        }
        afterSeparator = false;
      } else if (c == ' ' && trim
          && ((!outerQuote && sb.length() == 0) // Trimmed space before field
              || afterEndField)) {              // Trimmed space after field
      } else if (c == ' ' && trim && afterQuote) {
        afterEndField = true;
      } else if (outerQuote && afterQuote) {
        // ["abc"x]
        throw new ParseException("Extraneous character after end of quoted field", i);
      } else {
        // Common character.
        sb.append(c);
        afterSeparator = false;
      }
    }
  }
1092313
public static int splitString(String line, char[][][] buff) {
		int len=line.length();
		int wordCount=0;
		int pos=0;
		while(pos<len) {
			// Skip past blank space
			while(pos<len&&line.charAt(pos)<=' ') pos++;
			int start=pos;
			// Skip to the next blank space
			while(pos<len&&line.charAt(pos)>' ') pos++;
			if(pos>start) wordCount++;
		}

		char[][] words=buff[0];
		if(words==null || words.length<wordCount) buff[0]=words=new char[wordCount][];

		int wordPos=0;
		pos=0;
		while(pos<len) {
			// Skip past blank space
			while(pos<len&&line.charAt(pos)<=' ') pos++;
			int start=pos;
			// Skip to the next blank space
			while(pos<len&&line.charAt(pos)>' ') pos++;
			if(pos>start) {
				int chlen=pos-start;
				char[] tch=words[wordPos++]=new char[chlen];
				System.arraycopy(line.toCharArray(), start, tch, 0, chlen);
			}
		}

		return wordCount;
	}
952515
protected static Country parse(String line) throws IOException {
        try {
            int pos = line.indexOf(' ');
            if (pos < 0) throw new IOException("Invalid format, could not parse 2 char code");
            String code2 = line.substring(0, pos);
            int pos2 = line.indexOf(' ', pos+1);
            if (pos2 < 0) throw new IOException("Invalid format, could not parse 3 char code");
            String code3 = line.substring(pos+1, pos2);
            int pos3 = line.indexOf(' ', pos2+1);
            if (pos3 < 0) throw new IOException("Invalid format, could not parse 3 char digit code");
            String num3 = line.substring(pos2+1, pos3);
            // rest of line is the long name
            String longName = line.substring(pos3+1).trim();
            // was there a name?
            if (longName == null || longName.equals("")) {
                throw new IOException("Country name was null or empty");
            }

            // parse long name into its short name (strip anything after the last comma)
            String name = longName;
            int pos4 = longName.lastIndexOf(',');
            if (pos4 > 0) {
                // strip out the final part such as ", Republic of" from something like "Nigeria, Republic Of"
                name = longName.substring(0, pos4);
            }

            // create the new country
            return new Country(code2, name, longName);
        } catch (Exception e) {
            throw new IOException("Failed while parsing country for line: " + line, e);
        }
    }
1149168
public static <C extends Collection<String>> C splitString(String line, char delim, C words) {
		return splitString(line, 0, line.length(), delim, words);
	}
1192620
def split_line(line: str) -> typing.Tuple[str, str]:
    

    index = line.find(' ')
    if index == -1:
        return line.lower(), ''

    return line[:index].lower(), line[index:].strip()
1308372
public static String getLine(String content, int line) {
    if (content == null) {
      return null;
    }

    String[] contentSplit = content.replace("\r\n", "\n").split("\n");

    if (contentSplit.length < line) {
      return null;
    }
    return contentSplit[line - 1];
  }
169348
public static Tuple stringToTuple(String line) {
        // tokenize the line
        String nameParts[] = line.split("\t");

        // create the tuple, setting the first and last names
        Tuple tuple = new Tuple();
        tuple.set(TupleFields.LAST_NAME, nameParts[0]);
        tuple.set(TupleFields.FIRST_NAME, nameParts[1]);
        return tuple;
    }
787727
def __parse_stream(self, stream, parse_line):
        """"""

        if not stream:
            raise InvalidFormatError(cause='stream cannot be empty or None')

        nline = 0
        lines = stream.split('\n')

        for line in lines:
            nline += 1

            # Ignore blank lines and comments
            m = re.match(self.LINES_TO_IGNORE_REGEX, line, re.UNICODE)
            if m:
                continue

            m = re.match(self.VALID_LINE_REGEX, line, re.UNICODE)
            if not m:
                cause = "line %s: invalid format" % str(nline)
                raise InvalidFormatError(cause=cause)

            try:
                result = parse_line(m.group(1), m.group(2))
                yield result
            except InvalidFormatError as e:
                cause = "line %s: %s" % (str(nline), e)
                raise InvalidFormatError(cause=cause)