NamedPayloads¶
-
public abstract class
NamedPayloads
¶ A Named payloads is a kind of payload (file attachment) that use it’s filename to provide some informations for the system. It is a proxy design pattern that control the behavior of the actual files. In SFRM plugin, the default style of named payload is shown on the below:
- Outgoing Payload Repository - <service>$<message_id>$timestamp>
- Packaged Payload Repository - <service>$<message_id>
- Incoming Payload Repository - <service>$<message_id>
Creation Date: 6/10/2006.
Author: Twinsen Tsang
Constructors¶
NamedPayloads¶
-
public
NamedPayloads
(String payloadsName, int initialState, PayloadsRepository owner)¶ Explicit Constructor. This constructor is mainly used for creating a new payload proxy including the physical file and the proxy object. NOTE: The physical file is not created until it is necessary.
Parameters: - payloadsName – The name of the newly created payload.
- initialState – The initialState of the payloads, see
PayloadsState
for details. - owner – The owner of the payloads.
Throws: - NullPointerException – if the
owner
is null - IllegalArgumentException – if the
payloadsName
is null or theinitialState
is not invalid.
See also:
hk.hku.cecid.edi.sfrm.com.PayloadsRepostory
,hk.hku.cecid.edi.sfrm.com.PayloadsState
NamedPayloads¶
-
public
NamedPayloads
(File payloads, PayloadsRepository owner)¶ Explicit Constructor. The constructor is mainly used for creating the new payload proxy object only.
Parameters: - payloads – The file payload object.
- owner – The owner of the payloads.
See also:
hk.hku.cecid.edi.sfrm.PayloadsRepostory
Methods¶
clearPayloadCache¶
-
public void
clearPayloadCache
()¶ Clear / Delete the payload cache to free some space.
decode¶
-
protected abstract void
decode
()¶ Decode the payload root to become some useful information.
Throws: - ArrayIndexOutOfBoundsException – if the decoding fails due to the filename is in wrong format.
getOriginalRootname¶
getOwner¶
-
public PayloadsRepository
getOwner
()¶ Returns: get the owner of this payload.
getSize¶
-
public long
getSize
()¶ Returns: get the size of the payload, return 0 if the payload does not exist.
getStateForm¶
-
public static String
getStateForm
(int state)¶ Get the state form string according to the specified state.
Parameters: - state – The state you want to retrieve.
Throws: - IllegalArgumentException – if the state is invalid. For all state see PayloadsState.
isProcessed¶
-
public boolean
isProcessed
()¶ Returns: true if the payload’s name is starting with processed prefix.
isProcessing¶
-
public boolean
isProcessing
()¶ Returns: true if the payload’s name is startting with processing prefix.
isUploading¶
-
public boolean
isUploading
()¶ Returns: true if the payload’s name is startting with processing prefix.
load¶
-
public InputStream
load
()¶ Load the payload content from the input stream. NOTE: This method returns a new instance of input stream.
Throws: - IOException – Throws if the payload file does not exist.
Returns: the content input stream.
loadChannel¶
-
public ReadableByteChannel
loadChannel
()¶ Load the payload content from the input stream channel.
Throws: - IOException – Throws if the payload file does not exist.
Returns: the content input channel.
moveRoot¶
moveToRepository¶
-
public boolean
moveToRepository
(PayloadsRepository newOwner)¶ Move the root to another payloads repository. The owner of this payloads will changes to
newOwner
after invocation of this method.Parameters: - newOwner – The new owner of the payload repository.
Returns: true if the moving operation successfully, false if the
newOwner
is null or moving operation fail.
moveToRepositoryForce¶
-
public boolean
moveToRepositoryForce
(PayloadsRepository newOwner)¶ Move the root to another payloads repository force. The owner of this payloads will changes to
newOwner
after invocation of this method.Parameters: - newOwner – The new owner of the payload repository.
Returns: true if the moving operation successfully, false if the
newOwner
is null or moving operation fail.
renameRoot¶
save¶
-
public void
save
(InputStream content, boolean append)¶ Save the content from the input stream to this payloads. If the content stream is null, it save the file with empty content.
Parameters: - content – The input content stream.
- append – true if the new content is added to the existing content, false if the new content overwrite the existing.
setToPending¶
-
public boolean
setToPending
()¶ Set the status of payload to pending.
Returns: true if the operation run sucessfully.
setToProcessed¶
-
public boolean
setToProcessed
()¶ Set the status of payload to processed.
Returns: true if the operation run sucessfully.
setToProcessing¶
-
public boolean
setToProcessing
()¶ Set the status of payload to processing.
Returns: true if the operation run sucessfully.