From 916513a7ebcc2159c42603e477aa693e38d66a86 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 30 Sep 2020 16:51:27 +0100 Subject: [PATCH] HHH-14217 Code style --- .../engine/jdbc/env/spi/AnsiSqlKeywords.java | 5 +-- .../jdbc/internal/HighlightingFormatter.java | 37 ++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/spi/AnsiSqlKeywords.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/spi/AnsiSqlKeywords.java index 2ddf4d3cfc..27337c1529 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/spi/AnsiSqlKeywords.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/spi/AnsiSqlKeywords.java @@ -15,7 +15,7 @@ import java.util.Set; * * @author Steve Ebersole */ -public class AnsiSqlKeywords { +public final class AnsiSqlKeywords { /** * Singleton access */ @@ -23,7 +23,7 @@ public class AnsiSqlKeywords { private final Set keywordsSql2003; - public AnsiSqlKeywords() { + private AnsiSqlKeywords() { final Set keywordsSql2003 = new HashSet(); keywordsSql2003.add( "ADD" ); keywordsSql2003.add( "ALL" ); @@ -281,5 +281,4 @@ public class AnsiSqlKeywords { return keywordsSql2003; } - } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/HighlightingFormatter.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/HighlightingFormatter.java index 6f607b9b9c..bfe59d6efb 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/HighlightingFormatter.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/HighlightingFormatter.java @@ -48,10 +48,10 @@ public class HighlightingFormatter implements Formatter { * @param stringCode the ANSI escape code to use for highlighting SQL strings */ public HighlightingFormatter(String keywordCode, String stringCode, String quotedCode) { - keywordEscape =escape(keywordCode); - stringEscape = escape(stringCode); - quotedEscape = escape(quotedCode); - normalEscape = escape("0"); + keywordEscape =escape( keywordCode ); + stringEscape = escape( stringCode ); + quotedEscape = escape( quotedCode ); + normalEscape = escape( "0" ); } @Override @@ -60,46 +60,47 @@ public class HighlightingFormatter implements Formatter { StringBuilder result = new StringBuilder(); boolean inString = false; boolean inQuoted = false; - for (StringTokenizer tokenizer = new StringTokenizer( sql, symbolsAndWs, true ); + for ( StringTokenizer tokenizer = new StringTokenizer( sql, symbolsAndWs, true ); tokenizer.hasMoreTokens(); ) { String token = tokenizer.nextToken(); - switch (token) { + switch ( token ) { case "\"": case "`": // for MySQL - if (inString) { - result.append(token); + if ( inString ) { + result.append( token ); } - else if (inQuoted) { + else if ( inQuoted ) { inQuoted = false; - result.append(token).append(normalEscape); + result.append( token ).append( normalEscape ); } else { inQuoted = true; - result.append(quotedEscape).append(token); + result.append( quotedEscape ).append( token ); } break; case "'": - if (inQuoted) { - result.append("'"); + if ( inQuoted ) { + result.append( "'" ); } - else if (inString) { + else if ( inString ) { inString = false; - result.append("'").append(normalEscape); + result.append( "'" ).append( normalEscape ); } else { inString = true; - result.append(stringEscape).append("'"); + result.append( stringEscape ).append( "'" ); } break; default: if ( KEYWORDS.contains( token.toUpperCase() ) ) { - result.append(keywordEscape).append(token).append(normalEscape); + result.append( keywordEscape ).append( token ).append( normalEscape ); } else { - result.append(token); + result.append( token ); } } } return result.toString(); } + }