1 /* 2 [The "BSD licence"] 3 Copyright (c) 2007-2008 Leon, Jen-Yuan Su 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 1. Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 2. Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in the 13 documentation and/or other materials provided with the distribution. 14 3. The name of the author may not be used to endorse or promote products 15 derived from this software without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 package org.antlr.gunit; 29 30 import java.util.ArrayList; 31 import java.util.Collections; 32 import java.util.List; 33 34 public class GrammarInfo { 35 36 private String grammarName; // targeted grammar for unit test 37 private String treeGrammarName = null; // optional, required for testing tree grammar 38 private String grammarPackage = null; // optional, package parser lives in 39 private String testPackage = null; // optional, package of junit code 40 private String adaptor = null; // optional, required if using customized tree adaptor 41 private List<gUnitTestSuite> ruleTestSuites = new ArrayList<gUnitTestSuite>(); // testsuites for each testing rule 42 private StringBuffer unitTestResult = new StringBuffer(); 43 getGrammarName()44 public String getGrammarName() { 45 return grammarName; 46 } 47 setGrammarName(String grammarName)48 public void setGrammarName(String grammarName) { 49 this.grammarName = grammarName; 50 } 51 getTreeGrammarName()52 public String getTreeGrammarName() { 53 return treeGrammarName; 54 } 55 setTreeGrammarName(String treeGrammarName)56 public void setTreeGrammarName(String treeGrammarName) { 57 this.treeGrammarName = treeGrammarName; 58 } 59 getTestPackage()60 public String getTestPackage() { 61 return testPackage; 62 } 63 setTestPackage(String testPackage)64 public void setTestPackage(String testPackage) { 65 this.testPackage = testPackage; 66 } 67 getGrammarPackage()68 public String getGrammarPackage() { 69 return grammarPackage; 70 } 71 setGrammarPackage(String grammarPackage)72 public void setGrammarPackage(String grammarPackage) { 73 this.grammarPackage = grammarPackage; 74 } 75 getAdaptor()76 public String getAdaptor() { 77 return adaptor; 78 } 79 setAdaptor(String adaptor)80 public void setAdaptor(String adaptor) { 81 this.adaptor = adaptor; 82 } 83 getRuleTestSuites()84 public List<gUnitTestSuite> getRuleTestSuites() { 85 // Make this list unmodifiable so that we can refactor knowing it's not changed. 86 return Collections.unmodifiableList(ruleTestSuites); 87 } 88 addRuleTestSuite(gUnitTestSuite testSuite)89 public void addRuleTestSuite(gUnitTestSuite testSuite) { 90 this.ruleTestSuites.add(testSuite); 91 } 92 appendUnitTestResult(String result)93 public void appendUnitTestResult(String result) { 94 this.unitTestResult.append(result); 95 } 96 97 // We don't want people messing with the string buffer here, so don't return it. getUnitTestResult()98 public String getUnitTestResult() { 99 return unitTestResult.toString(); 100 } 101 setUnitTestResult(StringBuffer unitTestResult)102 public void setUnitTestResult(StringBuffer unitTestResult) { 103 this.unitTestResult = unitTestResult; 104 } 105 } 106