org.hibernate.engine.jdbc.internal.HighlightingFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.engine.jdbc.internal;
import org.hibernate.engine.jdbc.env.spi.AnsiSqlKeywords;
import org.hibernate.internal.util.StringHelper;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
/**
* Performs basic syntax highlighting for SQL using ANSI escape codes.
*
* @author Gavin King
*/
public final class HighlightingFormatter implements Formatter {
private static final Set KEYWORDS = new HashSet<>( AnsiSqlKeywords.INSTANCE.sql2003() );
static {
// additional keywords not reserved by ANSI SQL 2003
KEYWORDS.addAll( Arrays.asList( "KEY", "SEQUENCE", "CASCADE", "INCREMENT" ) );
}
public static final Formatter INSTANCE =
new HighlightingFormatter(
"34", // blue
"36", // cyan
"32"
);
private static final String SYMBOLS_AND_WS = "=>