/** * Returns the wrapped representation's reader. * * @return The wrapped representation's reader. * @see ContentStream#getReader() */ public Reader getReader() throws IOException { return representation.getReader(); }
@Override public Reader getReader() throws IOException { return getWrappedRepresentation().getReader(); }
/** * Constructor from a "text/uri-list" representation. * * @param uriList * The "text/uri-list" representation to parse. * @throws IOException */ public ReferenceList(Representation uriList) throws IOException { BufferedReader br = null; try { br = new BufferedReader(uriList.getReader(), /*IoUtils.BUFFER_SIZE*/8192); String line = br.readLine(); // Checks if the list reference is specified as the first comment. if ((line != null) && line.startsWith("#")) { setIdentifier(new Reference(line.substring(1).trim())); line = br.readLine(); } while (line != null) { if (!line.startsWith("#")) { add(new Reference(line.trim())); } line = br.readLine(); } } finally { if (br != null) { br.close(); } } }
/** * Constructor from a "text/uri-list" representation. * * @param uriList * The "text/uri-list" representation to parse. * @throws IOException */ public ReferenceList(Representation uriList) throws IOException { BufferedReader br = null; try { br = new BufferedReader(uriList.getReader(), IoUtils.BUFFER_SIZE); String line = br.readLine(); // Checks if the list reference is specified as the first comment. if ((line != null) && line.startsWith("#")) { setIdentifier(new Reference(line.substring(1).trim())); line = br.readLine(); } while (line != null) { if (!line.startsWith("#")) { add(new Reference(line.trim())); } line = br.readLine(); } } finally { if (br != null) { br.close(); } } }
@Override public void write(java.io.Writer writer) throws IOException { writer.write(getCallback()); writer.write("({\"status\":"); writer.write(Integer.toString(getStatus().getCode())); writer.write(",\"body\":"); if (MediaType.APPLICATION_JSON.equals(wrappedRepresentation .getMediaType())) { IoUtils.copy(wrappedRepresentation.getReader(), writer); } else { writer.write("\""); String text = wrappedRepresentation.getText(); if (text.indexOf('\"') >= 0) { text = text.replace("\"", "\\\""); } writer.write(text); writer.write("\""); } writer.write("});"); }
@Override public void write(java.io.Writer writer) throws IOException { writer.write(getCallback()); writer.write("({\"status\":"); writer.write(Integer.toString(getStatus().getCode())); writer.write(",\"body\":"); if (MediaType.APPLICATION_JSON.equals(wrappedRepresentation .getMediaType())) { IoUtils.copy(wrappedRepresentation.getReader(), writer); } else { writer.write("\""); String text = wrappedRepresentation.getText(); if (text.indexOf('\"') >= 0) { text = text.replace("\"", "\\\""); } writer.write(text); writer.write("\""); } writer.write("});"); }
result = new InputRepresentation(source.getStream()); } else if (Reader.class.isAssignableFrom(target)) { result = source.getReader(); } else if (ReaderRepresentation.class.isAssignableFrom(target)) { result = new ReaderRepresentation(source.getReader()); } else if (Serializable.class.isAssignableFrom(target) || target.isPrimitive()) {
/** * Returns a FreeMarker template from a representation and a configuration. * * @param config * The FreeMarker configuration. * @param templateRepresentation * The template representation. * @return The template or null if not found. */ public static Template getTemplate(Configuration config, Representation templateRepresentation) { try { // Instantiate the template with the character set of the template // representation if it has been set, otherwise use UTF-8. if (templateRepresentation.getCharacterSet() != null) { return new Template("template", templateRepresentation.getReader(), config, templateRepresentation.getCharacterSet().getName()); } return new Template("template", templateRepresentation.getReader(), config, CharacterSet.UTF_8.getName()); } catch (IOException e) { Context.getCurrentLogger().warning( "Unable to get the template from the representation " + templateRepresentation.getLocationRef() + ". Error message: " + e.getMessage()); return null; } }
@Override public Reader getReader() throws IOException { if (isDecoding()) { return IoUtils.getReader(getStream(), getCharacterSet()); } else { return getWrappedRepresentation().getReader(); } }
@Override public Reader getReader() throws IOException { if (canEncode()) { return IoUtils.getReader(getStream(), getCharacterSet()); } else { return getWrappedRepresentation().getReader(); } }
XMLReader xmlReader = spf.newSAXParser().getXMLReader(); this.source = new SAXSource(xmlReader, new InputSource( xmlRepresentation.getReader())); } catch (Exception e) { throw new IOException(
SesameUtils.parseAnnotations(entity.getReader(), baseUri, entity.getMediaType().getName());
.createReader( response.getEntity().getReader() ) )
.createReader( response.getEntity().getReader() ) )