001: package net.refractions.udig.style.sld.editor.internal;
002:
003: /*******************************************************************************
004: * Copyright (c) 2004 IBM Corporation and others.
005: * All rights reserved. This program and the accompanying materials
006: * are made available under the terms of the Eclipse Public License v1.0
007: * which accompanies this distribution, and is available at
008: * http://www.eclipse.org/legal/epl-v10.html
009: *
010: * Contributors:
011: * IBM Corporation - initial API and implementation
012: *******************************************************************************/
013:
014: import org.eclipse.jface.util.Assert;
015:
016: /**
017: * A page history entry.
018: */
019: final class PageHistoryEntry {
020: private String id;
021: private String label;
022: private Object argument;
023:
024: /**
025: * Creates a new entry.
026: *
027: * @param id the page id
028: * @param label the label to display, usually the page label
029: * @param argument an argument to pass to the page, may be
030: * <code>null</code>
031: */
032: public PageHistoryEntry(String id, String label, Object argument) {
033: Assert.isLegal(id != null);
034: Assert.isLegal(label != null);
035: this .id = id;
036: this .label = label;
037: this .argument = argument;
038: }
039:
040: /**
041: * Returns the page id.
042: *
043: * @return the page id
044: */
045: public String getId() {
046: return id;
047: }
048:
049: /**
050: * Returns the page argument.
051: *
052: * @return the page argument
053: */
054: public Object getArgument() {
055: return argument;
056: }
057:
058: /**
059: * Returns the page label.
060: *
061: * @return the page label
062: */
063: public String getLabel() {
064: return label;
065: }
066:
067: /*
068: * @see java.lang.Object#toString()
069: */
070: @Override
071: public String toString() {
072: if (argument == null)
073: return id;
074: return id + "(" + argument + ")"; //$NON-NLS-1$ //$NON-NLS-2$
075: }
076:
077: /*
078: * @see java.lang.Object#equals(java.lang.Object)
079: */
080: @Override
081: public boolean equals(Object obj) {
082: if (obj instanceof PageHistoryEntry) {
083: PageHistoryEntry other = (PageHistoryEntry) obj;
084: return id.equals(other.id)
085: && (argument == null && other.argument == null || argument
086: .equals(other.argument));
087: }
088: return super .equals(obj);
089: }
090:
091: /*
092: * @see java.lang.Object#hashCode()
093: */
094: @Override
095: public int hashCode() {
096: int argHash = argument == null ? 0
097: : argument.hashCode() & 0x0000ffff;
098: return id.hashCode() << 16 | argHash;
099: }
100: }
|