intarsys runtime library

de.intarsys.tools.attachment
Class AttachmentTools

java.lang.Object
  extended by de.intarsys.tools.attachment.AttachmentTools

public class AttachmentTools
extends Object

A tool class for implementing a generic attachment feature.

Attachments can be made for an object or a thread context.


Constructor Summary
AttachmentTools()
           
 
Method Summary
static void addAttachment(Attachment attachment)
          Add a Attachment to the thread context.
static void addAttachment(Object target, Attachment attachment)
          Add a Attachment to the target object.
static void addAttachment(Object target, String key, Object value)
          Add a Attachment to the target object.
static void addAttachment(String key, Object value)
          Add a Attachment to the thread context.
static void addAttachments(Attachment[] pAttachments)
          Add an array of Attachment instances to the thread context.
static void addAttachments(List<Attachment> pAttachments)
          Add a list of Attachment instances to the thread context.
static void addAttachments(Object target, Attachment[] pAttachments)
          Add an array of Attachment instances to the target object.
static void addAttachments(Object target, List<Attachment> pAttachments)
          Add a list of Attachment instances to the target object.
static void clearAttachments()
          Clear all attachments for the thread context.
static void clearAttachments(Object target)
          Clear all attachments for the target object.
static Attachment getAttachment(Object target, String key)
          Get the first Attachment matching "key" within the target object.
static Attachment getAttachment(String key)
          Get the first Attachment matching "key" in the thread context.
static Attachment[] getAttachments()
          Get all Attachment instances for the thread context.
static Attachment[] getAttachments(Object target)
          Get all Attachment instances for the target object.
static Attachment[] getAttachments(Object target, String key)
          Get all attachments matching "key" for the target object.
static Attachment[] getAttachments(String key)
          Get all attachments matching "key" in the thread context.
static boolean hasAttachment(Object target, String key)
          true if the target object has an attachment for "key"
static boolean hasAttachment(String key)
          true if the thread context has an attachment for "key"
static boolean removeAttached(Object attached)
          Remove attachment with attached object in the thread context.
static boolean removeAttached(Object target, Object attached)
          Remove attachment with attached object in the target object.
static boolean removeAttachment(Attachment pAttachment)
          Remove attachment in the thread context.
static boolean removeAttachment(Object target, Attachment pAttachment)
          Remove attachment in the target object.
static void removeAttachments(Object target, String key)
          Remove all attachments for key in the target object.
static void removeAttachments(String key)
          Remove all attachments for key in the thread context.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentTools

public AttachmentTools()
Method Detail

addAttachment

public static void addAttachment(Attachment attachment)
Add a Attachment to the thread context.

Parameters:
attachment - The new attachment

addAttachment

public static void addAttachment(Object target,
                                 Attachment attachment)
Add a Attachment to the target object.

Parameters:
target - The target object
attachment - The new attachment

addAttachment

public static void addAttachment(Object target,
                                 String key,
                                 Object value)
Add a Attachment to the target object.

Parameters:
target - The target object
key - The key
value - The attached object

addAttachment

public static void addAttachment(String key,
                                 Object value)
Add a Attachment to the thread context.

Parameters:
key - The key
value - The attached object

addAttachments

public static void addAttachments(Attachment[] pAttachments)
Add an array of Attachment instances to the thread context.

Parameters:
pAttachments -

addAttachments

public static void addAttachments(List<Attachment> pAttachments)
Add a list of Attachment instances to the thread context.

Parameters:
pAttachments -

addAttachments

public static void addAttachments(Object target,
                                  Attachment[] pAttachments)
Add an array of Attachment instances to the target object.

Parameters:
target - The target object
pAttachments -

addAttachments

public static void addAttachments(Object target,
                                  List<Attachment> pAttachments)
Add a list of Attachment instances to the target object.

Parameters:
target - The target object
pAttachments -

clearAttachments

public static void clearAttachments()
Clear all attachments for the thread context.


clearAttachments

public static void clearAttachments(Object target)
Clear all attachments for the target object.

Parameters:
target - The target object

getAttachment

public static Attachment getAttachment(Object target,
                                       String key)
Get the first Attachment matching "key" within the target object.

Parameters:
target - The target object
key - The key value that is searched
Returns:
The first matching Attachment or null

getAttachment

public static Attachment getAttachment(String key)
Get the first Attachment matching "key" in the thread context.

Parameters:
key - The key value that is searched
Returns:
The first matching Attachment or null

getAttachments

public static Attachment[] getAttachments()
Get all Attachment instances for the thread context.

Returns:
Get all attachments for the thread context.

getAttachments

public static Attachment[] getAttachments(Object target)
Get all Attachment instances for the target object.

Parameters:
target - The target object
Returns:
Get all attachments for object.

getAttachments

public static Attachment[] getAttachments(Object target,
                                          String key)
Get all attachments matching "key" for the target object.

Parameters:
target - The target object
key - The key value that is searched
Returns:
All matching attachments

getAttachments

public static Attachment[] getAttachments(String key)
Get all attachments matching "key" in the thread context.

Parameters:
key - The key value that is searched
Returns:
All matching attachments

hasAttachment

public static boolean hasAttachment(Object target,
                                    String key)
true if the target object has an attachment for "key"

Parameters:
target - The target object
key - The key value that is searched
Returns:
true if object has an attachment for "key"

hasAttachment

public static boolean hasAttachment(String key)
true if the thread context has an attachment for "key"

Parameters:
key - The key value that is searched
Returns:
true if object has an attachment for "key"

removeAttached

public static boolean removeAttached(Object attached)
Remove attachment with attached object in the thread context.

Parameters:
attached -
Returns:
true if removed

removeAttached

public static boolean removeAttached(Object target,
                                     Object attached)
Remove attachment with attached object in the target object.

Parameters:
target -
attached -
Returns:
true if removed

removeAttachment

public static boolean removeAttachment(Attachment pAttachment)
Remove attachment in the thread context.

Parameters:
pAttachment -
Returns:
true if removed

removeAttachment

public static boolean removeAttachment(Object target,
                                       Attachment pAttachment)
Remove attachment in the target object.

Parameters:
target -
pAttachment -
Returns:
true if removed

removeAttachments

public static void removeAttachments(Object target,
                                     String key)
Remove all attachments for key in the target object.

Parameters:
target - The target object
key - The key value for the attachments to be removed

removeAttachments

public static void removeAttachments(String key)
Remove all attachments for key in the thread context.

Parameters:
key - The key value for the attachments to be removed

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.