Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
31   62   9   31
8   41   0.29   1
1     9  
1    
 
  StringQuoter       Line # 22 31 0% 9 40 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
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.
15    */
16    package org.kuali.student.contract.writer;
17   
18    /**
19    *
20    * @author nwright
21    */
 
22    public class StringQuoter {
23   
 
24  0 toggle public static String quote(String value) {
25  0 if (value == null) {
26  0 return null;
27    }
28  0 StringBuffer buf = new StringBuffer(value.length() + 3);
29  0 buf.append('"');
30  0 boolean lastCharWasEscape = false;
31  0 for (int i = 0; i < value.length(); i++) {
32  0 char c = value.charAt(i);
33  0 switch (c) {
34  0 case '"':
35  0 if (!lastCharWasEscape) {
36  0 buf.append('\\');
37    }
38  0 lastCharWasEscape = false;
39  0 break;
40  0 case '\\':
41  0 if (!lastCharWasEscape) {
42  0 buf.append('\\');
43    }
44  0 lastCharWasEscape = true;
45  0 break;
46  0 case '\n':
47  0 case '\r':
48  0 buf.append('"');
49  0 buf.append("\n");
50  0 buf.append("\t + ");
51  0 buf.append('"');
52  0 lastCharWasEscape = false;
53  0 continue;
54  0 default:
55  0 lastCharWasEscape = false;
56    }
57  0 buf.append(c);
58    }
59  0 buf.append('"');
60  0 return buf.toString();
61    }
62    }