KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployers > spi > attachments > Attachments


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.deployers.spi.attachments;
23
24 import java.util.Map JavaDoc;
25
26 /**
27  * Attachments
28  *
29  * Represents a set of attachments
30  *
31  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
32  * @version $Revision: 1.1 $
33  */

34 public interface Attachments
35 {
36    /**
37     * Get all the attachments
38     *
39     * @return the unmodifiable attachments
40     */

41    Map JavaDoc<String JavaDoc, Object JavaDoc> getAttachments();
42
43    /**
44     * Add attachment
45     *
46     * @param name the name of the attachment
47     * @param attachment the attachment
48     * @return any previous attachment
49     * @throws IllegalArgumentException for a null name or attachment
50     */

51    Object JavaDoc addAttachment(String JavaDoc name, Object JavaDoc attachment);
52
53    /**
54     * Add attachment
55     *
56     * @param <T> the expected type
57     * @param name the name of the attachment
58     * @param attachment the attachment
59     * @param expectedType the expected type
60     * @return any previous attachment
61     * @throws IllegalArgumentException for a null name, attachment or expectedType
62     */

63    <T> T addAttachment(String JavaDoc name, T attachment, Class JavaDoc<T> expectedType);
64
65    /**
66     * Add attachment
67     *
68     * @param <T> the expected type
69     * @param name the name of the attachment
70     * @param attachment the attachment
71     * @param type the type
72     * @return any previous attachment
73     * @throws IllegalArgumentException for a null name, attachment or type
74     */

75    <T> T addAttachment(Class JavaDoc<T> type, T attachment);
76
77    /**
78     * Get attachment
79     *
80     * @param name the name of the attachment
81     * @return the attachment or null if not present
82     * @throws IllegalArgumentException for a null name
83     */

84    Object JavaDoc getAttachment(String JavaDoc name);
85
86    /**
87     * Get attachment
88     *
89     * @param <T> the expected type
90     * @param name the name of the attachment
91     * @param expectedType the expected type
92     * @return the attachment or null if not present
93     * @throws IllegalArgumentException for a null name or expectedType
94     */

95    <T> T getAttachment(String JavaDoc name, Class JavaDoc<T> expectedType);
96
97    /**
98     * Get attachment
99     *
100     * @param <T> the expected type
101     * @param name the name of the attachment
102     * @param type the type
103     * @return the attachment or null if not present
104     * @throws IllegalArgumentException for a null name or type
105     */

106    <T> T getAttachment(Class JavaDoc<T> type);
107    
108    /**
109     * Is the attachment present
110     *
111     * @param name the name of the attachment
112     * @return true when the attachment is present
113     * @throws IllegalArgumentException for a null name
114     */

115    boolean isAttachmentPresent(String JavaDoc name);
116    
117    /**
118     * Is the attachment present
119     *
120     * @param name the name of the attachment
121     * @param expectedType the expected type
122     * @return true when the attachment is present
123     * @throws IllegalArgumentException for a null name or expectedType
124     */

125    boolean isAttachmentPresent(String JavaDoc name, Class JavaDoc<?> expectedType);
126    
127    /**
128     * Is the attachment present
129     *
130     * @param name the name of the attachment
131     * @param type the type
132     * @return true when the attachment is present
133     * @throws IllegalArgumentException for a null name or type
134     */

135    boolean isAttachmentPresent(Class JavaDoc<?> type);
136
137    /**
138     * Remove attachment
139     *
140     * @param name the name of the attachment
141     * @return the attachment or null if not present
142     * @throws IllegalArgumentException for a null name
143     */

144    Object JavaDoc removeAttachment(String JavaDoc name);
145
146    /**
147     * Remove attachment
148     *
149     * @param <T> the expected type
150     * @param name the name of the attachment
151     * @return the attachment or null if not present
152     * @param expectedType the expected type
153     * @throws IllegalArgumentException for a null name or expectedType
154     */

155    <T> T removeAttachment(String JavaDoc name, Class JavaDoc<T> expectedType);
156
157    /**
158     * Remove attachment
159     *
160     * @param <T> the expected type
161     * @return the attachment or null if not present
162     * @param type the type
163     * @throws IllegalArgumentException for a null name or type
164     */

165    <T> T removeAttachment(Class JavaDoc<T> type);
166    
167    /**
168     * Clear the attachments
169     *
170     * @throws UnsupportedOperationException when not supported by the implementation
171     */

172    void clear();
173 }
174
Popular Tags