Source Code Cross Referenced for MessageObject.java in  » 6.0-JDK-Modules » j2me » com » sun » tck » wma » sms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.tck.wma.sms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.tck.wma.sms;
028:
029:        import com.sun.tck.wma.Message;
030:        import java.util.Date;
031:
032:        /**
033:         * A message for a message connection, composed of an address and data. There
034:         * are get and set methods for manipulating the address and data components of
035:         * the message. The data part can be the text, binary or multipart format. The
036:         * address part assumes this format:
037:         * <p> 
038:         * <code>protocol://[<em>phone_number</em>:][<em>port_number/ID</em>]</code>
039:         * <p>
040:         * and represents the address of a port/ID that can accept or receive messages. 
041:         *<p>
042:         * <code>MessageObject</code>s are instantiated when they are received from the
043:         * {@link com.sun.tck.wma.MessageConnection MessageConnection} or by using the
044:         * {@link MessageConnection#newMessage(String type)
045:         * MessageConnection.newMessage} message factory. Instances are freed when they
046:         * are garbage-collected or when they go out of scope. 
047:         */
048:        public class MessageObject implements  Message {
049:
050:            /** High-level message type. */
051:            protected String msgType = null;
052:
053:            /** High-level message address. */
054:            protected String msgAddress = null;
055:
056:            /** The time stamp, indicating when the message was sent. */
057:            protected long sentAt = -1;
058:
059:            /**
060:             * Creates a Message object without a buffer.
061:             *
062:             * @param type The message type: TEXT, BINARY or MULTIPART.
063:             * @param address The destination address of the message.
064:             */
065:            public MessageObject(String type, String address) {
066:                setType(type);
067:                setAddress(address);
068:            }
069:
070:            /**
071:             * Sets the message type.
072:             *
073:             * @param type The message type: TEXT, BINARY or MULTIPART.
074:             *
075:             * @exception IllegalArgumentException if the type is not valid.
076:             */
077:            public void setType(String type) {
078:                if (type == null) {
079:                    throw new IllegalArgumentException("Null message type.");
080:                }
081:                msgType = type;
082:            }
083:
084:            /**
085:             * Gets the message type.
086:             *
087:             * @return The current message type or <code>null</code> if no message type
088:             *     has been set.
089:             */
090:            public String getType() {
091:                return msgType;
092:            }
093:
094:            /**
095:             * Sets the address part of the message object. The address is a 
096:             * <code>String</code> and must be in the format:  
097:             * <code>protocol://<em>phone_number</em>:[<em>port</em>]</code>
098:             * The following code sample assigns an address to the <code>Message</code>
099:             * object.
100:             * <pre>
101:             *    ...
102:             *    String addr = "protocol://+123456789";
103:             *    Message msg = newMessage(MessageConnection.TEXT_MESSAGE); 
104:             *    msg.setAddress(addr);
105:             *    ...
106:             * </pre>
107:             *
108:             * @param address The address of the target device.
109:             *
110:             * @throws IllegalArgumentException if the address is not valid.
111:             *
112:             * @see #getAddress
113:             */
114:            public void setAddress(String address) {
115:
116:                msgAddress = address;
117:            }
118:
119:            /**
120:             * Gets the address from the message object as a <code>String</code>. If no
121:             * address is found in the message, this method returns <code>null</code>.
122:             * If the method is applied to an inbound message, the source address is
123:             * returned.  If it is applied to an outbound message, the destination
124:             * address is returned. 
125:             * <p>
126:             * The following code sample retrieves the address from a received message.
127:             * <pre>
128:             *    ...
129:             *    Message msg = conn.receive();
130:             *    String addr = msg.getAddress();
131:             *    ...
132:             * </pre>
133:             *    ...
134:             * @return The address in string form, or <code>null</code> if no 
135:             *         address was set.
136:             *
137:             * @see #setAddress
138:             */
139:            public String getAddress() {
140:                return msgAddress;
141:            }
142:
143:            /**
144:             * Sets the timestamp for inbound SMS messages.
145:             *
146:             * @param timestamp The time stamp in the message.
147:             *
148:             * @see #getTimeStamp
149:             */
150:            public void setTimeStamp(long timestamp) {
151:                sentAt = timestamp;
152:            }
153:
154:            /**
155:             * Returns the timestamp indicating when this message has been sent.
156:             * 
157:             * @return Date indicating the time stamp in the message or
158:             *         <code>null</code> if the time stamp was not set.
159:             *
160:             * @see #setTimeStamp
161:             */
162:            public Date getTimestamp() {
163:                return new Date(sentAt);
164:            }
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.