001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: Property.java,v 1.7 2005/12/04 13:46:05 jesper Exp $
023: package net.infonode.properties.base;
024:
025: import net.infonode.properties.base.exception.CantRemoveValueException;
026: import net.infonode.properties.base.exception.ImmutablePropertyException;
027: import net.infonode.properties.base.exception.InvalidPropertyException;
028: import net.infonode.properties.base.exception.InvalidPropertyValueException;
029:
030: /**
031: * A property is belongs to a {@link PropertyGroup} and contains name, description, type etc.
032: * A property can have multiple values which can be stored in any type of object.
033: *
034: * @author $Author: jesper $
035: * @version $Revision: 1.7 $
036: */
037: public interface Property {
038: /**
039: * Returns the property name.
040: *
041: * @return the property name
042: */
043: String getName();
044:
045: /**
046: * Returns a description of this property.
047: *
048: * @return a description of this property
049: */
050: String getDescription();
051:
052: /**
053: * Returns the value type of this property.
054: * The property can only be set to values that are of this class or a sub class of this class.
055: *
056: * @return the value type of this property
057: */
058: Class getType();
059:
060: /**
061: * Returns the property group that this property belongs to.
062: *
063: * @return the property group that this property belongs to
064: */
065: PropertyGroup getGroup();
066:
067: /**
068: * Returns the value of this property in a value container.
069: *
070: * @param valueContainer the object containing the value
071: * @return the value of this property in an valueContainer, null if the container doesn't contain the value
072: * @throws InvalidPropertyException if the property can not be read from the value container
073: */
074: Object getValue(Object valueContainer)
075: throws InvalidPropertyException;
076:
077: /**
078: * Sets the value of this property in an object.
079: *
080: * @param valueContainer the object to set the property value in
081: * @param value the value of the property
082: * @throws ImmutablePropertyException if this property is immutable
083: * @throws InvalidPropertyException if this property can't be set in the object
084: * @throws InvalidPropertyValueException if the property value is invalid
085: */
086: void setValue(Object valueContainer, Object value)
087: throws ImmutablePropertyException,
088: InvalidPropertyException, InvalidPropertyValueException;
089:
090: /**
091: * Returns true if the value can be assigned to this property.
092: *
093: * @param value the value to assign
094: * @return true if the value can be assigned to this property
095: */
096: boolean canBeAssiged(Object value);
097:
098: /**
099: * Returns true if this property is mutable.
100: *
101: * @return true if this property is mutable
102: */
103: boolean isMutable();
104:
105: /**
106: * Returns true if the value of this property can be removed from the valueContainer.
107: *
108: * @param valueContainer the object from which to remove the value
109: * @return true if the value of this property can be removed from the valueContainer
110: */
111: boolean valueIsRemovable(Object valueContainer);
112:
113: /**
114: * Returns true if this property has a value in the valueContainer.
115: *
116: * @param valueContainer the object that might contain the value
117: * @return true if this property has a value in the valueContainer
118: */
119: boolean valueIsSet(Object valueContainer);
120:
121: /**
122: * Removes the value of this property from an valueContainer.
123: *
124: * @param valueContainer the object in which to remove the value
125: * @throws ImmutablePropertyException if the property is immutable
126: * @throws CantRemoveValueException if the property value can't be removed from the valueContainer
127: */
128: void removeValue(Object valueContainer)
129: throws ImmutablePropertyException, CantRemoveValueException;
130: }
|