You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by tk...@apache.org on 2001/01/09 11:24:26 UTC

cvs commit: xml-batik/sources/org/apache/batik/transcoder Transcoder.java TranscoderException.java TranscodingHints.java

tkormann    01/01/09 02:24:26

  Modified:    sources/org/apache/batik/apps/rasterizer Main.java
               sources/org/apache/batik/apps/regard Main.java
               sources/org/apache/batik/apps/regsvggen Main.java
               sources/org/apache/batik/refimpl/transcoder
                        AbstractTranscoder.java BatikHints.java
                        JpegTranscoder.java
               sources/org/apache/batik/transcoder Transcoder.java
                        TranscoderException.java TranscodingHints.java
  Log:
  prepare the new API for transcoders. The old ones have been hacked to still compile. They all be moved in the appropriate directory soon.
  
  Revision  Changes    Path
  1.3       +6 -4      xml-batik/sources/org/apache/batik/apps/rasterizer/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/rasterizer/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2000/11/14 22:00:53	1.2
  +++ Main.java	2001/01/09 10:24:21	1.3
  @@ -17,8 +17,10 @@
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
  +import java.net.URL;
   import java.net.MalformedURLException;
   import org.apache.batik.refimpl.transcoder.ConcreteTranscoderFactory;
  +import org.apache.batik.refimpl.transcoder.ImageTranscoder;
   import org.apache.batik.transcoder.Transcoder;
   import org.apache.batik.transcoder.TranscoderFactory;
   import org.xml.sax.InputSource;
  @@ -27,11 +29,11 @@
    * A simple class that can generate images from svg documents.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: Main.java,v 1.2 2000/11/14 22:00:53 vhardy Exp $
  + * @version $Id: Main.java,v 1.3 2001/01/09 10:24:21 tkormann Exp $
    */
   public class Main {
   
  -    public static void writeImage(Transcoder transcoder,
  +    public static void writeImage(ImageTranscoder transcoder,
                                     String uri, String output) {
           try {
               System.out.println("Converting "+uri+" to "+output);
  @@ -41,7 +43,7 @@
               transcoder.transcodeToStream(isource, ostream);
               ostream.flush();
               ostream.close();
  -        } catch(IOException ex) {
  +        } catch(Exception ex) {
               System.out.println("Error while writing "+uri+" to "+output);
           }
       }
  @@ -118,7 +120,7 @@
               }
               File output = new File(directory, uri);
               try {
  -                writeImage(t,
  +                writeImage((ImageTranscoder)t,
                              f.toURL().toString(),
                              output.getAbsolutePath());
               } catch (MalformedURLException ex) {
  
  
  
  1.3       +7 -4      xml-batik/sources/org/apache/batik/apps/regard/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/regard/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2000/11/15 00:17:52	1.2
  +++ Main.java	2001/01/09 10:24:22	1.3
  @@ -34,6 +34,7 @@
   import org.apache.batik.refimpl.transcoder.ImageTranscoder;
   import org.apache.batik.transcoder.Transcoder;
   import org.apache.batik.transcoder.TranscoderFactory;
  +import org.apache.batik.transcoder.TranscoderException;
   import org.apache.batik.util.awt.image.ImageLoader;
   import org.xml.sax.InputSource;
   
  @@ -42,7 +43,7 @@
    *
    * @author <a href="mailto:spei@cs.uiowa.edu">Sheng Pei</a>
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version  $Id: Main.java,v 1.2 2000/11/15 00:17:52 vhardy Exp $
  + * @version  $Id: Main.java,v 1.3 2001/01/09 10:24:22 tkormann Exp $
    */
   public class Main {
   
  @@ -332,8 +333,8 @@
                   content += s;
                   break;
               }
  -            
  -            ImageTranscoder transcoder 
  +
  +            ImageTranscoder transcoder
                   = (ImageTranscoder)getTranscoder();
               BufferedImage bfDiff = transcoder.createImage(2*bfRef.getWidth(), 2*bfRef.getHeight());
   
  @@ -473,10 +474,12 @@
               InputSource isource = new InputSource(inputURI);
               OutputStream ostream =
                   new BufferedOutputStream(new FileOutputStream(output));
  -            transcoder.transcodeToStream(isource, ostream);
  +            ((ImageTranscoder)transcoder).transcodeToStream(isource, ostream);
               ostream.flush();
               ostream.close();
           } catch(IOException ex) {
  +            error("while writing "+inputURI+" to "+output+"\n"+ex.getMessage());
  +        } catch(TranscoderException ex) {
               error("while writing "+inputURI+" to "+output+"\n"+ex.getMessage());
           }
       }
  
  
  
  1.5       +6 -4      xml-batik/sources/org/apache/batik/apps/regsvggen/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/regsvggen/Main.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Main.java	2000/11/30 07:19:10	1.4
  +++ Main.java	2001/01/09 10:24:23	1.5
  @@ -62,7 +62,7 @@
    * A regression checking tool for SVG generator test cases.
    *
    * @author <a href="mailto:spei@cs.uiowa.edu">Sheng Pei</a>
  - * @version $Id: Main.java,v 1.4 2000/11/30 07:19:10 vhardy Exp $
  + * @version $Id: Main.java,v 1.5 2001/01/09 10:24:23 tkormann Exp $
    */
   public class Main {
   
  @@ -453,7 +453,7 @@
   
           g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                  RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  -        
  +
           g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                                  RenderingHints.VALUE_FRACTIONALMETRICS_ON);
   
  @@ -494,7 +494,7 @@
   
           // Second, create an instance of the generator and paint to it
   
  -        ImageHandler imageHandler 
  +        ImageHandler imageHandler
               = new ImageHandlerPNGEncoder(REGSVGGEN_DIRECTORY_NAME +
                                            FILE_SEPARATOR +
                                            REGSVGGEN_NEW_DIRECTORY_NAME,
  @@ -788,10 +788,12 @@
               InputSource isource = new InputSource(inputURI);
               OutputStream ostream =
                   new BufferedOutputStream(new FileOutputStream(output));
  -            transcoder.transcodeToStream(isource, ostream);
  +            ((ImageTranscoder)transcoder).transcodeToStream(isource, ostream);
               ostream.flush();
               ostream.close();
           } catch(IOException ex) {
  +            error("while writing "+inputURI+" to "+output+"\n"+ex.getMessage());
  +        } catch(Exception ex) {
               error("while writing "+inputURI+" to "+output+"\n"+ex.getMessage());
           }
       }
  
  
  
  1.7       +37 -8     xml-batik/sources/org/apache/batik/refimpl/transcoder/AbstractTranscoder.java
  
  Index: AbstractTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/refimpl/transcoder/AbstractTranscoder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractTranscoder.java	2001/01/08 13:19:53	1.6
  +++ AbstractTranscoder.java	2001/01/09 10:24:23	1.7
  @@ -20,9 +20,13 @@
   import org.apache.batik.dom.svg.SVGDocumentFactory;
   import org.apache.batik.refimpl.bridge.ConcreteGVTBuilder;
   import org.apache.batik.transcoder.Transcoder;
  +import org.apache.batik.transcoder.TranscoderInput;
  +import org.apache.batik.transcoder.TranscoderOutput;
  +import org.apache.batik.transcoder.ErrorHandler;
   import org.apache.batik.transcoder.TranscoderException;
   import org.apache.batik.transcoder.TranscodingHints;
   import org.w3c.dom.DOMException;
  +import org.w3c.dom.Document;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  @@ -30,7 +34,7 @@
    * A generic <tt>Transcoder</tt>.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: AbstractTranscoder.java,v 1.6 2001/01/08 13:19:53 hillion Exp $
  + * @version $Id: AbstractTranscoder.java,v 1.7 2001/01/09 10:24:23 tkormann Exp $
    */
   public abstract class AbstractTranscoder implements Transcoder {
   
  @@ -42,17 +46,22 @@
       protected TranscodingHints hints = new TranscodingHints();
   
       public AbstractTranscoder() {
  -        hints.put(TranscodingHints.KEY_XML_PARSER_CLASSNAME,
  +        hints.put(BatikHints.KEY_XML_PARSER_CLASSNAME,
                     "org.apache.crimson.parser.XMLReaderImpl");
  -        hints.put(TranscodingHints.KEY_GVT_BUILDER,
  +        hints.put(BatikHints.KEY_GVT_BUILDER,
                     new org.apache.batik.refimpl.bridge.ConcreteGVTBuilder());
  -        hints.put(TranscodingHints.KEY_DEFAULT_VIEWPORT,
  +        hints.put(BatikHints.KEY_DEFAULT_VIEWPORT,
                     new Viewport() {
               public float getWidth() { return 640f; }
               public float getHeight() { return 480f; }
           });
       }
   
  +    public void transcode(TranscoderInput input, TranscoderOutput output)
  +            throws TranscoderException {
  +        throw new Error();
  +    }
  +
       /**
        * Creates a <tt>Document</tt> using the specified isource and
        * call the <tt>transcodeToStream(Document, OutputStream).
  @@ -69,6 +78,9 @@
           }
       }
   
  +    public abstract void transcodeToStream(Document document, OutputStream ostream)
  +            throws TranscoderException;
  +
       public TranscodingHints getTranscodingHints() {
           return new TranscodingHints(hints);
       }
  @@ -82,30 +94,47 @@
       }
   
       /**
  +     * Sets the error handler this transcoder may use to report
  +     * warnings and errors.
  +     * @param handler to ErrorHandler to use
  +     */
  +    public void setErrorHandler(ErrorHandler handler) {
  +        throw new Error();
  +    }
  +
  +    /**
  +     * Returns the error handler this transcoder uses to report
  +     * warnings and errors, or null if any.
  +     */
  +    public ErrorHandler getErrorHandler() {
  +        throw new Error();
  +    }
  +
  +    /**
        * Returns the GVTBuilder to use.
        */
       protected GVTBuilder getGVTBuilder() {
  -        return (GVTBuilder) hints.get(TranscodingHints.KEY_GVT_BUILDER);
  +        return (GVTBuilder) hints.get(BatikHints.KEY_GVT_BUILDER);
       }
   
       /**
        * Returns the default Viewport to use.
        */
       protected Viewport getDefaultViewport() {
  -        return (Viewport) hints.get(TranscodingHints.KEY_DEFAULT_VIEWPORT);
  +        return (Viewport) hints.get(BatikHints.KEY_DEFAULT_VIEWPORT);
       }
   
       /**
        * Returns the Paint used to fill the background.
        */
       protected Paint getBackgroundPaint() {
  -        return (Paint) hints.get(TranscodingHints.KEY_BACKGROUND);
  +        return (Paint) hints.get(BatikHints.KEY_BACKGROUND);
       }
   
       /**
        * Returns the classname of the XML parser to use.
        */
       protected String getParserClassName() {
  -        return (String) hints.get(TranscodingHints.KEY_XML_PARSER_CLASSNAME);
  +        return (String) hints.get(BatikHints.KEY_XML_PARSER_CLASSNAME);
       }
   }
  
  
  
  1.3       +5 -5      xml-batik/sources/org/apache/batik/refimpl/transcoder/BatikHints.java
  
  Index: BatikHints.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/refimpl/transcoder/BatikHints.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BatikHints.java	2000/11/21 15:00:37	1.2
  +++ BatikHints.java	2001/01/09 10:24:23	1.3
  @@ -14,33 +14,33 @@
    * The default transcoder key and values.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: BatikHints.java,v 1.2 2000/11/21 15:00:37 tkormann Exp $
  + * @version $Id: BatikHints.java,v 1.3 2001/01/09 10:24:23 tkormann Exp $
    */
   public class BatikHints {
   
       public static final TranscodingHints.Key KEY_XML_PARSER_CLASSNAME =
  -            new TranscodingHints.Key() {
  +            new TranscodingHints.Key(0) {
           public boolean isCompatibleValue(Object v) {
               return (v instanceof String);
           }
       };
   
       public static final TranscodingHints.Key KEY_BACKGROUND =
  -            new TranscodingHints.Key() {
  +            new TranscodingHints.Key(1) {
           public boolean isCompatibleValue(Object v) {
               return (v instanceof java.awt.Paint);
           }
       };
   
       public static final TranscodingHints.Key KEY_GVT_BUILDER =
  -            new TranscodingHints.Key() {
  +            new TranscodingHints.Key(2) {
           public boolean isCompatibleValue(Object v) {
               return (v instanceof org.apache.batik.bridge.GVTBuilder);
           }
       };
   
       public static final TranscodingHints.Key KEY_DEFAULT_VIEWPORT =
  -            new TranscodingHints.Key() {
  +            new TranscodingHints.Key(3) {
           public boolean isCompatibleValue(Object v) {
               return (v instanceof org.apache.batik.bridge.Viewport);
           }
  
  
  
  1.6       +2 -2      xml-batik/sources/org/apache/batik/refimpl/transcoder/JpegTranscoder.java
  
  Index: JpegTranscoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/refimpl/transcoder/JpegTranscoder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JpegTranscoder.java	2000/11/15 12:28:18	1.5
  +++ JpegTranscoder.java	2001/01/09 10:24:24	1.6
  @@ -22,7 +22,7 @@
    * background color is white.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: JpegTranscoder.java,v 1.5 2000/11/15 12:28:18 tkormann Exp $
  + * @version $Id: JpegTranscoder.java,v 1.6 2001/01/09 10:24:24 tkormann Exp $
    */
   public class JpegTranscoder extends ImageTranscoder {
   
  @@ -30,7 +30,7 @@
        * Constructs a new jpeg transcoder.
        */
       public JpegTranscoder(){
  -        hints.put(TranscodingHints.KEY_BACKGROUND, Color.white);
  +        hints.put(BatikHints.KEY_BACKGROUND, Color.white);
       }
   
       /**
  
  
  
  1.2       +21 -23    xml-batik/sources/org/apache/batik/transcoder/Transcoder.java
  
  Index: Transcoder.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/Transcoder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Transcoder.java	2000/10/23 16:08:05	1.1
  +++ Transcoder.java	2001/01/09 10:24:24	1.2
  @@ -8,39 +8,24 @@
   
   package org.apache.batik.transcoder;
   
  -import java.io.OutputStream;
   import java.util.Map;
   
  -import org.w3c.dom.Document;
  -import org.xml.sax.InputSource;
  -
   /**
  - * Provides a way to transcode an input stream or a document.
  + * This class defines an API for transcoding.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: Transcoder.java,v 1.1 2000/10/23 16:08:05 tkormann Exp $
  + * @version $Id: Transcoder.java,v 1.2 2001/01/09 10:24:24 tkormann Exp $
    */
   public interface Transcoder {
   
  -    /**
  -     * Transcodes the specified input and write the result to the
  -     * specified output.
  -     * @param isource the input to transcode
  -     * @param ostream the ouput stream where to write the transcoded input
  -     * @exception TranscoderException if an error occured while transcoding
  -     */
  -    void transcodeToStream(InputSource isource, OutputStream ostream)
  -        throws TranscoderException;
  -
       /**
  -     * Transcodes the specified document and write the result to the
  -     * specified output.
  -     * @param document the document to transcode
  -     * @param ostream the ouput stream where to write the transcoded input
  +     * Transcodes the specified input in the specified output.
  +     * @param input the input to transcode
  +     * @param output the ouput where to transcode
        * @exception TranscoderException if an error occured while transcoding
        */
  -    void transcodeToStream(Document document, OutputStream ostream)
  -        throws TranscoderException;
  +    void transcode(TranscoderInput input, TranscoderOutput output)
  +            throws TranscoderException;
   
       /**
        * Returns the transcoding hints of this transcoder.
  @@ -48,7 +33,7 @@
       TranscodingHints getTranscodingHints();
   
       /**
  -     * Sets the value of a single preference for the transcoding algorithms.
  +     * Sets the value of a single preference for the transcoding process.
        * @param key the key of the hint to be set
        * @param value the value indicating preferences for the specified
        * hint category.
  @@ -61,6 +46,19 @@
        * @param hints the rendering hints to be set
        */
       void setTranscodingHints(Map hints);
  +
  +    /**
  +     * Sets the error handler this transcoder may use to report
  +     * warnings and errors.
  +     * @param handler to ErrorHandler to use
  +     */
  +    void setErrorHandler(ErrorHandler handler);
  +
  +    /**
  +     * Returns the error handler this transcoder uses to report
  +     * warnings and errors, or null if any.
  +     */
  +    ErrorHandler getErrorHandler();
   
       /**
        * Returns the mime type of the ouput format of this transcoder.
  
  
  
  1.2       +10 -7     xml-batik/sources/org/apache/batik/transcoder/TranscoderException.java
  
  Index: TranscoderException.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/TranscoderException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TranscoderException.java	2000/10/23 16:08:05	1.1
  +++ TranscoderException.java	2001/01/09 10:24:24	1.2
  @@ -12,24 +12,27 @@
    * Thrown when a transcoder is not able to transcode its input.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: TranscoderException.java,v 1.1 2000/10/23 16:08:05 tkormann Exp $
  + * @version $Id: TranscoderException.java,v 1.2 2001/01/09 10:24:24 tkormann Exp $
    */
  -public class TranscoderException extends RuntimeException {
  +public class TranscoderException extends Exception {
   
       /** The enclosed exception. */
       protected Exception ex;
   
       /**
  -     * Constructs a new empty transcoder exception.
  -     */
  -    public TranscoderException() {}
  -
  -    /**
        * Constructs a new transcoder exception with the specified detail message.
        * @param s the detail message of this exception
        */
       public TranscoderException(String s) {
           this(s, null);
  +    }
  +
  +    /**
  +     * Constructs a new transcoder exception with the specified detail message.
  +     * @param ex the enclosed exception
  +     */
  +    public TranscoderException(Exception ex) {
  +        this(null, ex);
       }
   
       /**
  
  
  
  1.3       +71 -36    xml-batik/sources/org/apache/batik/transcoder/TranscodingHints.java
  
  Index: TranscodingHints.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/TranscodingHints.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TranscodingHints.java	2000/11/21 15:01:00	1.2
  +++ TranscodingHints.java	2001/01/09 10:24:25	1.3
  @@ -15,53 +15,27 @@
   import java.util.HashMap;
   import java.util.Iterator;
   
  -import org.apache.batik.refimpl.transcoder.BatikHints;
  -
   /**
  - * The <tt>TranscodingHints</tt> class contains transcoding hints that
  - * can be used by <tt>Transcoder</tt> class.
  + * The <tt>TranscodingHints</tt> class defines a way to pass
  + * transcoding parameters or options to any transcoders.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: TranscodingHints.java,v 1.2 2000/11/21 15:01:00 tkormann Exp $
  + * @version $Id: TranscodingHints.java,v 1.3 2001/01/09 10:24:25 tkormann Exp $
    */
   public class TranscodingHints implements Map, Cloneable {
   
  -    /**
  -     * Background color key.
  -     */
  -    public static final Key KEY_BACKGROUND =
  -        BatikHints.KEY_BACKGROUND;
  -
  -    /**
  -     * The XML parser classname key.
  -     */
  -    public static final Key KEY_XML_PARSER_CLASSNAME =
  -        BatikHints.KEY_XML_PARSER_CLASSNAME;
  -
  -    /**
  -     * The default viewport.
  -     */
  -    public static final Key KEY_DEFAULT_VIEWPORT =
  -        BatikHints.KEY_DEFAULT_VIEWPORT;
  -
  -    /**
  -     * The <tt>GVTBuilder</tt> implementation to use.
  -     */
  -    public static final Key KEY_GVT_BUILDER =
  -        BatikHints.KEY_GVT_BUILDER;
  -
       /** The transcoding hints. */
  -    HashMap hintMap = new HashMap(7);
  +    private HashMap hintMap = new HashMap(7);
   
       /**
  -     * Constructs a new empty object.
  +     * Constructs a new empty <tt>TranscodingHints</tt>.
        */
       public TranscodingHints() {
       }
   
       /**
  -     * Constructs a new object with keys and values initialized from
  -     * the specified Map object (which may be null).
  +     * Constructs a new <tt>TranscodingHints</tt> with keys and values
  +     * initialized from the specified Map object (which may be null).
        *
        * @param init a map of key/value pairs to initialize the hints
        *          or null if the object should be empty
  @@ -73,7 +47,8 @@
       }
   
       /**
  -     * Constructs a new object with the specified key/value pair.
  +     * Constructs a new <tt>TranscodingHints</tt> with the specified
  +     * key/value pair.
        *
        * @param key the key of the particular hint property
        * @param value the value of the hint property specified with
  @@ -265,13 +240,73 @@
   
       /**
        * Defines the base type of all keys used to control various
  -     * aspects of the trancoding operations.
  +     * aspects of the transcoding operations. Instances of this class
  +     * are immutable and unique which means that tests for matches can
  +     * be made using the == operator instead of the more expensive
  +     * equals() method.
        */
       public abstract static class Key {
   
  +        private static Map identitymap = new HashMap(17);
  +
  +        private String getIdentity() {
  +            return "Instance("+privatekey+") of "+getClass().getName();
  +        }
  +
  +        private synchronized static void recordIdentity(Key k) {
  +            Object identity = k.getIdentity();
  +            if (identitymap.containsKey(identity)) {
  +                throw new IllegalArgumentException(identity+
  +                                                   " already registered");
  +            }
  +            identitymap.put(identity, k);
  +        }
  +
  +        private int privatekey;
  +
           /**
  -         * Returns true if the specified object is a valid value for this key.
  +         * Construcst a key using the indicated private key.  Each
  +         * subclass of Key maintains its own unique domain of integer
  +         * keys. No two objects with the same integer key and of the
  +         * same specific subclass can be constructed.  An exception
  +         * will be thrown if an attempt is made to construct another
  +         * object of a given class with the same integer key as a
  +         * pre-existing instance of that subclass of Key.
            */
  +        protected Key(int privatekey) {
  +            this.privatekey = privatekey;
  +            recordIdentity(this);
  +        }
  +
  +        /**
  +         * Returns true if the specified object is a valid value for
  +         * this key, false otherwise.
  +         */
           public abstract boolean isCompatibleValue(Object val);
  +
  +        /**
  +         * Returns the private integer key that the subclass
  +         * instantiated this Key with.
  +         */
  +        protected final int intKey() {
  +            return privatekey;
  +        }
  +
  +        /**
  +         * The hash code for all Key objects will be the same as the
  +         * system identity code of the object as defined by the
  +         * System.identityHashCode() method.
  +         */
  +        public final int hashCode() {
  +            return System.identityHashCode(this);
  +        }
  +
  +        /**
  +         * The equals method for all Key objects will return the same
  +         * result as the equality operator '=='.
  +         */
  +        public final boolean equals(Object o) {
  +            return this == o;
  +        }
       }
   }