KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > encoding > IndexPropBean


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package test.encoding;
18
19 import org.apache.axis.description.ElementDesc;
20 import org.apache.axis.description.FieldDesc;
21 import org.apache.axis.description.TypeDesc;
22
23 import javax.xml.namespace.QName JavaDoc;
24
25 /**
26  * Bean with an indexed property
27  */

28 public class IndexPropBean {
29     private java.lang.String JavaDoc[] name;
30     
31     public IndexPropBean() {}
32     
33     public java.lang.String JavaDoc getName(int i) {
34         return name[i];
35     }
36     
37     public void setName(int i, java.lang.String JavaDoc name){
38         this.name[i] = name;
39     }
40     
41     public java.lang.String JavaDoc[] getName() {
42         return name;
43     }
44     
45     public void setName(java.lang.String JavaDoc name[]){
46         this.name = name;
47     }
48
49     public boolean equals(Object JavaDoc obj)
50     {
51         if (obj == null || !(obj instanceof IndexPropBean))
52             return false;
53         IndexPropBean other = (IndexPropBean)obj;
54         if (other.name == null && this.name == null)
55             return true;
56         if (other.name != null &&
57             java.util.Arrays.equals(other.name, name))
58             return true;
59         return false;
60     }
61
62     public int hashCode() {
63         int _hashCode = 0;
64         if (name != null) {
65             for (int i=0;
66                  i<java.lang.reflect.Array.getLength(name);
67                  i++) {
68                 java.lang.Object JavaDoc obj = java.lang.reflect.Array.get(name, i);
69                 if (obj != null) {
70                     _hashCode += obj.hashCode();
71                 }
72             }
73         }
74         return _hashCode;
75     }
76     // Type metadata
77
private static TypeDesc typeDesc;
78     
79     static {
80         typeDesc = new TypeDesc(IndexPropBean.class);
81         FieldDesc field;
82
83         field = new ElementDesc();
84         field.setFieldName("name");
85         field.setXmlName(new QName JavaDoc("", "name"));
86         typeDesc.addFieldDesc(field);
87     }
88     
89     public static TypeDesc getTypeDesc()
90     {
91         return typeDesc;
92     }
93
94     /**
95      * Get Custom Serializer
96      */

97     public static org.apache.axis.encoding.Serializer getSerializer(
98            java.lang.String JavaDoc mechType,
99            java.lang.Class JavaDoc _javaType,
100            javax.xml.namespace.QName JavaDoc _xmlType) {
101         return
102           new org.apache.axis.encoding.ser.BeanSerializer(
103             _javaType, _xmlType, typeDesc);
104     }
105
106     /**
107      * Get Custom Deserializer
108      */

109     public static org.apache.axis.encoding.Deserializer getDeserializer(
110            java.lang.String JavaDoc mechType,
111            java.lang.Class JavaDoc _javaType,
112            javax.xml.namespace.QName JavaDoc _xmlType) {
113         return
114           new org.apache.axis.encoding.ser.BeanDeserializer(
115             _javaType, _xmlType, typeDesc);
116     }
117 }
118
Popular Tags