]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.argeo
.slc
.process
;
19 import java
.util
.ArrayList
;
20 import java
.util
.Date
;
21 import java
.util
.List
;
22 import java
.util
.StringTokenizer
;
23 import java
.util
.UUID
;
25 public class SlcExecutionStep
{
26 public final static String TYPE_START
= "START";
27 public final static String TYPE_END
= "END";
28 public final static String TYPE_PHASE_START
= "PHASE_START";
29 public final static String TYPE_PHASE_END
= "PHASE_END";
30 public final static String TYPE_LOG
= "LOG";
32 private String uuid
= UUID
.randomUUID().toString();
34 private Date begin
= new Date();
35 private List
<String
> logLines
= new ArrayList
<String
>();
37 /** Empty constructor */
38 public SlcExecutionStep() {
41 /** Creates a step of type LOG. */
42 public SlcExecutionStep(String log
) {
46 /** Creates a step of the given type. */
47 public SlcExecutionStep(String type
, String log
) {
52 public String
getUuid() {
56 public void setUuid(String uuid
) {
60 public String
getType() {
64 public void setType(String type
) {
68 public Date
getBegin() {
72 public void setBegin(Date begin
) {
76 public List
<String
> getLogLines() {
80 public void setLogLines(List
<String
> logLines
) {
81 this.logLines
= logLines
;
84 public void addLog(String log
) {
88 StringTokenizer st
= new StringTokenizer(log
, "\n");
89 while (st
.hasMoreTokens())
90 logLines
.add(removeNonXmlChars(st
.nextToken()));
94 * Removes non XML compliant characters (from
95 * http://stackoverflow.com/questions
96 * /20762/how-do-you-remove-invalid-hexadecimal
97 * -characters-from-an-xml-based-data-source-pr)
99 private static String
removeNonXmlChars(String inString
) {
100 if (inString
== null)
103 StringBuilder newString
= new StringBuilder();
106 for (int i
= 0; i
< inString
.length(); i
++) {
108 ch
= inString
.charAt(i
);
109 // remove any characters outside the valid UTF-8 range as well as
110 // all control characters
111 // except tabs and new lines
112 if ((ch
< 0x00FD && ch
> 0x001F) || ch
== '\t' || ch
== '\n'
114 newString
.append(ch
);
117 return newString
.toString();
122 public String
toString() {
123 return getClass().getSimpleName() + "#" + uuid
;