001 package org.apache.tapestry.internal.pageload;
002
003 import java.io.Serializable;
004 import java.util.Locale;
005
006 /**
007 * Alterantive implementation of {@link org.apache.tapestry.util.MultiKey} that is specifically
008 * intended to be used to store and retrieve pages from a pool.
009 *
010 */
011 public class PageKey implements Serializable {
012
013 String _pageName;
014 Locale _locale;
015
016 /**
017 * Constructs a new instance for the specified page / locale.
018 * @param pageName
019 * The page.
020 * @param locale
021 * Locale of the page.
022 */
023 public PageKey(String pageName, Locale locale)
024 {
025 _pageName = pageName;
026 _locale = locale;
027 }
028
029 public String getPageName()
030 {
031 return _pageName;
032 }
033
034 public String toString()
035 {
036 return "PageKey[" +
037 "_pageName='" + _pageName + '\'' +
038 '\n' +
039 ", _locale=" + _locale +
040 '\n' +
041 ']';
042 }
043
044 public boolean equals(Object o)
045 {
046 if (this == o) return true;
047 if (o == null || getClass() != o.getClass()) return false;
048
049 PageKey pageKey = (PageKey) o;
050
051 if (_locale != null ? !_locale.equals(pageKey._locale) : pageKey._locale != null) return false;
052 if (_pageName != null ? !_pageName.equals(pageKey._pageName) : pageKey._pageName != null) return false;
053
054 return true;
055 }
056
057 public int hashCode()
058 {
059 int result;
060 result = (_pageName != null ? _pageName.hashCode() : 0);
061 result = 31 * result + (_locale != null ? _locale.hashCode() : 0);
062 return result;
063 }
064 }