Skip to content

Commit

Permalink
Spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 22, 2023
1 parent 6a14bbd commit c7c41cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.common.utils;

import com.google.common.base.Strings;
Expand All @@ -13,6 +12,7 @@
public class StringUtils {
/**
* Unquote any string with mark specified.
*
* @param text string
* @param mark quotation mark
* @return An unquoted string whose outer pair of (single/double/back-tick) quotes have been
Expand All @@ -26,11 +26,10 @@ public static String unquote(String text, String mark) {
}

/**
* Unquote Identifier which has " or ' or ` as mark.
* Strings quoted by ' or " with two of these quotes appearing next to each other in the quote
* acts as an escape
* Example: 'Test''s' will result in 'Test's', similar with those single quotes being replaced
* with double.
* Unquote Identifier which has " or ' or ` as mark. Strings quoted by ' or " with two of these
* quotes appearing next to each other in the quote acts as an escape Example: 'Test''s' will
* result in 'Test's', similar with those single quotes being replaced with double.
*
* @param text string
* @return An unquoted string whose outer pair of (single/double/back-tick) quotes have been
* removed
Expand All @@ -45,10 +44,7 @@ public static String unquoteText(String text) {
char firstChar = text.charAt(0);
char lastChar = text.charAt(text.length() - 1);

if (firstChar == lastChar
&& (firstChar == '\''
|| firstChar == '"'
|| firstChar == '`')) {
if (firstChar == lastChar && (firstChar == '\'' || firstChar == '"' || firstChar == '`')) {
enclosingQuote = firstChar;
} else {
return text;
Expand All @@ -67,8 +63,7 @@ public static String unquoteText(String text) {
for (int chIndex = 1; chIndex < text.length() - 1; chIndex++) {
currentChar = text.charAt(chIndex);
nextChar = text.charAt(chIndex + 1);
if (currentChar == enclosingQuote
&& nextChar == currentChar) {
if (currentChar == enclosingQuote && nextChar == currentChar) {
chIndex++;
}
textSB.append(currentChar);
Expand All @@ -79,9 +74,9 @@ public static String unquoteText(String text) {

/**
* Unquote Identifier which has ` as mark.
*
* @param identifier identifier that possibly enclosed by double quotes or back ticks
* @return An unquoted string whose outer pair of (double/back-tick) quotes have been
* removed
* @return An unquoted string whose outer pair of (double/back-tick) quotes have been removed
*/
public static String unquoteIdentifier(String identifier) {
if (isQuoted(identifier, "`")) {
Expand All @@ -92,16 +87,15 @@ public static String unquoteIdentifier(String identifier) {
}

/**
* Returns a formatted string using the specified format string and
* arguments, as well as the {@link Locale#ROOT} locale.
* Returns a formatted string using the specified format string and arguments, as well as the
* {@link Locale#ROOT} locale.
*
* @param format format string
* @param args arguments referenced by the format specifiers in the format string
* @param args arguments referenced by the format specifiers in the format string
* @return A formatted string
* @throws IllegalFormatException If a format string contains an illegal syntax, a format
* specifier that is incompatible with the given arguments,
* insufficient arguments given the format string, or other
* illegal conditions.
* specifier that is incompatible with the given arguments, insufficient arguments given the
* format string, or other illegal conditions.
* @see java.lang.String#format(Locale, String, Object...)
*/
public static String format(final String format, Object... args) {
Expand All @@ -111,4 +105,4 @@ public static String format(final String format, Object... args) {
private static boolean isQuoted(String text, String mark) {
return !Strings.isNullOrEmpty(text) && text.startsWith(mark) && text.endsWith(mark);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ private static DefaultFunctionResolver pi() {
}

/**
* <b>Definition of pow(x, y)/power(x, y) function.</b><br>
* Calculate the value of x raised to the power of y<br>
* The supported signature of pow/power function is<br>
Expand Down

0 comments on commit c7c41cc

Please sign in to comment.