Package sg.dex.starfish.impl
Class AAsset
- java.lang.Object
-
- sg.dex.starfish.impl.AAsset
-
- All Implemented Interfaces:
Asset
- Direct Known Subclasses:
AMemoryAsset
,ARemoteAsset
,FileAsset
,ResourceAsset
,SquidAsset
,URIAsset
public abstract class AAsset extends Object implements Asset
Abstract base class for immutable asset implementationsIncludes default handing of metadata
- Version:
- 0.5
- Author:
- Mike
-
-
Field Summary
Fields Modifier and Type Field Description protected String
id
protected String
metadataString
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAssetID()
Gets the ID for this Asset.DID
getDID()
Gets the DID for this asset.Map<String,Object>
getMetadata()
Gets a copy of the JSON metadata for this asset, as a map of strings to values.String
getMetadataString()
Returns the metadata for this asset as a String.Map<String,Object>
getParamValue()
Gets the representation of this asset as required to pass to a remote invokable service.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface sg.dex.starfish.Asset
getContent, getContentStream, isBundle, isDataAsset, isOperation
-
-
-
-
Method Detail
-
getAssetID
public String getAssetID()
Description copied from interface:Asset
Gets the ID for this Asset.The format of the asset ID is determined by the implementation.
- Specified by:
getAssetID
in interfaceAsset
- Returns:
- the assetID
-
getMetadata
public Map<String,Object> getMetadata()
Description copied from interface:Asset
Gets a copy of the JSON metadata for this asset, as a map of strings to values.Asset metadata will differ as per type of asset: (e.g. dataset, operation, bundle)
- Specified by:
getMetadata
in interfaceAsset
- Returns:
- New clone of the parsed JSON metadata for this asset
-
getDID
public DID getDID()
Description copied from interface:Asset
Gets the DID for this asset. The DID may include a DID path to specify the precise asset if the DID refers to an agent managing the asset. Throws an exception if a DID is not available or cannot be constructed.- Specified by:
getDID
in interfaceAsset
- Returns:
- The global DID for this asset.
- See Also:
- W3C DID spec
-
getParamValue
public Map<String,Object> getParamValue()
Description copied from interface:Asset
Gets the representation of this asset as required to pass to a remote invokable service.- Specified by:
getParamValue
in interfaceAsset
- Returns:
- A map representing this asset
-
getMetadataString
public String getMetadataString()
Description copied from interface:Asset
Returns the metadata for this asset as a String. Assets should store their metadata by deafult as a valid JSON string.Warning: Some implementations may not validate the JSON on asset creation and it is possible for the metadata String to contain invalid JSON.
- Specified by:
getMetadataString
in interfaceAsset
- Returns:
- The metadata of this asset as a String
-
-