View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator;
9   
10  /**
11   * 
12   * class AnyType - define union type class
13   * 
14   * @author lacquaviva
15   */
16  import java.util.HashMap;
17  import java.util.Map;
18  import java.util.Set;
19  
20  public class AnyType implements SearchedType {
21  
22  	public static final String CORBA_ANY_TYPE = "org.omg.CORBA.Any";
23  	public static final String CORBA_ANY_IMPL_TYPE = "com.sun.corba.se.impl.corba.AnyImpl";
24  	public static final String SEPARATOR_STR = "#";
25  	public static final String EXCEPTION_STR = "exception";
26  	public static final String PARAMETER_STR = "parameter";
27  	public static final String RETURN_STR = "return";
28  
29  	// if Type is Any type(true) or class containing anyType(false)
30  	private boolean isAnyType = false;
31  
32  	// if method signature element is exception(true) or parameter(false)
33  	private boolean isException = false;
34  
35  	// represent the mapping construction for any
36  	private String typeName = null;
37  
38  	// the enclosing class of any
39  	private Class clsHavingAny = null;
40  
41  	// represent the mapping construction for any
42  	private String fieldName = null;
43  
44  	// index of method signature element(parameter or exception)
45  	private int idxParamOrExc = -1;
46  
47  	// the name of the method containing the Any
48  	private String methodName = null;
49  
50  	/**
51  	 * Constructor
52  	 */
53  	public AnyType(Class clsParent, String fldName, boolean isExc,
54  			int paramOrExceptionIdx, String metName) {
55  		clsHavingAny = clsParent;
56  		fieldName = fldName;
57  		if (clsHavingAny == null)
58  			isAnyType = true;
59  
60  		isException = isExc;
61  		idxParamOrExc = paramOrExceptionIdx;
62  		methodName = metName;
63  
64  		constructTypeName();
65  	}
66  
67  	private void constructTypeName() {
68  		if (isAnyType) {
69  			typeName = methodName + SEPARATOR_STR;
70  			if (isException) {
71  				typeName += EXCEPTION_STR + idxParamOrExc;
72  			} else {
73  				if (idxParamOrExc > -1)
74  					typeName += PARAMETER_STR + idxParamOrExc;
75  				else
76  					typeName += RETURN_STR;
77  
78  			}
79  
80  		} else {
81  			typeName = clsHavingAny.getName() + SEPARATOR_STR + fieldName;
82  		}
83  
84  	}
85  
86  	public AnyType() {
87  
88  	}
89  
90  	public String getTypeName() {
91  
92  		return typeName;
93  	}
94  
95  	public void setTypeName(String typeName) {
96  		this.typeName = typeName;
97  
98  	}
99  	
100 	public static boolean isAnyType(String type)
101 	{
102 		if (CORBA_ANY_TYPE.equals(type) || CORBA_ANY_IMPL_TYPE.equals(type))
103 			return true;
104 		return false;
105 	}
106 
107 }