package com.dbxml.xml;

/*
 * dbXML - Native XML Database
 * Copyright (C) 1999-2004  The dbXML Group, L.L.C.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id: SymbolTableSymbols.java,v 1.4 2004/08/22 04:18:43 bradford Exp $
 */

import com.dbxml.xml.dom.DOMHelper;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;

/**
 * SymbolTableSymbols is class that represents the hard-coded definition
 * of a compressed symbol table.
 */

public final class SymbolTableSymbols extends SymbolTable {
   private static final String SYSSYMS_XML = "SymbolTableSymbols.xml";

   private static Element elem;
   static {
      try {
         InputStream is = SymbolTableSymbols.class.getResourceAsStream(SYSSYMS_XML);
         InputStreamReader isr = new InputStreamReader(is, "UTF8");
         BufferedReader br = new BufferedReader(isr, 4096);

         elem = DOMHelper.parse(new InputSource(br)).getDocumentElement();
         br.close();
      }
      catch ( Exception e ) {
         System.err.println("FATAL ERROR: Generating System Symbols");
         e.printStackTrace(System.err);
         System.exit(1);
      }
   }

   private SymbolTableSymbols() {
      streamFromXML(elem);
   }

   public static SymbolTableSymbols getInstance() {
      return new SymbolTableSymbols();
   }
}

