01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.description.builder.converter;
20:
21: import org.apache.axis2.jaxws.description.builder.FieldDescriptionComposite;
22:
23: import java.lang.reflect.Field;
24: import java.lang.reflect.Modifier;
25: import java.util.ArrayList;
26: import java.util.List;
27:
28: /** This class will be used to convert Java Fields into FieldDescriptionComposite objects. */
29: public class JavaFieldsToFDCConverter {
30:
31: private Field[] fields;
32:
33: public JavaFieldsToFDCConverter(Field[] fields) {
34: this .fields = fields;
35: }
36:
37: /**
38: * This method will be called to create <code>FieldDescriptionComposite</code> objects for public
39: * fields in a given Class.
40: *
41: * @return - <code>List</code>
42: */
43: public List<FieldDescriptionComposite> convertFields() {
44: List<FieldDescriptionComposite> fdcList = new ArrayList<FieldDescriptionComposite>();
45: for (Field field : fields) {
46: FieldDescriptionComposite fdc = new FieldDescriptionComposite();
47: fdc.setFieldName(field.getName());
48: fdc
49: .setModifierType(Modifier.toString(field
50: .getModifiers()));
51: attachHandlerChainAnnotation(fdc, field);
52: attachWebServiceRefAnnotation(fdc, field);
53: }
54: return fdcList;
55: }
56:
57: /**
58: * This method will drive the call to attach @HandlerChain annotation data if it is found on the
59: * Field.
60: *
61: * @param fdc - <code>FieldDescriptionComposite</code>
62: * @param field - <code>Field</code>
63: */
64: private void attachHandlerChainAnnotation(
65: FieldDescriptionComposite fdc, Field field) {
66: ConverterUtils.attachHandlerChainAnnotation(fdc, field);
67: }
68:
69: /**
70: * This method will drive the call to attach @WebServiceRef annotation data
71: * if it is found on the Field.
72: * @param fdc - <code>FieldDescriptionComposite</code>
73: * @param field - <code>Field</code>
74: */
75: private void attachWebServiceRefAnnotation(
76: FieldDescriptionComposite fdc, Field field) {
77: ConverterUtils.attachWebServiceRefAnnotation(fdc, field);
78: }
79: }
|