1 17 package org.alfresco.web.bean.repository; 18 19 import java.util.Collection ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 import java.util.Set ; 23 24 import org.alfresco.service.namespace.NamespacePrefixResolver; 25 import org.alfresco.service.namespace.QNameMap; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 34 public final class QNameNodeMap<K,V> extends QNameMap implements Map , Cloneable 35 { 36 private Node parent = null; 37 private Map <String , NodePropertyResolver> resolvers = new HashMap <String , NodePropertyResolver>(16, 1.0f); 38 39 44 public QNameNodeMap(NamespacePrefixResolver resolver, Node parent) 45 { 46 super(resolver); 47 if (parent == null) 48 { 49 throw new IllegalArgumentException ("Parent Node cannot be null!"); 50 } 51 this.parent = parent; 52 } 53 54 60 public void addPropertyResolver(String name, NodePropertyResolver resolver) 61 { 62 this.resolvers.put(name, resolver); 63 } 64 65 72 public boolean containsPropertyResolver(String name) 73 { 74 return this.resolvers.containsKey(name); 75 } 76 77 80 public boolean containsKey(Object key) 81 { 82 return (this.contents.containsKey(Repository.resolveToQNameString((String )key)) || 83 this.resolvers.containsKey(key)); 84 } 85 86 89 public Object get(Object key) 90 { 91 String qnameKey = Repository.resolveToQNameString(key.toString()); 92 Object obj = this.contents.get(qnameKey); 93 if (obj == null) 94 { 95 NodePropertyResolver resolver = this.resolvers.get(key.toString()); 97 if (resolver != null) 98 { 99 obj = resolver.get(this.parent); 100 this.contents.put(qnameKey, obj); 103 } 104 } 105 106 return obj; 107 } 108 109 115 public Object getRaw(Object key) 116 { 117 return this.contents.get(Repository.resolveToQNameString((String )key)); 118 } 119 120 123 public Object clone() 124 { 125 QNameNodeMap map = new QNameNodeMap(this.resolver, this.parent); 126 map.putAll(this); 127 if (this.resolvers.size() != 0) 128 { 129 map.resolvers = (Map )((HashMap )this.resolvers).clone(); 130 } 131 return map; 132 } 133 } 134 | Popular Tags |