Skip to main content
summaryrefslogtreecommitdiffstats
blob: f78cd599d95774900da2d787186b8e412871f514 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*******************************************************************************
 * 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.sampleapp.codegen;

import java.util.Enumeration;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.ws.internal.common.StringUtils;
import org.eclipse.jst.ws.internal.consumption.codegen.Generator;
import org.eclipse.jst.ws.internal.consumption.codegen.bean.AttributeVisitor;
import org.eclipse.jst.ws.internal.consumption.codegen.bean.FieldVisitor;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.DataType;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeElement;
import org.eclipse.jst.ws.internal.consumption.datamodel.beanmodel.TypeFactory;
import org.eclipse.wst.ws.internal.datamodel.Element;

/**
* Objects of this class represent a ResultFileHelp2generator.
* */
public class ResultFileTypeGenerator extends ResultFileHelp2Generator 
{

  // Copyright
  public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";



  public String fTypeIdName;
 
  /**
  * Constructor.
  * @param buffer StringBuffer object that this code generator writes to 
  */
  public ResultFileTypeGenerator (StringBuffer buffer)
  {
      super(buffer);
  }
  
  /**
  * Visit Method generates code for this Visitor
  * @param Parameter parameter code will be generated 
  */
  public IStatus visit (Object object)
  {
     Element typeElement = (Element)object;
     TypeElement type = (TypeElement)typeElement;      
     // right now we only have simple to worry about
     if(type.isSimple() || TypeFactory.recognizedBean(type.getName())){
       // create the type that represents the simple type name
       DataType dataType = TypeFactory.createType(type.getName(),type.getOwningElement().getMUID());
  
       String nodeName = getTypeOwnerId()+ "Temp";
       fbuffer.append(dataType.stringConversion(type.getName(),nodeName,getTypeOwnerId()));

       putResidentVector(nodeName);
     }

     else {
       //must be complex
       String typeName = typeElement.getName(); 
       fTypeIdName = idName(typeName);
              
       AttributeVisitor attributeVisitor = new AttributeVisitor();
       ResultFileAttributeGenerator resultFileAttributeGenerator = new ResultFileAttributeGenerator(fbuffer);
       resultFileAttributeGenerator.setNumberFactory(getNumberFactory());
       attributeVisitor.run(typeElement,resultFileAttributeGenerator);
       setNumberFactory(resultFileAttributeGenerator.getNumberFactory());
       fbuffer = resultFileAttributeGenerator.getStringBuffer();

       FieldVisitor fieldVisitor = new FieldVisitor();
       ResultFileAttributeGenerator resultFileAttributeGenerator2 = new ResultFileAttributeGenerator(fbuffer);
       resultFileAttributeGenerator2.setNumberFactory(getNumberFactory());
       fieldVisitor.run(typeElement,resultFileAttributeGenerator2);
       setNumberFactory(resultFileAttributeGenerator2.getNumberFactory());
       fbuffer = resultFileAttributeGenerator2.getStringBuffer();

      
       fbuffer.append(Generator.DOUBLE_TAB + "%>" + StringUtils.NEWLINE);
       fbuffer.append(Generator.DOUBLE_TAB + "<jsp:useBean id=\"" + fTypeIdName + "\" scope=\"session\" class=\"" + typeName + "\" />" + StringUtils.NEWLINE);
       fbuffer.append(Generator.DOUBLE_TAB + "<%" + StringUtils.NEWLINE);
         
       Enumeration e = resultFileAttributeGenerator.getResidentVector().elements();
       while(e.hasMoreElements()){
          fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e.nextElement() + StringUtils.NEWLINE);
       }

       Enumeration e2 = resultFileAttributeGenerator2.getResidentVector().elements();
       while(e2.hasMoreElements()){
          fbuffer.append(Generator.DOUBLE_TAB + fTypeIdName + "." + e2.nextElement() + StringUtils.NEWLINE);
       } 
       putResidentVector(fTypeIdName);
       //end of changes
     
    }
     
     return Status.OK_STATUS;
  }   
  

  
}

Back to the top