nicolaken    2003/01/12 02:28:04

  Modified:    morphos/src/java/org/apache/commons/morphos/factories
                        BasicMorpherFactory.java
               morphos/src/java/org/apache/commons/morphos
                        ObjectFlavor.java
  Added:       morphos/src/java/org/apache/commons/morphos/helpers
                        FlavorPair.java
  Log:
  PAtch sent by Tomek Pik [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.3       +9 -4      
jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/factories/BasicMorpherFactory.java
  
  Index: BasicMorpherFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/factories/BasicMorpherFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicMorpherFactory.java  29 Aug 2002 07:07:59 -0000      1.2
  +++ BasicMorpherFactory.java  12 Jan 2003 10:28:03 -0000      1.3
  @@ -64,7 +64,12 @@
   import org.apache.commons.morphos.Morpher;
   import org.apache.commons.morphos.MorpherFactory;
   import org.apache.commons.morphos.ObjectFlavor;
  +import org.apache.commons.morphos.helpers.FlavorPair;
  +
   import java.util.HashMap;
  +import java.util.Collection;
  +import java.util.Iterator;
  +import java.util.Map;
   
   /**
    *
  
  
  
  1.1                  
jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/helpers/FlavorPair.java
  
  Index: FlavorPair.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/helpers/FlavorPair.java,v
 1.1 2003/01/12 10:28:03 nicolaken Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/12 10:28:03 $
   *
   * ====================================================================
   *
   * 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 [EMAIL PROTECTED]
   *
   * 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.helpers;
  
  import org.apache.commons.morphos.ObjectFlavor;
  
  /**
   * Pair of {@link ObjectFlavor} instances.
   * 
   * Represents possible morphing.
   * 
   * @author Tomasz Pik
   * @version $Revision: 1.1 $
   */
  public class FlavorPair {
  
      private ObjectFlavor input;
      private ObjectFlavor output;
  
      /**
       * @param input flavor of possible Morpher input
       * @param output flavor of possible Morpher output
       */
      public FlavorPair(ObjectFlavor input, ObjectFlavor output) {
          this.input = input;
          this.output = output;
      }
  
      /**
       * @@return output flavor of pair.
       */
      public ObjectFlavor getOutputFlavor() {
          return output;
      }
  
      /**
       * @return input flavor of pair.
       */
      public ObjectFlavor getInputFlavor() {
          return input;
      }    
  }
  
  
  
  1.2       +44 -5     
jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavor.java
  
  Index: ObjectFlavor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/morphos/src/java/org/apache/commons/morphos/ObjectFlavor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectFlavor.java 25 Jul 2002 13:18:10 -0000      1.1
  +++ ObjectFlavor.java 12 Jan 2003 10:28:03 -0000      1.2
  @@ -84,6 +84,7 @@
        *
        * @param dataType The mime type
        * @param dataForm The format in which the data is (object, file, stream, etc)
  +     * @throws IllegalArgumentException if one (or both) of agumentets is 
<code>null</code>
        */
        public ObjectFlavor (String dataType, String dataForm) {
          setDataType(dataType);
  @@ -98,10 +99,29 @@
          setDataForm("");
        }
   
  +     /**
  +      * Sets data type of this flavor.
  +      * 
  +      * Data type cannot be <code>null</code>.
  +      * 
  +      * @param dataType The mime type
  +      * @throws IllegalArgumentException if <code>dataType</code>
  +      *         is <code>null</code>.
  +      */
        void setDataType(String dataType){
          this.dataType = dataType;
        }
        
  +     /**
  +      * Sets data form of this flavor.
  +      * 
  +      * Data form cannot be <code>null</code>.
  +      * 
  +      * @param dataForm The format in which the data is
  +      *       (object, file, stream, etc)
  +      * @throws IllegalArgumentException if <code>dataForm</code>
  +      *         is <code>null</code>.
  +      */
        void setDataForm(String dataForm){
          this.dataForm = dataForm;
        }
  @@ -113,7 +133,26 @@
        String getdataForm(){
          return dataForm; 
        }
  -          
  +
  +    /**
  +     * @see Object#equals(java.lang.Object)
  +     */
  +    public boolean equals(Object o) {
  +        try {
  +            ObjectFlavor other = (ObjectFlavor) o;
  +            return (other.getdataType().equals(dataType) &&
  +                    other.getdataForm().equals(dataForm));
  +        } catch (ClassCastException cce) {
  +            return false;
  +        }  
  +    }
  +
  +    /**
  +     * @see Object#hashCode()
  +     */
  +    public int hashCode() {
  +        return (dataType + "->" + dataForm).hashCode();
  +    }
   }
   
   
  
  
  

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

Reply via email to