public synchronized void parse(InputStream stream) throws IOException { this.status = null; try { // TODO: currently not caching the parser since we make no assumptions // or restrictions on concurrent parsing getParser(); RepositoryHandler repositoryHandler = new RepositoryHandler(); xmlReader.setContentHandler(new RepositoryDocHandler(REPOSITORY_ELEMENT, repositoryHandler)); xmlReader.parse(new InputSource(stream)); if (isValidXML()) { theState = repositoryHandler.getRepository(); } } catch (SAXException e) { throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } finally { stream.close(); } }
public void startElement(String name, Attributes attributes) { if (PROPERTIES_ELEMENT.equals(name)) { if (propertiesHandler == null) { propertiesHandler = new PropertiesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (CHILDREN_ELEMENT.equals(name)) { if (childrenHandler == null) { childrenHandler = new ChildrenHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else { invalidElement(name, attributes); } }
public void startElement(String name, Attributes attributes) { if (PROPERTIES_ELEMENT.equals(name)) { if (propertiesHandler == null) { propertiesHandler = new PropertiesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (CHILDREN_ELEMENT.equals(name)) { if (childrenHandler == null) { childrenHandler = new ChildrenHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else { invalidElement(name, attributes); } }
public synchronized void parse(InputStream stream) throws IOException { this.status = null; try { // TODO: currently not caching the parser since we make no assumptions // or restrictions on concurrent parsing getParser(); RepositoryHandler repositoryHandler = new RepositoryHandler(); xmlReader.setContentHandler(new RepositoryDocHandler(REPOSITORY_ELEMENT, repositoryHandler)); xmlReader.parse(new InputSource(stream)); if (isValidXML()) { theState = repositoryHandler.getRepository(); } } catch (SAXException e) { throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } finally { stream.close(); } }
protected void handleRootAttributes(Attributes attributes) { attrValues = parseAttributes(attributes, required, optional); attrValues[2] = checkVersion(REPOSITORY_ELEMENT, VERSION_ATTRIBUTE, attrValues[2]).toString(); }
protected void handleRootAttributes(Attributes attributes) { attrValues = parseAttributes(attributes, required, optional); attrValues[2] = checkVersion(REPOSITORY_ELEMENT, VERSION_ATTRIBUTE, attrValues[2]).toString(); }