KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > core > AttributeAccessor


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.core;
18
19 /**
20  * Interface defining a generic contract for attaching and accessing metadata
21  * to/from arbitrary objects.
22  *
23  * @author Rob Harrop
24  * @since 2.0
25  */

26 public interface AttributeAccessor {
27
28     /**
29      * Set the attribute defined by <code>name</code> to the supplied <code>value</code>.
30      * If <code>value</code> is <code>null</code>, the attribute is {@link #removeAttribute removed}.
31      * <p>In general, users should take care to prevent overlaps with other
32      * metadata attributes by using fully-qualified names, perhaps using
33      * class or package names as prefix.
34      * @param name the unique attribute key
35      * @param value the attribute value to be attached
36      */

37     void setAttribute(String JavaDoc name, Object JavaDoc value);
38
39     /**
40      * Get the value of the attribute identified by <code>name</code>.
41      * Return <code>null</code> if the attribute doesn't exist.
42      * @param name the unique attribute key
43      * @return the current value of the attribute, if any
44      */

45     Object JavaDoc getAttribute(String JavaDoc name);
46
47     /**
48      * Remove the attribute identified by <code>name</code> and return its value.
49      * Return <code>null</code> if no attribute under <code>name</code> is found.
50      * @param name the unique attribute key
51      * @return the last value of the attribute, if any
52      */

53     Object JavaDoc removeAttribute(String JavaDoc name);
54
55     /**
56      * Return <code>true</code> if the attribute identified by <code>name</code> exists.
57      * Otherwise return <code>false</code>.
58      * @param name the unique attribute key
59      */

60     boolean hasAttribute(String JavaDoc name);
61
62     /**
63      * Return the names of all attributes.
64      */

65     String JavaDoc[] attributeNames();
66
67 }
68
Popular Tags