1 8 9 package org.uddi4j.util; 10 11 import org.uddi4j.UDDIElement; 12 import org.uddi4j.UDDIException; 13 import org.w3c.dom.Element ; 14 15 39 public class KeyedReference extends UDDIElement 40 { 41 public static final String UDDI_TAG = "keyedReference"; 42 43 protected Element base = null; 44 45 String tModelKey = null; 46 String keyName = null; 47 String keyValue = null; 48 49 55 public KeyedReference() { 56 } 57 58 64 public KeyedReference(String keyName, 65 String keyValue) { 66 this.keyName = keyName; 67 this.keyValue = keyValue; 68 } 69 70 public KeyedReference(String keyName, String keyValue, String tModelKey) { 71 this(keyName, keyValue); 72 this.tModelKey = tModelKey; 73 } 74 75 85 public KeyedReference(Element base) throws UDDIException { 86 super(base); 88 tModelKey = base.getAttribute("tModelKey"); 89 keyName = getAttr(base,"keyName"); 90 keyValue = getAttr(base,"keyValue"); 91 } 92 93 private String getAttr(Element base, String attrname) 94 { 95 if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() ) 96 { 97 return base.getAttribute(attrname); 98 } 99 return null; 100 } 101 102 public void setTModelKey(String s) { 103 tModelKey = s; 104 } 105 106 public void setKeyName(String s) { 107 keyName = s; 108 } 109 110 public void setKeyValue(String s) { 111 keyValue = s; 112 } 113 114 public String getTModelKey() { 115 return tModelKey; 116 } 117 118 119 public String getKeyName() { 120 return keyName; 121 } 122 123 124 public String getKeyValue() { 125 return keyValue; 126 } 127 128 129 138 public void saveToXML(Element parent) { 139 base = parent.getOwnerDocument().createElement(UDDI_TAG); 140 if (tModelKey!=null) 142 { 143 base.setAttribute("tModelKey", tModelKey); 144 } 145 if (keyName!=null) 146 { 147 base.setAttribute("keyName", keyName); 148 } 149 if (keyValue!=null) 150 { 151 base.setAttribute("keyValue", keyValue); 152 } 153 parent.appendChild(base); 154 } 155 156 public boolean equals(Object obj) 158 { 159 boolean result = false; 160 if (obj != null && obj instanceof KeyedReference) 161 { 162 KeyedReference otherKeyedReference = (KeyedReference)obj; 163 if ((tModelKey == null && otherKeyedReference.tModelKey == null) || 164 (tModelKey != null && tModelKey.equalsIgnoreCase(otherKeyedReference.tModelKey))) 165 { 166 if ((keyName == null && otherKeyedReference.keyName == null) || 167 (keyName != null && keyName.equals(otherKeyedReference.keyName))) 168 { 169 if ((keyValue == null && otherKeyedReference.keyValue == null) || 170 (keyValue != null && keyValue.equals(otherKeyedReference.keyValue))) 171 { 172 result = true; 173 } 174 } 175 } 176 } 177 return result; 178 } 179 180 } 181 | Popular Tags |