001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * Anchor.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report;
030:
031: import java.io.Serializable;
032:
033: /**
034: * An anchor is a possible target for external hyperlinks.
035: * <p/>
036: * In HTML anchors would be produced by using <a name="anchorname">. This
037: * class is immutable.
038: *
039: * @author Thomas Morgner
040: * @see AnchorElement
041: * @deprecated Ancors should not be created this way. Add a Anchor-Style-Expression instead.
042: */
043: public class Anchor implements Serializable {
044: /** Unique identifier for long-term persistence. */
045: private static final long serialVersionUID = 8495721791372012478L;
046:
047: /**
048: * The name of the anchor. Should be unique within the report.
049: */
050: private String name;
051:
052: /**
053: * Creates a new anchor with the given name.
054: *
055: * @param name the name of the anchor.
056: * @throws NullPointerException if the given name is null.
057: */
058: public Anchor(final String name) {
059: if (name == null) {
060: throw new NullPointerException();
061: }
062: this .name = name;
063: }
064:
065: /**
066: * Returns the name of the anchor.
067: *
068: * @return the name
069: */
070: public String getName() {
071: return name;
072: }
073:
074: /**
075: * Checks, whether the given object is an anchor with the same name as this one.
076: *
077: * @param obj the other object.
078: * @return true, if the object is equal to this one, false otherwise.
079: */
080: public boolean equals(final Object obj) {
081: if (this == obj) {
082: return true;
083: }
084: if (!(obj instanceof Anchor)) {
085: return false;
086: }
087:
088: final Anchor anchor = (Anchor) obj;
089:
090: if (!name.equals(anchor.name)) {
091: return false;
092: }
093:
094: return true;
095: }
096:
097: /**
098: * Computes a hashcode for this anchor.
099: *
100: * @return the hashcode.
101: */
102: public int hashCode() {
103: return name.hashCode();
104: }
105: }
|