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