jvanzyl     00/12/25 12:59:56

  Modified:    src/java/org/apache/velocity/texen/util StringUtil.java
  Log:
  - Made the chop() sensitive to the EOL character or a particular
    platform. Added to fix the problem with Torque leaving extra
    characters in the SQL generated under Windows. The chop()
    will now consider EOL a single characters regardless of
    platform.
  
  Revision  Changes    Path
  1.8       +15 -2     
jakarta-velocity/src/java/org/apache/velocity/texen/util/StringUtil.java
  
  Index: StringUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/util/StringUtil.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StringUtil.java   2000/12/20 06:28:39     1.7
  +++ StringUtil.java   2000/12/25 20:59:55     1.8
  @@ -67,6 +67,8 @@
    */
   public class StringUtil extends BaseUtil
   {
  +    private static final String EOL = System.getProperty("line.separator");
  +    private static final int EOL_LENGTH = EOL.length();
       
       /**
        * Concatenates a list of objects as a String
  @@ -120,14 +122,25 @@
   
       /**
        * Chop i characters off the end of a string.
  +     * This method is sensitive to the EOL for a
  +     * particular platform. The EOL character will
  +     * considered a single character.
        *
        * @param string String to chop.
        * @param i Number of characters to chop.
        * @return String with processed answer.
        */
  -    public static String chop(String string, int i)
  +    public static String chop(String s, int i)
       {
  -        return(string.substring(0, string.length() - i));
  +        for (int j = 0; j < i; j++)
  +        {
  +            if (EOL.indexOf(s.substring(s.length() - 1)) > 0 && EOL_LENGTH == 2)
  +                s = s.substring(0, s.length() - 2);
  +            else
  +                s = s.substring(0, s.length() - 1);
  +        }            
  +    
  +        return s;
       }
   
       /**
  
  
  

Reply via email to