1 19 31 32 package org.netbeans.modules.schema2beansdev.beangraph; 33 34 public class SchemaTypeMappingType implements org.netbeans.modules.schema2beansdev.beangraph.CommonBean { 35 public static final String SCHEMA_TYPE_NAMESPACE = "SchemaTypeNamespace"; public static final String SCHEMA_TYPE_NAME = "SchemaTypeName"; public static final String JAVA_TYPE = "JavaType"; public static final String ROOT = "Root"; public static final String BEAN = "Bean"; public static final String CAN_BE_EMPTY = "CanBeEmpty"; 42 private java.lang.String _SchemaTypeNamespace; 43 private java.lang.String _SchemaTypeName; 44 private java.lang.String _JavaType; 45 private boolean _Root; 46 private boolean _isSet_Root = false; 47 private boolean _Bean; 48 private boolean _isSet_Bean = false; 49 private boolean _CanBeEmpty; 50 private boolean _isSet_CanBeEmpty = false; 51 52 55 public SchemaTypeMappingType() { 56 _SchemaTypeName = ""; 57 _JavaType = ""; 58 } 59 60 63 public SchemaTypeMappingType(java.lang.String schemaTypeName, java.lang.String javaType) { 64 _SchemaTypeName = schemaTypeName; 65 _JavaType = javaType; 66 } 67 68 71 public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source) { 72 this(source, false); 73 } 74 75 79 public SchemaTypeMappingType(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType source, boolean justData) { 80 _SchemaTypeNamespace = source._SchemaTypeNamespace; 81 _SchemaTypeName = source._SchemaTypeName; 82 _JavaType = source._JavaType; 83 _Root = source._Root; 84 _isSet_Root = source._isSet_Root; 85 _Bean = source._Bean; 86 _isSet_Bean = source._isSet_Bean; 87 _CanBeEmpty = source._CanBeEmpty; 88 _isSet_CanBeEmpty = source._isSet_CanBeEmpty; 89 } 90 91 public void setSchemaTypeNamespace(java.lang.String value) { 93 _SchemaTypeNamespace = value; 94 } 95 96 public java.lang.String getSchemaTypeNamespace() { 97 return _SchemaTypeNamespace; 98 } 99 100 public void setSchemaTypeName(java.lang.String value) { 102 _SchemaTypeName = value; 103 } 104 105 public java.lang.String getSchemaTypeName() { 106 return _SchemaTypeName; 107 } 108 109 public void setJavaType(java.lang.String value) { 111 _JavaType = value; 112 } 113 114 public java.lang.String getJavaType() { 115 return _JavaType; 116 } 117 118 public void setRoot(boolean value) { 120 _Root = value; 121 _isSet_Root = true; 122 } 123 124 public boolean isRoot() { 125 return _Root; 126 } 127 128 public void setBean(boolean value) { 130 _Bean = value; 131 _isSet_Bean = true; 132 } 133 134 public boolean isBean() { 135 return _Bean; 136 } 137 138 public void setCanBeEmpty(boolean value) { 140 _CanBeEmpty = value; 141 _isSet_CanBeEmpty = true; 142 } 143 144 public boolean isCanBeEmpty() { 145 return _CanBeEmpty; 146 } 147 148 public void writeNode(java.io.Writer out) throws java.io.IOException { 149 String myName; 150 myName = "schemaTypeMappingType"; 151 writeNode(out, myName, ""); } 153 154 public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException { 155 writeNode(out, nodeName, null, indent, new java.util.HashMap ()); 156 } 157 158 161 public void writeNode(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException { 162 out.write(indent); 163 out.write("<"); 164 if (namespace != null) { 165 out.write((String )namespaceMap.get(namespace)); 166 out.write(":"); 167 } 168 out.write(nodeName); 169 out.write(">\n"); 170 String nextIndent = indent + " "; 171 if (_SchemaTypeNamespace != null) { 172 out.write(nextIndent); 173 out.write("<schema-type-namespace"); out.write(">"); org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeNamespace, false); 176 out.write("</schema-type-namespace>\n"); } 178 if (_SchemaTypeName != null) { 179 out.write(nextIndent); 180 out.write("<schema-type-name"); out.write(">"); org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _SchemaTypeName, false); 183 out.write("</schema-type-name>\n"); } 185 if (_JavaType != null) { 186 out.write(nextIndent); 187 out.write("<java-type"); out.write(">"); org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.writeXML(out, _JavaType, false); 190 out.write("</java-type>\n"); } 192 if (_isSet_Root) { 193 out.write(nextIndent); 194 out.write("<root"); out.write(">"); out.write(_Root ? "true" : "false"); 197 out.write("</root>\n"); } 199 if (_isSet_Bean) { 200 out.write(nextIndent); 201 out.write("<bean"); out.write(">"); out.write(_Bean ? "true" : "false"); 204 out.write("</bean>\n"); } 206 if (_isSet_CanBeEmpty) { 207 out.write(nextIndent); 208 out.write("<can-be-empty"); out.write(">"); out.write(_CanBeEmpty ? "true" : "false"); 211 out.write("</can-be-empty>\n"); } 213 out.write(indent); 214 out.write("</"); 215 if (namespace != null) { 216 out.write((String )namespaceMap.get(namespace)); 217 out.write(":"); 218 } 219 out.write(nodeName); 220 out.write(">\n"); 221 } 222 223 public void readNode(org.w3c.dom.Node node) { 224 readNode(node, new java.util.HashMap ()); 225 } 226 227 public void readNode(org.w3c.dom.Node node, java.util.Map namespacePrefixes) { 228 if (node.hasAttributes()) { 229 org.w3c.dom.NamedNodeMap attrs = node.getAttributes(); 230 org.w3c.dom.Attr attr; 231 java.lang.String attrValue; 232 boolean firstNamespaceDef = true; 233 for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) { 234 attr = (org.w3c.dom.Attr ) attrs.item(attrNum); 235 String attrName = attr.getName(); 236 if (attrName.startsWith("xmlns:")) { 237 if (firstNamespaceDef) { 238 firstNamespaceDef = false; 239 namespacePrefixes = new java.util.HashMap (namespacePrefixes); 241 } 242 String attrNSPrefix = attrName.substring(6, attrName.length()); 243 namespacePrefixes.put(attrNSPrefix, attr.getValue()); 244 } 245 } 246 } 247 org.w3c.dom.NodeList children = node.getChildNodes(); 248 for (int i = 0, size = children.getLength(); i < size; ++i) { 249 org.w3c.dom.Node childNode = children.item(i); 250 String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern()); 251 String childNodeValue = ""; 252 if (childNode.getFirstChild() != null) { 253 childNodeValue = childNode.getFirstChild().getNodeValue(); 254 } 255 if (childNodeName == "schema-type-namespace") { 256 _SchemaTypeNamespace = childNodeValue; 257 } 258 else if (childNodeName == "schema-type-name") { 259 _SchemaTypeName = childNodeValue; 260 } 261 else if (childNodeName == "java-type") { 262 _JavaType = childNodeValue; 263 } 264 else if (childNodeName == "root") { 265 if (childNode.getFirstChild() == null) 266 _Root = true; 267 else 268 _Root = java.lang.Boolean.valueOf(childNodeValue).booleanValue(); 269 _isSet_Root = true; 270 } 271 else if (childNodeName == "bean") { 272 if (childNode.getFirstChild() == null) 273 _Bean = true; 274 else 275 _Bean = java.lang.Boolean.valueOf(childNodeValue).booleanValue(); 276 _isSet_Bean = true; 277 } 278 else if (childNodeName == "can-be-empty") { 279 if (childNode.getFirstChild() == null) 280 _CanBeEmpty = true; 281 else 282 _CanBeEmpty = java.lang.Boolean.valueOf(childNodeValue).booleanValue(); 283 _isSet_CanBeEmpty = true; 284 } 285 else { 286 } 288 } 289 } 290 291 public void validate() throws org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException { 292 boolean restrictionFailure = false; 293 boolean restrictionPassed = false; 294 if (getSchemaTypeName() == null) { 297 throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getSchemaTypeName() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "schemaTypeName", this); } 299 if (getJavaType() == null) { 301 throw new org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException("getJavaType() == null", org.netbeans.modules.schema2beansdev.beangraph.BeanGraph.ValidateException.FailureType.NULL_VALUE, "javaType", this); } 303 } 307 308 public void changePropertyByName(String name, Object value) { 309 if (name == null) return; 310 name = name.intern(); 311 if (name == "schemaTypeNamespace") 312 setSchemaTypeNamespace((java.lang.String )value); 313 else if (name == "schemaTypeName") 314 setSchemaTypeName((java.lang.String )value); 315 else if (name == "javaType") 316 setJavaType((java.lang.String )value); 317 else if (name == "root") 318 setRoot(((java.lang.Boolean )value).booleanValue()); 319 else if (name == "bean") 320 setBean(((java.lang.Boolean )value).booleanValue()); 321 else if (name == "canBeEmpty") 322 setCanBeEmpty(((java.lang.Boolean )value).booleanValue()); 323 else 324 throw new IllegalArgumentException (name+" is not a valid property name for SchemaTypeMappingType"); 325 } 326 327 public Object fetchPropertyByName(String name) { 328 if (name == "schemaTypeNamespace") 329 return getSchemaTypeNamespace(); 330 if (name == "schemaTypeName") 331 return getSchemaTypeName(); 332 if (name == "javaType") 333 return getJavaType(); 334 if (name == "root") 335 return (isRoot() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); 336 if (name == "bean") 337 return (isBean() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); 338 if (name == "canBeEmpty") 339 return (isCanBeEmpty() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); 340 throw new IllegalArgumentException (name+" is not a valid property name for SchemaTypeMappingType"); 341 } 342 343 public String nameSelf() { 344 return "SchemaTypeMappingType"; 345 } 346 347 public String nameChild(Object childObj) { 348 return nameChild(childObj, false, false); 349 } 350 351 356 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName) { 357 return nameChild(childObj, returnConstName, returnSchemaName, false); 358 } 359 360 365 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) { 366 if (childObj instanceof java.lang.String ) { 367 java.lang.String child = (java.lang.String ) childObj; 368 if (child == _SchemaTypeNamespace) { 369 if (returnConstName) { 370 return SCHEMA_TYPE_NAMESPACE; 371 } else if (returnSchemaName) { 372 return "schema-type-namespace"; 373 } else if (returnXPathName) { 374 return "schema-type-namespace"; 375 } else { 376 return "SchemaTypeNamespace"; 377 } 378 } 379 if (child == _SchemaTypeName) { 380 if (returnConstName) { 381 return SCHEMA_TYPE_NAME; 382 } else if (returnSchemaName) { 383 return "schema-type-name"; 384 } else if (returnXPathName) { 385 return "schema-type-name"; 386 } else { 387 return "SchemaTypeName"; 388 } 389 } 390 if (child == _JavaType) { 391 if (returnConstName) { 392 return JAVA_TYPE; 393 } else if (returnSchemaName) { 394 return "java-type"; 395 } else if (returnXPathName) { 396 return "java-type"; 397 } else { 398 return "JavaType"; 399 } 400 } 401 } 402 if (childObj instanceof java.lang.Boolean ) { 403 java.lang.Boolean child = (java.lang.Boolean ) childObj; 404 if (((java.lang.Boolean )child).booleanValue() == _Root) { 405 if (returnConstName) { 406 return ROOT; 407 } else if (returnSchemaName) { 408 return "root"; 409 } else if (returnXPathName) { 410 return "root"; 411 } else { 412 return "Root"; 413 } 414 } 415 if (((java.lang.Boolean )child).booleanValue() == _Bean) { 416 if (returnConstName) { 417 return BEAN; 418 } else if (returnSchemaName) { 419 return "bean"; 420 } else if (returnXPathName) { 421 return "bean"; 422 } else { 423 return "Bean"; 424 } 425 } 426 if (((java.lang.Boolean )child).booleanValue() == _CanBeEmpty) { 427 if (returnConstName) { 428 return CAN_BE_EMPTY; 429 } else if (returnSchemaName) { 430 return "can-be-empty"; 431 } else if (returnXPathName) { 432 return "can-be-empty"; 433 } else { 434 return "CanBeEmpty"; 435 } 436 } 437 } 438 return null; 439 } 440 441 444 public org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] childBeans(boolean recursive) { 445 java.util.List children = new java.util.LinkedList (); 446 childBeans(recursive, children); 447 org.netbeans.modules.schema2beansdev.beangraph.CommonBean[] result = new org.netbeans.modules.schema2beansdev.beangraph.CommonBean[children.size()]; 448 return (org.netbeans.modules.schema2beansdev.beangraph.CommonBean[]) children.toArray(result); 449 } 450 451 454 public void childBeans(boolean recursive, java.util.List beans) { 455 } 456 457 public boolean equals(Object o) { 458 return o instanceof org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType && equals((org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType) o); 459 } 460 461 public boolean equals(org.netbeans.modules.schema2beansdev.beangraph.SchemaTypeMappingType inst) { 462 if (inst == this) { 463 return true; 464 } 465 if (inst == null) { 466 return false; 467 } 468 if (!(_SchemaTypeNamespace == null ? inst._SchemaTypeNamespace == null : _SchemaTypeNamespace.equals(inst._SchemaTypeNamespace))) { 469 return false; 470 } 471 if (!(_SchemaTypeName == null ? inst._SchemaTypeName == null : _SchemaTypeName.equals(inst._SchemaTypeName))) { 472 return false; 473 } 474 if (!(_JavaType == null ? inst._JavaType == null : _JavaType.equals(inst._JavaType))) { 475 return false; 476 } 477 if (_isSet_Root != inst._isSet_Root) { 478 return false; 479 } 480 if (_isSet_Root) { 481 if (!(_Root == inst._Root)) { 482 return false; 483 } 484 } 485 if (_isSet_Bean != inst._isSet_Bean) { 486 return false; 487 } 488 if (_isSet_Bean) { 489 if (!(_Bean == inst._Bean)) { 490 return false; 491 } 492 } 493 if (_isSet_CanBeEmpty != inst._isSet_CanBeEmpty) { 494 return false; 495 } 496 if (_isSet_CanBeEmpty) { 497 if (!(_CanBeEmpty == inst._CanBeEmpty)) { 498 return false; 499 } 500 } 501 return true; 502 } 503 504 public int hashCode() { 505 int result = 17; 506 result = 37*result + (_SchemaTypeNamespace == null ? 0 : _SchemaTypeNamespace.hashCode()); 507 result = 37*result + (_SchemaTypeName == null ? 0 : _SchemaTypeName.hashCode()); 508 result = 37*result + (_JavaType == null ? 0 : _JavaType.hashCode()); 509 result = 37*result + (_isSet_Root ? 0 : (_Root ? 0 : 1)); 510 result = 37*result + (_isSet_Bean ? 0 : (_Bean ? 0 : 1)); 511 result = 37*result + (_isSet_CanBeEmpty ? 0 : (_CanBeEmpty ? 0 : 1)); 512 return result; 513 } 514 515 public String toString() { 516 java.io.StringWriter sw = new java.io.StringWriter (); 517 try { 518 writeNode(sw); 519 } catch (java.io.IOException e) { 520 throw new RuntimeException (e); 522 } 523 return sw.toString(); 524 } 525 526 } 527 528 529 574 | Popular Tags |