View Javadoc

1   /*
2    * To change this template, choose Tools | Templates
3    * and open the template in the editor.
4    */
5   package org.kuali.student.contract.model.util;
6   
7   import java.io.PrintStream;
8   
9   import org.kuali.student.contract.model.ServiceMethod;
10  import org.kuali.student.contract.model.ServiceMethodError;
11  import org.kuali.student.contract.model.ServiceMethodParameter;
12  
13  /**
14   *
15   * @author nwright
16   */
17  public class ServiceMethodDumper {
18  
19      private ServiceMethod method;
20      private PrintStream out;
21  
22      public ServiceMethodDumper(ServiceMethod method, PrintStream out) {
23          this.method = method;
24          this.out = out;
25      }
26  
27      public void dump() {
28          out.println(method.getService() + "." + method.getName() + " - " + method.getDescription());
29          for (ServiceMethodParameter param : method.getParameters()) {
30              out.println(" Param: " + param.getName() + " (" + param.getType() + ") " + param.getDescription() + " http://XXX" + param.getUrl());
31          }
32          for (ServiceMethodError param : method.getErrors()) {
33              out.println(" Error: " + param.getType() + " - " + param.getDescription());
34          }
35          out.println(" return: " + method.getReturnValue().getType() + " - " + method.getReturnValue().
36                  getDescription() + " http://XXX" + method.getReturnValue().getUrl());
37      }
38  
39      public void writeTabbedHeader() {
40          out.print("Service");
41          out.print("\t");
42          out.print("Key");
43          out.print("\t");
44          out.print("ShortName");
45          out.print("\t");
46          out.print("LongName");
47          out.print("\t");
48          out.print("Description");
49          out.print("\t");
50          out.print("url");
51          out.println("");
52      }
53  
54      public void writeTabbedData() {
55          out.print(method.getService());
56          out.print("\t");
57          out.print("Method");
58          out.print("\t");
59          out.print(method.getName());
60          out.print("\t");
61          out.print("");
62          out.print("\t");
63          out.print("");
64          out.print("\t");
65          out.print(method.getUrl());
66          out.println();
67  
68          out.print(method.getService());
69          out.print("\t");
70          out.print("Description");
71          out.print("\t");
72          out.print(method.getDescription());
73          out.print("\t");
74          out.print("");
75          out.println();
76          if (method.getParameters().size() == 0) {
77              out.print(method.getService());
78              out.print("\t");
79              out.print("Parameters");
80              out.print("\t");
81              out.print("None");
82              out.print("\t");
83              out.print("None");
84              out.print("\t");
85              out.print("No parameters");
86              out.print("\t");
87              out.print("");
88              out.println();
89          } else {
90              String parameters = "Parameters";
91              for (ServiceMethodParameter param : method.getParameters()) {
92                  out.print(method.getService());
93                  out.print("\t");
94                  out.print(parameters);
95                  parameters = "";
96                  out.print("\t");
97                  out.print(param.getType());
98                  out.print("\t");
99                  out.print(param.getName());
100                 out.print("\t");
101                 out.print(param.getDescription());
102                 out.print("\t");
103                 out.print(param.getUrl());
104                 out.println();
105             }
106         }
107 
108         out.print(method.getService());
109         out.print("\t");
110         out.print("Return");
111         out.print("\t");
112         out.print(method.getReturnValue().getType());
113         out.print("\t");
114         out.print(method.getReturnValue().getDescription());
115         out.print("\t");
116         out.print("");
117         out.print("\t");
118         out.print(method.getReturnValue().getUrl());
119         out.println();
120 
121         String errors = "Errors";
122         for (ServiceMethodError error : method.getErrors()) {
123             out.print(method.getService());
124             out.print("\t");
125             out.print(errors);
126             errors = "";
127             out.print("\t");
128             out.print(error.getType());
129             out.print("\t");
130             out.print(error.getDescription());
131             out.print("\t");
132             out.print("");
133             out.print("\t");
134             out.print("");
135             out.println();
136         }
137 
138         out.print(method.getService());
139         out.print("\t");
140         out.print("Capabilities");
141         out.print("\t");
142         out.print("");
143         out.print("\t");
144         out.print("");
145         out.print("\t");
146         out.print("");
147         out.print("\t");
148         out.print("");
149         out.println();
150 
151         out.print(method.getService());
152         out.print("\t");
153         out.print("Use Cases");
154         out.print("\t");
155         out.print("");
156         out.print("\t");
157         out.print("");
158         out.print("\t");
159         out.print("");
160         out.print("\t");
161         out.print("");
162         out.println();
163 
164         out.print(method.getService());
165         out.print("\t");
166         out.print("Comments/Feedback");
167         out.print("\t");
168         out.print("");
169         out.print("\t");
170         out.print("");
171         out.print("\t");
172         out.print("");
173         out.print("\t");
174         out.print("");
175         out.println();
176     }
177 }