001: /*
002: * Copyright (c) 2002-2008 Gargoyle Software Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: * 2. Redistributions in binary form must reproduce the above copyright notice,
010: * this list of conditions and the following disclaimer in the documentation
011: * and/or other materials provided with the distribution.
012: * 3. The end-user documentation included with the redistribution, if any, must
013: * include the following acknowledgment:
014: *
015: * "This product includes software developed by Gargoyle Software Inc.
016: * (http://www.GargoyleSoftware.com/)."
017: *
018: * Alternately, this acknowledgment may appear in the software itself, if
019: * and wherever such third-party acknowledgments normally appear.
020: * 4. The name "Gargoyle Software" must not be used to endorse or promote
021: * products derived from this software without prior written permission.
022: * For written permission, please contact info@GargoyleSoftware.com.
023: * 5. Products derived from this software may not be called "HtmlUnit", nor may
024: * "HtmlUnit" appear in their name, without prior written permission of
025: * Gargoyle Software Inc.
026: *
027: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
028: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
029: * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
030: * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
031: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
032: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
033: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
036: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037: */
038: package com.gargoylesoftware.htmlunit;
039:
040: import java.util.HashSet;
041: import java.util.Set;
042:
043: /**
044: * Contains information about a plugin as available in javascript through document.navigator.plugins
045: * as well as the associated mime types (for Firefox browser simulation).
046: * @version $Revision: 2144 $
047: * @author Marc Guillemot
048: *
049: * @see <a href="http://www.xulplanet.com/references/objref/Plugin.html">XUL Planet</a>
050: */
051: public class PluginConfiguration {
052: private String description_;
053: private String filename_;
054: private String name_;
055: private Set mimeTypes_ = new HashSet();
056:
057: /**
058: * Holds information about a single mime type associated with a plugin
059: */
060: public static class MimeType {
061: private String description_;
062: private String suffixes_;
063: private String type_;
064:
065: /**
066: * C'tor initializing fields
067: * @param type the mime type
068: * @param description the type description
069: * @param suffixes the file suffixes
070: */
071: public MimeType(final String type, final String description,
072: final String suffixes) {
073: type_ = type;
074: description_ = description;
075: suffixes_ = suffixes;
076: }
077:
078: /**
079: * Return the mime type's description
080: * @return the description.
081: */
082: public String getDescription() {
083: return description_;
084: }
085:
086: /**
087: * Return the mime type's suffixes
088: * @return the suffixes.
089: */
090: public String getSuffixes() {
091: return suffixes_;
092: }
093:
094: /**
095: * Return the mime type
096: * @return the type.
097: */
098: public String getType() {
099: return type_;
100: }
101:
102: /**
103: * @return the hashCode of the type
104: */
105: public int hashCode() {
106: return type_.hashCode();
107: }
108: }
109:
110: /**
111: * C'tor initializing fields
112: * @param name the plugin name
113: * @param description the plugin description
114: * @param filename the plugin filename
115: */
116: public PluginConfiguration(final String name,
117: final String description, final String filename) {
118: name_ = name;
119: description_ = description;
120: filename_ = filename;
121: }
122:
123: /**
124: * Gets the plugin's description
125: * @return the description.
126: */
127: public String getDescription() {
128: return description_;
129: }
130:
131: /**
132: * Gets the plugin's file name
133: * @return the file name.
134: */
135: public String getFilename() {
136: return filename_;
137: }
138:
139: /**
140: * Gets the plugin's name
141: * @return the name.
142: */
143: public String getName() {
144: return name_;
145: }
146:
147: /**
148: * Gets the associated mime types
149: * @return a set of {@link MimeType}
150: */
151: public Set getMimeTypes() {
152: return mimeTypes_;
153: }
154:
155: /**
156: * @return the hashCode of the plugin name
157: */
158: public int hashCode() {
159: return name_.hashCode();
160: }
161: }
|