public interface ISObject extends Serializable
Represent an item stored in an IStorageService
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_CONTENT_LENGTH
Store the content length
|
static String |
ATTR_CONTENT_TYPE
A standard attribute: content-type
|
static String |
ATTR_FILE_NAME
A standard attribute: filename
|
static String |
ATTR_SS_CTX
The storage service context path
|
static String |
ATTR_SS_ID
The storage service ID
|
static String |
ATTR_URL
Store the URL point to this sobject
|
static osgl.version.Version |
VERSION |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
asByteArray() |
File |
asFile() |
InputStream |
asInputStream()
Returns an
InputStream connect to the sobject. |
String |
asString() |
String |
asString(Charset charset) |
void |
consumeOnce(org.osgl.Osgl.Function<InputStream,?> consumer)
Consume the inputstream of this storage object one time and then close the input stream
|
String |
getAttribute(String key)
Return attribute associated with this storage object by key.
|
Map<String,String> |
getAttributes() |
String |
getContentType()
Return
content type attribute |
Throwable |
getException()
Return previous exception that cause the sobject invalid
|
String |
getFilename()
Returns
filename attribute |
String |
getKey() |
long |
getLength() |
String |
getUrl()
Returns URL set to this SObject.
|
boolean |
hasAttribute() |
boolean |
isDumb()
Returns
true if this SObject is dumb |
boolean |
isEmpty()
Is content is empty
|
boolean |
isValid()
Is this storage object valid.
|
ISObject |
setAttribute(String key,
String val)
Set an attribute to the storage object associated by key specified.
|
ISObject |
setAttributes(Map<String,String> attrs)
Set attributes to the storage object
|
void |
setContentType(String contentType)
Set
content type attribute |
void |
setFilename(String filename)
Set
filename attribute |
static final osgl.version.Version VERSION
static final String ATTR_CONTENT_TYPE
A standard attribute: content-type
static final String ATTR_FILE_NAME
A standard attribute: filename
static final String ATTR_SS_ID
The storage service ID
static final String ATTR_SS_CTX
The storage service context path
static final String ATTR_URL
Store the URL point to this sobject
static final String ATTR_CONTENT_LENGTH
Store the content length
String getKey()
long getLength()
String getUrl()
Returns URL set to this SObject.
Calling to this method shall have the same result as
calling getAttribute(String) using
ATTR_URL:
String url = sobj.getAttribute(ISObject.ATTR_URL);
String getContentType()
Return content type attribute
void setFilename(String filename)
Set filename attribute
filename - the filename to be setvoid setContentType(String contentType)
Set content type attribute
contentType - the content type to be setString getAttribute(String key)
Return attribute associated with this storage object by key. If there is no such attribute found then null is returned
null if not foundISObject setAttribute(String key, String val)
Set an attribute to the storage object associated by key specified.
key - attribute keyval - attribute valueISObject setAttributes(Map<String,String> attrs)
Set attributes to the storage object
attrs - boolean hasAttribute()
true if the storage object has attributesMap<String,String> getAttributes()
boolean isEmpty()
Is content is empty
boolean isValid()
Is this storage object valid. A storage object is not valid if the file/input stream is not readable
Throwable getException()
Return previous exception that cause the sobject invalid
File asFile() throws org.osgl.exception.UnexpectedIOException
org.osgl.exception.UnexpectedIOExceptionString asString() throws org.osgl.exception.UnexpectedIOException
org.osgl.exception.UnexpectedIOExceptionString asString(Charset charset) throws org.osgl.exception.UnexpectedIOException
org.osgl.exception.UnexpectedIOExceptionbyte[] asByteArray()
throws org.osgl.exception.UnexpectedIOException
org.osgl.exception.UnexpectedIOExceptionInputStream asInputStream() throws org.osgl.exception.UnexpectedIOException
Returns an InputStream connect to the sobject. Note it is caller’s responsibility to close the inputStream
org.osgl.exception.UnexpectedIOExceptionvoid consumeOnce(org.osgl.Osgl.Function<InputStream,?> consumer) throws org.osgl.exception.UnexpectedIOException
Consume the inputstream of this storage object one time and then close the input stream
consumer - the consumer functionorg.osgl.exception.UnexpectedIOExceptionboolean isDumb()
Returns true if this SObject is dumb
true if this instance is dumbCopyright © 2013–2017 OSGL (Open Source General Library). All rights reserved.