0001: /*
0002: * $RCSfile: NegotiableCapability.java,v $
0003: *
0004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * Use is subject to license terms.
0007: *
0008: * $Revision: 1.1 $
0009: * $Date: 2005/02/11 04:57:51 $
0010: * $State: Exp $
0011: */package javax.media.jai.remote;
0012:
0013: import java.io.Serializable;
0014: import java.util.ArrayList;
0015: import java.util.Enumeration;
0016: import java.util.List;
0017: import java.util.Hashtable;
0018: import java.util.Vector;
0019: import javax.media.jai.OperationDescriptor;
0020: import javax.media.jai.ParameterList;
0021: import javax.media.jai.ParameterListImpl;
0022: import javax.media.jai.ParameterListDescriptor;
0023: import javax.media.jai.ParameterListDescriptorImpl;
0024: import javax.media.jai.util.CaselessStringKey;
0025:
0026: /**
0027: * A <code>NegotiableCapability</code> represents the capabilities of an
0028: * object. These capabilities can be used to negotiate with the capabilities
0029: * of a similar object. Each <code>NegotiableCapability</code> is
0030: * characterized by the category it belongs to, as returned by the
0031: * <code>getCategory()</code> method, by the actual name of the capability
0032: * it represents, as returned by the <code>getCapabilityName()</code> method
0033: * and by a list of parameter name-value pairs that define the
0034: * <code>NegotiableCapability</code>. Every <code>NegotiableCapability</code>
0035: * object also holds references to a representation of the objects that
0036: * generated it. These can be accessed via the <code>getGenerators()</code>
0037: * method. The creator or generator of a <code>NegotiableCapability</code>
0038: * can supply any representation of itself while constructing the
0039: * <code>NegotiableCapability</code>. No interpretation is forced by this
0040: * class, that is left upto the generating class and to the class that
0041: * utilizes the <code>NegotiableCapability</code> to get the negotiated
0042: * results. The negotiation is performed by the
0043: * <code>negotiate()</code> method. Since this method returns a
0044: * <code>NegotiableCapability</code>, this method can be used repeatedly to
0045: * perform multiple negotiations. If the negotiation fails, null will be
0046: * returned from the <code>negotiate()</code> method. Every successful
0047: * negotiation will add the generator of the <code>NegotiableCapability</code>
0048: * negotiated with, to the set of generators of the resultant
0049: * <code>NegotiableCapability</code>. The generators are intended to help
0050: * the user of <code>NegotiableCapability</code> identify the object that
0051: * created the <code>NegotiableCapability</code> and therefore the object
0052: * that can be relied on to be able to handle the parameters agreed on during
0053: * negotiation. For example, if the negotiation is to be performed to choose
0054: * a compatible <code>TileEncoder</code>, <code>TileDecoder</code> pair
0055: * for data compression/decompression, the category would be "tileCodec",
0056: * the capabilityName would be a specific tile encoding format, say "jpeg"
0057: * and the generator for the <code>NegotiableCapability</code> could be the
0058: * <code>TileDecoderFactory</code>/<code>TileEncoderFactory</code> object
0059: * that generated that <code>NegotiableCapability</code>. After a
0060: * successful negotiation, the <code>NegotiableCapability</code> that is
0061: * the result of the negotiation will contain a
0062: * <code>TileEncoderFactory</code> and a <code>TileDecoderFactory</code>
0063: * object as the generators for that <code>NegotiableCapability</code>.
0064: * These two objects can then be retrieved using the
0065: * <code>getGenerators</code> method and used to do the encoding and
0066: * decoding and can be relied to be compatible, since the negotiation
0067: * was successful between their respective
0068: * <code>NegotiableCapability</code> objects.
0069: *
0070: * <p> The number, name, Class type and default values for the parameters in
0071: * this class is specified by the <code>ParameterListDescriptor</code>
0072: * returned from <code>getParameterListDescriptor</code> method. Each
0073: * parameter value in this class must be a class that implements the
0074: * <code>Negotiable</code> interface. It is for this reason that all of
0075: * the <code>ParameterList</code> set methods that take primitive data
0076: * types as arguments and all the <code>ParameterList</code> get methods
0077: * that return primitive data types are overridden in this class
0078: * to throw an IllegalArgumentException, as this class only accepts
0079: * <code>Negotiable</code>'s as parameter values in order to facilitate
0080: * negotiation on parameters. It may be noted that the implementation of
0081: * the version of <code>ParameterList.setParameter</code> that takes
0082: * an <code>Object</code> as the parameter value, in this class
0083: * throws an <code>IllegalArgumentException</code> if the supplied
0084: * <code>Object</code> to be set does not implement the
0085: * <code>Negotiable</code> interface. If no <code>Negotiable</code> value is
0086: * available as the value for a particular parameter, <code>null</code>
0087: * should be set as the value. A null value returned from the
0088: * <code>getNegotiatedValue(String)</code> method is however valid, since
0089: * the single value result of the negotiation can be null.
0090: * Similarly the <code>Object</code> returned from the
0091: * <code>ParameterList.getObjectParameter</code> implementation in this class
0092: * is always a class that implements the <code>Negotiable</code> interface,
0093: * and not a wrapper class of a primitive data type, as documented for this
0094: * method in <code>ParameterList</code>. The
0095: * <code>getParamValueRange(String parameterName)</code> and the
0096: * <code>getEnumeratedParameterValues(String parameterName)</code> methods
0097: * of the <code>ParameterListDescriptor</code> returned from
0098: * <code>getParameterListDescriptor</code> method of this class should be
0099: * implemented to return null, since these methods are not meaningful when
0100: * the parameter values are <code>Negotiable</code>.
0101: *
0102: * <p>In order for the negotiation to be successful, the category and the
0103: * capabilityName of the two <code>NegotiableCapability</code> objects must be
0104: * the same. In addition, negotiation on each of the parameters must be
0105: * successful. Since each parameter is represented as a
0106: * <code>Negotiable</code>, negotiation on it can be performed using the
0107: * <code>Negotiable.negotiate(Negotiable negotiable)</code> method. The
0108: * <code>NegotiableCapability</code> returned from the
0109: * <code>negotiate(NegotiableCapability capability)</code> method
0110: * contains the same category and capabilityName as that of the
0111: * <code>NegotiableCapability</code> objects being negotiated as well as
0112: * including the negotiated values for each parameter. If the negotiation fails
0113: * for any one parameter, the negotiation for the
0114: * <code>NegotiableCapability</code>s as a whole is said to fail (unless
0115: * preference <code>NegotiableCapability</code> objects are involved in
0116: * the negotiation, as described below) and a null is returned.
0117: *
0118: * <p> In order to get a single negotiated value from the set of valid
0119: * values represented as the <code>Negotiable</code> value for a parameter,
0120: * the <code>getNegotiatedValue(String parameterName)</code> method can be
0121: * called. If the negotiation was successful, an <code>Object</code> which
0122: * is the negotiated result will be returned, otherwise a
0123: * <code>null</code> (signifying that the negotiation failed) will be
0124: * returned.
0125: *
0126: * <p> <code>NegotiableCapability</code> objects can be classified as being
0127: * either preferences or non-preferences. A non-preference describes the
0128: * capabilities of an object completely by specifying <code>Negotiable</code>
0129: * values for each and every parameter defined in the
0130: * <code>ParameterListDescriptor</code> returned from
0131: * <code>getParameterListDescriptor</code> method. A non-preference is allowed
0132: * to not specify the value of a particular parameter, if a default value
0133: * for that parameter exists (i.e. the default value is not
0134: * <code>null</code>). When a non-preference is created, all parameter
0135: * values are initialized to their default values, and therefore if any
0136: * parameter value is left unset at the time of the negotiation, the
0137: * default value that was set at time of initialization will be used for
0138: * the negotiation. If the default value happened to be <code>null</code>,
0139: * the negotiation in this case would fail. Note that all references to
0140: * values in this paragraph, whether default or not, refered to the
0141: * objects implementing the <code>Negotiable</code> interface that are
0142: * the values set for a particular parameter name.
0143: *
0144: * A preference on the other hand specifies preferences for the selection of
0145: * a prefered set of (maybe even a single) parameter value from the set of
0146: * valid ones at negotiation time.
0147: * A preference is allowed to specify <code>Negotiable</code> parameter
0148: * values for a subset of parameters, if it so wishes. For those parameters
0149: * for whom the preference does not specify values, the preference is
0150: * indicating a don't-care attitude, and the result of the negotiation for
0151: * such a parameter will be the <code>Negotiable</code> value from the
0152: * non-preference object the preference is negotiating with. Note that the
0153: * default value is not substituted for a parameter whose value has not been
0154: * specified in a preference. A <code>NegotiableCapability</code> which is
0155: * a preference should return true from the <code>isPreference</code> method,
0156: * a non-preference object that defines values for all the parameters (or
0157: * relies on defaults) should return false from this method. As a rule, the
0158: * result of negotiation between one non-preference and another is a
0159: * non-preference, between a preference and a non-preference is a
0160: * non-preference and that between two preferences is a preference, if
0161: * the negotiation is successful. It may be noted that preferences are
0162: * not expected to specify their generators, since in general, preferences
0163: * don't come from objects that can support them. However if generators are
0164: * specified within a preference, they will be added to the set of generators
0165: * of the resultant <code>NegotiableCapability</code> in the event of a
0166: * successful negotiation.
0167: *
0168: * <p> Negotiation between a preference and a non-preference
0169: * <code>NegotiableCapability</code> results in a non-preference
0170: * <code>NegotiableCapability</code>. For each parameter, if a value is
0171: * specified (i.e the value is not <code>null</code>)
0172: * in both the preference and the non-preference, then if these values
0173: * have a common subset, the negotiation will succeed on this parameter,
0174: * if there is no commonality, then the negotiation will fail on this
0175: * parameter and thus also fail as a whole. If the preference doesn't
0176: * specify a value for a parameter (i.e the value is <code>null</code>),
0177: * then the value specified by the non-preference for that same parameter
0178: * is chosen as a result of the successful negotiation on that parameter.
0179: *
0180: * <p> Negotiation between two preference <code>NegotiableCapability</code>
0181: * objects results in a preference <code>NegotiableCapability</code>. For
0182: * each parameter, if a value is specified (i.e the value is not
0183: * <code>null</code>) in both the preference objects, the negotiation on
0184: * that parameter will have a value which is the portion that is common
0185: * to both. If there is no commonality, negotiation will fail on this
0186: * parameter (<code>null</code> will be returned) and thus also fail as
0187: * a whole. If the value for a particular parameter is specified in one
0188: * preference and not in the other, the negotiated value will be the one
0189: * specified. If for a particular parameter, no value is specified in
0190: * either preference, the negotiated value for that parameter will be
0191: * <code>null</code>, and the negotiation as a whole on the
0192: * <code>NegotiableCapability</code> will not fail.
0193: *
0194: * <p> When a preference <code>NegotiableCapability</code> is constructed,
0195: * the values of all the parameters defined in the
0196: * <code>ParameterListDescriptor</code> returned from
0197: * <code>getParameterListDescriptor</code> method, are initialized to
0198: * <code>null</code>. <code>null</code> within this class represents a
0199: * value that has not been specified. Such values are only allowed on
0200: * a preference <code>NegotiableCapability</code>. On the other hand when
0201: * a non-preference <code>NegotiableCapability</code> is
0202: * constructed, all the values are initialized to their default values.
0203: *
0204: * <p>All names are treated in a case-retentive and case-insensitive manner.
0205: *
0206: * @since JAI 1.1
0207: */
0208: public class NegotiableCapability extends ParameterListImpl implements
0209: Serializable {
0210:
0211: private String category;
0212: private String capabilityName;
0213: private List generators;
0214: private boolean isPreference = false;
0215:
0216: /**
0217: * Creates a <code>NegotiableCapability</code> with the specified
0218: * <code>category</code> and <code>capabilityName</code>.
0219: *
0220: * @param category The category this capability belongs to.
0221: * @param capabilityName The name of this capability.
0222: * @param generators A <code>List</code> containing representations
0223: * of the objects that generated this
0224: * <code>NegotiableCapability</code> or null, if
0225: * there are none.
0226: * @param descriptor The descriptor that describes the parameters for
0227: * this class.
0228: * @param isPreference Boolean specifying whether this class represents
0229: * a preference or a non-preference.
0230: *
0231: * @throws IllegalArgumentException if category is null.
0232: * @throws IllegalArgumentException if capabilityName is null.
0233: * @throws IllegalArgumentException if descriptor is null.
0234: * @throws IllegalArgumentException if any of the default values returned
0235: * from the supplied descriptor's getParamDefaults() method is
0236: * ParameterListDescriptor.NO_PARAMETER_DEFAULT. null should be used to
0237: * represent the absence of a default.
0238: * @throws IllegalArgumentException if any of the <code>Class</code>
0239: * types returned from the supplied descriptor's getParamClasses() method
0240: * does not implement <code>Negotiable</code>.
0241: */
0242: public NegotiableCapability(String category, String capabilityName,
0243: List generators, ParameterListDescriptor descriptor,
0244: boolean isPreference) {
0245: super (descriptor);
0246:
0247: if (category == null) {
0248: throw new IllegalArgumentException(JaiI18N
0249: .getString("NegotiableCapability0"));
0250: }
0251:
0252: if (capabilityName == null) {
0253: throw new IllegalArgumentException(JaiI18N
0254: .getString("NegotiableCapability1"));
0255: }
0256:
0257: ParameterListDescriptor desc = getParameterListDescriptor();
0258: int numParams = desc.getNumParameters();
0259: String names[] = desc.getParamNames();
0260: Class classes[] = desc.getParamClasses();
0261: Object defaults[] = desc.getParamDefaults();
0262:
0263: for (int i = 0; i < numParams; i++) {
0264:
0265: // Check that all paramClasses implement Negotiable.
0266: if (Negotiable.class.isAssignableFrom(classes[i]) == false) {
0267: throw new IllegalArgumentException(JaiI18N
0268: .getString("NegotiableCapability4"));
0269: }
0270:
0271: if (defaults[i] == ParameterListDescriptor.NO_PARAMETER_DEFAULT) {
0272: throw new IllegalArgumentException(JaiI18N
0273: .getString("NegotiableCapability5"));
0274: }
0275: }
0276:
0277: this .category = category;
0278: this .capabilityName = capabilityName;
0279: this .generators = generators;
0280: this .isPreference = isPreference;
0281: }
0282:
0283: /**
0284: * Returns the category of this <code>NegotiableCapability</code>.
0285: */
0286: public String getCategory() {
0287: return category;
0288: }
0289:
0290: /**
0291: * Returns the name of this <code>NegotiableCapability</code>.
0292: */
0293: public String getCapabilityName() {
0294: return capabilityName;
0295: }
0296:
0297: /**
0298: * Returns the <code>List</code> containing representations of the
0299: * objects that generated this <code>NegotiableCapability</code>. This
0300: * method will return null, if there are no generators for this
0301: * <code>NegotiableCapability</code>.
0302: */
0303: public List getGenerators() {
0304: return generators;
0305: }
0306:
0307: /**
0308: * Set the specified <code>List</code> as the generators for this
0309: * <code>NegotiableCapability</code>. A generator is a representation
0310: * of the object that generated this <code>NegotiableCapability</code>.
0311: *
0312: * @param generators The <code>List</code> of generators.
0313: */
0314: public void setGenerators(List generators) {
0315: this .generators = generators;
0316: }
0317:
0318: /**
0319: * Returns true if this <code>NegotiableCapability</code> is a
0320: * preference, false otherwise.
0321: */
0322: public boolean isPreference() {
0323: return isPreference;
0324: }
0325:
0326: /**
0327: * Returns a single negotiated value from the <code>Negotiable</code> that
0328: * represents the set of valid values for the given parameter. This
0329: * method uses the <code>Negotiable.getNegotiatedValue</code> to get
0330: * the negotiated value for the <code>Negotiable</code> value of the
0331: * parameter specified by <code>parameterName</code>. If this
0332: * <code>NegotiableCapability</code> is a non-preference, then a valid
0333: * <code>Negotiable</code> must be present as the value of the specified
0334: * parameter, and a single value from that <code>Negotiable</code> will
0335: * be returned. If this <code>NegotiableCapability</code> is a preference
0336: * the specified parameter may have a <code>null</code> as its value.
0337: * In this case, this <code>null</code> will be returned as the
0338: * negotiated value.
0339: *
0340: * @param parameterName The name of parameter to return the negotiated
0341: * value for.
0342: * @throws IllegalArgumentException if the parameterName is not one of
0343: * those described by the associated <code>ParameterListDescriptor</code>.
0344: */
0345: public Object getNegotiatedValue(String parameterName) {
0346: Negotiable value = (Negotiable) getObjectParameter(parameterName);
0347: if (value == null)
0348: return null;
0349: return value.getNegotiatedValue();
0350: }
0351:
0352: /**
0353: * Performs negotiation between this <code>NegotiableCapability</code>
0354: * and the given <code>NegotiableCapability</code>. Returns the common
0355: * subset supported by this <code>NegotiableCapability</code> and the given
0356: * <code>NegotiableCapability</code> if the negotiation is successful,
0357: * null otherwise.
0358: *
0359: * <p>In order for the negotiation to be successful, the category and the
0360: * capabilityName of the supplied <code>NegotiableCapability</code> object
0361: * must be the same as of this class. In addition, negotiation on each of
0362: * the parameters must be successful. Since each parameter is represented
0363: * as a <code>Negotiable</code>, negotiation on it can be performed using
0364: * the <code>Negotiable.negotiate()</code> method. The
0365: * <code>NegotiableCapability</code> returned contains the same category,
0366: * capabilityName as that of this class and also includes the negotiated
0367: * values for each parameter. If the negotiation fails for any one
0368: * parameter, the negotiation for the <code>NegotiableCapability</code>s
0369: * as a whole is said to fail and a null is returned. The result of
0370: * negotiation between one non-preference and another is a non-preference,
0371: * between a preference and a non-preference is a non-preference and
0372: * that between two preferences is a preference, if the negotiation is
0373: * successful.
0374: *
0375: * If this <code>NegotiableCapability</code> is a non-preference, i.e
0376: * the <code>isPreference()</code> method returns false, and the
0377: * supplied <code>NegotiableCapability</code> argument is also a
0378: * non-preference, then the negotiation will fail if the number and
0379: * <code>Class</code> of parameters in both the
0380: * <code>NegotiableCapability</code> objects is not the same.
0381: * If either one of the <code>NegotiableCapability</code> objects is
0382: * a preference and the other is a non-preference, the number of
0383: * parameters are not required to match. For those parameters whose names
0384: * are the same in both the <code>NegotiableCapability</code> objects,
0385: * the <code>Class</code> types have to match, otherwise the negotiation
0386: * will fail. Those parameters that exist in the non-preference
0387: * <code>NegotiableCapability</code> object but not in the preference
0388: * <code>NegotiableCapability</code> object do not take part in the
0389: * negotiation, but are directly set on the resultant
0390: * <code>NegotiableCapability</code> object if the negotiation
0391: * is successful on the common parameters. Those parameters that
0392: * exist in the preference <code>NegotiableCapability</code> object but
0393: * not in the non-preference <code>NegotiableCapability</code> object
0394: * are ignored, do not take part in the negotiation and are not
0395: * reflected in the resultant <code>NegotiableCapability</code> in the
0396: * event of a successful negotiation. If both the
0397: * <code>NegotiableCapability</code> objects are preferences, then
0398: * only the common parameters take part in the negotiation and the
0399: * ones that aren't present in both the <code>NegotiableCapability</code>s
0400: * are directly set on the resultant <code>NegotiableCapability</code>
0401: * object if the negotiation is successful on the common parameters.
0402: * For the common parameters, the <code>Class</code> types have to match,
0403: * otherwise the negotiation will fail. The check for the compatibility
0404: * of the <code>ParameterListDescriptor</code> of the supplied
0405: * <code>NegotiableCapability</code> with the current
0406: * <code>NegotiableCapability</code>'s <code>ParameterListDescriptor</code>
0407: * is done using the <code>areParameterListDescriptorsCompatible()</code>
0408: * method.
0409:
0410: * It may be noted that the <code>ParameterListDescriptor</code> of
0411: * the <code>NegotiableCapability</code> returned as a result of a
0412: * successful negotiation will implement the getParamDefaults() and
0413: * the getParamValueRange() methods in terms of the values returned
0414: * from the same methods on the <code>ParameterListDescriptor</code>
0415: * associated with this class, if the negotiation took place between
0416: * two preferences, or from the same methods on the
0417: * <code>ParameterListDescriptor</code> associated with the
0418: * non-preference otherwise.
0419: *
0420: * <p> If the supplied <code>NegotiableCapability</code> is null, then
0421: * the negotiation will fail and null will be returned.
0422: *
0423: * @param capability The <code>NegotiableCapability</code> to negotiate
0424: * with.
0425: * @returns the <code>NegotiableCapability</code> that is the result of a
0426: * successful negotiation, null if the negotiation failed.
0427: */
0428: public NegotiableCapability negotiate(
0429: NegotiableCapability capability) {
0430:
0431: if (capability == null) {
0432: return null;
0433: }
0434:
0435: if (capability.getCategory().equalsIgnoreCase(category) == false
0436: || capability.getCapabilityName().equalsIgnoreCase(
0437: capabilityName) == false) {
0438: // Negotiation failed
0439: return null;
0440: }
0441:
0442: // If the PLD's are not compatible for negotiation, fail the
0443: // negotiation
0444: if (areParameterListDescriptorsCompatible(capability) == false) {
0445: return null;
0446: }
0447:
0448: int negStatus;
0449: if (capability.isPreference() == true) {
0450: if (isPreference == true) {
0451: negStatus = 0;
0452: } else {
0453: negStatus = 1;
0454: }
0455: } else {
0456: if (isPreference == true) {
0457: negStatus = 2;
0458: } else {
0459: negStatus = 3;
0460: }
0461: }
0462:
0463: ParameterListDescriptor pld = getParameterListDescriptor();
0464: ParameterListDescriptor otherPld = capability
0465: .getParameterListDescriptor();
0466: String this Names[] = pld.getParamNames();
0467: if (this Names == null)
0468: this Names = new String[0];
0469: String otherNames[] = otherPld.getParamNames();
0470: if (otherNames == null)
0471: otherNames = new String[0];
0472: Hashtable this Hash = hashNames(this Names);
0473: Hashtable otherHash = hashNames(otherNames);
0474:
0475: Class this Classes[] = pld.getParamClasses();
0476: Class otherClasses[] = otherPld.getParamClasses();
0477: Object this Defaults[] = pld.getParamDefaults();
0478: Object otherDefaults[] = otherPld.getParamDefaults();
0479:
0480: NegotiableCapability result = null;
0481: String currParam;
0482: Negotiable this Value, otherValue, resultValue;
0483: ArrayList resultGenerators = new ArrayList();
0484: if (generators != null)
0485: resultGenerators.addAll(generators);
0486: if (capability.getGenerators() != null)
0487: resultGenerators.addAll(capability.getGenerators());
0488:
0489: switch (negStatus) {
0490:
0491: case 0:
0492:
0493: Vector commonNames = commonElements(this Hash, otherHash);
0494: Hashtable commonHash = hashNames(commonNames);
0495: Vector this Extras = removeAll(this Hash, commonHash);
0496: Vector otherExtras = removeAll(otherHash, commonHash);
0497:
0498: int this ExtraLength = this Extras.size();
0499: int otherExtraLength = otherExtras.size();
0500:
0501: // Create a new PLD which is the amalgamation of the two
0502: // NC's PLD's
0503: Vector resultParams = new Vector(commonNames);
0504: resultParams.addAll(this Extras);
0505: resultParams.addAll(otherExtras);
0506: int resultLength = resultParams.size();
0507: String resultNames[] = new String[resultLength];
0508: for (int i = 0; i < resultLength; i++) {
0509: resultNames[i] = (String) resultParams.elementAt(i);
0510: }
0511:
0512: Class resultClasses[] = new Class[resultLength];
0513: Object resultDefaults[] = new Object[resultLength];
0514: Object resultValidValues[] = new Object[resultLength];
0515: String name;
0516: int count;
0517: for (count = 0; count < commonNames.size(); count++) {
0518: name = (String) commonNames.elementAt(count);
0519: resultClasses[count] = this Classes[getIndex(this Hash,
0520: name)];
0521: resultDefaults[count] = this Defaults[getIndex(this Hash,
0522: name)];
0523: resultValidValues[count] = pld.getParamValueRange(name);
0524: }
0525: for (int i = 0; i < this ExtraLength; i++) {
0526: name = (String) this Extras.elementAt(i);
0527: resultClasses[count + i] = this Classes[getIndex(
0528: this Hash, name)];
0529: resultDefaults[count + i] = this Defaults[getIndex(
0530: this Hash, name)];
0531: resultValidValues[count + i] = pld
0532: .getParamValueRange(name);
0533: }
0534: count += this ExtraLength;
0535: for (int i = 0; i < otherExtraLength; i++) {
0536: name = (String) otherExtras.elementAt(i);
0537: resultClasses[i + count] = otherClasses[getIndex(
0538: otherHash, name)];
0539: resultDefaults[i + count] = otherDefaults[getIndex(
0540: otherHash, name)];
0541: resultValidValues[i + count] = otherPld
0542: .getParamValueRange(name);
0543: }
0544:
0545: ParameterListDescriptorImpl resultPLD = new ParameterListDescriptorImpl(
0546: null, resultNames, resultClasses, resultDefaults,
0547: resultValidValues);
0548:
0549: // Both NC's are preferences
0550: result = new NegotiableCapability(category, capabilityName,
0551: resultGenerators, resultPLD, true);
0552:
0553: for (int i = 0; i < commonNames.size(); i++) {
0554: currParam = (String) commonNames.elementAt(i);
0555: this Value = (Negotiable) getObjectParameter(currParam);
0556: otherValue = (Negotiable) capability
0557: .getObjectParameter(currParam);
0558:
0559: // If one of the values is null, select the other one, and
0560: // negotiation succeeds. Note that this also takes care
0561: // of the scenario when both are null, therefore the result
0562: // is null, and on a non-pref, this would have failed the
0563: // negotiation, but on a pref, it doesn't, so we just set
0564: // null (otherValue) as the result and allow negotiation to
0565: // succeed.
0566: if (this Value == null) {
0567: result.setParameter(currParam, otherValue);
0568: continue;
0569: }
0570:
0571: if (otherValue == null) {
0572: result.setParameter(currParam, this Value);
0573: continue;
0574: }
0575:
0576: // Following only gets executed if neither of the two is
0577: // a null, and therefore both have set values. If negotiation
0578: // fails, the negotiation as a whole is failed, otherwise
0579: // set the result on the resultant NC.
0580: resultValue = this Value.negotiate(otherValue);
0581: if (resultValue == null) {
0582: return null;
0583: }
0584:
0585: result.setParameter(currParam, resultValue);
0586: }
0587:
0588: // Copy the extra ones directly into the result
0589: for (int i = 0; i < this ExtraLength; i++) {
0590: currParam = (String) this Extras.elementAt(i);
0591: result.setParameter(currParam,
0592: (Negotiable) getObjectParameter(currParam));
0593: }
0594:
0595: for (int i = 0; i < otherExtraLength; i++) {
0596: currParam = (String) otherExtras.elementAt(i);
0597: result.setParameter(currParam, (Negotiable) capability
0598: .getObjectParameter(currParam));
0599: }
0600:
0601: break;
0602:
0603: case 1:
0604:
0605: // The given capability is a pref, while this is a non-pref
0606: commonNames = commonElements(this Hash, otherHash);
0607: commonHash = hashNames(commonNames);
0608: this Extras = removeAll(this Hash, commonHash);
0609:
0610: // Create a new PLD which is the amalgamation of the two
0611: // NC's PLD's
0612: resultParams = new Vector(commonNames);
0613: resultParams.addAll(this Extras);
0614: resultLength = resultParams.size();
0615: resultNames = new String[resultLength];
0616: for (int i = 0; i < resultLength; i++) {
0617: resultNames[i] = (String) resultParams.elementAt(i);
0618: }
0619:
0620: resultClasses = new Class[resultLength];
0621: resultDefaults = new Object[resultLength];
0622: resultValidValues = new Object[resultLength];
0623:
0624: count = 0;
0625: for (count = 0; count < commonNames.size(); count++) {
0626: name = (String) commonNames.elementAt(count);
0627: resultClasses[count] = this Classes[getIndex(this Hash,
0628: name)];
0629: resultDefaults[count] = this Defaults[getIndex(this Hash,
0630: name)];
0631: resultValidValues[count] = pld.getParamValueRange(name);
0632: }
0633: for (int i = 0; i < this Extras.size(); i++) {
0634: name = (String) this Extras.elementAt(i);
0635: resultClasses[i + count] = this Classes[getIndex(
0636: this Hash, name)];
0637: resultDefaults[i + count] = this Defaults[getIndex(
0638: this Hash, name)];
0639: resultValidValues[i + count] = pld
0640: .getParamValueRange(name);
0641: }
0642:
0643: resultPLD = new ParameterListDescriptorImpl(null,
0644: resultNames, resultClasses, resultDefaults,
0645: resultValidValues);
0646:
0647: result = new NegotiableCapability(category, capabilityName,
0648: resultGenerators, resultPLD, false);
0649:
0650: for (int i = 0; i < commonNames.size(); i++) {
0651: currParam = (String) commonNames.elementAt(i);
0652: this Value = (Negotiable) getObjectParameter(currParam);
0653: otherValue = (Negotiable) capability
0654: .getObjectParameter(currParam);
0655:
0656: if (this Value == null) {
0657: // If non-pref doesn't have value, negotiation fails right
0658: // away
0659: return null;
0660: }
0661:
0662: if (otherValue == null) {
0663: // If pref value is null, then non-pref's value wins.
0664: // This needs to be done separately, since
0665: // non-null.negotiate(null) returns null, which is *not*
0666: // what we want.
0667: result.setParameter(currParam, this Value);
0668: } else {
0669: // Do the negotiation.
0670: resultValue = this Value.negotiate(otherValue);
0671:
0672: if (resultValue == null) {
0673: // Negotiation on one parameter failed, so negotiation
0674: // on the entire NC has also failed, return null to
0675: // signify this
0676: return null;
0677: } else {
0678: result.setParameter(currParam, resultValue);
0679: }
0680: }
0681: }
0682:
0683: // Copy the extra ones directly into the result
0684: for (int i = 0; i < this Extras.size(); i++) {
0685: currParam = (String) this Extras.elementAt(i);
0686: resultValue = (Negotiable) getObjectParameter(currParam);
0687: if (resultValue == null)
0688: return null;
0689: result.setParameter(currParam, resultValue);
0690: }
0691:
0692: break;
0693:
0694: case 2:
0695:
0696: // The given capability is a non-pref, while this is a pref
0697: commonNames = commonElements(this Hash, otherHash);
0698: commonHash = hashNames(commonNames);
0699: otherExtras = removeAll(otherHash, commonHash);
0700:
0701: // Create a new PLD which is the amalgamation of the two
0702: // NC's PLD's
0703: resultParams = new Vector(commonNames);
0704: resultParams.addAll(otherExtras);
0705: resultLength = resultParams.size();
0706: resultNames = new String[resultLength];
0707: for (int i = 0; i < resultLength; i++) {
0708: resultNames[i] = (String) resultParams.elementAt(i);
0709: }
0710:
0711: resultClasses = new Class[resultLength];
0712: resultDefaults = new Object[resultLength];
0713: resultValidValues = new Object[resultLength];
0714: count = 0;
0715: for (count = 0; count < commonNames.size(); count++) {
0716: name = (String) commonNames.elementAt(count);
0717: resultClasses[count] = this Classes[getIndex(this Hash,
0718: name)];
0719: resultDefaults[count] = this Defaults[getIndex(this Hash,
0720: name)];
0721: resultValidValues[count] = pld.getParamValueRange(name);
0722: }
0723:
0724: for (int i = 0; i < otherExtras.size(); i++) {
0725: name = (String) otherExtras.elementAt(i);
0726: resultClasses[i + count] = otherClasses[getIndex(
0727: otherHash, name)];
0728: resultDefaults[i + count] = otherDefaults[getIndex(
0729: otherHash, name)];
0730: resultValidValues[i + count] = otherPld
0731: .getParamValueRange(name);
0732: }
0733:
0734: resultPLD = new ParameterListDescriptorImpl(null,
0735: resultNames, resultClasses, resultDefaults,
0736: resultValidValues);
0737:
0738: result = new NegotiableCapability(category, capabilityName,
0739: resultGenerators, resultPLD, false);
0740:
0741: for (int i = 0; i < commonNames.size(); i++) {
0742: currParam = (String) commonNames.elementAt(i);
0743: this Value = (Negotiable) getObjectParameter(currParam);
0744: otherValue = (Negotiable) capability
0745: .getObjectParameter(currParam);
0746:
0747: // If non-pref doesn't have value, negotiation fails right
0748: // away
0749: if (otherValue == null) {
0750: return null;
0751: }
0752:
0753: if (this Value == null) {
0754: // If pref value is null, then non-pref's value wins.
0755: // This needs to be done separately, since
0756: // non-null.negotiate(null) returns null, which is *not*
0757: // what we want.
0758: result.setParameter(currParam, otherValue);
0759: } else {
0760: // Do the negotiation.
0761: resultValue = otherValue.negotiate(this Value);
0762:
0763: if (resultValue == null) {
0764: // Negotiation on one parameter failed, so negotiation
0765: // on the entire NC has also failed, return null to
0766: // signify this
0767: return null;
0768: } else {
0769: result.setParameter(currParam, resultValue);
0770: }
0771: }
0772: }
0773:
0774: for (int i = 0; i < otherExtras.size(); i++) {
0775: currParam = (String) otherExtras.elementAt(i);
0776: resultValue = (Negotiable) capability
0777: .getObjectParameter(currParam);
0778: if (resultValue == null)
0779: return null;
0780: result.setParameter(currParam, resultValue);
0781: }
0782:
0783: break;
0784:
0785: case 3:
0786:
0787: // Both are non-prefs
0788: result = new NegotiableCapability(category, capabilityName,
0789: resultGenerators, pld, false);
0790:
0791: for (int i = 0; i < this Names.length; i++) {
0792: currParam = this Names[i];
0793: this Value = (Negotiable) getObjectParameter(currParam);
0794: otherValue = (Negotiable) capability
0795: .getObjectParameter(currParam);
0796:
0797: // failed since in nonpref-nonpref negotiation, both
0798: // Negotiables must have a non-null value
0799: if (this Value == null || otherValue == null) {
0800: return null;
0801: }
0802:
0803: resultValue = this Value.negotiate(otherValue);
0804:
0805: if (resultValue == null) {
0806: // Negotiation on one parameter failed, so negotiation
0807: // on the entire NC has also failed, return null to
0808: // signify this
0809: return null;
0810: } else {
0811: result.setParameter(currParam, resultValue);
0812: }
0813: }
0814:
0815: break;
0816: }
0817:
0818: return result;
0819: }
0820:
0821: /**
0822: * Returns true if the <code>ParameterListDescriptor</code> of the
0823: * supplied <code>NegotiableCapability</code> is compatible with the
0824: * <code>ParameterListDescriptor</code> of this class for negotiation
0825: * purposes. If both the <code>NegotiableCapability</code> objects are
0826: * non-preferences, both the number of parameters as well as the
0827: * <code>Class</code> type of the parameters has to match for this
0828: * method to return true. If either one or both of the
0829: * <code>NegotiableCapability</code> objects is a preference, then
0830: * the <code>Class</code> type of the same named parameters in both
0831: * the <code>NegotiableCapability</code> object's
0832: * <code>ParameterListDescriptor</code>s has to match for this
0833: * method to return true.
0834: *
0835: * @param other The <code>NegotiableCapability</code> to check
0836: * compatibility for negotiation purposes for.
0837: * @throws IllegalArgumentException if other is null.
0838: */
0839: public boolean areParameterListDescriptorsCompatible(
0840: NegotiableCapability other) {
0841:
0842: if (other == null) {
0843: throw new IllegalArgumentException(JaiI18N
0844: .getString("NegotiableCapability6"));
0845: }
0846:
0847: ParameterListDescriptor this Desc = getParameterListDescriptor();
0848: ParameterListDescriptor otherDesc = other
0849: .getParameterListDescriptor();
0850:
0851: String this Names[] = this Desc.getParamNames();
0852: if (this Names == null)
0853: this Names = new String[0];
0854: String otherNames[] = otherDesc.getParamNames();
0855: if (otherNames == null)
0856: otherNames = new String[0];
0857: Hashtable this Hash = hashNames(this Names);
0858: Hashtable otherHash = hashNames(otherNames);
0859:
0860: if (isPreference == false && other.isPreference() == false) {
0861:
0862: // The number of parameters must be the same.
0863: if (this Desc.getNumParameters() != otherDesc
0864: .getNumParameters())
0865: return false;
0866:
0867: // The same names should be present in both in the same order.
0868: if (containsAll(this Hash, otherHash) == false)
0869: return false;
0870:
0871: Class this ParamClasses[] = this Desc.getParamClasses();
0872: Class otherParamClasses[] = otherDesc.getParamClasses();
0873: for (int i = 0; i < this Names.length; i++) {
0874: if (this ParamClasses[i] != otherParamClasses[getIndex(
0875: otherHash, this Names[i])])
0876: return false;
0877: }
0878:
0879: return true;
0880:
0881: } else {
0882:
0883: Vector commonNames = commonElements(this Hash, otherHash);
0884:
0885: Class this ParamClasses[] = this Desc.getParamClasses();
0886: Class otherParamClasses[] = otherDesc.getParamClasses();
0887: String currName;
0888: for (int i = 0; i < commonNames.size(); i++) {
0889: currName = (String) commonNames.elementAt(i);
0890: if (this ParamClasses[getIndex(this Hash, currName)] != otherParamClasses[getIndex(
0891: otherHash, currName)])
0892: return false;
0893: }
0894:
0895: return true;
0896: }
0897: }
0898:
0899: // A case insensitive containsAll for Hashtables containing Strings
0900: private boolean containsAll(Hashtable this Hash, Hashtable otherHash) {
0901:
0902: CaselessStringKey this NameKey;
0903: for (Enumeration i = this Hash.keys(); i.hasMoreElements();) {
0904: this NameKey = (CaselessStringKey) i.nextElement();
0905: if (otherHash.containsKey(this NameKey) == false)
0906: return false;
0907: }
0908:
0909: return true;
0910: }
0911:
0912: // Return only those names which exist in thisNames but not in otherNames
0913: private Vector removeAll(Hashtable this Hash, Hashtable otherHash) {
0914:
0915: Vector v = new Vector();
0916: CaselessStringKey this NameKey;
0917: for (Enumeration i = this Hash.keys(); i.hasMoreElements();) {
0918: this NameKey = (CaselessStringKey) i.nextElement();
0919: if (otherHash.containsKey(this NameKey))
0920: continue;
0921: else
0922: v.add(this NameKey.toString());
0923: }
0924:
0925: return v;
0926: }
0927:
0928: private int getIndex(Hashtable h, String s) {
0929: return ((Integer) h.get(new CaselessStringKey(s))).intValue();
0930: }
0931:
0932: private Vector commonElements(Hashtable this Hash,
0933: Hashtable otherHash) {
0934:
0935: Vector v = new Vector();
0936: CaselessStringKey this NameKey;
0937: for (Enumeration i = this Hash.keys(); i.hasMoreElements();) {
0938: this NameKey = (CaselessStringKey) i.nextElement();
0939: if (otherHash.containsKey(this NameKey))
0940: v.add(this NameKey.toString());
0941: }
0942:
0943: return v;
0944: }
0945:
0946: private Hashtable hashNames(String paramNames[]) {
0947:
0948: Hashtable h = new Hashtable();
0949: if (paramNames != null) {
0950: for (int i = 0; i < paramNames.length; i++) {
0951: h.put(new CaselessStringKey(paramNames[i]),
0952: new Integer(i));
0953: }
0954: }
0955:
0956: return h;
0957: }
0958:
0959: private Hashtable hashNames(Vector paramNames) {
0960:
0961: Hashtable h = new Hashtable();
0962: if (paramNames != null) {
0963: for (int i = 0; i < paramNames.size(); i++) {
0964: h.put(new CaselessStringKey((String) (paramNames
0965: .elementAt(i))), new Integer(i));
0966: }
0967: }
0968:
0969: return h;
0970: }
0971:
0972: /***************** Overridden methods from ParameterList *****************/
0973:
0974: /**
0975: * Overrides the method in <code>ParameterListImpl</code> to throw
0976: * an IllegalArgumentException since parameter values set on this class
0977: * must be a <code>Negotiable</code>.
0978: *
0979: * @param paramName a <code>String</code> naming a parameter.
0980: * @param b a <code>byte</code> value for the parameter.
0981: *
0982: * @throws IllegalArgumentException since the value being set is not a
0983: * <code>Negotiable</code>.
0984: */
0985: public ParameterList setParameter(String paramName, byte b) {
0986: throw new IllegalArgumentException(JaiI18N
0987: .getString("NegotiableCapability2"));
0988: }
0989:
0990: /**
0991: * Overrides the method in <code>ParameterListImpl</code> to throw
0992: * an IllegalArgumentException since parameter values set on this class
0993: * must be a <code>Negotiable</code>.
0994: *
0995: * @param paramName a <code>String</code> naming a parameter.
0996: * @param b a <code>boolean</code> value for the parameter.
0997: *
0998: * @throws IllegalArgumentException since the value being set is not a
0999: * <code>Negotiable</code>.
1000: */
1001: public ParameterList setParameter(String paramName, boolean b) {
1002: throw new IllegalArgumentException(JaiI18N
1003: .getString("NegotiableCapability2"));
1004: }
1005:
1006: /**
1007: * Overrides the method in <code>ParameterListImpl</code> to throw
1008: * an IllegalArgumentException since parameter values set on this class
1009: * must be a <code>Negotiable</code>.
1010: *
1011: * @param paramName a <code>String</code> naming a parameter.
1012: * @param c a <code>char</code> value for the parameter.
1013: *
1014: * @throws IllegalArgumentException since the value being set is not a
1015: * <code>Negotiable</code>.
1016: */
1017: public ParameterList setParameter(String paramName, char c) {
1018: throw new IllegalArgumentException(JaiI18N
1019: .getString("NegotiableCapability2"));
1020: }
1021:
1022: /**
1023: * Overrides the method in <code>ParameterListImpl</code> to throw
1024: * an IllegalArgumentException since parameter values set on this class
1025: * must be a <code>Negotiable</code>.
1026: *
1027: * @param paramName a <code>String</code> naming a parameter.
1028: * @param s a short value for the parameter.
1029: *
1030: * @throws IllegalArgumentException since the value being set is not a
1031: * <code>Negotiable</code>.
1032: */
1033: public ParameterList setParameter(String paramName, short s) {
1034: throw new IllegalArgumentException(JaiI18N
1035: .getString("NegotiableCapability2"));
1036: }
1037:
1038: /**
1039: * Overrides the method in <code>ParameterListImpl</code> to throw
1040: * an IllegalArgumentException since parameter values set on this class
1041: * must be a <code>Negotiable</code>.
1042: *
1043: * @param paramName a <code>String</code> naming a parameter.
1044: * @param i an <code>int</code> value for the parameter.
1045: *
1046: * @throws IllegalArgumentException since the value being set is not a
1047: * <code>Negotiable</code>.
1048: */
1049: public ParameterList setParameter(String paramName, int i) {
1050: throw new IllegalArgumentException(JaiI18N
1051: .getString("NegotiableCapability2"));
1052: }
1053:
1054: /**
1055: * Overrides the method in <code>ParameterListImpl</code> to throw
1056: * an IllegalArgumentException since parameter values set on this class
1057: * must be a <code>Negotiable</code>.
1058: *
1059: * @param paramName a <code>String</code> naming a parameter.
1060: * @param l a <code>long</code> value for the parameter.
1061: *
1062: * @throws IllegalArgumentException since the value being set is not a
1063: * <code>Negotiable</code>.
1064: */
1065: public ParameterList setParameter(String paramName, long l) {
1066: throw new IllegalArgumentException(JaiI18N
1067: .getString("NegotiableCapability2"));
1068: }
1069:
1070: /**
1071: * Overrides the method in <code>ParameterListImpl</code> to throw
1072: * an IllegalArgumentException since parameter values set on this class
1073: * must be a <code>Negotiable</code>.
1074: *
1075: * @param paramName a <code>String</code> naming a parameter.
1076: * @param f a <code>float</code> value for the parameter.
1077: *
1078: * @throws IllegalArgumentException since the value being set is not a
1079: * <code>Negotiable</code>.
1080: */
1081: public ParameterList setParameter(String paramName, float f) {
1082: throw new IllegalArgumentException(JaiI18N
1083: .getString("NegotiableCapability2"));
1084: }
1085:
1086: /**
1087: * Overrides the method in <code>ParameterListImpl</code> to throw
1088: * an IllegalArgumentException since parameter values set on this class
1089: * must be a <code>Negotiable</code>.
1090: *
1091: * @param paramName a <code>String</code> naming a parameter.
1092: * @param d a <code>double</code> value for the parameter.
1093: *
1094: * @throws IllegalArgumentException since the value being set is not a
1095: * <code>Negotiable</code>.
1096: */
1097: public ParameterList setParameter(String paramName, double d) {
1098: throw new IllegalArgumentException(JaiI18N
1099: .getString("NegotiableCapability2"));
1100: }
1101:
1102: /**
1103: * Overrides the superclass method to ensure only a <code>Negotiable</code>
1104: * object can be added as the value of the parameter.
1105: *
1106: * @param paramName A <code>String</code> naming a parameter.
1107: * @param obj An Object value for the parameter.
1108: *
1109: * @throws IllegalArgumentException if obj is not an instance of
1110: * <code>Negotiable</code>.
1111: */
1112: public ParameterList setParameter(String paramName, Object obj) {
1113:
1114: if (obj != null && !(obj instanceof Negotiable)) {
1115: throw new IllegalArgumentException(JaiI18N
1116: .getString("NegotiableCapability2"));
1117: }
1118:
1119: super .setParameter(paramName, obj);
1120: return this ;
1121: }
1122:
1123: // getObjectParameter method doesn't need to be overridden since it
1124: // is implemented in ParameterListImpl and can return a Negotiable as
1125: // an Object
1126:
1127: /**
1128: * Overrides the method in <code>ParameterListImpl</code> to throw
1129: * an IllegalArgumentException since parameter values in this class
1130: * are <code>Negotiable</code> and therefore cannot be returned as
1131: * a primitive data type.
1132: *
1133: * @param paramName the name of the parameter to be returned.
1134: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1135: * cannot be returned as a primitive data type.
1136: */
1137: public byte getByteParameter(String paramName) {
1138: throw new IllegalArgumentException(JaiI18N
1139: .getString("NegotiableCapability3"));
1140: }
1141:
1142: /**
1143: * Overrides the method in <code>ParameterListImpl</code> to throw
1144: * an IllegalArgumentException since parameter values in this class
1145: * are <code>Negotiable</code> and therefore cannot be returned as
1146: * a primitive data type.
1147: *
1148: * @param paramName the name of the parameter to be returned.
1149: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1150: * cannot be returned as a primitive data type.
1151: */
1152: public boolean getBooleanParameter(String paramName) {
1153: throw new IllegalArgumentException(JaiI18N
1154: .getString("NegotiableCapability3"));
1155: }
1156:
1157: /**
1158: * Overrides the method in <code>ParameterListImpl</code> to throw
1159: * an IllegalArgumentException since parameter values in this class
1160: * are <code>Negotiable</code> and therefore cannot be returned as
1161: * a primitive data type.
1162: *
1163: * @param paramName the name of the parameter to be returned.
1164: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1165: * cannot be returned as a primitive data type.
1166: */
1167: public char getCharParameter(String paramName) {
1168: throw new IllegalArgumentException(JaiI18N
1169: .getString("NegotiableCapability3"));
1170: }
1171:
1172: /**
1173: * Overrides the method in <code>ParameterListImpl</code> to throw
1174: * an IllegalArgumentException since parameter values in this class
1175: * are <code>Negotiable</code> and therefore cannot be returned as
1176: * a primitive data type.
1177: *
1178: * @param paramName the name of the parameter to be returned.
1179: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1180: * cannot be returned as a primitive data type.
1181: */
1182: public short getShortParameter(String paramName) {
1183: throw new IllegalArgumentException(JaiI18N
1184: .getString("NegotiableCapability3"));
1185: }
1186:
1187: /**
1188: * Overrides the method in <code>ParameterListImpl</code> to throw
1189: * an IllegalArgumentException since parameter values in this class
1190: * are <code>Negotiable</code> and therefore cannot be returned as
1191: * a primitive data type.
1192: *
1193: * @param paramName the name of the parameter to be returned.
1194: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1195: * cannot be returned as a primitive data type.
1196: */
1197: public int getIntParameter(String paramName) {
1198: throw new IllegalArgumentException(JaiI18N
1199: .getString("NegotiableCapability3"));
1200: }
1201:
1202: /**
1203: * Overrides the method in <code>ParameterListImpl</code> to throw
1204: * an IllegalArgumentException since parameter values in this class
1205: * are <code>Negotiable</code> and therefore cannot be returned as
1206: * a primitive data type.
1207: *
1208: * @param paramName the name of the parameter to be returned.
1209: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1210: * cannot be returned as a primitive data type.
1211: */
1212: public long getLongParameter(String paramName) {
1213: throw new IllegalArgumentException(JaiI18N
1214: .getString("NegotiableCapability3"));
1215: }
1216:
1217: /**
1218: * Overrides the method in <code>ParameterListImpl</code> to throw
1219: * an IllegalArgumentException since parameter values in this class
1220: * are <code>Negotiable</code> and therefore cannot be returned as
1221: * a primitive data type.
1222: *
1223: * @param paramName the name of the parameter to be returned.
1224: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1225: * cannot be returned as a primitive data type.
1226: */
1227: public float getFloatParameter(String paramName) {
1228: throw new IllegalArgumentException(JaiI18N
1229: .getString("NegotiableCapability3"));
1230: }
1231:
1232: /**
1233: * Overrides the method in <code>ParameterListImpl</code> to throw
1234: * an IllegalArgumentException since parameter values in this class
1235: * are <code>Negotiable</code> and therefore cannot be returned as
1236: * a primitive data type.
1237: *
1238: * @param paramName the name of the parameter to be returned.
1239: * @throws IllegalArgumentException since a <code>Negotiable</code> value
1240: * cannot be returned as a primitive data type.
1241: */
1242: public double getDoubleParameter(String paramName) {
1243: throw new IllegalArgumentException(JaiI18N
1244: .getString("NegotiableCapability3"));
1245: }
1246: }
|