Skip to main content
summaryrefslogtreecommitdiffstats
blob: 680c079647146c7dcd08cfb8482e291be74e324d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitoractions;

import java.util.Vector;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jem.java.ArrayType;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jem.java.JavaHelpers;
import org.eclipse.jem.java.JavaParameter;
import org.eclipse.jst.ws.internal.consumption.codegen.javamofvisitors.JavaMofBeanVisitor;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory;



/**
* Objects of this class represent a JavaMofBeanVisitorAction.
* This VisitorAction will create a BeanElement using the 
* JavaClass and the BeanModelElementsFactory
* It will also automatically walk the methods in the JavaClass
* */
public class DetectNonJavaCharsParameterVisitorAction extends VisitorActionImpl 
{

  public DetectNonJavaCharsParameterVisitorAction ( Vector messages, Vector beans)
  	{
  		super (messages, beans);
  	}

  /**
  * Create a method element from the method 
  * @param Method the class to be used to create the method
  **/
  public IStatus visit (Object ijavaParameter)
  {
    
    JavaParameter javaParameter = (JavaParameter) ijavaParameter;
    JavaClass javaClass = null;
    if ( javaParameter.getJavaType() instanceof JavaClass) 
    	{
    	javaClass = (JavaClass) javaParameter.getJavaType();
    	if (javaClass.isArray())
    	  {
    	    JavaHelpers componentType = ((ArrayType)javaClass).getComponentTypeAsHelper();
    	    if (componentType instanceof JavaClass)
    	      {
    	        javaClass = (JavaClass)componentType;
    	      }
    	    else
    	      {
    	        javaClass = null; //The array contains primitive types, there is no need for further checking.
    	      }
    	  }
    	}
   	if (toBeVisited(javaClass))    {
			DetectNonJavaCharsBeanVisitorAction beanVisitorAction = new DetectNonJavaCharsBeanVisitorAction(getMessages(), getBeansVisited());
			JavaMofBeanVisitor beanVisitor = new JavaMofBeanVisitor();
			beanVisitor.run(javaClass,beanVisitorAction);
  	  	}
   	
   	return Status.OK_STATUS;
  }
  

  private boolean toBeVisited (JavaClass javaClass)
  {
	//check for recognized types 
	if( javaClass == null	||
	   javaClass.isPrimitive() ||
	   javaClass.getJavaName().startsWith("javax") ||
       TypeFactory.recognizedBean(javaClass.getJavaName()))
	    	return false;
	else
		  	return true;
	}
}

Back to the top