01: // FileAttribute.java
02: // $Id: FileAttribute.java,v 1.7 2002/06/09 10:14:29 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.tools.resources;
07:
08: import java.io.File;
09:
10: /**
11: * The generic description of an FileAttribute.
12: */
13:
14: public class FileAttribute extends SimpleAttribute {
15:
16: /**
17: * Is the given object a valid FileAttribute value ?
18: * @param obj The object to test.
19: * @return A boolean <strong>true</strong> if okay.
20: */
21:
22: public boolean checkValue(Object obj) {
23: return (obj instanceof File);
24: }
25:
26: /**
27: * Pickle an integer to the given output stream.
28: * @param obj The object to pickle.
29: */
30:
31: public String pickle(Object obj) {
32: if (obj instanceof String)
33: return (String) obj;
34: else
35: return ((File) obj).getPath();
36: }
37:
38: /**
39: * Unpickle an integer from the given input stream.
40: * @param value the string representation of this integer
41: * @return An instance of Integer.
42: */
43:
44: public Object unpickle(String value) {
45: return new File(value);
46: }
47:
48: public FileAttribute(String name, File def, int flags) {
49: super (name, def, flags);
50: this .type = "java.io.File".intern();
51: }
52:
53: public FileAttribute() {
54: super();
55: }
56:
57: }
|