Java Code Examples for org.apache.calcite.avatica.util.Casing#TO_LOWER

The following examples show how to use org.apache.calcite.avatica.util.Casing#TO_LOWER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlAdvisor.java    From Quicksql with MIT License 6 votes vote down vote up
/**
 * Returns casing which is preferred for replacement.
 * For instance, {@code en => ename, EN => ENAME}.
 * When input has mixed case, {@code Casing.UNCHANGED} is returned.
 * @param word input word
 * @return preferred casing when replacing input word
 */
private Casing getPreferredCasing(String word) {
  if (word == prevWord) {
    return prevPreferredCasing;
  }
  boolean hasLower = false;
  boolean hasUpper = false;
  int i = 0;
  while (i < word.length() && !(hasLower && hasUpper)) {
    int codePoint = word.codePointAt(i);
    hasLower |= Character.isLowerCase(codePoint);
    hasUpper |= Character.isUpperCase(codePoint);
    i += Character.charCount(codePoint);
  }
  Casing preferredCasing;
  if (hasUpper && !hasLower) {
    preferredCasing = Casing.TO_UPPER;
  } else if (!hasUpper && hasLower) {
    preferredCasing = Casing.TO_LOWER;
  } else {
    preferredCasing = Casing.UNCHANGED;
  }
  prevWord = word;
  prevPreferredCasing = preferredCasing;
  return preferredCasing;
}
 
Example 2
Source File: SqlDialectFactoryImpl.java    From Quicksql with MIT License 6 votes vote down vote up
private Casing getCasing(DatabaseMetaData databaseMetaData, boolean quoted) {
  try {
    if (quoted
        ? databaseMetaData.storesUpperCaseQuotedIdentifiers()
        : databaseMetaData.storesUpperCaseIdentifiers()) {
      return Casing.TO_UPPER;
    } else if (quoted
        ? databaseMetaData.storesLowerCaseQuotedIdentifiers()
        : databaseMetaData.storesLowerCaseIdentifiers()) {
      return Casing.TO_LOWER;
    } else if (quoted
        ? (databaseMetaData.storesMixedCaseQuotedIdentifiers()
            || databaseMetaData.supportsMixedCaseQuotedIdentifiers())
        : (databaseMetaData.storesMixedCaseIdentifiers()
            || databaseMetaData.supportsMixedCaseIdentifiers())) {
      return Casing.UNCHANGED;
    } else {
      return Casing.UNCHANGED;
    }
  } catch (SQLException e) {
    throw new IllegalArgumentException("cannot deduce casing", e);
  }
}
 
Example 3
Source File: SqlAdvisor.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Returns casing which is preferred for replacement.
 * For instance, {@code en => ename, EN => ENAME}.
 * When input has mixed case, {@code Casing.UNCHANGED} is returned.
 * @param word input word
 * @return preferred casing when replacing input word
 */
private Casing getPreferredCasing(String word) {
  if (word == prevWord) {
    return prevPreferredCasing;
  }
  boolean hasLower = false;
  boolean hasUpper = false;
  int i = 0;
  while (i < word.length() && !(hasLower && hasUpper)) {
    int codePoint = word.codePointAt(i);
    hasLower |= Character.isLowerCase(codePoint);
    hasUpper |= Character.isUpperCase(codePoint);
    i += Character.charCount(codePoint);
  }
  Casing preferredCasing;
  if (hasUpper && !hasLower) {
    preferredCasing = Casing.TO_UPPER;
  } else if (!hasUpper && hasLower) {
    preferredCasing = Casing.TO_LOWER;
  } else {
    preferredCasing = Casing.UNCHANGED;
  }
  prevWord = word;
  prevPreferredCasing = preferredCasing;
  return preferredCasing;
}
 
Example 4
Source File: SqlDialectFactoryImpl.java    From calcite with Apache License 2.0 6 votes vote down vote up
private Casing getCasing(DatabaseMetaData databaseMetaData, boolean quoted) {
  try {
    if (quoted
        ? databaseMetaData.storesUpperCaseQuotedIdentifiers()
        : databaseMetaData.storesUpperCaseIdentifiers()) {
      return Casing.TO_UPPER;
    } else if (quoted
        ? databaseMetaData.storesLowerCaseQuotedIdentifiers()
        : databaseMetaData.storesLowerCaseIdentifiers()) {
      return Casing.TO_LOWER;
    } else if (quoted
        ? (databaseMetaData.storesMixedCaseQuotedIdentifiers()
            || databaseMetaData.supportsMixedCaseQuotedIdentifiers())
        : (databaseMetaData.storesMixedCaseIdentifiers()
            || databaseMetaData.supportsMixedCaseIdentifiers())) {
      return Casing.UNCHANGED;
    } else {
      return Casing.UNCHANGED;
    }
  } catch (SQLException e) {
    throw new IllegalArgumentException("cannot deduce casing", e);
  }
}
 
Example 5
Source File: AvaticaDatabaseMetaData.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public boolean storesLowerCaseIdentifiers() throws SQLException {
  return unquotedCasing() == Casing.TO_LOWER;
}
 
Example 6
Source File: AvaticaDatabaseMetaData.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
  return quotedCasing() == Casing.TO_LOWER;
}