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