classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] [FYI]: Patch for javax.print.attribute.standard package


From: Wolfgang Baer
Subject: Re: [cp-patches] [FYI]: Patch for javax.print.attribute.standard package
Date: Mon, 16 Jan 2006 10:10:29 +0100
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Hi,

Mark Wielaard wrote:
Hi Wolfgang,

On Fri, 2006-01-13 at 23:44 +0100, Wolfgang Baer wrote:
Evrything I do here is to call one instance of every container class
so it gets loaded and everyone of its static MediaSize objects are
instantiated. Should I put a comment here ?


Please do. I see now how initializing one static field makes sure all
static fields are initialized, but since I had to ask it wasn't
immediately obvious (at least to me).
[...]
I still think this is kind of strange. It means any user can "register"
new MediaSizes even by accident. Please also add a good comment about
this to the MediaSize constructor.

This adds the comment to the static initializer and every constructor.

2006-01-16  Wolfgang Baer  <address@hidden>

        * javax/print/attribute/standard/MediaSize.java:
        (static_initializer): Added comment.
        (MediaSize): Added javadoc to mention cache registration.
        (MediaSize): Likewise.
        (MediaSize): Likewise.
        (MediaSize): Likewise.

Wolfgang

Index: MediaSize.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/print/attribute/standard/MediaSize.java,v
retrieving revision 1.5
diff -u -r1.5 MediaSize.java
--- MediaSize.java      14 Jan 2006 10:29:58 -0000      1.5
+++ MediaSize.java      16 Jan 2006 09:05:19 -0000
@@ -72,7 +72,14 @@
   static
     {
       mediaCache = new ArrayList();
-
+      
+      // We call one instance of every container class to make sure it gets
+      // loaded during class initialization and therefore all other static
+      // fields of this container class also.
+      
+      // This is needed to put all MediaSize instance into the mediaCache
+      // for use by the static methods in this class.
+      
       MediaSize tmp = MediaSize.ISO.A0;
       tmp = MediaSize.JIS.B0;
       tmp = MediaSize.Engineering.A;
@@ -83,13 +90,18 @@
   private MediaSizeName media;
   
   /**
-   * Creates a <code>MediaSize</code> object.
+   * Creates a <code>MediaSize</code> object. The created object will be added 
+   * to an internal cache used in the static methods of this class for lookup 
+   * of available <code>MediaSize</code> instances.
    *
    * @param x the size in x direction
    * @param y the size in y direction
    * @param units the units to use for the sizes
    *
    * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
+   * 
+   * @see #findMedia(float, float, int)
+   * @see #getMediaSizeForName(MediaSizeName)
    */
   public MediaSize(float x, float y, int units)
   {
@@ -99,7 +111,9 @@
   
   /**
    * Creates a <code>MediaSize</code> object associated with the given
-   * media name.
+   * media name. The created object will be added to an internal cache used 
+   * in the static methods of this class for lookup of available 
+   * <code>MediaSize</code> instances.
    *
    * @param x the size in x direction
    * @param y the size in y direction
@@ -107,6 +121,9 @@
    * @param media the media name to associate
    *
    * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
+   * 
+   * @see #findMedia(float, float, int)
+   * @see #getMediaSizeForName(MediaSizeName)
    */
   public MediaSize(float x, float y, int units, MediaSizeName media)
   {
@@ -116,13 +133,18 @@
   }
   
   /**
-   * Creates a <code>MediaSize</code> object.
+   * Creates a <code>MediaSize</code> object. The created object will be added 
+   * to an internal cache used in the static methods of this class for lookup 
+   * of available <code>MediaSize</code> instances.
    *
    * @param x the size in x direction
    * @param y the size in y direction
    * @param units the units to use for the sizes
    *
    * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
+   * 
+   * @see #findMedia(float, float, int)
+   * @see #getMediaSizeForName(MediaSizeName)
    */
   public MediaSize(int x, int y, int units)
   {
@@ -132,7 +154,9 @@
   
   /**
    * Creates a <code>MediaSize</code> object associated with the given
-   * media name.
+   * media name. The created object will be added to an internal cache used 
+   * in the static methods of this class for lookup of available 
+   * <code>MediaSize</code> instances.
    *
    * @param x the size in x direction
    * @param y the size in y direction
@@ -140,6 +164,9 @@
    * @param media the media name to associate
    *
    * @exception IllegalArgumentException if x or y &lt; 0 or units &lt; 1
+   * 
+   * @see #findMedia(float, float, int)
+   * @see #getMediaSizeForName(MediaSizeName)
    */
   public MediaSize(int x, int y, int units, MediaSizeName media)
   {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]