public InputStream openStream(ReferenceContext context) throws DereferenceException { throw new DereferenceException("Can't dereference VM objects"); }
/** * Return the data at the {@link URL} represented by this external reference */ public InputStream openStream(ReferenceContext context) throws DereferenceException { try { return httpUrl.openStream(); } catch (IOException e) { throw new DereferenceException(e); } }
/** * Return the data at the {@link URL} represented by this external reference */ public InputStream openStream(ReferenceContext context) throws DereferenceException { try { return httpUrl.openStream(); } catch (IOException e) { throw new DereferenceException(e); } }
/** * Return the data at the {@link URL} represented by this external reference */ public InputStream openStream(ReferenceContext context) throws DereferenceException { try { return httpUrl.openStream(); } catch (IOException e) { throw new DereferenceException(e); } }
/** * Fakes a de-reference operation, returning a byte stream over the string * data. */ public InputStream openStream(ReferenceContext arg0) { try { return new ByteArrayInputStream(this.contents .getBytes(getCharset())); } catch (UnsupportedEncodingException e) { throw new DereferenceException(e); } }
/** * Fakes a de-reference operation, returning a byte stream over the string * data. */ public InputStream openStream(ReferenceContext arg0) { try { return new ByteArrayInputStream(this.contents .getBytes(getCharset())); } catch (UnsupportedEncodingException e) { throw new DereferenceException(e); } }
/** * Fakes a de-reference operation, returning a byte stream over the string * data. */ public InputStream openStream(ReferenceContext arg0) { try { return new ByteArrayInputStream(this.contents .getBytes(getCharset())); } catch (UnsupportedEncodingException e) { throw new DereferenceException(e); } }
/** * {@inheritDoc} */ @Override public String getCharset() throws DereferenceException { if (!httpUrl.getProtocol().equals("http")) { return null; // Don't know } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); return method.getResponseCharSet(); } catch (HttpException e) { throw new DereferenceException(e); } catch (IOException e) { throw new DereferenceException(e); } finally { method.releaseConnection(); } }
/** * {@inheritDoc} */ @Override public String getCharset() throws DereferenceException { if (!httpUrl.getProtocol().equals("http")) { return null; // Don't know } HeadMethod method = new HeadMethod(httpUrl.toExternalForm()); HttpClient httpClient = new HttpClient(); try { httpClient.executeMethod(method); return method.getResponseCharSet(); } catch (HttpException e) { throw new DereferenceException(e); } catch (IOException e) { throw new DereferenceException(e); } finally { method.releaseConnection(); } }
/** * Fakes a de-reference operation, returning a byte stream over the node. */ public InputStream openStream(ReferenceContext context) { try { String result = ""; if (node == null) { result = ""; } else if (node.isLiteral()) { result = ((Literal) node).getLexicalForm(); } else if (node.isResource()) { Resource resource = (Resource) node; if (resource.isURIResource()) { result = resource.getURI(); } else { Model model = ResourceUtils.reachableClosure(resource); StringWriter stringWriter = new StringWriter(); model.write(stringWriter, "RDF/XML-ABBREV"); result = stringWriter.toString(); } } return new ByteArrayInputStream(result.getBytes(getCharset())); } catch (UnsupportedEncodingException e) { throw new DereferenceException(e); } }