Debian Codegraph @

src/dr/xml/ContentRule.java

raw symbols SCIP
1 /*
2 * ContentRule.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.xml;
27
28 import java.util.Collections;
29 import java.util.Set;
30
31 /**
32 * A syntax rule to ensure that allows one to document arbitrary content.
33 */
34 public class ContentRule implements XMLSyntaxRule {
35
36 /**
37 * Creates a required element rule.
38 */
39 public ContentRule(String htmlDescription) {
40 this.htmlDescription = htmlDescription;
41 }
42
43 /**
44 * @return true
45 */
46 public boolean isSatisfied(XMLObject xo) { return true; }
47
48 public boolean containsAttribute(String name) {
49 return false;
50 }
51
52 /**
53 * @return a string describing the rule.
54 */
55 public String ruleString() { return htmlDescription; }
56
57 /**
58 * @return a string describing the rule.
59 */
60 public String htmlRuleString(XMLDocumentationHandler handler) {
61 return htmlDescription;
62 }
63
64 /**
65 * @return a string describing the rule.
66 */
67 public String wikiRuleString(XMLDocumentationHandler handler, String prefix) {
68 return prefix + ":" + htmlDescription;
69 }
70
71 /**
72 * @return a string describing the rule.
73 */
74 public String markdownRuleString(XMLDocumentationHandler handler, String prefix) {
75 return prefix + ": " + htmlDescription + "\n";
76 }
77
78 /**
79 * @return a string describing the rule.
80 */
81 public String ruleString(XMLObject xo) { return null; }
82
83 /**
84 * @return a set containing the required types of this rule.
85 */
86 public Set<Class> getRequiredTypes() { return Collections.EMPTY_SET; }
87
88 public boolean isLegalElementName(String elementName) {
89 return true;
90 }
91
92 public boolean isLegalSubelementName(String elementName) {
93 return true;
94 }
95
96 public boolean isLegalElementClass(Class c) {
97 return true;
98 }
99
100 public boolean isAttributeRule() { return false; }
101
102 private final String htmlDescription;
103 }