/** * Parse the an xml file * @param is the inputsource to parse * @param handler the SAX event handler to use * @throws SAXException if an error occurs during parsing * @throws IOException if an error occurs reading from the InputSource * @throws ParserConfigurationException if there is an error in the config */ public static void parse(InputSource is, DefaultHandler handler) throws SAXException, IOException, ParserConfigurationException { parse(is, handler, true); }
/** * Parse the an xml file * @param is the inputsource to parse * @param handler the SAX event handler to use * @throws SAXException if an error occurs during parsing * @throws IOException if an error occurs reading from the InputSource * @throws ParserConfigurationException if there is an error in the config */ public static void parse(InputSource is, DefaultHandler handler) throws SAXException, IOException, ParserConfigurationException { parse(is, handler, true); }
/** * Parse TemplateQueries from XML. * * @param reader the saved templates * @param version the version of the xml format, an attribute of the ProfileManager * @return a Map from template name to TemplateQuery */ public static Map<String, TemplateQuery> unmarshalTemplates(Reader reader, int version) { Map<String, TemplateQuery> templates = new LinkedHashMap<String, TemplateQuery>(); try { SAXParser.parse(new InputSource(reader), new TemplateQueryHandler(templates, version)); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return templates; }
/** * Parse TemplateQueries from XML. * * @param reader the saved templates * @param version the version of the xml format, an attribute of the ProfileManager * @return a Map from template name to TemplateQuery */ public static Map<String, TemplateQuery> unmarshalTemplates(Reader reader, int version) { Map<String, TemplateQuery> templates = new LinkedHashMap<String, TemplateQuery>(); try { SAXParser.parse(new InputSource(reader), new TemplateQueryHandler(templates, version)); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } return templates; }
/** * Parse PathQueries from XML, declaring which model should be used in preference to the * default model retrieved by <code>Model::getInstanceByName</code>. * @param reader the saved queries * @param version the version of the xml, an attribute on the profile manager * @param model The model to use in preference. May be null. * @return a Map from query name to PathQuery */ public static Map<String, PathQuery> unmarshalPathQueries(Reader reader, int version, Model model) { Map<String, PathQuery> queries = new LinkedHashMap<String, PathQuery>(); try { InputSource src = new InputSource(reader); DefaultHandler handler = new PathQueryHandler(queries, version, model); SAXParser.parse(src, handler); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } return queries; }
/** * Parse PathQueries from XML, declaring which model should be used in preference to the * default model retrieved by <code>Model::getInstanceByName</code>. * @param reader the saved queries * @param version the version of the xml, an attribute on the profile manager * @param model The model to use in preference. May be null. * @return a Map from query name to PathQuery */ public static Map<String, PathQuery> unmarshalPathQueries(Reader reader, int version, Model model) { Map<String, PathQuery> queries = new LinkedHashMap<String, PathQuery>(); try { InputSource src = new InputSource(reader); DefaultHandler handler = new PathQueryHandler(queries, version, model); SAXParser.parse(src, handler); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } return queries; }
/** * Read source model information in InterMine XML format and * create a set of ClassDescriptors. * * @param reader the source model to parse * @param packageName the package name that all the classes should be in * @return a set of ClassDescriptors * @throws ModelParserException if something goes wrong with parsing the class descriptors. */ @Override public Set<ClassDescriptor> generateClassDescriptors(Reader reader, String packageName) throws ModelParserException { try { ModelHandler handler = new ModelHandler(); handler.packageName = packageName; SAXParser.parse(new InputSource(reader), handler); return handler.classes; } catch (Exception e) { throw new ModelParserException(e); } }
/** * Read source model information in InterMine XML format and * create a set of ClassDescriptors. * * @param reader the source model to parse * @param packageName the package name that all the classes should be in * @return a set of ClassDescriptors * @throws ModelParserException if something goes wrong with parsing the class descriptors. */ @Override public Set<ClassDescriptor> generateClassDescriptors(Reader reader, String packageName) throws ModelParserException { try { ModelHandler handler = new ModelHandler(); handler.packageName = packageName; SAXParser.parse(new InputSource(reader), handler); return handler.classes; } catch (Exception e) { throw new ModelParserException(e); } }
/** * Read source model information in InterMine XML format and * construct a InterMine Model object. * * @param reader the source model to parse * @return the InterMine Model created * @throws ModelParserException if something goes wrong with parsing the class descriptors. */ @Override public Model process(Reader reader) throws ModelParserException { try { ModelHandler handler = new ModelHandler(); SAXParser.parse(new InputSource(reader), handler); Model model = new Model( handler.modelName, handler.packageName, handler.version, handler.classes); return model; } catch (Exception e) { throw new ModelParserException(e); } }
/** * Read source model information in InterMine XML format and * construct a InterMine Model object. * * @param reader the source model to parse * @return the InterMine Model created * @throws ModelParserException if something goes wrong with parsing the class descriptors. */ @Override public Model process(Reader reader) throws ModelParserException { try { ModelHandler handler = new ModelHandler(); SAXParser.parse(new InputSource(reader), handler); Model model = new Model( handler.modelName, handler.packageName, handler.version, handler.classes); return model; } catch (Exception e) { throw new ModelParserException(e); } }