cziegeler    02/02/05 04:13:52

  Modified:    src/scratchpad/org/apache/avalon/excalibur/source
                        SourceUtil.java
  Log:
  Added file support
  
  Revision  Changes    Path
  1.6       +20 -2     
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceUtil.java
  
  Index: SourceUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SourceUtil.java   5 Feb 2002 09:48:07 -0000       1.5
  +++ SourceUtil.java   5 Feb 2002 12:13:52 -0000       1.6
  @@ -10,6 +10,7 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.xml.sax.InputSource;
   import java.io.ByteArrayOutputStream;
  +import java.io.File;
   import java.io.IOException;
   import java.io.OutputStreamWriter;
   import java.util.BitSet;
  @@ -20,7 +21,7 @@
    * Utility class for source resolving.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2002/02/05 09:48:07 $
  + * @version CVS $Revision: 1.6 $ $Date: 2002/02/05 12:13:52 $
    */
   public final class SourceUtil
   {
  @@ -254,7 +255,9 @@
       }
   
       /**
  -     * Return a new <code>InputSource</code> object
  +     * Return a new <code>InputSource</code> object that uses
  +     * the <code>InputStream</code> and the system ID of the
  +     * <code>Source</code> object.
        *
        * @throws IOException if I/O error occured.
        */
  @@ -264,6 +267,21 @@
           final InputSource newObject = new InputSource( 
source.getInputStream() );
           newObject.setSystemId( source.getSystemId() );
           return newObject;
  +    }
  +
  +    /**
  +     * Return a <code>File</code> object associated with the 
<code>Source</code> object.
  +     *
  +     * @return The corresponding <code>File</code> object or null if the
  +     *         <code>Source</code> object does not point to a file URI.
  +     */
  +    public static File getFile(Source source)
  +    {
  +        final String systemId = source.getSystemId();
  +        if ( systemId.startsWith("file:") ) {
  +            return new File( systemId.substring(5) );
  +        }
  +        return null;
       }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to