public final String getQuotedString()

in src/main/java/com/univocity/parsers/common/input/AbstractCharInputReader.java [473:550]


	public final String getQuotedString(char quote, char escape, char escapeEscape, int maxLength, char stop1, char stop2, boolean keepQuotes, boolean keepEscape, boolean trimLeading, boolean trimTrailing) {
		if (i == 0) {
			return null;
		}

		int i = this.i;

		while (true) {
			if (i >= length) {
				return null;
			}
			ch = buffer[i];
			if (ch == quote) {
				if (buffer[i - 1] == escape) {
					if (keepEscape) {
						i++;
						continue;
					}
					return null;
				}
				if (i + 1 < length) {
					char next = buffer[i + 1];
					if (next == stop1 || next == stop2) {
						break;
					}
				}

				return null;
			} else if (ch == escape && !keepEscape) {
				if (i + 1 < length) {
					char next = buffer[i + 1];
					if (next == quote || next == escapeEscape) {
						return null;
					}
				}
			} else if (lineSeparator1 == ch && normalizeLineEndings && (lineSeparator2 == '\0' || i + 1 < length && lineSeparator2 == buffer[i + 1])) {
				return null;
			}
			i++;
		}

		int pos = this.i;
		int len = i - this.i;
		if (len > maxLength) { //validating before trailing whitespace handling so this behaves as an appender.
			return null;
		}

		if (keepQuotes) {
			pos--;
			len += 2;
		} else {
			if (trimTrailing) {
				while (len > 0 && buffer[pos + len - 1] <= ' ') {
					len--;
				}
			}
			if (trimLeading) {
				while (len > 0 && buffer[pos] <= ' ') {
					pos++;
					len--;
				}
			}
		}

		this.i = i + 1;

		String out;
		if (len <= 0) {
			out = "";
		} else {
			out = new String(buffer, pos, len);
		}

		if (this.i >= length) {
			updateBuffer();
		}
		return out;
	}