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(Lang.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 |
isAccessDenied()
Is access to the resource represented by this sobject denied.
|
boolean |
isBinary()
Probe if the storage object is binary or text
|
boolean |
isDumb()
Returns
true if this SObject is dumb |
boolean |
isEmpty()
Is content is empty
|
boolean |
isExists()
Is the resource exists.
|
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
true if the sobject is empty, false otherwiseboolean isExists()
Is the resource exists.
Note if this method returns true then isValid() must return false.
true if the resource back this sobject exists, false otherwiseboolean isValid()
Is this storage object valid. A storage object is not valid if the file/input stream is not readable
true if this sobject is valid or false otherwiseboolean isAccessDenied()
Is access to the resource represented by this sobject denied.
Note if this method returns true then false`isValid() must
return
true if access to the resource back this sobject denied, false otherwise.Throwable getException()
Return previous exception that cause the sobject invalid
File asFile() throws UnexpectedIOException
UnexpectedIOExceptionString asString() throws UnexpectedIOException
UnexpectedIOExceptionString asString(Charset charset) throws UnexpectedIOException
UnexpectedIOExceptionbyte[] asByteArray()
throws UnexpectedIOException
UnexpectedIOExceptionInputStream asInputStream() throws UnexpectedIOException
Returns an InputStream connect to the sobject. Note it is caller’s responsibility to close the inputStream
UnexpectedIOExceptionvoid consumeOnce(Lang.Function<InputStream,?> consumer) throws UnexpectedIOException
Consume the inputstream of this storage object one time and then close the input stream
consumer - the consumer functionUnexpectedIOExceptionboolean isDumb()
Returns true if this SObject is dumb
true if this instance is dumbboolean isBinary()
Probe if the storage object is binary or text
true if the storage object is binary, false otherwiseCopyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.