Top Description Fields Constructors Methods
org.eclipse.jetty.util.resource

public Class MemoryResource

extends Resource
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, java.net.URI, .URISyntaxException, .URL, java.nio.channels.Channels, .ReadableByteChannel, java.nio.file.Path, java.time.Instant, java.util.Collection, .List, .Objects, org.eclipse.jetty.util.FileID, .IO

An in memory Resource created from a URL

Field Summary

Modifier and TypeField and Description
private final byte[]
private final Instant
private final URI

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public Collection<Resource>
getAllResources()

Overrides org.eclipse.jetty.util.resource.Resource.getAllResources.

Get a deep collection of contained resources.
public String
getFileName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getFileName.

The file name of the resource.

public String
getName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getName.

The full name of the resource.
public Path
getPath()

Implements abstract org.eclipse.jetty.util.resource.Resource.getPath.

Return the Path corresponding to this resource.
public URI
getURI()

Implements abstract org.eclipse.jetty.util.resource.Resource.getURI.

URI representing the resource.
public boolean
isContainedIn(Resource
the containing resource
container
)

Overrides org.eclipse.jetty.util.resource.Resource.isContainedIn.

Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.
public boolean
isDirectory()

Implements abstract org.eclipse.jetty.util.resource.Resource.isDirectory.

Return true if resource represents a directory of potential resources.
public boolean
isReadable()

Implements abstract org.eclipse.jetty.util.resource.Resource.isReadable.

True if the resource is readable.
public Instant
lastModified()

Overrides org.eclipse.jetty.util.resource.Resource.lastModified.

The time the resource was last modified.
public long
length()

Overrides org.eclipse.jetty.util.resource.Resource.length.

Length of the resource.
public List<Resource>
list()

Overrides org.eclipse.jetty.util.resource.Resource.list.

List of contents of a directory Resource.

public InputStream
newInputStream()

Overrides org.eclipse.jetty.util.resource.Resource.newInputStream.

Creates a new input stream to the resource.
public ReadableByteChannel
public Resource
resolve(String
the encoded subUriPath
subUriPath
)

Implements abstract org.eclipse.jetty.util.resource.Resource.resolve.

Resolve an existing Resource.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.eclipse.jetty.util.resource.Resource:
containscopyTodumpensureDirExistsgetPathTogetRealURIisAliasiteratorresolveDifferentFileSystem

Field Detail

_bytesback to summary
private final byte[] _bytes
_createdback to summary
private final Instant _created
_uriback to summary
private final URI _uri

Constructor Detail

MemoryResourceback to summary
pack-priv MemoryResource(URL url)

Method Detail

existsback to summary
public boolean exists()

Overrides org.eclipse.jetty.util.resource.Resource.exists.

Doc from org.eclipse.jetty.util.resource.Resource.exists.

Equivalent to Files#exists(Path, LinkOption...) with the following parameters: getPath() and LinkOption#NOFOLLOW_LINKS.

Returns:boolean

true if the represented resource exists.

Annotations
@Override
getAllResourcesback to summary
public Collection<Resource> getAllResources()

Overrides org.eclipse.jetty.util.resource.Resource.getAllResources.

Doc from org.eclipse.jetty.util.resource.Resource.getAllResources.

Get a deep collection of contained resources.

Returns:Collection<Resource>

A collection of all Resources deeply contained within this resource if it is a directory, otherwise an empty collection is returned.

Annotations
@Override
getFileNameback to summary
public String getFileName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getFileName.

Doc from org.eclipse.jetty.util.resource.Resource.getFileName.

The file name of the resource.

This is the last segment of the path.

Returns:String

the filename of the resource, or "" if there are no path segments (eg: path of "/"), or null if resource cannot determine a filename.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.eclipse.jetty.util.resource.Resource.getName.

Doc from org.eclipse.jetty.util.resource.Resource.getName.

The full name of the resource.

Returns:String

the full name of the resource, or null if there is no name for the resource.

Annotations
@Override
getPathback to summary
public Path getPath()

Implements abstract org.eclipse.jetty.util.resource.Resource.getPath.

Doc from org.eclipse.jetty.util.resource.Resource.getPath.

Return the Path corresponding to this resource.

Returns:Path

the path or null if there is no Path representation.

Annotations
@Override
getURIback to summary
public URI getURI()

Implements abstract org.eclipse.jetty.util.resource.Resource.getURI.

Doc from org.eclipse.jetty.util.resource.Resource.getURI.

URI representing the resource.

Returns:URI

a URI representing the given resource, or null if there is no URI representation of the resource.

Annotations
@Override
isContainedInback to summary
public boolean isContainedIn(Resource container)

Overrides org.eclipse.jetty.util.resource.Resource.isContainedIn.

Doc from org.eclipse.jetty.util.resource.Resource.isContainedIn.

Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.

Parameters
container:Resource

the containing resource

Returns:boolean

true if this Resource is contained, false otherwise

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements abstract org.eclipse.jetty.util.resource.Resource.isDirectory.

Doc from org.eclipse.jetty.util.resource.Resource.isDirectory.

Return true if resource represents a directory of potential resources.

Returns:boolean

true if the represented resource is a container/directory.

Annotations
@Override
isReadableback to summary
public boolean isReadable()

Implements abstract org.eclipse.jetty.util.resource.Resource.isReadable.

Doc from org.eclipse.jetty.util.resource.Resource.isReadable.

True if the resource is readable.

Returns:boolean

true if the represented resource exists, and can read from.

Annotations
@Override
lastModifiedback to summary
public Instant lastModified()

Overrides org.eclipse.jetty.util.resource.Resource.lastModified.

Doc from org.eclipse.jetty.util.resource.Resource.lastModified.

The time the resource was last modified.

Returns:Instant

the last modified time instant, or Instant#EPOCH if unable to obtain last modified.

Annotations
@Override
lengthback to summary
public long length()

Overrides org.eclipse.jetty.util.resource.Resource.length.

Doc from org.eclipse.jetty.util.resource.Resource.length.

Length of the resource.

Returns:long

the length of the resource in bytes, or -1L if unable to provide a size (such as a directory resource).

Annotations
@Override
listback to summary
public List<Resource> list()

Overrides org.eclipse.jetty.util.resource.Resource.list.

Doc from org.eclipse.jetty.util.resource.Resource.list.

List of contents of a directory Resource.

Ordering is java.nio.file.FileSystem dependent, so callers may wish to sort the return value to ensure deterministic behavior.

Returns:List<Resource>

a mutable list of resources contained in the directory resource, or an empty immutable list if unable to build the list (e.g. the resource is not a directory or not readable).

Annotations
@Override
newInputStreamback to summary
public InputStream newInputStream() throws IOException

Overrides org.eclipse.jetty.util.resource.Resource.newInputStream.

Doc from org.eclipse.jetty.util.resource.Resource.newInputStream.

Creates a new input stream to the resource.

Returns:InputStream

an input stream to the resource or null if one is not available.

Annotations
@Override
Exceptions
IOException:
if there is a problem opening the input stream
newReadableByteChannelback to summary
public ReadableByteChannel newReadableByteChannel() throws IOException

Overrides org.eclipse.jetty.util.resource.Resource.newReadableByteChannel.

Doc from org.eclipse.jetty.util.resource.Resource.newReadableByteChannel.

Readable ByteChannel for the resource.

Returns:ReadableByteChannel

a readable java.nio.channels.ByteChannel to the resource or null if one is not available.

Annotations
@Override
Exceptions
IOException:
if unable to open the readable bytechannel for the resource.
resolveback to summary
public Resource resolve(String subUriPath)

Implements abstract org.eclipse.jetty.util.resource.Resource.resolve.

Doc from org.eclipse.jetty.util.resource.Resource.resolve.

Resolve an existing Resource.

Parameters
subUriPath:String

the encoded subUriPath

Returns:Resource

an existing Resource representing the requested subUriPath, or null if resource does not exist.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override