001: /*
002: * This file is part of PFIXCORE.
003: *
004: * PFIXCORE is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU Lesser General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * PFIXCORE 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
012: * GNU Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public License
015: * along with PFIXCORE; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package de.schlund.pfixcore.editor2.core.dom;
020:
021: /**
022: * Provides functionality common to all classes implementing Page
023: *
024: * @author Sebastian Marsching <sebastian.marsching@1und1.de>
025: */
026: public abstract class AbstractPage implements Page {
027:
028: /* (non-Javadoc)
029: * @see java.lang.Comparable#compareTo(java.lang.Object)
030: */
031: public int compareTo(Page page) {
032: int ret = this .getHandlerPath()
033: .compareTo(page.getHandlerPath());
034: if (ret != 0) {
035: return ret;
036: }
037: ret = this .getName().compareTo(page.getName());
038: if (ret == 0) {
039: if (this .getVariant() == null && page.getVariant() == null) {
040: ret = 0;
041: } else if (this .getVariant() == null) {
042: ret = 1;
043: } else if (page.getVariant() == null) {
044: ret = -1;
045: } else {
046: ret = this .getVariant().compareTo(page.getVariant());
047: }
048: }
049: return ret;
050: }
051:
052: /*
053: * (non-Javadoc)
054: *
055: * @see java.lang.Object#equals(java.lang.Object)
056: */
057: public boolean equals(Object obj) {
058: if (!(obj instanceof Page)) {
059: return false;
060: }
061: Page page = (Page) obj;
062: return this .getFullName().equals(page.getFullName())
063: && this .getProject().equals(page.getProject());
064: }
065:
066: /*
067: * (non-Javadoc)
068: *
069: * @see java.lang.Object#hashCode()
070: */
071: public int hashCode() {
072: return ("PAGE: " + this .toString()).hashCode();
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see java.lang.Object#toString()
079: */
080: public String toString() {
081: return this .getProject().getName() + "/" + this .getFullName();
082: }
083:
084: /* (non-Javadoc)
085: * @see de.schlund.pfixcore.editor2.core.dom.Page#getFullName()
086: */
087: public String getFullName() {
088: if (this .getVariant() == null) {
089: return this .getName();
090: } else {
091: return this .getName() + "::" + this .getVariant().getName();
092: }
093: }
094:
095: /* (non-Javadoc)
096: * @see de.schlund.pfixcore.editor2.core.dom.Page#hasSubPages()
097: */
098: public boolean hasSubPages() {
099: return (this .getSubPages().size() != 0);
100: }
101: }
|