Codota Logo
Representation.getStream
Code IndexAdd Codota to your IDE (free)

How to use
getStream
method
in
org.restlet.representation.Representation

Best Java code snippets using org.restlet.representation.Representation.getStream (Showing top 20 results out of 315)

  • Common ways to obtain Representation
private void myMethod () {
Representation r =
  • Codota Iconnew EmptyRepresentation()
  • Codota IconClientResource clientResource;clientResource.get()
  • Codota IconResponse response;response.getEntity()
  • Smart code suggestions by Codota
}
origin: org.restlet.jse/org.restlet.ext.lucene

/**
 * Returns the wrapped representation's stream.
 * 
 * @return The wrapped representation's stream.
 * @see ContentStream#getStream()
 */
public InputStream getStream() throws IOException {
  return representation.getStream();
}
origin: org.restlet.jee/org.restlet.ext.httpclient

public InputStream getContent() throws IOException,
    IllegalStateException {
  return entity.getStream();
}
origin: stackoverflow.com

 Representation representation = resource.get();
InputStream stream = representation.getStream();
origin: org.restlet.gae/org.restlet.ext.freemarker

/**
 * Returns the reader for the template source.
 * 
 * @param templateSource
 *            The template source {@link Representation}.
 * @param characterSet
 *            The reader character set.
 */
public Reader getReader(Object templateSource, String characterSet)
    throws IOException {
  Representation r = (Representation) templateSource;
  return new InputStreamReader(r.getStream(), characterSet);
}
origin: org.restlet.jee/org.restlet.ext.xml

@Override
public InputSource getInputSource() throws IOException {
  if (this.xmlRepresentation != null && this.xmlRepresentation.isAvailable()) {
    return new InputSource(this.xmlRepresentation.getStream());
  }
  return new InputSource((InputStream) null);
}
origin: org.restlet.osgi/org.restlet

/**
 * {@inheritDoc}<br>
 * 
 * The stream of the underlying representation is wrapped with a new
 * instance of the {@link DigestInputStream} class, which allows to compute
 * progressively the digest value.
 */
@Override
public InputStream getStream() throws IOException {
  return new DigestInputStream(getWrappedRepresentation().getStream(),
      this.computedDigest);
}
origin: org.restlet.android/org.restlet.ext.xml

@Override
public InputSource getInputSource() throws IOException {
  if (this.xmlRepresentation.isAvailable()) {
    return new InputSource(this.xmlRepresentation.getStream());
  }
  return new InputSource((InputStream) null);
}
origin: org.restlet.osgi/org.restlet

@Override
public InputStream getStream() throws IOException {
  return getWrappedRepresentation().getStream();
}
origin: stackoverflow.com

 ClientResource cr = new ClientResource("http://10.0.2.2:8888/download/");
cr.setRequestEntityBuffering(true);
DownloadResource downloadResource = cr.wrap(DownloadResourceProtocol.class);
// Remote invocation - seamless:
Representation representation = downloadResource.download();
// Using data:
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(representation.getStream(), byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
Log.i("Byte array: " + Arrays.toString(byteArray));
origin: org.restlet.osgi/org.restlet

/**
 * Exhaust the content of the representation by reading it and silently
 * discarding anything read. By default, it relies on {@link #getStream()}
 * and closes the retrieved stream in the end.
 * 
 * @return The number of bytes consumed or -1 if unknown.
 */
public long exhaust() throws IOException {
  long result = -1L;
  if (isAvailable()) {
    InputStream is = getStream();
    result = IoUtils.exhaust(is);
    is.close();
  }
  return result;
}
origin: org.restlet.jee/org.restlet.ext.jaxrs

  /**
   * @see AbstractProvider#writeTo(Object, Class, Type, Annotation[],
   *      MediaType, MultivaluedMap, OutputStream)
   */
  @Override
  public void writeTo(Form form, Class<?> type, Type genericType,
      Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream) throws IOException {
    Representation formRepr = form.getWebRepresentation();
    IoUtils.copy(formRepr.getStream(), entityStream);
  }
}
origin: org.restlet.jee/org.restlet.ext.jaxrs

@Override
public InputStream getInputStream() {
  try {
    return getRequest().getEntity().getStream();
  } catch (IOException e) {
    Context.getCurrentLogger().log(Level.WARNING,
        "Unable to get the request entity input stream.", e);
    return null;
  }
}
origin: jtalks-org/jcommune

private Map<String, String> parseUserDetails(Representation repr) throws JAXBException, IOException {
  JAXBContext context = JAXBContext.newInstance(Authentication.class);
  Unmarshaller unmarshaller = context.createUnmarshaller();
  Authentication auth = (Authentication) unmarshaller.unmarshal(repr.getStream());
  Map<String, String> authInfo = new HashMap<>();
  authInfo.put("username", auth.getCredintals().getUsername());
  authInfo.put("email", auth.getProfile().getEmail());
  authInfo.put("firstName", auth.getProfile().getFirstName());
  authInfo.put("lastName", auth.getProfile().getLastName());
  authInfo.put("enabled", String.valueOf(auth.getProfile().isEnabled()));
  return authInfo;
}
origin: org.restlet.osgi/org.restlet

private Status replaceFile(Request request, File file) {
  File tmp = null;
  try {
    tmp = File.createTempFile("restlet-upload", "bin");
    if (request.isEntityAvailable()) {
      Files.copy(request.getEntity().getStream(), tmp.toPath(), REPLACE_EXISTING);
    }
  } catch (IOException ioe) {
    getLogger().log(WARNING, "Unable to create the temporary file", ioe);
    cleanTemporaryFileIfUploadNotResumed(tmp);
    return new Status(SERVER_ERROR_INTERNAL, "Unable to create a temporary file");
  }
  return replaceFileByTemporaryFile(request, file, tmp);
}
origin: org.restlet.osgi/org.restlet

@Override
public InputStream getStream() throws IOException {
  if (canEncode()) {
    return IoUtils.getStream(this);
  } else {
    return getWrappedRepresentation().getStream();
  }
}
origin: org.restlet.jee/org.restlet.ext.jaxrs

  /**
   * @see MessageBodyWriter#writeTo(Object, Class, Type, Annotation[],
   *      MediaType, MultivaluedMap, OutputStream)
   */
  @Override
  public void writeTo(MultivaluedMap<String, String> mmap, Class<?> type,
      Type genericType, Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream) throws IOException {
    Form form = Converter.toForm(mmap);
    Representation formRepr = form.getWebRepresentation();
    IoUtils.copy(formRepr.getStream(), entityStream);
  }
}
origin: uk.bl.wa.discovery/warc-indexer

private void getWctMetadata( SolrRecord solr ) {
  
  ClientResource cr = new ClientResource( WctRestletUrl + this.solr.getFieldValue( WctFields.WCT_INSTANCE_ID ) );
  try {
    this.read( cr.get().getStream() );
  } catch (ResourceException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
}
origin: ukwa/webarchive-discovery

private void getWctMetadata( SolrRecord solr ) {
  
  ClientResource cr = new ClientResource( WctRestletUrl + this.solr.getFieldValue( WctFields.WCT_INSTANCE_ID ) );
  try {
    this.read( cr.get().getStream() );
  } catch (ResourceException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
}
origin: ontopia/ontopia

@Override
public <T> T toObject(Representation source, Class<T> target, Resource resource) throws IOException {
  LocatorIF base_address = null; // todo from header/params
  
  try {
    TopicMapReaderIF reader = getFragmentReader(source.getStream(), base_address);
    TopicMapIF fragment = reader.read();
    return objectFromFragment(fragment, target, resource);
  } catch (OntopiaRuntimeException ore) {
    throw OntopiaRestErrors.COULD_NOT_READ_FRAGMENT.build(ore);
  }
}
origin: com.github.ansell.oas/oas-webservice-impl

/**
 * Tests whether the RDF/JSON page when there are no annotations is correct.
 */
@Test
public void testAnnotationListEmptyJson() throws Exception
{
  final ClientResource getResource =
      new ClientResource(this.getUrl(this.propertyUtil.get(OasProps.PROP_BULK_FETCH_ANNOTATION_PATH,
          OasProps.DEF_BULK_FETCH_ANNOTATION_PATH)));
  
  final Representation results = getResource.get(RestletUtilMediaType.APPLICATION_RDF_JSON);
  
  // Expecting HTTP 200 OK response
  Assert.assertEquals(200, getResource.getResponse().getStatus().getCode());
  // Expecting application/json MIME type for response
  Assert.assertEquals(RestletUtilMediaType.APPLICATION_RDF_JSON.getName(), results.getMediaType().getName());
  
  this.assertRdf(results.getStream(), RDFFormat.RDFJSON, 0);
}

org.restlet.representationRepresentationgetStream

Javadoc

Returns a stream with the representation's content. This method is ensured to return a fresh stream for each invocation unless it is a transient representation, in which case null is returned.

Popular methods of Representation

  • getMediaType
  • getText
    Converts the representation to a string value. Be careful when using this method as the conversion o
  • isAvailable
    Indicates if some fresh content is potentially available, without having to actually call one of the
  • write
    Writes the representation to a byte channel. This method is ensured to write the full content for ea
  • setMediaType
  • getCharacterSet
  • getReader
    Returns a characters reader with the representation's content. This method is ensured to return a fr
  • getSize
    Returns the total size in bytes if known, UNKNOWN_SIZE (-1) otherwise. When ranges are used, this mi
  • setCharacterSet
  • getModificationDate
  • release
    Releases the representation and all associated objects like streams, channels or files which are use
  • getLanguages
  • release,
  • getLanguages,
  • setModificationDate,
  • getEncodings,
  • getLocationRef,
  • setTag,
  • exhaust,
  • getDisposition,
  • getTag

Popular in Java

  • Making http requests using okhttp
  • getApplicationContext (Context)
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now