| 1 | /* |
| 2 | * XMLObjectParser.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.Map; |
| 29 | |
| 30 | public interface XMLObjectParser { |
| 31 | |
| 32 | /** |
| 33 | * |
| 34 | * @return (Java) class of parsed element (i.e. class of object retuned in parseXMLObject) |
| 35 | */ |
| 36 | Class getReturnType(); |
| 37 | |
| 38 | /** |
| 39 | * @param store contains all named objects that have already been parsed. |
| 40 | */ |
| 41 | Object parseXMLObject(XMLObject xo, String id, Map<String, XMLObject> store, boolean strictXML) throws XMLParseException; |
| 42 | |
| 43 | /** |
| 44 | * |
| 45 | * @return Parser name, which is identical to name of xml element parsed by it. |
| 46 | */ |
| 47 | String getParserName(); |
| 48 | |
| 49 | /** |
| 50 | * |
| 51 | * @return A list of parser name synonyms (including name returned by getParserName) |
| 52 | */ |
| 53 | String[] getParserNames(); |
| 54 | |
| 55 | /** |
| 56 | * |
| 57 | * @return Human readable description of xml element parsed by parser. |
| 58 | */ |
| 59 | String getParserDescription(); |
| 60 | |
| 61 | /** |
| 62 | * |
| 63 | * @return true if an example is available. |
| 64 | */ |
| 65 | boolean hasExample(); |
| 66 | |
| 67 | /** |
| 68 | * |
| 69 | * @return element example |
| 70 | */ |
| 71 | String getExample(); |
| 72 | |
| 73 | |
| 74 | /** |
| 75 | * @return a description of this parser as HTML. |
| 76 | */ |
| 77 | String toHTML(XMLDocumentationHandler handler); |
| 78 | |
| 79 | String toWiki(XMLDocumentationHandler handler); |
| 80 | |
| 81 | String toMarkdown(XMLDocumentationHandler handler); |
| 82 | |
| 83 | /** |
| 84 | * @return an array of syntax rules required by this element. |
| 85 | * Order is not important. |
| 86 | */ |
| 87 | XMLSyntaxRule[] getSyntaxRules(); |
| 88 | |
| 89 | /** |
| 90 | * True if a top level element with that name is allowed. |
| 91 | * @param elementName |
| 92 | * @return |
| 93 | */ |
| 94 | boolean isAllowed(String elementName); |
| 95 | |
| 96 | boolean hasSyntaxRules(); |
| 97 | } |