01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.export;
18:
19: /**
20: * A type-safe enumeration representing a format for data export. Currently the only
21: * implemented format is XML.
22: *
23: * @see ExportDataSet
24: * @see Exporter
25: *
26: * @author ewestfal
27: */
28: public class ExportFormat {
29:
30: private static final String XML_FORMAT = "XML";
31: private static final String XML_EXT = ".xml";
32: private static final String XML_MIME = "application/xml";
33:
34: public static final ExportFormat XML = new ExportFormat(XML_FORMAT,
35: XML_EXT, XML_MIME);
36:
37: private final String formatName;
38: private final String extension;
39: private final String mimeType;
40:
41: private ExportFormat(String formatName, String extension,
42: String mimeType) {
43: this .formatName = formatName;
44: this .extension = extension;
45: this .mimeType = mimeType;
46: }
47:
48: public String getFormatName() {
49: return formatName;
50: }
51:
52: public String getExtension() {
53: return extension;
54: }
55:
56: public String getMimeType() {
57: return mimeType;
58: }
59:
60: public static ExportFormat getFormatForName(String formatName) {
61: if (formatName.equals(XML.getFormatName())) {
62: return XML;
63: }
64: return null;
65: }
66:
67: public boolean equals(Object object) {
68: if (object instanceof ExportFormat) {
69: return formatName
70: .equals(((ExportFormat) object).formatName);
71: }
72: return false;
73: }
74:
75: public int hashCode() {
76: return formatName.hashCode();
77: }
78:
79: public String toString() {
80: return formatName;
81: }
82:
83: }
|