Changeset 1241


Ignore:
Timestamp:
06/28/13 13:26:30 (11 years ago)
Author:
pharms
Message:
  • applied code formating
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-utils/src/main/java/de/ugoe/cs/util/StringTools.java

    r927 r1241  
    2525final public class StringTools { 
    2626 
    27         /** 
    28         * <p> 
    29         * Private constructor to prevent initializing of the class. 
    30         * </p> 
    31         */ 
    32         private StringTools() { 
     27    /** 
     28    * <p> 
     29    * Private constructor to prevent initializing of the class. 
     30    * </p> 
     31    */ 
     32    private StringTools() { 
    3333 
    34         } 
     34    } 
    3535 
    36         /** 
    37         * <p> 
    38         * Simplifies use of operation system specific line separators. 
    39         * </p> 
    40         */ 
    41         public final static String ENDLINE = System.getProperty("line.separator"); 
     36    /** 
     37    * <p> 
     38    * Simplifies use of operation system specific line separators. 
     39    * </p> 
     40    */ 
     41    public final static String ENDLINE = System.getProperty("line.separator"); 
    4242 
    43         /** 
    44          * <p> 
    45          * Replaces all occurrences of {@literal &, <, >, ', and "} with their 
    46          * respective XML entities {@literal &amp;, &lt;, &gt;, &apos;, and &quot;} 
    47          * without destroying already existing entities. 
    48          * </p> 
    49          *  
    50          * @param str 
    51          *            String where the XML entities are to be replaced 
    52          * @return new String, where the XML entities are used instead of the 
    53          *         literals 
    54          */ 
    55         public static String xmlEntityReplacement(String str) { 
    56                 String result = str; 
    57                 if (result != null && !"".equals(result)) { 
    58                         result = result 
    59                                         .replaceAll("&(?!(?:lt|gt|apos|quot|amp);)", "&amp;"); 
    60                         result = result.replaceAll("<", "&lt;"); 
    61                         result = result.replaceAll(">", "&gt;"); 
    62                         result = result.replaceAll("'", "&apos;"); 
    63                         result = result.replaceAll("\"", "&quot;"); 
    64                 } 
    65                 return result; 
    66         } 
     43    /** 
     44     * <p> 
     45     * Replaces all occurrences of {@literal &, <, >, ', and "} with their respective XML entities 
     46     * {@literal &amp;, &lt;, &gt;, &apos;, and &quot;} without destroying already existing 
     47     * entities. 
     48     * </p> 
     49     *  
     50     * @param str 
     51     *            String where the XML entities are to be replaced 
     52     * @return new String, where the XML entities are used instead of the literals 
     53     */ 
     54    public static String xmlEntityReplacement(String str) { 
     55        String result = str; 
     56        if (result != null && !"".equals(result)) { 
     57            result = result.replaceAll("&(?!(?:lt|gt|apos|quot|amp);)", "&amp;"); 
     58            result = result.replaceAll("<", "&lt;"); 
     59            result = result.replaceAll(">", "&gt;"); 
     60            result = result.replaceAll("'", "&apos;"); 
     61            result = result.replaceAll("\"", "&quot;"); 
     62        } 
     63        return result; 
     64    } 
    6765} 
Note: See TracChangeset for help on using the changeset viewer.