001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent;
019:
020: import java.util.Map;
021:
022: import de.finix.contelligent.core.PropertyType;
023: import de.finix.contelligent.exception.TypeException;
024: import de.finix.contelligent.persistence.TypeProperty;
025: import de.finix.contelligent.xml.elements.TypeMetainfoElement;
026:
027: /**
028: * This class represents the type of a Contelligent {@link Component}.
029: */
030: public interface Type {
031:
032: String getName();
033:
034: ComponentPath getBlueprintPath();
035:
036: boolean isBlueprint();
037:
038: TypeMetainfoElement getMetainfoElement();
039:
040: String getTypeGroup();
041:
042: String getClassName();
043:
044: /**
045: * @deprecated This method is no longer supported for external use and may
046: * return null if the type has not been instanciated yet.
047: */
048: Class getTypeClass();
049:
050: String getSuperTypeName();
051:
052: boolean restrictsOnly();
053:
054: Map getMergedPropertyMap();
055:
056: Map getOriginalPropertyMap();
057:
058: String toString();
059:
060: int hashCode();
061:
062: boolean equals(Object anObject);
063:
064: /**
065: * Sets all properties of the given component according to this type
066: * definition. The map is expected to contain either (String,String) or
067: * (String,Double) entries only. If the map is null or empty all properties
068: * will receive the default value of this type. Properties which are not
069: * defined by this type are ignored.
070: *
071: * @param component
072: * a <code>Component</code> value
073: * @param propertyMap
074: * a map containing either (String,String) or (String,Double)
075: * entries
076: */
077: void setProperties(Component component, Map propertyValues)
078: throws TypeException;
079:
080: /**
081: * Returns a <code>Map</code> containing those properties of the given
082: * component whose values differ from those of this type. This means that
083: * final properties are never contained in this map. <BR>
084: * The keys of the map are the {@link TypeProperty#getName names} of the
085: * properties and the values may either be <code>String</code> or
086: * <code>Double</code> instances depending on the type of the property.
087: * All numeric types will be converted into <code>Double</code> and all
088: * others will be converted into a <code>String</code> instance using the
089: * converter method {@link #toString} defined in this handler class. <BR>
090: * To determine the value of a property a get method is called which means
091: * the components class must define a method 'getProp' for a property named
092: * 'prop'.
093: *
094: * @param component
095: * a <code>Component</code> value
096: * @param includeRN
097: * indicates whether non-persistent properties are included or
098: * not.
099: * @return a <code>Map</code> value
100: * @exception TypeException
101: * if an error occurs
102: * @see PropertyType
103: */
104: Map getProperties(Component component, boolean includeRN)
105: throws TypeException;
106:
107: /**
108: * Returns a <code>Map</code> containing those properties of the given
109: * component whose values differ from those of this type. This means that
110: * final properties are never contained in this map. <BR>
111: * The keys of the map are the {@link TypeProperty#getName names} of the
112: * properties and the values may either be <code>String</code> or
113: * <code>Double</code> instances depending on the type of the property.
114: * All numeric types will be converted into <code>Double</code> and all
115: * others will be converted into a <code>String</code> instance using the
116: * converter method {@link #toString} defined in this handler class. <BR>
117: * To determine the value of a property a get method is called which means
118: * the components class must define a method 'getProp' for a property named
119: * 'prop'.
120: *
121: * @param component
122: * a <code>Component</code> value
123: * @param includeRN
124: * indicates whether non-persistent properties are included or
125: * not.
126: * @param includeW
127: * indicates whether write-only are included or
128: * not. Note that these should never be made accessible
129: * to clients.
130: * @return a <code>Map</code> value
131: * @exception TypeException
132: * if an error occurs
133: * @see PropertyType
134: */
135: Map getProperties(Component component, boolean includeRN,
136: boolean includeW) throws TypeException;
137:
138: /**
139: * Returns a newly created <code>Map</code> containing the converted
140: * properties of the given map. The conversion is equivalent to that made by
141: * {@link #getProperties(Component, boolean)}, the only difference is that
142: * this method is not able to convert any instance values (which may be of
143: * type <code>int</code> or <code>float</code>) but only the
144: * <code>String</code> values from the given map. <BR>
145: * So the given map is expected to contain (String,String) entries only
146: * while the returned one contains either (String, String) or
147: * (String,Double) entries depending on the {@link PropertyType type} of the
148: * property. Only whose values differ from those of this type will be
149: * converted, for example final properties are never contained in the
150: * returned map.
151: *
152: * @param componentPropertyMap
153: * a <code>Map</code> value
154: * @param typeInfo
155: * a <code>TypeInfo</code> value
156: * @return a <code>Map</code> value
157: * @exception PropertyException
158: * if an error occurs
159: */
160: Map getProperties(Map componentPropertyMap, boolean includeRN)
161: throws TypeException;
162:
163: /**
164: * Anser this type's supertype.
165: *
166: * @return
167: */
168: Type getSuperType();
169:
170: /**
171: * Check whether this type is a subtype of the given type.
172: *
173: * @param type
174: * @return
175: */
176: boolean isSubTypeOf(String type);
177:
178: /**
179: * Check whether this type is a subtype of the given type or equal the given
180: * type.
181: *
182: * @param type
183: * @return
184: */
185: boolean isInstanceOf(String type);
186:
187: }
|