Pagelet

public class Pagelet

A Pagelet contains a URL representing a page or a fragment of a page. By default, it caches the content of the pagelet softly. Therefore, each invocation of openStream() may or may not cause an actual access to the pagelet URL, depending on the memory status and whether caching is enabled.

Author:Hugo Y. K. Lam

See also: PageletStore

Constructors

Pagelet

public Pagelet(String id, URL pagelet)

Creates a new instance of Pagelet.

Parameters:
  • id – the pagelet ID.
  • pagelet – the pagelet URL.

Methods

getId

public String getId()

Gets the pagelet ID.

Returns:the pagelet ID.

getURL

public URL getURL()

Gets the URL of the pagelet.

Returns:the URL of the pagelet.

isCacheEnabled

public boolean isCacheEnabled()

Checks if caching is enabled.

Returns:true if caching is enabled.

openStream

public InputStream openStream()

Opens an input stream for reading the content of the pagelet.

Throws:
  • IOException – if unable to create a new input stream.
Returns:

the input stream of the pagelet.

setCacheEnabled

public void setCacheEnabled(boolean isCacheEnabled)

Sets whether caching should be enabled.

Parameters:
  • isCacheEnabled – true if caching should be enabled.

toString

public String toString()

Returns a string representation of this pagelet.

Returns:a string representation of this pagelet.

See also: java.lang.Object.toString()