01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 name, Object 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 getAttribute(String 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 removeAttribute(String 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 name);
61:
62: /**
63: * Return the names of all attributes.
64: */
65: String[] attributeNames();
66:
67: }
|