| 1 | /* |
| 2 | * XMLSyntaxRule.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.Set; |
| 29 | |
| 30 | public interface XMLSyntaxRule { |
| 31 | |
| 32 | /** |
| 33 | * Returns true if the rule is satisfied for the given XML object. |
| 34 | */ |
| 35 | public boolean isSatisfied(XMLObject object); |
| 36 | |
| 37 | /** |
| 38 | * Check if rule contains attribute of that name |
| 39 | * |
| 40 | * @param name attribute name |
| 41 | * @return true if contains attribute |
| 42 | */ |
| 43 | public boolean containsAttribute(String name); |
| 44 | |
| 45 | /** |
| 46 | * Describes the rule in general. |
| 47 | */ |
| 48 | public String ruleString(); |
| 49 | |
| 50 | /** |
| 51 | * Describes the rule in html. |
| 52 | */ |
| 53 | public String htmlRuleString(XMLDocumentationHandler handler); |
| 54 | |
| 55 | /** |
| 56 | * Describes the rule in wiki. |
| 57 | */ |
| 58 | public String wikiRuleString(XMLDocumentationHandler handler, String prefix); |
| 59 | |
| 60 | /** |
| 61 | * Describes the rule in markdown. |
| 62 | */ |
| 63 | public String markdownRuleString(XMLDocumentationHandler handler, String prefix); |
| 64 | |
| 65 | /** |
| 66 | * Describes the rule as pertains to the given object. |
| 67 | * In particular if object does not satisfy the rule then how. |
| 68 | */ |
| 69 | public String ruleString(XMLObject object); |
| 70 | |
| 71 | /** |
| 72 | * @return the classes potentially required by this rule. |
| 73 | */ |
| 74 | public Set<Class> getRequiredTypes(); |
| 75 | |
| 76 | /** |
| 77 | * Check for possible elements: catch typos, old syntax and elements with identical names to global |
| 78 | * xml element parsers. |
| 79 | * @param elementName |
| 80 | * @return true if rule allows a element with that name |
| 81 | */ |
| 82 | boolean isLegalElementName(String elementName); |
| 83 | |
| 84 | /** |
| 85 | * |
| 86 | * @param c class type |
| 87 | * @return true if rule accepts an element which, after parsing, is represented as a class of type 'c' |
| 88 | */ |
| 89 | boolean isLegalElementClass(Class c); |
| 90 | |
| 91 | /** |
| 92 | * |
| 93 | * @param elementName |
| 94 | * @return true if rule allows a sub-element with that name |
| 95 | */ |
| 96 | boolean isLegalSubelementName(String elementName); |
| 97 | } |