public static List parseMultiIdentifier()

in adb3client/src/main/java/com/alibaba/cloud/analyticdb/adb3client/model/TableName.java [68:138]


	public static List<String> parseMultiIdentifier(String identifier) {
		if (identifier == null) {
			return null;
		}
		List<String> ret = new ArrayList<>();
		boolean isQuoteState = false;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < identifier.length(); ++i) {
			char c = identifier.charAt(i);
			if (isQuoteState) {
				if (c == QUOTE) {
					if (i < identifier.length() - 1) {
						if (identifier.charAt(i + 1) == QUOTE) {
							sb.append(QUOTE);
						} else if (identifier.charAt(i + 1) == SPLIT) {
							isQuoteState = false;
							ret.add(sb.toString());
							sb.setLength(0);
						} else {
							throw new InvalidIdentifierException(identifier);
						}
						++i;
					} else {
						ret.add(sb.toString());
						sb.setLength(0);
					}
				} else {
					sb.append(c);
				}
			} else {
				char lowerC = (char) (c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c);
				if (sb.length() == 0) {
					if (c == QUOTE) {
						isQuoteState = true;
					} else if (c == SPLIT) {
						throw new InvalidIdentifierException(identifier);
					} else {
						sb.append(lowerC);
					}
				} else {
					if (c == QUOTE) {
						throw new InvalidIdentifierException(identifier);
					} else if (c == SPLIT) {
						String text = sb.toString();
						sb.setLength(0);
						if (IDENTIFIER_PATTERN.matcher(text).find()) {
							ret.add(text);
						} else {
							throw new InvalidIdentifierException(identifier);
						}
					} else {
						sb.append(lowerC);
					}
				}
			}
		}

		if (sb.length() > 0) {
			if (isQuoteState) {
				throw new InvalidIdentifierException(identifier);
			}
			String text = sb.toString();
			sb.setLength(0);
			if (IDENTIFIER_PATTERN.matcher(text).find()) {
				ret.add(text);
			} else {
				throw new InvalidIdentifierException(identifier);
			}
		}
		return ret;
	}