001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Rustem V. Rafikov
019: * @version $Revision: 1.3 $
020: */package javax.imageio.spi;
021:
022: import org.apache.harmony.x.imageio.metadata.IIOMetadataUtils;
023:
024: import javax.imageio.metadata.IIOMetadataFormat;
025:
026: public abstract class ImageReaderWriterSpi extends IIOServiceProvider
027: implements RegisterableService {
028:
029: protected String[] names;
030: protected String[] suffixes;
031: protected String[] MIMETypes;
032: protected String pluginClassName;
033: protected boolean supportsStandardStreamMetadataFormat;
034: protected String nativeStreamMetadataFormatName;
035: protected String nativeStreamMetadataFormatClassName;
036: protected String[] extraStreamMetadataFormatNames;
037: protected String[] extraStreamMetadataFormatClassNames;
038: protected boolean supportsStandardImageMetadataFormat;
039: protected String nativeImageMetadataFormatName;
040: protected String nativeImageMetadataFormatClassName;
041: protected String[] extraImageMetadataFormatNames;
042: protected String[] extraImageMetadataFormatClassNames;
043:
044: public ImageReaderWriterSpi(String vendorName, String version,
045: String[] names, String[] suffixes, String[] MIMETypes,
046: String pluginClassName,
047: boolean supportsStandardStreamMetadataFormat,
048: String nativeStreamMetadataFormatName,
049: String nativeStreamMetadataFormatClassName,
050: String[] extraStreamMetadataFormatNames,
051: String[] extraStreamMetadataFormatClassNames,
052: boolean supportsStandardImageMetadataFormat,
053: String nativeImageMetadataFormatName,
054: String nativeImageMetadataFormatClassName,
055: String[] extraImageMetadataFormatNames,
056: String[] extraImageMetadataFormatClassNames) {
057: super (vendorName, version);
058:
059: if (names == null || names.length == 0) {
060: throw new NullPointerException(
061: "format names array cannot be NULL or empty");
062: }
063:
064: if (pluginClassName == null) {
065: throw new NullPointerException(
066: "Plugin class name cannot be NULL");
067: }
068:
069: // We clone all the arrays to be consistent with the fact that
070: // some methods of this class must return clones of the arrays
071: // as it is stated in the spec.
072: this .names = names.clone();
073: this .suffixes = suffixes == null ? null : suffixes.clone();
074: this .MIMETypes = MIMETypes == null ? null : MIMETypes.clone();
075: this .pluginClassName = pluginClassName;
076: this .supportsStandardStreamMetadataFormat = supportsStandardStreamMetadataFormat;
077: this .nativeStreamMetadataFormatName = nativeStreamMetadataFormatName;
078: this .nativeStreamMetadataFormatClassName = nativeStreamMetadataFormatClassName;
079:
080: this .extraStreamMetadataFormatNames = extraStreamMetadataFormatNames == null ? null
081: : extraStreamMetadataFormatNames.clone();
082:
083: this .extraStreamMetadataFormatClassNames = extraStreamMetadataFormatClassNames == null ? null
084: : extraStreamMetadataFormatClassNames.clone();
085:
086: this .supportsStandardImageMetadataFormat = supportsStandardImageMetadataFormat;
087: this .nativeImageMetadataFormatName = nativeImageMetadataFormatName;
088: this .nativeImageMetadataFormatClassName = nativeImageMetadataFormatClassName;
089:
090: this .extraImageMetadataFormatNames = extraImageMetadataFormatNames == null ? null
091: : extraImageMetadataFormatNames.clone();
092:
093: this .extraImageMetadataFormatClassNames = extraImageMetadataFormatClassNames == null ? null
094: : extraImageMetadataFormatClassNames.clone();
095: }
096:
097: public ImageReaderWriterSpi() {
098: }
099:
100: public String[] getFormatNames() {
101: return names.clone();
102: }
103:
104: public String[] getFileSuffixes() {
105: return suffixes == null ? null : suffixes.clone();
106: }
107:
108: public String[] getExtraImageMetadataFormatNames() {
109: return extraImageMetadataFormatNames == null ? null
110: : extraImageMetadataFormatNames.clone();
111: }
112:
113: public String[] getExtraStreamMetadataFormatNames() {
114: return extraStreamMetadataFormatNames == null ? null
115: : extraStreamMetadataFormatNames.clone();
116: }
117:
118: public IIOMetadataFormat getImageMetadataFormat(String formatName) {
119: return IIOMetadataUtils.instantiateMetadataFormat(formatName,
120: supportsStandardImageMetadataFormat,
121: nativeImageMetadataFormatName,
122: nativeImageMetadataFormatClassName,
123: extraImageMetadataFormatNames,
124: extraImageMetadataFormatClassNames);
125: }
126:
127: public IIOMetadataFormat getStreamMetadataFormat(String formatName) {
128: return IIOMetadataUtils.instantiateMetadataFormat(formatName,
129: supportsStandardStreamMetadataFormat,
130: nativeStreamMetadataFormatName,
131: nativeStreamMetadataFormatClassName,
132: extraStreamMetadataFormatNames,
133: extraStreamMetadataFormatClassNames);
134: }
135:
136: public String[] getMIMETypes() {
137: return MIMETypes == null ? null : MIMETypes.clone();
138: }
139:
140: public String getNativeImageMetadataFormatName() {
141: return nativeImageMetadataFormatName;
142: }
143:
144: public String getNativeStreamMetadataFormatName() {
145: return nativeStreamMetadataFormatName;
146: }
147:
148: public String getPluginClassName() {
149: return pluginClassName;
150: }
151:
152: public boolean isStandardImageMetadataFormatSupported() {
153: return supportsStandardImageMetadataFormat;
154: }
155:
156: public boolean isStandardStreamMetadataFormatSupported() {
157: return supportsStandardStreamMetadataFormat;
158: }
159: }
|