KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > MimeMappingDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  package com.sun.enterprise.deployment;
24
25 import com.sun.enterprise.deployment.web.MimeMapping;
26 import java.io.Serializable JavaDoc;
27
28     /*** I represent a mapping between a mime type and a file extension for specifiying how
29     * to handle mime types in a J2EE WAR.
30     *@author Danny Coward
31     */

32
33 public class MimeMappingDescriptor implements MimeMapping, Serializable JavaDoc {
34     private String JavaDoc extension;
35     private String JavaDoc mimeType;
36     
37     /** copy constructor */
38     public MimeMappingDescriptor(MimeMappingDescriptor other) {
39     // super(other);
40
extension = other.extension;
41     mimeType = other.mimeType;
42     }
43
44     /** Construct the mapping for the given extension to the given mime type. */
45     public MimeMappingDescriptor(String JavaDoc extension, String JavaDoc mimeType) {
46     this.extension = extension;
47     this.mimeType = mimeType;
48     }
49     
50     /* Default constructor. */
51     public MimeMappingDescriptor() {
52     }
53
54     /** Return the filename extension for this mapping. */
55     public String JavaDoc getExtension() {
56     if (this.extension == null) {
57         this.extension = "";
58     }
59     return this.extension;
60     }
61     
62     /** Set the filename extension for this mapping. */
63     public void setExtension(String JavaDoc extension) {
64     this.extension = extension;
65     }
66     
67     /** Get the mime type for this mapping. */
68     public String JavaDoc getMimeType() {
69     if (this.mimeType == null) {
70         this.mimeType = "";
71     }
72     return this.mimeType;
73     }
74     /** Set the mime type for this mapping. */
75     public void setMimeType(String JavaDoc mimeType) {
76     this.mimeType = mimeType;
77     }
78     /** My pretty format. */
79     public void print(StringBuffer JavaDoc toStringBuffer) {
80     toStringBuffer.append("MimeMapping: ").append(this.getExtension()).append("@").append(this.getMimeType());
81     }
82
83 }
84
Popular Tags