001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018 package echopoint.model;
019
020 import com.thoughtworks.xstream.annotations.XStreamAlias;
021
022 import java.io.Serializable;
023
024 /**
025 * An asbtract base class for model objects that represent the clickable
026 * sections in a {@link echopoint.ImageMap}. Concrete sub-classes exist that
027 * represent the different types of shapes that are supported by HTML image
028 * maps.
029 *
030 * <p><b>Note:</b> Development of this component was sponsored by
031 * <a href='http://tcnbroadcasting.com/index.jsp' target='_top'>TCN
032 * Broadcasting</a>. We are grateful for their support and sponsorship.</p>
033 *
034 * @author Rakesh 2008-10-19
035 * @version $Id: MapSection.java 70 2008-10-20 10:02:42Z sptrakesh $
036 */
037 @XStreamAlias( "mapSection" )
038 public abstract class MapSection implements Serializable
039 {
040 private static final long serialVersionUID = 1l;
041
042 /** The action command to associate with this clickable section. */
043 protected String actionCommand;
044
045 /** The alternate text (title) to associate with the clickable section. */
046 protected String altText;
047
048 /** Default constructor. */
049 protected MapSection() {}
050
051 /**
052 * Create a new instance using the specified action command and title.
053 *
054 * @param actionCommand The action command to associated with this section.
055 * @param altText The title to associate with this section.
056 */
057 protected MapSection( final String actionCommand, final String altText )
058 {
059 setActionCommand( actionCommand );
060 setAltText( altText );
061 }
062
063 /**
064 * Compare the specified object with this instance for equality.
065 *
066 * @param o The object to be compared.
067 * @return Return <code>true</code> if the two objects are equivalent.
068 */
069 @Override
070 public boolean equals( final Object o )
071 {
072 if ( this == o ) return true;
073 if ( o == null || getClass() != o.getClass() ) return false;
074
075 MapSection that = (MapSection) o;
076 return !( actionCommand != null ? !actionCommand.equals( that.actionCommand ) :
077 that.actionCommand != null ) && !( altText != null ?
078 !altText.equals( that.altText ) : that.altText != null );
079 }
080
081 /**
082 * Compute a hash code for this instance.
083 *
084 * @return The hash code for this instance.
085 */
086 @Override
087 public int hashCode()
088 {
089 int result;
090 result = ( actionCommand != null ? actionCommand.hashCode() : 0 );
091 result = 31 * result + ( altText != null ? altText.hashCode() : 0 );
092 return result;
093 }
094
095 /**
096 * Accessor for property 'actionCommand'.
097 *
098 * @return Value for property 'actionCommand'.
099 */
100 public String getActionCommand()
101 {
102 return actionCommand;
103 }
104
105 /**
106 * Mutator for property 'actionCommand'.
107 *
108 * @param actionCommand Value to set for property 'actionCommand'.
109 */
110 public void setActionCommand( final String actionCommand )
111 {
112 this.actionCommand = actionCommand;
113 }
114
115 /**
116 * Accessor for property 'altText'.
117 *
118 * @return Value for property 'altText'.
119 */
120 public String getAltText()
121 {
122 return altText;
123 }
124
125 /**
126 * Mutator for property 'altText'.
127 *
128 * @param altText Value to set for property 'altText'.
129 */
130 public void setAltText( final String altText )
131 {
132 this.altText = altText;
133 }
134 }