Debian Codegraph @

src/dr/app/beauti/generator/BaseComponentGenerator.java

raw symbols SCIP
1 /*
2 * BaseComponentGenerator.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.beauti.generator;
27
28 import dr.app.beauti.options.BeautiOptions;
29 import dr.app.beauti.util.XMLWriter;
30
31 /**
32 * This is an abstract base class for component generators. Currently it simply
33 * wraps each insertion with a pair of comments.
34 * @author Andrew Rambaut
35 * @version $Id$
36 */
37 public abstract class BaseComponentGenerator extends Generator implements ComponentGenerator {
38 private Generator callingGenerator;
39
40 protected BaseComponentGenerator(final BeautiOptions options) {
41 super(options, null);
42 }
43
44 @Override
45 public void checkOptions() throws GeneratorException {
46 // default is to do nothing
47 }
48
49 public void generateAtInsertionPoint(Generator generator, final InsertionPoint point, final Object item, final XMLWriter writer) {
50 callingGenerator = generator;
51 writer.writeComment("START " + getCommentLabel());
52 generate(point, item, "", writer);
53 writer.writeComment("END " + getCommentLabel());
54 writer.writeBlankLine();
55 }
56
57 public void generateAtInsertionPoint(Generator generator, final InsertionPoint point, final Object item, final String prefix, final XMLWriter writer) {
58 callingGenerator = generator;
59 writer.writeComment("START " + getCommentLabel());
60 generate(point, item, prefix, writer);
61 writer.writeComment("END " + getCommentLabel());
62 writer.writeBlankLine();
63 }
64
65 public Generator getCallingGenerator() {
66 return callingGenerator;
67 }
68
69 protected abstract void generate(final InsertionPoint point, final Object item, final String prefix, final XMLWriter writer);
70
71 protected abstract String getCommentLabel();
72 }