001: /*
002: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License version
007: * 2 only, as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful, but
010: * WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * General Public License version 2 for more details (a copy is
013: * included at /legal/license.txt).
014: *
015: * You should have received a copy of the GNU General Public License
016: * version 2 along with this work; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018: * 02110-1301 USA
019: *
020: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021: * Clara, CA 95054 or visit www.sun.com if you need additional
022: * information or have any questions.
023: */
024: package com.sun.midp.jump.push.executive;
025:
026: import java.io.Serializable;
027:
028: /**
029: * PushRegistry connection info.
030: *
031: * <p>Simple, structure like class</p>
032: *
033: * <p><strong>TBD</strong>: at see
034: * <code>javax.microedition.io.PushRegistry#registerConnection</code></p>
035: */
036: public final class JUMPConnectionInfo implements Serializable {
037: /**
038: * Generic connection <i>protocol</i>, <i>host</i> and <i>port
039: * number</i> (optional parameters may be included separated with
040: * semi-colons (;)).
041: */
042: public final String connection;
043:
044: /**
045: * Class name of the <tt>MIDlet</tt> to be launched, when external data is
046: * available.
047: */
048: public final String midlet;
049:
050: /**
051: * A connection URL string indicating which senders are allowed to cause
052: * <tt>MIDlet</tt> to be launched.
053: */
054: public final String filter;
055:
056: /**
057: * Ctor to create filled structure.
058: *
059: * @param connection generic connection <i>protocol</i>, <i>host</i> and
060: * <i>port number</i> (optional parameters may be included separated with
061: * semi-colons (;))
062: *
063: * @param midlet class name of the <tt>MIDlet</tt> to be launched,
064: * when external data is available
065: *
066: * @param filter a connection URL string indicating which senders are
067: * allowed to cause <tt>MIDlet</tt> to be launched
068: *
069: * @throws IllegalArgumentException if any of <code>connection</code>,
070: * <code>midlet</code> or <code>filter</code> is <code>null</code>
071: *
072: * <p>
073: * TBD: unittest <code>null</code> params
074: * </p>
075: */
076: public JUMPConnectionInfo(final String connection,
077: final String midlet, final String filter) {
078: if (connection == null) {
079: throw new IllegalArgumentException("connection is null");
080: }
081: this .connection = connection;
082:
083: if (midlet == null) {
084: throw new IllegalArgumentException("midlet is null");
085: }
086: this .midlet = midlet;
087:
088: if (filter == null) {
089: throw new IllegalArgumentException("filter is null");
090: }
091: this .filter = filter;
092: }
093:
094: /**
095: * Implements <code>Object.equals()</code>.
096: *
097: * @param obj object to compare with
098: *
099: * @return <code>true</code> if equal, <code>fasle</code> otherwise
100: */
101: public boolean equals(final Object obj) {
102: if (!(obj instanceof JUMPConnectionInfo)) {
103: return false;
104: }
105:
106: JUMPConnectionInfo rhs = (JUMPConnectionInfo) obj;
107: return (this == rhs)
108: || (connection.equals(rhs.connection)
109: && midlet.equals(rhs.midlet) && filter
110: .equals(rhs.filter));
111: }
112:
113: /**
114: * Implements <code>Object.hashCode()</code>.
115: *
116: * @return hash code
117: */
118: public int hashCode() {
119: return connection.hashCode() + midlet.hashCode()
120: + filter.hashCode();
121: }
122: }
|