001: /*
002: * $RCSfile: TileCodecParameterList.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:57:55 $
010: * $State: Exp $
011: */package javax.media.jai.tilecodec;
012:
013: import javax.media.jai.ParameterListDescriptor;
014: import javax.media.jai.ParameterListImpl;
015:
016: /**
017: * A subclass of <code>ParameterListImpl</code> that is specific to
018: * tile codecs. This class functions in either one or both of the two
019: * registry modes supported by the <code>TileCodecDescriptor</code>
020: * - "tileEncoder" and "tileDecoder".
021: *
022: * <p> This class is not intended to be subclassed for each individual
023: * <code>TileEncoder</code> or <code>TileDecoder</code>. This is a generic
024: * class which can be used as is for representing a parameter list for
025: * any tile encoding/decoding format. The <code>ParameterListDescriptor</code>
026: * provided as argument to the constructor should be the one returned from
027: * the <code>getParameterListDescriptor()</code> method of the
028: * <code>TileCodecDescriptor</code> for the given format name.
029: *
030: * <p> If the associated <code>TileCodecDescriptor</code>'s
031: * <code>includesSampleModelInfo()</code> method returns false, then for the
032: * "tileDecoder" mode, this class will be expected to contain a parameter
033: * named "sampleModel" with a non-null <code>SampleModel</code> as its value.
034: *
035: * @since JAI 1.1
036: */
037: public class TileCodecParameterList extends ParameterListImpl {
038:
039: // The name of the format
040: private String formatName;
041:
042: // The modes valid for this class
043: private String validModes[];
044:
045: /**
046: * Creates a <code>TileCodecParameterList</code>. The
047: * <code>validModes</code> argument specifies the registry modes valid
048: * for this <code>TileCodecParameterList</code>. This should contain
049: * the "tileEncoder" registry mode or the "tileDecoder" registry
050: * mode or both. The supplied descriptor object specifies the names
051: * and number of the valid parameters, their <code>Class</code> types,
052: * as well as the <code>Range</code> of valid values for each parameter.
053: *
054: * @param formatName The name of the format, parameters for which are
055: * specified through this parameter list.
056: * @param validModes An array of <code>String</code> objects specifying
057: * which registry modes are valid for this parameter list.
058: * @param descriptor The <code>ParameterListDescriptor</code> object that
059: * describes all valid parameters for this format. This
060: * must be the the same descriptor that is returned from
061: * the <code>getParameterListDescriptor()</code> method of
062: * the <code>TileCodecDescriptor</code> for the given
063: * formatName.
064: *
065: * @throws IllegalArgumentException if formatName is null.
066: * @throws IllegalArgumentException if validModes is null.
067: * @throws IllegalArgumentException if descriptor is null.
068: */
069: public TileCodecParameterList(String formatName,
070: String validModes[], ParameterListDescriptor descriptor) {
071: super (descriptor);
072:
073: // Cause IllegalArgumentException to be thrown if any of the
074: // arguments is null.
075: if (formatName == null) {
076: throw new IllegalArgumentException(JaiI18N
077: .getString("TileCodecDescriptorImpl0"));
078: }
079:
080: if (validModes == null) {
081: throw new IllegalArgumentException(JaiI18N
082: .getString("TileCodecParameterList0"));
083: }
084:
085: if (descriptor == null) {
086: throw new IllegalArgumentException(JaiI18N
087: .getString("TileCodecParameterList1"));
088: }
089:
090: this .formatName = formatName;
091: this .validModes = validModes;
092: }
093:
094: /**
095: * Returns the name of the format which this parameter list describes.
096: */
097: public String getFormatName() {
098: return formatName;
099: }
100:
101: /**
102: * Returns true if the parameters in this
103: * <code>TileCodecParameterList</code> are valid for the specified
104: * registry mode name, false otherwise. The valid modes for
105: * this class are the "tileEncoder" registry mode, and the
106: * "tileDecoder" registry mode.
107: */
108: public boolean isValidForMode(String registryModeName) {
109: for (int i = 0; i < validModes.length; i++) {
110: if (validModes[i].equalsIgnoreCase(registryModeName)) {
111: return true;
112: }
113: }
114:
115: return false;
116: }
117:
118: /**
119: * Returns all the modes that this <code>TileCodecParameterList</code>
120: * is valid for, as a <code>String</code> array.
121: */
122: public String[] getValidModes() {
123: return (String[]) validModes.clone();
124: }
125: }
|