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.client;
20:
21: import javax.xml.ws.BindingProvider;
22: import java.util.HashMap;
23:
24: public class PropertyValidator {
25:
26: private static HashMap<String, Class> map = new HashMap<String, Class>();
27:
28: static {
29: map
30: .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
31: String.class);
32: map.put(BindingProvider.USERNAME_PROPERTY, String.class);
33: map.put(BindingProvider.PASSWORD_PROPERTY, String.class);
34: map.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
35: Boolean.class);
36: map.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.class);
37: map.put(BindingProvider.SOAPACTION_URI_PROPERTY, String.class);
38: }
39:
40: /**
41: * Checks to see if the property value is valid given the name of the property and the type that
42: * is expected by JAX-WS.
43: *
44: * @param propName
45: * @param value
46: * @return
47: */
48: public static boolean validate(String propName, Object value) {
49: Class expectedType = map.get(propName);
50: if (expectedType != null) {
51: if (expectedType.equals(value.getClass())) {
52: return true;
53: } else {
54: return false;
55: }
56: }
57:
58: return true;
59: }
60:
61: public static Class getExpectedValue(String key) {
62: return map.get(key);
63: }
64: }
|