cziegeler    2003/10/20 01:47:29

  Modified:    src/java/org/apache/cocoon/components/source SourceUtil.java
  Log:
  Changing to Serviceable
  
  Revision  Changes    Path
  1.9       +38 -1     
cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java
  
  Index: SourceUtil.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SourceUtil.java   25 Sep 2003 12:54:21 -0000      1.8
  +++ SourceUtil.java   20 Oct 2003 08:47:29 -0000      1.9
  @@ -152,6 +152,8 @@
        * directly implement the LexicalHandler interface!
        * @param  source    the data
        * @throws ProcessingException if no suitable converter is found
  +     * @deprecated Use the [EMAIL PROTECTED] #toSAX(ServiceManager, Source, 
String, ContentHandler)
  +     *             method instead.
        */
       static public void toSAX( ComponentManager manager, Source source,
                                   String mimeTypeHint,
  @@ -180,12 +182,47 @@
       }
   
       /**
  +     * Generates SAX events from the given source
  +     * <b>NOTE</b> : if the implementation can produce lexical events, care 
should be taken
  +     * that <code>handler</code> can actually
  +     * directly implement the LexicalHandler interface!
  +     * @param  source    the data
  +     * @throws ProcessingException if no suitable converter is found
  +     */
  +    static public void toSAX( ServiceManager manager, Source source,
  +                                String mimeTypeHint,
  +                                ContentHandler handler)
  +    throws SAXException, IOException, ProcessingException {
  +        if ( source instanceof XMLizable ) {
  +            ((XMLizable)source).toSAX( handler );
  +        } else {
  +            String mimeType = source.getMimeType();
  +            if ( null == mimeType) mimeType = mimeTypeHint;
  +            XMLizer xmlizer = null;
  +            try {
  +                xmlizer = (XMLizer) manager.lookup( XMLizer.ROLE);
  +                xmlizer.toSAX( source.getInputStream(),
  +                               mimeType,
  +                               source.getURI(),
  +                               handler );
  +            } catch (SourceException se) {
  +                throw SourceUtil.handle(se);
  +            } catch (ServiceException ce) {
  +                throw new ProcessingException("Exception during streaming 
source.", ce);
  +            } finally {
  +                manager.release( xmlizer );
  +            }
  +        }
  +    }
  +
  +    /**
        * Generates SAX events from the given source by parsing it.
        * <b>NOTE</b> : if the implementation can produce lexical events, care 
should be taken
        * that <code>handler</code> can actually
        * directly implement the LexicalHandler interface!
        * @param  source    the data
        * @throws ProcessingException if no suitable converter is found
  +     * @deprecated Use [EMAIL PROTECTED] #parse(ServiceManager, Source, 
ContentHandler}.
        */
       static public void parse( ComponentManager manager, 
                                   Source source,
  
  
  

Reply via email to