1 17 package org.alfresco.repo.policy; 18 19 import org.alfresco.service.cmr.dictionary.ClassDefinition; 20 import org.alfresco.service.cmr.dictionary.DictionaryService; 21 import org.alfresco.service.cmr.repository.NodeRef; 22 import org.alfresco.service.namespace.QName; 23 24 25 31 class ClassBehaviourBinding implements BehaviourBinding 32 { 33 private DictionaryService dictionary; 35 36 private QName classQName; 38 39 private NodeRef nodeRef; 41 42 43 50 ClassBehaviourBinding(DictionaryService dictionary, NodeRef nodeRef, QName classQName) 51 { 52 this.dictionary = dictionary; 53 this.nodeRef = nodeRef; 54 this.classQName = classQName; 55 } 56 57 63 ClassBehaviourBinding(DictionaryService dictionary, QName classQName) 64 { 65 this(dictionary, null, classQName); 66 } 67 68 DictionaryService getDictionary() 69 { 70 return dictionary; 71 } 72 73 76 public BehaviourBinding generaliseBinding() 77 { 78 BehaviourBinding generalisedBinding = null; 79 ClassDefinition classDefinition = dictionary.getClass(classQName); 80 if (classDefinition == null) 81 { 82 throw new PolicyException("Class definition " + classQName.toPrefixString() + " does not exist."); 83 } 84 85 QName parentClassName = classDefinition.getParentName(); 86 if (parentClassName != null) 87 { 88 generalisedBinding = new ClassBehaviourBinding(dictionary, parentClassName); 89 } 90 return generalisedBinding; 91 } 92 93 98 public NodeRef getNodeRef() 99 { 100 return nodeRef; 101 } 102 103 108 public QName getClassQName() 109 { 110 return classQName; 111 } 112 113 @Override 114 public boolean equals(Object obj) 115 { 116 if (obj == null || !(obj instanceof ClassBehaviourBinding)) 117 { 118 return false; 119 } 120 return classQName.equals(((ClassBehaviourBinding)obj).classQName); 121 } 122 123 @Override 124 public int hashCode() 125 { 126 return classQName.hashCode(); 127 } 128 129 @Override 130 public String toString() 131 { 132 return "ClassBinding[class=" + classQName + "]"; 133 } 134 135 } 136 | Popular Tags |