01: // MimeTypeAttribute.java
02: // $Id: MimeTypeAttribute.java,v 1.5 2002/06/09 11:26:17 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.frames;
07:
08: import org.w3c.tools.resources.Attribute;
09: import org.w3c.tools.resources.SimpleAttribute;
10:
11: import org.w3c.www.mime.MimeType;
12: import org.w3c.www.mime.MimeTypeFormatException;
13:
14: /**
15: * The generic class of Mime type attributes.
16: */
17:
18: public class MimeTypeAttribute extends SimpleAttribute {
19:
20: /**
21: * Is the given object a valid MimeTypeAttribute value ?
22: * @param obj The object to test.
23: * @return A boolean <strong>true</strong> if okay.
24: */
25:
26: public boolean checkValue(Object obj) {
27: return (obj instanceof MimeType) || (obj == null);
28: }
29:
30: public String pickle(Object obj) {
31: return ((MimeType) obj).toString();
32: }
33:
34: public Object unpickle(String value) {
35: try {
36: return new MimeType(value);
37: } catch (MimeTypeFormatException ex) {
38: return null;
39: }
40: }
41:
42: public MimeTypeAttribute(String name, Object def, int flags) {
43: super (name, def, flags);
44: this .type = "org.w3c.www.mime.MimeType".intern();
45: }
46:
47: public MimeTypeAttribute() {
48: super();
49: }
50: }
|