001: //WebOnSwing - Web Application Framework
002: //Copyright (C) 2003 Fernando Damian Petrola
003: //
004: //This library is free software; you can redistribute it and/or
005: //modify it under the terms of the GNU Lesser General Public
006: //License as published by the Free Software Foundation; either
007: //version 2.1 of the License, or (at your option) any later version.
008: //
009: //This library is distributed in the hope that it will be useful,
010: //but WITHOUT ANY WARRANTY; without even the implied warranty of
011: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: //Lesser General Public License for more details.
013: //
014: //You should have received a copy of the GNU Lesser General Public
015: //License along with this library; if not, write to the Free Software
016: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: package net.ar.webonswing.managers.pages;
019:
020: import java.io.*;
021:
022: import net.ar.webonswing.*;
023: import net.ar.webonswing.helpers.*;
024:
025: import org.apache.commons.lang.*;
026:
027: public class HtmlPageManagerEntry implements Serializable {
028: protected String pageClass;
029: protected String windowClass;
030: protected String webPath;
031: protected String windowPlace;
032:
033: public HtmlPageManagerEntry() {
034: }
035:
036: public HtmlPageManagerEntry(String aPath, String aPageClassName,
037: String aWindowClassName, String aWindowPlace) {
038: webPath = aPath;
039: pageClass = aPageClassName;
040: windowClass = aWindowClassName;
041: windowPlace = aWindowPlace;
042: }
043:
044: public String getPageClassName() {
045: return pageClass;
046: }
047:
048: public boolean like(HtmlPageManagerEntry anEntry) {
049: boolean theResult = anEntry.getPageClassName() == null
050: || anEntry.getPageClassName()
051: .equals(getPageClassName());
052: theResult &= anEntry.getWindowClassName() == null
053: || anEntry.getWindowClassName().equals(
054: getWindowClassName());
055: theResult &= anEntry.getPath() == null
056: || anEntry.getPath().equals(getPath());
057:
058: return theResult;
059: }
060:
061: public HtmlPageManagerEntry getDefaultEntryLike() {
062: if (pageClass != null) {
063: if (pageClass.endsWith("Page"))
064: windowClass = pageClass.substring(0,
065: pageClass.length() - 4);
066:
067: webPath = "/" + StringUtils.replace(windowClass, ".", "/");
068: } else if (windowClass != null) {
069: pageClass = windowClass + "Page";
070: webPath = "/" + StringUtils.replace(windowClass, ".", "/");
071: } else if (webPath != null) {
072: windowClass = StringUtils.replace(webPath, "/", ".")
073: .substring(1);
074: pageClass = windowClass + "Page";
075: }
076:
077: windowPlace = WosFramework.getInstance().getPageManager()
078: .getDefaultWindowPlace();
079:
080: if (pageClass == null || windowClass == null || webPath == null)
081: throw new WebOnSwingException("Cannot find an entry like '"
082: + this + "'");
083:
084: try {
085: Class.forName(pageClass);
086: } catch (ClassNotFoundException e) {
087: pageClass = WosFramework.getInstance().getPageManager()
088: .getDefaultPageClass();
089: }
090:
091: return this ;
092: }
093:
094: public String getPath() {
095: return webPath;
096: }
097:
098: public String getWindowClassName() {
099: return windowClass;
100: }
101:
102: public void setPageClassName(String unString) {
103: pageClass = unString;
104: }
105:
106: public void setPath(String unString) {
107: webPath = unString;
108: }
109:
110: public void setWindowClassName(String unString) {
111: windowClass = unString;
112: }
113:
114: public String toString() {
115: return "Path= " + getPath() + " : Page= " + getPageClassName()
116: + " : Window= " + getWindowClassName();
117: }
118:
119: public boolean equals(Object obj) {
120: if (obj instanceof HtmlPageManagerEntry)
121: return getPath().equals(
122: ((HtmlPageManagerEntry) obj).getPath());
123: else
124: return getPath().equals(obj.toString());
125: }
126:
127: public int hashCode() {
128: return getPath().hashCode();
129: }
130:
131: public String getWindowPlace() {
132: return windowPlace;
133: }
134:
135: public void setWindowPlace(String aWindowPlace) {
136: windowPlace = aWindowPlace;
137: }
138: }
|