public void startElement(String name, Attributes attributes) { checkCancel(); }
public ChildHandler(AbstractHandler parentHandler, Attributes attributes, List<URI> repos) { super(parentHandler, CHILD_ELEMENT); String[] values = parseAttributes(attributes, required, optional); this.repos = repos; //skip entire subrepository if the location is missing if (values[0] == null) return; currentRepo = checkURI(REQUIRED_CAPABILITY_ELEMENT, URI_ATTRIBUTE, values[0]); }
public void processingInstruction(String target, String data) throws SAXException { if (repositoryType.equals(target)) { Version repositoryVersion = extractPIVersion(target, data); if (!XML_TOLERANCE.isIncluded(repositoryVersion)) { throw new SAXException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, XML_TOLERANCE)); } } } }
try { bufferedInput = new BufferedInputStream(input); CompositeParser repositoryParser = new CompositeParser(Activator.getContext(), Activator.ID, type); repositoryParser.setErrorContext(location.toExternalForm()); repositoryParser.parse(input); IStatus result = repositoryParser.getStatus(); switch (result.getSeverity()) { case IStatus.CANCEL : LogHelper.log(result); CompositeRepositoryState repositoryState = repositoryParser.getRepositoryState(); if (repositoryState == null) throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
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 finished() { if (isValidXML()) { state = new CompositeRepositoryState(); state.setName(attrValues[0]); state.setType(attrValues[1]); state.setVersion(attrValues[2]); state.setDescription(attrValues[3]); state.setProvider(attrValues[4]); state.setProperties((propertiesHandler == null ? new OrderedProperties(0) // : propertiesHandler.getProperties())); state.setChildren((childrenHandler == null ? new URI[0] // : childrenHandler.getChildren())); } } }
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); } }
try { bufferedInput = new BufferedInputStream(input); CompositeParser repositoryParser = new CompositeParser(Activator.getContext(), Activator.ID, type); repositoryParser.setErrorContext(location.toExternalForm()); repositoryParser.parse(input); IStatus result = repositoryParser.getStatus(); switch (result.getSeverity()) { case IStatus.CANCEL : LogHelper.log(result); CompositeRepositoryState repositoryState = repositoryParser.getRepositoryState(); if (repositoryState == null) throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
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 finished() { if (isValidXML()) { state = new CompositeRepositoryState(); state.setName(attrValues[0]); state.setType(attrValues[1]); state.setVersion(attrValues[2]); state.setDescription(attrValues[3]); state.setProvider(attrValues[4]); state.setProperties((propertiesHandler == null ? new OrderedProperties(0) // : propertiesHandler.getProperties())); state.setChildren((childrenHandler == null ? new URI[0] // : childrenHandler.getChildren())); } } }
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 ChildHandler(AbstractHandler parentHandler, Attributes attributes, List<URI> repos) { super(parentHandler, CHILD_ELEMENT); String[] values = parseAttributes(attributes, required, optional); this.repos = repos; //skip entire subrepository if the location is missing if (values[0] == null) return; currentRepo = checkURI(REQUIRED_CAPABILITY_ELEMENT, URI_ATTRIBUTE, values[0]); }
public void processingInstruction(String target, String data) throws SAXException { if (repositoryType.equals(target)) { Version repositoryVersion = extractPIVersion(target, data); if (!XML_TOLERANCE.isIncluded(repositoryVersion)) { throw new SAXException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, XML_TOLERANCE)); } } } }
public void startElement(String name, Attributes attributes) { checkCancel(); }