001: /*
002: Copyright (c) 2003 eInnovation Inc. All rights reserved
003:
004: This library is free software; you can redistribute it and/or modify it under the terms
005: of the GNU Lesser General Public License as published by the Free Software Foundation;
006: either version 2.1 of the License, or (at your option) any later version.
007:
008: This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
009: without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: See the GNU Lesser General Public License for more details.
011: */
012:
013: package com.openedit.users;
014:
015: import java.io.Serializable;
016: import java.util.Map;
017:
018: /**
019: * This interface represents an object that can contain properties.
020: *
021: * @author Eric Galluzzo
022: */
023: public interface PropertyContainer extends Serializable {
024: /**
025: * Get all the properties on this object as a read-only map.
026: *
027: * @return A read-only map of all the properties on this object
028: */
029: Map getProperties();
030:
031: /**
032: * Get the value of the given property of this object.
033: *
034: * @param inPropertyName The property name
035: *
036: * @return The property value, or <code>null</code> if the property does not exist on this
037: * object
038: */
039: Object get(String inPropertyName);
040:
041: /**
042: * Set the given property of this object. Note that depending on the implementation, only
043: * certain types may be supported for the property value. All implementations must support at
044: * least String. However, it is recommended that implementations support at least the
045: * following types:
046: *
047: * <ul>
048: * <li>
049: * Boolean
050: * </li>
051: * <li>
052: * Double
053: * </li>
054: * <li>
055: * Integer
056: * </li>
057: * <li>
058: * String
059: * </li>
060: * <li>
061: * Object[]
062: * </li>
063: * </ul>
064: *
065: * Property names must conform to the regular expression <code>[A-Za-z_][A-Za-z0-9_.]</code>.
066: * In other words, the first character must be an underscore or letter; and each subsequent
067: * character must be an underscore, period, letter, or digit.
068: *
069: * @param inPropertyName The property name
070: * @param inPropertyValue The property value
071: *
072: * @throws InvalidPropertyNameException If the property name was invalid
073: * @throws UnsupportedPropertyTypeException If the property value was of an unsupported type
074: * @throws UserManagerException If the property could not be set
075: */
076: void put(String inPropertyName, Object inPropertyValue)
077: throws UserManagerException;
078:
079: /**
080: * Add all the specified properties to this object. Note that the keys in the given map must
081: * be strings (property names), and that the values must satisfy the implementation's
082: * requirements for property values.
083: *
084: * @param inProperties The properties to set
085: *
086: * @throws UserManagerException If any of the properties could not be set
087: *
088: * @see #put(String, Object)
089: */
090: void putAll(Map inProperties) throws UserManagerException;
091:
092: /**
093: * Remove the given property from this object. If no such property exists, this method will do
094: * nothing.
095: *
096: * @param inPropertyName The name of the property to remove
097: *
098: * @throws UserManagerException If the property exists and could not be removed
099: */
100: void remove(String inPropertyName) throws UserManagerException;
101:
102: /**
103: * Remove the given properties from this object. Any properties that do not
104: * exist will be silently ignored.
105: *
106: * @param inProperties The names of the properties to remove
107: *
108: * @throws UserManagerException If a property exists and could not be removed
109: */
110: void removeAll(String[] inProperties) throws UserManagerException;
111:
112: /**
113: * Returns the value for the given property, converted from a String to a
114: * boolean.
115: *
116: * @param inPropertyName The property name
117: *
118: * @return The boolean value
119: */
120: boolean getBoolean(String inPropertyName);
121:
122: /**
123: * Returns the string value for the given property.
124: *
125: * @param inPropertyName The property name
126: *
127: * @return The string value
128: */
129: String getString(String inPropertyName);
130:
131: /**
132: * Puts the given property in this map, except that null values are removed
133: * and no saving is performed.
134: *
135: * @param inPropertyName The property name
136: * @param inPropertyValue The property value
137: */
138: void safePut(String inPropertyName, Object inPropertyValue);
139: }
|