db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker PCKey.java PBKey.java
Date Sat, 18 Dec 2004 13:42:30 GMT
arminw      2004/12/18 05:42:30

  Modified:    src/java/org/apache/ojb/broker PBKey.java
  Added:       src/java/org/apache/ojb/broker PCKey.java
  Log:
  introduce PCKey, the replacement of PBKey
  
  Revision  Changes    Path
  1.15      +6 -65     db-ojb/src/java/org/apache/ojb/broker/PBKey.java
  
  Index: PBKey.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/PBKey.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PBKey.java	25 Sep 2004 14:26:17 -0000	1.14
  +++ PBKey.java	18 Dec 2004 13:42:30 -0000	1.15
  @@ -22,18 +22,12 @@
    * <br>
    * The used <i>jcdAlias</i> name represents an alias for a connection
    * defined in the repository file.
  - *
  - * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  + * 
  + * @deprecated Use {@link PCKey} instead.
    * @version $Id$
    */
  -public class PBKey implements Cloneable, Serializable
  +public class PBKey extends PCKey
   {
  -	static final long serialVersionUID = -8858811398162391578L;
  -    private final String jcdAlias;
  -    private final String user;
  -    private final String password;
  -    private int hashCode;
  -
       /**
        * Constructor for new PBKey.
        * @param jcdAlias alias name, defined in the repository file.
  @@ -42,9 +36,7 @@
        */
       public PBKey(final String jcdAlias, final String user, final String password)
       {
  -        this.jcdAlias = jcdAlias;
  -        this.user = user;
  -        this.password = password;
  +        super(jcdAlias, user, password);
       }
   
       /**
  @@ -55,62 +47,11 @@
           this(jcdAlias, null, null);
       }
   
  -    public boolean equals(Object obj)
  -    {
  -        if (obj == this)
  -        {
  -            return true;
  -        }
  -        if (!(obj instanceof PBKey))
  -        {
  -            return false;
  -        }
  -
  -        return this.hashCode() == obj.hashCode();
  -    }
  -
       /**
        * Returns an 'deep' copy of this key.
        */
       public Object clone() throws CloneNotSupportedException
       {
  -        return new PBKey(this.jcdAlias, this.user, this.password);
  -    }
  -
  -    /**
  -     * Return the hash code of this PBKey,
  -     * formed by the repository-, user-, password-name.
  -     */
  -    public int hashCode()
  -    {
  -        if(hashCode == 0)
  -        {
  -            hashCode = (this.jcdAlias + this.user + this.password).hashCode(); 
  -        }
  -        return hashCode;
  -    }
  -
  -    public String toString()
  -    {
  -        return this.getClass().getName() + ": jcdAlias="+jcdAlias+", user="+user+
  -                (user != null ? ", password=*****" : ", password="+password);
  -    }
  -
  -    /**
  -     * Returns the jcd-alias name, defined in the repository file.
  -     */
  -    public String getAlias()
  -    {
  -        return jcdAlias;
  -    }
  -
  -    public String getUser()
  -    {
  -        return user;
  -    }
  -
  -    public String getPassword()
  -    {
  -        return password;
  +        return new PBKey(getAlias(), getUser(), getPassword());
       }
   }
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/PCKey.java
  
  Index: PCKey.java
  ===================================================================
  package org.apache.ojb.broker;
  
  import java.io.Serializable;
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  /**
   * A immutable key to identify {@link PersistenceConfiguration} instances.
   * <br>
   * The used <i>pcAlias</i> name represents an alias for a
   * persistence configuration defined in the repository file or
   * in associated {@link org.apache.ojb.broker.metadata.PersistenceConfigurationDescriptor}.
   *
   * @version $Id: PCKey.java,v 1.1 2004/12/18 13:42:30 arminw Exp $
   */
  public class PCKey implements Cloneable, Serializable
  {
      static final long serialVersionUID = -8858811398162391578L;
      private final String pcAlias;
      private final String user;
      private final String password;
      private int hashCode;
  
      /**
       * Constructor for new PBKey.
       * @param pcAlias Alias name, defined in the repository file.
       * @param user The user name.
       * @param password The password.
       */
      public PCKey(final String pcAlias, final String user, final String password)
      {
          if(pcAlias == null)
          {
              throw new NullPointerException("The alias name was 'null'");
          }
          this.pcAlias = pcAlias;
          this.user = user;
          this.password = password;
      }
  
      /**
       * Convenience constructor for {@link #PCKey(String, String, String)}.
       */
      public PCKey(final String pcAlias)
      {
          this(pcAlias, null, null);
      }
  
      public boolean equals(Object obj)
      {
          if (obj == this)
          {
              return true;
          }
          if (!(obj instanceof PCKey))
          {
              return false;
          }
          PCKey other = (PCKey) obj;
          return this.pcAlias.equals(other.getAlias())
                  && (user != null ? user.equals(other.user) : null == other.user)
                  && (password != null ? password.equals(other.password) : null ==
other.password);
      }
  
      /**
       * Returns an 'deep' copy of this key.
       */
      public Object clone() throws CloneNotSupportedException
      {
          return new PCKey(this.pcAlias, this.user, this.password);
      }
  
      /**
       * Return the hash code of this PBKey,
       * formed by the repository-, user-, password-name.
       */
      public int hashCode()
      {
          if(hashCode == 0)
          {
              hashCode = pcAlias.hashCode()
                      + (user != null ? user.hashCode() : 0)
                      + (password != null ? password.hashCode() : 0);
          }
          return hashCode;
      }
  
      public String toString()
      {
          return this.getClass().getName() + ": pcAlias="+pcAlias+", user="+user+
                  (user != null ? ", password=*****" : ", password="+password);
      }
  
      /**
       * Returns the persistence configuration alias name,
       * defined in the repository file or
       * in associated {@link org.apache.ojb.broker.metadata.PersistenceConfigurationDescriptor}.
       */
      public String getAlias()
      {
          return pcAlias;
      }
  
      public String getUser()
      {
          return user;
      }
  
      public String getPassword()
      {
          return password;
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message