jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Cronin" <tcro...@interwoven.com>
Subject RE: Cache Keys
Date Thu, 01 Sep 2005 18:48:39 GMT
Wait no I'm not...

The key work fine against a Map.

>/**********************************************************************
*
>******
>   * @see java.lang.Object#equals(java.lang.Object)
> 
>***********************************************************************
*
>*****/
>  public boolean equals(Object o)
>  {
>    if (o instanceof Key)
>    {
>      return false;
>    }
>    if (this == o)
>    {
>      return true;
>    }
>    Key that = (Key) o;
>    return new EqualsBuilder()
>      .append(mSite, that.mSite)
>      .append(mPage, that.mPage)
>      .append(mLocale, that.mLocale)
>      .append(mComponent, that.mComponent)
>      .isEquals();
>  }
-----Original Message-----
From: John McNally [mailto:jmcnally@collab.net] 
Sent: Wednesday, August 31, 2005 1:42 PM
To: JCS Users List
Subject: Re: Cache Keys

Think you're missing a !

  public boolean equals(Object o)
  {
    if (o instanceof Key)
    {
      return false;
    }



Tim Cronin wrote:

>I'm using and object as the cache key is there something special I have
>to do?
>
>Here is my key class
>
>public class Key implements Serializable
>{
>  /**
>   * the site
>   */
>  private String mSite = null;
>
>  /**
>   * the page
>   */
>  private String mPage = null;
>
>  /**
>   * the locale
>   */
>  private String mLocale = null;
>
>  /**
>   * the component ID
>   */
>  private String mComponent = null;
>
> 
>/**********************************************************************
*
>******
>   * create new Key (used for purge)
>   *
>   * @param site the site
> 
>***********************************************************************
*
>*****/
>  public Key(String site)
>  {
>    mSite = site;
>  }
>
> 
>/**********************************************************************
*
>******
>   * create new Key (used for purge)
>   *
>   * @param site the site
>   * @param page the page
> 
>***********************************************************************
*
>*****/
>  public Key(String site, String page)
>  {
>    mSite = site;
>    mPage = page;
>  }
>
> 
>/**********************************************************************
*
>******
>   * create new Key (for page)
>   *
>   * @param site the site
>   * @param page the page
>   * @param locale the locale
> 
>***********************************************************************
*
>*****/
>  public Key(String site, String page, String locale)
>  {
>    mLocale = locale;
>    mPage = page;
>    mSite = site;
>  }
>
> 
>/**********************************************************************
*
>******
>   * create new Key (for component key)
>   *
>   * @param k the key (for the page)
>   * @param component the component
> 
>***********************************************************************
*
>*****/
>  public Key(Key k, String component)
>  {
>    mSite = k.mSite;
>    mPage = k.mPage;
>    mLocale = k.mLocale;
>    mComponent = component;
>  }
>
> 
>/**********************************************************************
*
>******
>   * Gets The component.
>   *
>   * @return Returns the component.
> 
>***********************************************************************
*
>*****/
>  public String getComponent()
>  {
>    return mComponent;
>  }
>
> 
>/**********************************************************************
*
>******
>   * Gets The locale.
>   *
>   * @return Returns the locale.
> 
>***********************************************************************
*
>*****/
>  public String getLocale()
>  {
>    return mLocale;
>  }
>
> 
>/**********************************************************************
*
>******
>   * Gets The page.
>   *
>   * @return Returns the page.
> 
>***********************************************************************
*
>*****/
>  public String getPage()
>  {
>    return mPage;
>  }
>
> 
>/**********************************************************************
*
>******
>   * Gets The site.
>   *
>   * @return Returns the site.
> 
>***********************************************************************
*
>*****/
>  public String getSite()
>  {
>    return mSite;
>  }
>
> 
>/**********************************************************************
*
>******
>   * get the xpath logic to use to filter cache options
>   *
>   * @return the xpath logic string
> 
>***********************************************************************
*
>*****/
>  public String getXPath()
>  {
>    StringBuffer buff = new StringBuffer();
>
> 
>buff.append("[@site='").append(StringEscapeUtils.escapeJava(mSite)).app
e
>nd("'");
>
>    if (mPage != null)
>    {
>      buff.append(" and
>@page='").append(StringEscapeUtils.escapeJava(mPage)).append("'");
>    }
>
>    buff.append("]");
>
>    return buff.toString();
>  }
> 
>/**********************************************************************
*
>******
>   * @see java.lang.Object#equals(java.lang.Object)
> 
>***********************************************************************
*
>*****/
>  public boolean equals(Object o)
>  {
>    if (o instanceof Key)
>    {
>      return false;
>    }
>    if (this == o)
>    {
>      return true;
>    }
>    Key that = (Key) o;
>    return new EqualsBuilder()
>      .append(mSite, that.mSite)
>      .append(mPage, that.mPage)
>      .append(mLocale, that.mLocale)
>      .append(mComponent, that.mComponent)
>      .isEquals();
>  }
>
> 
>/**********************************************************************
*
>******
>   * @see java.lang.Object#hashCode()
> 
>***********************************************************************
*
>*****/
>  public int hashCode()
>  {
>    return new HashCodeBuilder()
>      .append(mSite)
>      .append(mPage)
>      .append(mLocale)
>      .append(mComponent)
>      .toHashCode();
>  }
>
> 
>/**********************************************************************
*
>******
>   * @see java.lang.Object#toString()
> 
>***********************************************************************
*
>*****/
>  public String toString()
>  {
>    return new ToStringBuilder(this)
>      .append("mSite", mSite)
>      .append("mPage", mPage)
>      .append("mLocale", mLocale)
>      .append("mComponent", mComponent)
>      .toString();
>  }
>}
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: jcs-users-help@jakarta.apache.org
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org


Mime
View raw message