1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.betwixt.schema;
19
20 import java.beans.IntrospectionException;
21 import java.util.Collection;
22 import java.util.Iterator;
23
24 import org.apache.commons.betwixt.ElementDescriptor;
25
26
27
28
29
30
31 public class LocalComplexType extends ComplexType {
32
33
34 public LocalComplexType() {}
35
36 public LocalComplexType(TranscriptionConfiguration configuration, ElementDescriptor elementDescriptor, Schema schema) throws IntrospectionException {
37 super(configuration, elementDescriptor, schema);
38 }
39
40 public boolean equals(Object obj) {
41 boolean result = false;
42 if (obj instanceof GlobalComplexType) {
43 GlobalComplexType complexType = (GlobalComplexType) obj;
44 result =
45 equalContents(attributes, complexType.attributes) &&
46 equalContents(elements, complexType.elements);
47
48 }
49 return result;
50 }
51
52
53 private boolean equalContents(Collection one, Collection two)
54 {
55
56 if (one.size() != two.size()) {
57 return false;
58 }
59 for (Iterator it=one.iterator();it.hasNext();) {
60 Object object = it.next();
61 if (!two.contains(object)) {
62 return false;
63 }
64 }
65 return true;
66 }
67
68 public int hashCode() {
69 return 0;
70 }
71
72
73
74
75
76
77
78 private boolean isEqual(String one, String two) {
79 boolean result = false;
80 if (one == null) {
81 result = (two == null);
82 }
83 else
84 {
85 result = one.equals(two);
86 }
87
88 return result;
89 }
90
91 public String toString() {
92 StringBuffer buffer = new StringBuffer();
93 buffer.append("<xsd:complexType>");
94 buffer.append("<xsd:sequence>");
95 for (Iterator it=elements.iterator(); it.hasNext();) {
96 buffer.append(it.next());
97 }
98 buffer.append("</xsd:sequence>");
99
100 for (Iterator it=attributes.iterator(); it.hasNext();) {
101 buffer.append(it.next());
102 }
103 buffer.append("</xsd:complexType>");
104 return buffer.toString();
105 }
106 }