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