190N/A/*
190N/A * CDDL HEADER START
190N/A *
190N/A * The contents of this file are subject to the terms of the
190N/A * Common Development and Distribution License (the "License").
190N/A * You may not use this file except in compliance with the License.
190N/A *
190N/A * See LICENSE.txt included in this distribution for the specific
190N/A * language governing permissions and limitations under the License.
190N/A *
190N/A * When distributing Covered Code, include this CDDL HEADER in each
190N/A * file and include the License file at LICENSE.txt.
190N/A * If applicable, add the following below this CDDL HEADER, with the
190N/A * fields enclosed by brackets "[]" replaced with your own identifying
190N/A * information: Portions Copyright [yyyy] [name of copyright owner]
190N/A *
190N/A * CDDL HEADER END
190N/A */
190N/A
190N/A/*
1072N/A * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
190N/A */
190N/Apackage org.opensolaris.opengrok.analysis.sql;
190N/A
190N/Aimport java.io.BufferedReader;
190N/Aimport java.io.IOException;
190N/Aimport java.io.InputStreamReader;
943N/Aimport java.util.Collections;
190N/Aimport java.util.HashSet;
190N/Aimport java.util.Locale;
190N/Aimport java.util.Set;
190N/A
439N/A@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
456N/Apublic final class Consts {
943N/A private static final Set<String> reservedKeywords;
190N/A static {
943N/A HashSet<String> kwds = new HashSet<String>();
190N/A try {
1117N/A //populateKeywordSet(kwds, "sql2003reserved.dat");
1431N/A //populateKeywordSet(kwds, "sql2008reserved.dat");
1431N/A populateKeywordSet(kwds, "sql2011reserved.dat");
190N/A } catch (IOException ioe) {
190N/A throw new RuntimeException(ioe);
190N/A }
943N/A reservedKeywords = Collections.unmodifiableSet(kwds);
190N/A }
190N/A
456N/A private Consts() {
456N/A // Util class, can not be constructed.
456N/A }
1190N/A
190N/A private static void populateKeywordSet(Set<String> set, String file)
190N/A throws IOException
190N/A {
1117N/A String line,lline;
190N/A BufferedReader reader =
190N/A new BufferedReader(new InputStreamReader(
190N/A Consts.class.getResourceAsStream(file), "US-ASCII"));
345N/A try {
345N/A while ((line = reader.readLine()) != null) {
1117N/A line=line.trim();
1117N/A lline = line.toLowerCase(Locale.US);
464N/A if (line.charAt(0) != '#') {
345N/A set.add(line);
1117N/A set.add(lline);
345N/A }
190N/A }
345N/A } finally {
421N/A reader.close();
190N/A }
190N/A }
190N/A
943N/A static Set<String> getReservedKeywords() {
943N/A return reservedKeywords;
190N/A }
190N/A}