You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2004/07/12 15:04:55 UTC

cvs commit: cocoon-2.1/src/test/org/apache/cocoon/util/test IOUtilsTestCase.java

antonio     2004/07/12 06:04:55

  Modified:    .        status.xml
               src/java/org/apache/cocoon/util IOUtils.java
               src/test/org/apache/cocoon/util/test IOUtilsTestCase.java
  Log:
  Deprecate methods in class o.a.c.util.IOUtils:
  
  1- public static String pathComponent(String filename);
  2- public static String fileComponent(String filename);
  3- public static String baseName(String filename);
  4- public static byte[] objectToBytes(Object object);
  5- public static Object bytesToObject(byte[] bytes);
  
  Revision  Changes    Path
  1.398     +13 -2     cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.397
  retrieving revision 1.398
  diff -u -r1.397 -r1.398
  --- status.xml	12 Jul 2004 12:47:29 -0000	1.397
  +++ status.xml	12 Jul 2004 13:04:55 -0000	1.398
  @@ -204,9 +204,20 @@
   
     <changes>
     <release version="@version@" date="@date@">
  +   <action dev="AG" type="update">
  +     Deprecated methods in class org.apache.cocoon.util.IOUtils
  +     to be removed in cocoon 2.3:
  +     <ul>
  +       <li>String baseName(String filename)</li>
  +       <li>Object bytesToObject(byte[] bytes)</li>
  +       <li>String fileComponent(String filename)</li>
  +       <li>byte[] objectToBytes(Object object)</li>
  +       <li>String pathComponent(String filename)</li>
  +     </ul>
  +   </action>
     <action dev="AG" type="update">
        Deprecated class org.apache.cocoon.util.JavaArchiveFilter.
  -     To be removed in cocoon 2.3. Moved to the deprecated dir
  +     To be removed in cocoon 2.3. Moved to the deprecated dir.
      </action>
      <action dev="AG" type="update">
        Update qdox to 1.5 and jdt-core to 3.0.0.
  
  
  
  1.6       +16 -15    cocoon-2.1/src/java/org/apache/cocoon/util/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/util/IOUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IOUtils.java	18 Apr 2004 23:06:11 -0000	1.5
  +++ IOUtils.java	12 Jul 2004 13:04:55 -0000	1.6
  @@ -198,10 +198,7 @@
       if ("".equals(filename)) {
           return "";
       }
  -    if(File.separatorChar == '\\')
  -        filename = filename.replace('/','\\');
  -    else
  -        filename = filename.replace('\\','/');
  +    filename = (File.separatorChar == '\\') ? filename.replace('/','\\') : filename.replace('\\','/');
       String[] path = StringUtils.split(filename, File.separator);
       int start = (path[0].length() == 0) ? 1 : 0;
   
  @@ -212,23 +209,22 @@
           buffer.append(File.separator);
         }
   
  -      if(path[i].equals("..")) {
  -        int lio = buffer.length()-2;
  -        while (lio>=0) {
  -          if (buffer.substring(lio).startsWith(File.separator))
  +      if (path[i].equals("..")) {
  +        int lio;
  +        for (lio = buffer.length() - 2; lio >= 0; i--) {
  +          if (buffer.substring(lio).startsWith(File.separator)) {
               break;
  -
  -          lio--;
  +          }
           }
  -
  -        if (lio>=0)
  +        if (lio >= 0) {
             buffer.setLength(lio);
  -
  +        }
         } else {
           char[] chars = path[i].toCharArray();
   
  -        if (chars.length < 1 || !Character.isLetter(chars[0])) 
  +        if (chars.length < 1 || !Character.isLetter(chars[0])) {
             buffer.append('_');
  +        }
   
           for (int j = 0; j < chars.length; j++) {
             if (org.apache.cocoon.util.StringUtils.isAlphaNumeric(chars[j])) {
  @@ -253,6 +249,7 @@
      *
      * @param filename The filename
      * @return The path information
  +   * @deprecated To be removed in cocoon 2.3
      */
     public static String pathComponent(String filename) {
       int i = filename.lastIndexOf(File.separator);
  @@ -265,6 +262,7 @@
      *
      * @param filename The filename
      * @return The filename sans path information
  +   * @deprecated To be removed in cocoon 2.3
      */
     public static String fileComponent(String filename) {
       int i = filename.lastIndexOf(File.separator);
  @@ -277,6 +275,7 @@
      *
      * @param filename The filename
      * @return The filename sans extension
  +   * @deprecated To be removed in cocoon 2.3
      */
     public static String baseName(String filename) {
       int i = filename.lastIndexOf('.');
  @@ -363,6 +362,7 @@
      *
      * @param object to convert
      * @return byte array from the object
  +   * @deprecated To be removed in cocoon 2.3
      */
     public static byte[] objectToBytes(Object object) throws IOException {
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
  @@ -376,6 +376,7 @@
      *
      * @param bytes array to convert
      * @return object
  +   * @deprecated To be removed in cocoon 2.3
      */
     public static Object bytesToObject(byte[] bytes) throws IOException, ClassNotFoundException {
       ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
  
  
  
  1.6       +1 -20     cocoon-2.1/src/test/org/apache/cocoon/util/test/IOUtilsTestCase.java
  
  Index: IOUtilsTestCase.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/test/org/apache/cocoon/util/test/IOUtilsTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IOUtilsTestCase.java	18 Apr 2004 23:06:11 -0000	1.5
  +++ IOUtilsTestCase.java	12 Jul 2004 13:04:55 -0000	1.6
  @@ -109,24 +109,5 @@
               assertEquals(message, expected, result);
           }
       }
  -
  -
  -    /**
  -     * A unit test for <code>objectToBytes()</code>, and <code>bytesToObject()</code>
  -     *
  -     * @exception  Exception  Description of Exception
  -     * @since
  -     */
  -    public void testObjectToBytesBytesToObject() throws Exception {
  -        String test = "test";
  -        String expected = "test";
  -
  -        String message = "Test " + "'" + test + "'";
  -
  -        byte[] bytes = IOUtils.objectToBytes(test);
  -        String result = (String) IOUtils.bytesToObject(bytes);
  -
  -        assertEquals(message, expected, result);
  -    }
   }