Coverage Report - org.kuali.student.r2.common.util.RichTextHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
RichTextHelper
0%
0/15
0%
0/6
2.2
 
 1  
 
 2  
 /*
 3  
  * Copyright 2011 The Kuali Foundation
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 1.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl1.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.student.r2.common.util;
 18  
 
 19  
 import org.kuali.student.r2.common.dto.RichTextInfo;
 20  
 
 21  
 /**
 22  
  * Utility to convert text between plain and formatted
 23  
  * @author nwright
 24  
  */
 25  0
 public class RichTextHelper {
 26  
 
 27  
     public RichTextInfo toRichTextInfo(String plain, String formatted) {
 28  0
         if (plain == null) {
 29  0
             return null;
 30  
         }
 31  0
         RichTextInfo info = new RichTextInfo();
 32  0
         info.setFormatted(formatted);
 33  0
         info.setPlain(plain);
 34  0
         return info;
 35  
     }
 36  
 
 37  
     public RichTextInfo fromFormatted(String plain) {
 38  0
         return toRichTextInfo(plain, formatted2Plain(plain));
 39  
     }
 40  
 
 41  
     public RichTextInfo fromPlain(String plain) {
 42  0
         return toRichTextInfo(plain, plain2Formatted(plain));
 43  
     }
 44  
 
 45  
     public String formatted2Plain(String forematted) {
 46  0
         if (forematted == null) {
 47  0
             return null;
 48  
         }
 49  
         // TODO: actually implement a real conversion
 50  0
         return forematted.replaceAll("<br>", "\n");
 51  
     }
 52  
 
 53  
     public String plain2Formatted(String plain) {
 54  0
         if (plain == null) {
 55  0
             return null;
 56  
         }
 57  
         // TODO: actually implement a real conversion
 58  0
         return plain.replaceAll("\n", "<br>");
 59  
     }
 60  
 }