1 /* 2 * db2sa: DB2 Syntax Assistant 3 * Copyright (C) Andres Gomez Casanova 4 * 5 * This file is part of db2sa. 6 * 7 * db2sa is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * db2sa is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this library; if not, see <http://www.gnu.org/licenses/>. 19 * 20 * Contact: 21 * a n g o c a at y a h o o dot c o m 22 * Cra. 45 No 61 - 31, Bogota, Colombia. 23 * 24 * Author: $LastChangedBy: angoca $: 25 * Date: $LastChangedDate: 2009-07-08 19:56:43 +0200 (Wed, 08 Jul 2009) $: 26 * Revision: $LastChangedRevision: 357 $: 27 * URL: $HeadURL: https://db2sa.svn.sourceforge.net/svnroot/db2sa/branches/db2sa_beta/source-code/src/main/java/name/angoca/db2sa/readers/GrammarReader.java $: 28 */ 29 package name.angoca.db2sa.readers; 30 31 import name.angoca.db2sa.Configurator; 32 import name.angoca.db2sa.Constants; 33 import name.angoca.db2sa.messages.Messages; 34 35 import org.xml.sax.InputSource; 36 37 /** 38 * This is the grammar reader.<br/> 39 * <b>Control Version</b><br /> 40 * <ul> 41 * <li>0.0.1 Class creation.</li> 42 * <li>0.1.0 First Implementation of the XML reader.</li> 43 * <li>0.2.0 Use of ConfigurationReader.</li> 44 * <li>0.2.1 Throw exception before.</li> 45 * <li>0.2.2 final.</li> 46 * <li>1.0.0 Moved to version 1.</li> 47 * </ul> 48 * 49 * @author Andres Gomez Casanova <a 50 * href="mailto:a n g o c a at y a h o o dot c o m">(AngocA)</a> 51 * @version 1.0.0 2009-07-19 52 */ 53 public final class GrammarReader { 54 55 /** 56 * Hide the default constructor. 57 */ 58 private GrammarReader() { 59 // Nothing to do. No tests. 60 } 61 62 /** 63 * Reads the grammar file and creates the structure of the graph. 64 * 65 * @return The content of the file. 66 */ 67 public static InputSource /* ! */read() { 68 InputSource content = null; 69 70 final String fileName = Configurator.getInstance().getProperty( 71 Constants.GRAMMAR_FILE_NAME); 72 if (fileName == null) { 73 // TODO revisar que cuando se lance esta excepcion termine la 74 // ejecucion del programa 75 // TODO Lanzar una exception propia, no genérica. 76 throw new RuntimeException(Messages 77 .getString("GrammarReader" //$NON-NLS-1$ 78 + ".ERROR_GETTING_PROPERTY") //$NON-NLS-1$ 79 + Constants.GRAMMAR_FILE_NAME); 80 } 81 content = new InputSource(fileName); 82 return content; 83 } 84 }