1 package org.sapia.regis.remote; 2 3 import java.rmi.Remote ; 4 import java.util.ArrayList ; 5 import java.util.Collection ; 6 import java.util.Iterator ; 7 import java.util.Map ; 8 9 import org.sapia.regis.Node; 10 import org.sapia.regis.Path; 11 import org.sapia.regis.Property; 12 import org.sapia.regis.Query; 13 14 21 public class RemoteNode implements Node, Remote { 22 23 private Node delegate; 24 25 RemoteNode(Node delegate){ 26 this.delegate = delegate; 27 } 28 29 public Path getAbsolutePath() { 30 return node().getAbsolutePath(); 31 } 32 33 public Node getChild(Path path) { 34 return wrap(node().getChild(path)); 35 } 36 37 public Node getChild(String name) { 38 return wrap(node().getChild(name)); 39 } 40 41 public Collection getChildren() { 42 return wrap(node().getChildren()); 43 } 44 45 public Collection getLinks(boolean prepended) { 46 return wrap(node().getLinks(prepended)); 47 } 48 49 public Collection getIncludes() { 50 return wrap(node().getIncludes()); 51 } 52 53 public Collection getNodes(Query query) { 54 return wrap(node().getNodes(query)); 55 } 56 57 public String getName() { 58 return node().getName(); 59 } 60 61 public Node getParent() { 62 return wrap(node().getParent()); 63 } 64 65 public Map getProperties() { 66 return node().getProperties(); 67 } 68 69 public Map getProperties(Map values) { 70 return node().getProperties(values); 71 } 72 73 public Property getProperty(String key) { 74 return node().getProperty(key); 75 } 76 77 public Collection getPropertyKeys() { 78 return node().getPropertyKeys(); 79 } 80 81 public String getType() { 82 return node().getType(); 83 } 84 85 public boolean isInheritsParent() { 86 return node().isInheritsParent(); 87 } 88 89 public boolean isRoot() { 90 return node().isRoot(); 91 } 92 93 public long lastModifChecksum() { 94 return node().lastModifChecksum(); 95 } 96 97 public Property renderProperty(String key) { 98 return node().renderProperty(key); 99 } 100 101 public Property renderProperty(String key, Map values) { 102 return node().renderProperty(key, values); 103 } 104 105 private Collection wrap(Collection nodes){ 106 Collection toReturn = new ArrayList (nodes.size()); 107 Iterator itr = nodes.iterator(); 108 while(itr.hasNext()){ 109 Node n = (Node)itr.next(); 110 toReturn.add(new RemoteNode(n)); 111 } 112 return toReturn; 113 } 114 115 private Node wrap(Node node){ 116 if (node == null) { 117 return null; 118 } else { 119 return new RemoteNode(node); 120 } 121 } 122 123 Node node(){ 124 return RemoteSessions.get().attach(delegate); 125 } 126 } 127 | Popular Tags |