001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/courier/tags/sakai_2-4-1/courier-util/util/src/java/org/sakaiproject/util/BaseDelivery.java $
003: * $Id: BaseDelivery.java 7855 2006-04-17 15:33:53Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.util;
021:
022: import org.sakaiproject.courier.api.Delivery;
023:
024: /**
025: * <p>
026: * BaseDelivery is a base class for all Delivery objects.
027: * </p>
028: */
029: public class BaseDelivery implements Delivery {
030: /** The address. */
031: protected String m_address = null;
032:
033: /** The elementId. */
034: protected String m_elementId = null;
035:
036: /**
037: * Construct.
038: *
039: * @param address
040: * The address.
041: * @param elementId
042: * The elementId.
043: */
044: public BaseDelivery(String address, String elementId) {
045: m_address = address;
046: m_elementId = elementId;
047: }
048:
049: /**
050: * Set the delivery address.
051: *
052: * @param address
053: * The delivery address.
054: */
055: public void setAddress(String address) {
056: m_address = address;
057: }
058:
059: /**
060: * Access the delivery address.
061: *
062: * @return The delivery address.
063: */
064: public String getAddress() {
065: return m_address;
066: }
067:
068: /**
069: * Set the HTML Element Id that this delivery is in reference to.
070: *
071: * @param id
072: * The HTML Element Id that this delivery is in reference to.
073: */
074: public void setElement(String id) {
075: m_elementId = id;
076: }
077:
078: /**
079: * Access the HTML Element Id that this delivery is in reference to.
080: *
081: * @return The HTML Element Id that this delivery is in reference to.
082: */
083: public String getElement() {
084: return m_elementId;
085: }
086:
087: /**
088: * Perform any pre-delivery actions. Note: this is run in the same usage session as is being delivered to.
089: */
090: public void act() {
091: }
092:
093: /**
094: * Compose a javascript message for delivery to the browser client window.
095: *
096: * @return The javascript message to send to the browser client window.
097: */
098: public String compose() {
099: return "";
100: }
101:
102: /**
103: * Display.
104: */
105: public String toString() {
106: return m_address + " : " + m_elementId;
107: }
108:
109: /**
110: * Are these the same?
111: *
112: * @return true if obj is the same Delivery as this one.
113: */
114: public boolean equals(Object obj) {
115: if (!(obj instanceof BaseDelivery))
116: return false;
117:
118: BaseDelivery bob = (BaseDelivery) obj;
119: if (StringUtil.different(bob.getAddress(), getAddress()))
120: return false;
121: if (StringUtil.different(bob.getElement(), getElement()))
122: return false;
123:
124: return true;
125: }
126: }
|