001 /*
002 *
003 * $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
004 *
005 * This file is part of *** M y C o R e ***
006 * See http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, in a file called gpl.txt or license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 */
023
024 package org.mycore.datamodel.ifs;
025
026 /**
027 * Instances of this class represent information about the content type of a
028 * file.
029 *
030 * @author Frank Lützenkirchen
031 */
032 public class MCRFileContentType {
033 /** The unique ID of this file content type */
034 protected String ID;
035
036 /** The label of this file content type */
037 protected String label;
038
039 /** The URL where information such as a plug-in download page can be found */
040 protected String url;
041
042 /** The MIME type used to deliver this file type to a client browser */
043 protected String mimeType;
044
045 /**
046 * Constructs a new file content type instance. The list of known file
047 * content types is defined in an XML file that is specified in the property
048 * MCR.IFS.FileContentTypes.DefinitionFile, and that file is searched in the
049 * CLASSPATH directories or JAR files and parsed by
050 * MCRFileContentTypeFactory.
051 *
052 * @see MCRFileContentTypeFactory
053 *
054 * @param ID
055 * the unique content type ID
056 * @param label
057 * the label of this content type
058 * @param url
059 * the url where information like a plug-in can be found
060 * @param mimeType
061 * the MIME type used for this content type
062 */
063 MCRFileContentType(String ID, String label, String url, String mimeType) {
064 this.ID = ID;
065 this.label = label;
066 this.url = url;
067 this.mimeType = mimeType;
068 }
069
070 /**
071 * Returns the unique ID of this file content type
072 *
073 * @return the unique ID of this file content type
074 */
075 public String getID() {
076 return this.ID;
077 }
078
079 /**
080 * Returns the label of this file content type
081 *
082 * @return the label of this file content type
083 *
084 */
085 public String getLabel() {
086 return this.label;
087 }
088
089 /**
090 * Returns the MIME type used to deliver this file type to a client browser.
091 * If no MIME type is set, the default type "application/octet-stream" for
092 * binary content is returned.
093 *
094 * @return the MIME type used to deliver this file type to a client browser
095 */
096 public String getMimeType() {
097 return ((mimeType != null) ? mimeType : "application/octet-stream");
098 }
099
100 /**
101 * Returns the URL where additional information like a plug-in download page
102 * can be found
103 *
104 * @return the URL of additional information, or null
105 */
106 public String getURL() {
107 return this.url;
108 }
109
110 public String toString() {
111 StringBuffer sb = new StringBuffer();
112 sb.append("ID = ").append(this.getID()).append("\n");
113 sb.append("label = ").append(this.getLabel()).append("\n");
114 sb.append("mime = ").append(this.getMimeType()).append("\n");
115 sb.append("url = ").append(this.getURL());
116
117 return sb.toString();
118 }
119 }