OpenKeyWord  Build_ID: 457, Datum: 01.02.2020 07:45:48
Dont repeat yourself. - Do it once and only once!
LogFunctionDebug.java
1 package okw.log.log2html;
2 
3 import org.apache.commons.text.StringEscapeUtils;
4 
5 public class LogFunctionDebug extends LogBaseNode
6 {
7 
8  String myReturn = "";
9 
10  private String type = "Function";
11  private String functionName;
12  private String[] parameter;
13 
14  LogFunctionDebug( LogBase Parent, String fpsFunctionName, String... fpsParameter )
15  {
16  setParent( Parent );
17  myID = AllCount;
18 
19  functionName = fpsFunctionName;
20  parameter = fpsParameter;
21 
22  // inkrementieren FunctionCount
23  this.FunctionCount();
24 
25  StringBuilder StrBuilder = new StringBuilder();
26 
27  StrBuilder.append( fpsFunctionName + "(" );
28 
29  Boolean GreaterOne = false;
30  for ( String sParameter : fpsParameter )
31  {
32  if ( GreaterOne )
33  {
34  StrBuilder.append( ", " );
35  }
36  else
37  {
38  GreaterOne = true;
39  }
40 
41  StrBuilder.append( sParameter );
42  }
43 
44  StrBuilder.append( ")" );
45 
46  this.Info = StrBuilder.toString();
47  }
48 
49  public void setReturn( String fpsReturn )
50  {
51  myReturn = fpsReturn;
52  }
53 
54  protected void SetFail()
55  {
56  //Nur Inkrementieren wenn dieser testfall noch nicht als Fail markiert wurde.
57  if ( !( this.bError || this.bException ) )
58  {
59  FunctionFail++;
60  }
61  }
62 
63  protected void SetPass()
64  {
65  FunctionPass++;
66  }
67 
68  @Override
69  protected String getHTMLResult()
70  {
71  StringBuilder sbResult = new StringBuilder();
72 
73  String lvsIndention = this.getLevelIndention();
74 
75  //sbResult.append( lvsIndention + "<blockquote class='" + this.getClass().getSimpleName() + "'>\n" );
76 
77  sbResult.append( lvsIndention + "<div class='" + this.getClass().getSimpleName() + "'>\n" );
78  sbResult.append( lvsIndention + myIndentionBase + "<div class='Header'>\n" );
79 
80  if ( !this.myLogs.isEmpty() )
81  {
82  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='FoldMe' onClick='div_change(" + myID.toString()
83  + ")'></div>\n" );
84  }
85 
86  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='Duration'>" + this.myDuration.getSeconds( "#0.000" ) + " s</div>" );
87 
88  // Exception-icon einfügen wenn bException = true
89  if ( this.bException )
90  {
91  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='ExceptionSign' title='Exception...'></div>\n" );
92  }
93 
94  // Error-icon einfügen wenn bError = true
95  if ( this.bError )
96  {
97  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='ErrorSign' title='Error...'></div>\n" );
98  }
99 
100  if ( this.bWarning )
101  {
102  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='WarningSign' title='Warning...'></div>\n" );
103  }
104 
105  if ( this.bException || this.bError )
106  {
107  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='Info_Fail'>" + StringEscapeUtils.escapeHtml4(this.Info) + "</div>\n" );
108  }
109  else
110  {
111  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='SuccessSign' title='Success...'></div>\n" );
112  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='Info_Pass'>" + StringEscapeUtils.escapeHtml4(this.Info) + "</div>\n" );
113  }
114 
115  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "</div>\n" ); // end Header
116 
117  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div class='Body' id='" + myID.toString() + "' style='display: none;'>\n" );
118 
119  for ( LogBase myLog : this.myLogs )
120  {
121  sbResult.append( myLog.getHTMLResult() );
122  }
123 
124  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "<div>Return: " + StringEscapeUtils.escapeHtml4(this.myReturn) + "</div>\n" ); // Return-Value at the end...
125 
126  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "</div>\n" ); // end Body
127 
128  sbResult.append( lvsIndention + myIndentionBase + myIndentionBase + "</div>\n" ); // end Rahmen
129  //sbResult.append( lvsIndention + "</blockquote>\n");
130 
131  return sbResult.toString();
132  }
133 
134  @Override
135  protected void ErrorCount()
136  {
137  ErrorCount++;
138 
139  this.FunctionFail();
140 
141  this.bError = true;
142 
143  if ( myParent != null )
144  {
145  myParent.ErrorCount();
146  }
147  }
148 
149  @Override
150  protected void ExceptionCount()
151  {
152  ExceptionCount++;
153 
154  this.FunctionFail();
155 
156  this.bException = true;
157 
158  if ( myParent != null )
159  {
160  myParent.ExceptionCount();
161  }
162  }
163 
164  @Override
165  protected void FunctionFail()
166  {
167  if ( !( this.bError || this.bException ) )
168  myParent.FunctionFail();
169  }
170 
171  @Override
172  protected String getJSONNodeProperties()
173  {
174  StringBuilder myJSON = new StringBuilder();
175 
176  myJSON.append( this.jsonElementComma( "type", this.type ) );
177  // Info
178  myJSON.append( this.jsonElementComma( "Info", this.Info ) );
179 
180  myJSON.append( this.jsonElementComma( "Function", this.functionName ) );
181 
182  for ( Integer i = 0; i < this.parameter.length; i++ )
183  {
184 
185  myJSON.append( this.jsonElementComma( "Parameter" + i.toString(), parameter[i] ) );
186  }
187 
188  return myJSON.toString();
189  }
190 }
okw.log.log2html.LogBaseNode
Definition: LogBaseNode.java:3
okw.log.log2html.LogBase
Definition: LogBase.java:7
okw.log.log2html.LogFunctionDebug
Definition: LogFunctionDebug.java:5