001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.rm.metadata;
020:
021: import java.util.List;
022:
023: import org.openharmonise.commons.dsi.*;
024: import org.openharmonise.rm.DataAccessException;
025: import org.openharmonise.rm.resources.AbstractProfiledObject;
026: import org.openharmonise.rm.resources.metadata.properties.*;
027: import org.openharmonise.rm.resources.metadata.properties.ranges.*;
028:
029: /**
030: * This class represents a <code>Profile</code> which is a value of a profile
031: * property instance. It extends <code>Profile</code> with a different
032: * implementation of <code>getAvailableProperties</code> which is dependant
033: * on the <code>Property</code> which this profile is the value for the
034: * instance of.
035: *
036: * @author Michael Bell
037: * @version $Revision: 1.2 $
038: *
039: */
040: public class ProfileValue extends Profile {
041:
042: /**
043: * The <code>Property</code> which this profile is the value for the
044: * instance of
045: */
046: private Property m_prop = null;
047:
048: /**
049: * Constructs a <code>ProfileValue</code>
050: *
051: */
052: public ProfileValue() {
053: super ();
054: }
055:
056: /**
057: * Constructs a <code>ProfileValue</code> with an interface to the data store
058: *
059: * @param dbintrf the data store interface
060: */
061: public ProfileValue(AbstractDataStoreInterface dbintrf) {
062: super (dbintrf);
063:
064: }
065:
066: /**
067: * Constructs a <code>ProfileValue</code> with an interface to the data store
068: * and a reference to the profiled object which this value is associated to.
069: *
070: * @param dbintrf the data store interface
071: * @param obj the profiled object
072: */
073: public ProfileValue(AbstractDataStoreInterface dbintrf,
074: AbstractProfiledObject obj) {
075: super (dbintrf, obj);
076:
077: }
078:
079: /**
080: * Constructs an existing <code>ProfileValue</code> with an interface to the
081: * data store, the id of the <code>ProfileValue</code> and a reference to the
082: * profiled object which this value is associated to
083: *
084: * @param dbintrf the data store interface
085: * @param nId the profile id
086: * @param obj the profiled object
087: */
088: public ProfileValue(AbstractDataStoreInterface dbintrf, int nId,
089: AbstractProfiledObject obj) {
090: super (dbintrf, nId, obj);
091:
092: }
093:
094: /**
095: * Sets the <code>Property</code> this <code>Profile</code> is a value for.
096: *
097: * @param prop the <code>Property</code>
098: */
099: public void setProperty(Property prop) {
100: m_prop = prop;
101: }
102:
103: /**
104: * Returns the <code>Property</code> for which this <code>Profile</code>
105: * is a value for.
106: *
107: * @return the <code>Property</code> for which this <code>Profile</code>
108: * is a value for
109: */
110: public Property getProperty() {
111: return m_prop;
112: }
113:
114: /* (non-Javadoc)
115: * @see org.openharmonise.rm.metadata.Profile#getAvailableProperties()
116: */
117: public List getAvailableProperties() throws DataAccessException {
118: List props = null;
119: if (m_prop != null) {
120: ProfileRange range = (ProfileRange) m_prop.getRange();
121:
122: props = range.getAllowedProperties(m_dsi);
123: } else {
124: props = super.getAvailableProperties();
125: }
126:
127: return props;
128: }
129:
130: }
|