1 21 22 package org.armedbear.lisp; 23 24 import java.util.HashMap ; 25 26 public final class LogicalPathname extends Pathname 27 { 28 private static final HashMap map = new HashMap (); 29 30 private LogicalPathname() 31 { 32 device = Keyword.UNSPECIFIC; 35 } 36 37 public LispObject typeOf() 38 { 39 return Symbol.LOGICAL_PATHNAME; 40 } 41 42 public LispClass classOf() 43 { 44 return BuiltInClass.LOGICAL_PATHNAME; 45 } 46 47 public LispObject typep(LispObject type) throws ConditionThrowable 48 { 49 if (type == Symbol.LOGICAL_PATHNAME) 50 return T; 51 if (type == BuiltInClass.LOGICAL_PATHNAME) 52 return T; 53 return super.typep(type); 54 } 55 56 private static final Primitive2 _SET_LOGICAL_PATHNAME_TRANSLATIONS = 59 new Primitive2("%set-logical-pathname-translations", PACKAGE_SYS, false, 60 "host new-translations") 61 { 62 public LispObject execute(LispObject first, LispObject second) 63 throws ConditionThrowable 64 { 65 String host = first.getStringValue().toUpperCase(); 66 map.put(host, NIL); return NIL; 68 } 69 }; 70 71 private static final Primitive1 LOGICAL_PATHNAME_TRANSLATIONS = 73 new Primitive1("logical-pathname-translations", "host") 74 { 75 public LispObject execute(LispObject arg) throws ConditionThrowable 76 { 77 return NIL; 78 } 79 }; 80 81 private static final Primitive1 LOAD_LOGICAL_PATHNAME_TRANSLATIONS = 83 new Primitive1("load-logical-pathname-translations", "host") 84 { 85 public LispObject execute(LispObject arg) throws ConditionThrowable 86 { 87 String host = arg.getStringValue().toUpperCase(); 88 if (map.get(host) != null) 89 return NIL; 90 return signal(new LispError("LOAD-LOGICAL-PATHNAME-TRANSLATIONS is not implemented.")); 91 } 92 }; 93 94 private static final Primitive1 LOGICAL_PATHNAME = 96 new Primitive1("logical-pathname", "pathspec") 97 { 98 public LispObject execute(LispObject arg) throws ConditionThrowable 99 { 100 if (arg instanceof LogicalPathname) 101 return arg; 102 if (arg instanceof AbstractString) { 103 String s = arg.getStringValue(); 104 int index = s.indexOf(':'); 105 if (index >= 0) { 106 String host = s.substring(0, index).toUpperCase(); 107 LogicalPathname p = new LogicalPathname(); 108 p.host = new SimpleString(host); 109 return p; 110 } 111 return NIL; 112 } 113 if (arg instanceof Stream) 114 return NIL; 115 return signal(new TypeError(String.valueOf(arg) + 116 " is not a string, stream, or logical pathname.")); 117 } 118 }; 119 } 120 | Popular Tags |