commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos AbstractMorpher.java BasicMorpherFactory.java Morpher.java MorpherFactory.java MorpherPipeline.java MorphException.java Morphos.java ObjectFlavor.java ObjectFlavorException.java package.html
Date Thu, 25 Jul 2002 13:18:11 GMT
nicolaken    2002/07/25 06:18:11

  Added:       morphos/src/java/org/apache/commons/morphos
                        AbstractMorpher.java BasicMorpherFactory.java
                        Morpher.java MorpherFactory.java
                        MorpherPipeline.java MorphException.java
                        Morphos.java ObjectFlavor.java
                        ObjectFlavorException.java package.html
  Log:
  Initial Morphos codebase, based on the discussions on commons-dev.
  Corrently the Factories and pipelining are not yet done, although there are
  already the interfaces.
  The main class, Morphos, currently uses the HSSFMorpher hardcoded.
  The only Morpher supplied is the HSSFMorpher.
  To try, run
    ant examples
  and look in the build directory.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/AbstractMorpher.java
  
  Index: AbstractMorpher.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/AbstractMorpher.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  /**
   * @author Nicola Ken Barozzi
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   public class AbstractMorpher implements Morpher {
  
       public void setInput(Object input) throws ObjectFlavorException{
         throw new ObjectFlavorException("The ObjectFlavor used is not supported by this morpher.");
       }
       
       public void setOutput(Object output) throws ObjectFlavorException{
         throw new ObjectFlavorException("The ObjectFlavor used is not supported by this morpher.");
    
       }
  
       public void morph() throws MorphException{
         throw new MorphException("This is a passive Morpher, the morphing process must be
done in a pipeline.");     
       }
       
       /*
       void addNotificationListener(NotificationListener nl);
       void removeNotificationListener(NotificationListener nl);
       void clearNotificationListeners();
  */
          
  }
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/BasicMorpherFactory.java
  
  Index: BasicMorpherFactory.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/BasicMorpherFactory.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  import org.apache.commons.morphos.morphers.poi.*;
  
   public class BasicMorpherFactory implements MorpherFactory {
  
       BasicMorpherFactory() {
       
       }
  
       public Morpher getMorpher(ObjectFlavor inputFlavor, ObjectFlavor outputFlavor){
         return new HSSFMorpher();
       }
       
       public Morpher getMorpher(String name){
         return new HSSFMorpher();
       }
  
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morpher.java
  
  Index: Morpher.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morpher.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  /**
  <pre>
    [Example]
  
  // Create the Manager that gives me the morphers 
  Morpherfactory  mfactory = new SimpleMorpherFactory("mmanager-conf.xml");
  
  // Get a jaxp Morpher by name
  Morpher jaxpmorpher =  mfactory.getMorpher("jaxp");
  
  jaxpmorpher.setStylesheet("transform.xml");
  
  // Get a Morpher that serializes an XML dom to a stream
  Morpher streammorpher =
    mfactory.getMorpher(
       new DataType("text/xml", "object/dom"),
       new DataType("text/xml", "stream/unix")
     );
  
  //Chain the two:
  
  MorpherPipeline mpipeline =  new SimpleMorpherPipeline();
  mpipeline.addStage(jaxpmorpher );
  mpipeline.addStage(streammorpher );
  
  try{
    mpipeline.setInput(myDomObject);
    mpipeline.setOutput(outputstream);
    mpipeline.morph();
  }
  catch(MorphException ioe){
   .....}
  catch(OblectFlavorException ofe){
  .....}
  </pre>
   *
   * @author Nicola Ken Barozzi
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   
   public interface Morpher {
  
      /**
       * Construct a "call method" rule with the specified method name.
       *
       * @param input The associated Digester
       */
       void setInput(Object input) throws ObjectFlavorException;
       
       
       void setOutput(Object output) throws ObjectFlavorException;
       
     /**
       * Execute the morph.
       * Usually it's needed to have setInput(Object input) and setOutput(Object output)
       * called before.
       */
       void morph() throws MorphException;
  /*
       void addNotificationListener(NotificationListener nl);
       void removeNotificationListener(NotificationListener nl);
       void clearNotificationListeners();
  */
  }
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorpherFactory.java
  
  Index: MorpherFactory.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorpherFactory.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  /**
   * The Morphers' manager.
   * There is a getDefaultFactory method for easy use.
   * Used in frameworks it's better not to use it and rely on
   * services that give the proper MorpherFactory.
   *
   * @author Nicola Ken Barozzi
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   
   public interface MorpherFactory {
  
      /**
       * Construct a "call method" rule with the specified method name.
       *
       * @param digester The associated Digester
       * @param methodName Method name of the parent method to call
       * @param paramCount The number of parameters to collect, or
       *  zero for a single argument from the body of ths element
       * @param paramTypes The Java class names of the arguments
       *  (if you wish to use a primitive type, specify the corresonding
       *  Java wrapper class instead, such as <code>java.lang.Boolean</code>
       *  for a <code>boolean</code> parameter)
       */
  
       Morpher getMorpher(ObjectFlavor inputFlavor, ObjectFlavor outputFlavor);
       Morpher getMorpher(String name);
  
  }
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorpherPipeline.java
  
  Index: MorpherPipeline.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorpherPipeline.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  /**
   * Rule implementation that calls a method on the top (parent)
   * object, passing arguments collected from subsequent
   * <code>CallParamRule</code> rules or from the body of this
   * element. 
   * By using {@link #CallMethodRule(String methodName)} 
   * a method call can be made to a method which accepts no
   * arguments.
   *
   * @author Nicola Ken Barozzi
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   
   public interface MorpherPipeline extends Morpher {
  
      /**
       * Construct a "call method" rule with the specified method name.
       *
       * @param digester The associated Digester
       * @param methodName Method name of the parent method to call
       * @param paramCount The number of parameters to collect, or
       *  zero for a single argument from the body of ths element
       * @param paramTypes The Java class names of the arguments
       *  (if you wish to use a primitive type, specify the corresonding
       *  Java wrapper class instead, such as <code>java.lang.Boolean</code>
       *  for a <code>boolean</code> parameter)
       *
       * @deprecated The digester instance is now set in the {@link Digester#addRule} method.

       * Use {@link #CallMethodRule(String methodName,int paramCount, String [] paramTypes)}
instead.
       */
       void addStage(Morpher nextMorpher); 
  }
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorphException.java
  
  Index: MorphException.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/MorphException.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
   public class MorphException extends Exception {
   
     public MorphException(String message){
       super(message);
     }
     
     public MorphException(String message, Throwable cause){
       super(message, cause);
     }
     
     public MorphException(Throwable cause){
       super(cause);
     }
     
  }
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morphos.java
  
  Index: Morphos.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/Morphos.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  import java.io.*;
  
  import javax.xml.parsers.SAXParserFactory;
  
  import org.apache.commons.morphos.*;
  import org.apache.commons.morphos.morphers.poi.*;
  import org.apache.commons.morphos.morphers.dataform.*;
  
  import org.xml.sax.InputSource;
  import org.xml.sax.XMLReader;
  
  /**
   * @author Nicola Ken Barozzi
   * @author svenk@imost.de
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   
   public class Morphos {
   
  	public static void main(String args[]) throws Exception{
  		if(args.length!=2){
  			System.err.println("Usage: org.apache.commons.morphos.morphers.poi.test.HSSF infile outfile");
  			System.exit(2);
  		}
                  
                  //------------------------------------------------------------         
      
                  //WARNING: pipelineing done by hand; uses only fixed morphers
                  //------------------------------------------------------------
                  //Can use more stages for modularity, like string->File
                  // then File->InputStream, then the following.
                  //Need to integrate with Transformers for simple stuff.
                  //------------------------------------------------------------
                  // also here we give a morpher to a morpher, sometimes we give
                  // the output... needs to be thought better maybe...
  
                  InputSource input = new InputSource(new FileInputStream(args[0]));	
  		OutputStream output = new FileOutputStream(args[1]);
                  
                  
  		InputSource2SAXMorpher morpher1 = new InputSource2SAXMorpher();
  		morpher1.setInput(input);
                  
                    HSSFMorpher morpher2 = new HSSFMorpher();
  		  morpher2.setOutput(output);
                    
                  morpher1.setOutput(morpher2);
                  
                  morpher1.morph();
                  
                  output.flush();
                  output.close();
  	}
  	
  }
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavor.java
  
  Index: ObjectFlavor.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavor.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
  
  /**
   * Describes what the format of the data is.
   * It consists of a dataType (format) and a dataForm (representation).
   * For example a gif image file and a jped image file have a
   * different dataType but same dataForm (file).
   * An SVG file and an SVG DOM in memory have same dataType but
   * different dataForm.
   *
   * @author Nicola Ken Barozzi
   * @version $Revision: 1.1 $ $Date: 2002/07/25 13:18:10 $
   */
   
   public class ObjectFlavor {
   
     String dataType;
     String dataForm;
    
      /**
       * Construct an ObjectFlavor.
       *
       * @param dataType The mime type
       * @param dataForm The format in which the data is (object, file, stream, etc)
       */
       public ObjectFlavor (String dataType, String dataForm) {
         setDataType(dataType);
         setDataForm(dataForm);
       }
  
      /**
       * Construct an ObjectFlavor.
       */
       public ObjectFlavor () {
         setDataType("");
         setDataForm("");
       }
  
       void setDataType(String dataType){
         this.dataType = dataType;
       }
       
       void setDataForm(String dataForm){
         this.dataForm = dataForm;
       }
  
       String getdataType(){ 
         return dataType; 
       }
       
       String getdataForm(){
         return dataForm; 
       }
            
  }
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavorException.java
  
  Index: ObjectFlavorException.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavorException.java,v
1.1 2002/07/25 13:18:10 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/25 13:18:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.morphos;
  
   public class ObjectFlavorException extends Exception {
   
     public ObjectFlavorException(String message){
       super(message);
     }
     
     public ObjectFlavorException(String message, Throwable cause){
       super(message, cause);
     }
     
     public ObjectFlavorException(Throwable cause){
       super(cause);
     }
     
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/package.html
  
  Index: package.html
  ===================================================================
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
  <head>
    <title>Package Documentation for org.apache.commons.digester Package</title>
  </head>
    <body style="background-color: white;">
   The Morphos package transforms "file formats" in a pluggable and extensible 
  manner.<br>
    <br>
        <a name="doc.Depend"></a>   
  <h3>External Dependencies</h3>
        
  <ul>
       <li>Xerces</li>
    <li>POI 1.7-dev<br>
    </li>
       
  </ul>
      <a name="doc.Intro"></a>   
  <h3>Introduction</h3>
        
  <p>Morphos is a package with the aim of transforming "file formats" in a pluggable
  and extensible manner.<br>
   The code units to transform from-to different formats are called Morphers.</p>
   These morphers transform between different ObjectFlavors, that specify both 
  the datatype and the dataform.<br>
   For example a gif image file and a jped image file have a different dataType 
  but same dataForm (file).<br>
   An SVG file and an SVG DOM in memory have same dataType but different dataForm<br>
   <br>
   Morphos is the commandline version.<br>
   MorpherFactory make it possible to specify clever ways of autoresolving
  morphers given the ObjectFlavors. 
  <p></p>
   <br>
      <a name="doc.Properties"></a>   
  <h3>Example of full-feature use</h3>
        
  <p>/** </p>
   
  <pre>//<span style="font-weight: bold;"> NOTE</span> Currently Factories
are not yet implemented, you must<br>//      create Morphers with <span
   style="font-weight: bold;">new</span><br><br>//<span
   style="font-weight: bold;"> NOTE </span>Currently pipelining is not yet done,
it has to be<br>//      done by hand<br><br>// Create the Manager that gives
me the morphers <br>Morpherfactory  mfactory = new SimpleMorpherFactory("mmanager-conf.xml");<br><br>//
Get a jaxp Morpher by name<br>Morpher jaxpmorpher =  mfactory.getMorpher("jaxp");<br><br>jaxpmorpher.setStylesheet("transform.xml");<br><br>//
Get a Morpher that serializes an XML dom to a stream<br>Morpher streammorpher =<br>
 mfactory.getMorpher(<br>     new ObjectFlavor("text/xml", "object/dom"),<br>
    new ObjectFlavor("text/xml", "stream/unix")<br>   );<br><br>//Chain
the two:<br><br>MorpherPipeline mpipeline =  new SimpleMorpherPipeline();<br>mpipeline.addStage(jaxpmorpher
);<br>mpipeline.addStage(streammorpher );<br><br>try{<br>  mpipeline.setInput(myDomObject);<br>
 mpipeline.setOutput(outputstream);<br>  mpipeline.morph();<br>}<br>catch(MorphException
ioe){<br> .....}<br>catch(OblectFlavorException ofe){<br>.....}<br></pre>
       <br>
     <br>
  </body>
  </html>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message