Source Code Cross Referenced for MessageLog.java in  » 6.0-JDK-Modules » j2me » gov » nist » siplite » stack » 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 » gov.nist.siplite.stack 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Portions Copyright  2000-2007 Sun Microsystems, Inc. All Rights
003:         * Reserved.  Use is subject to license terms.
004:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005:         * 
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License version
008:         * 2 only, as published by the Free Software Foundation.
009:         * 
010:         * This program is distributed in the hope that it will be useful, but
011:         * WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * General Public License version 2 for more details (a copy is
014:         * included at /legal/license.txt).
015:         * 
016:         * You should have received a copy of the GNU General Public License
017:         * version 2 along with this work; if not, write to the Free Software
018:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019:         * 02110-1301 USA
020:         * 
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022:         * Clara, CA 95054 or visit www.sun.com if you need additional
023:         * information or have any questions.
024:         */
025:        /*
026:         */
027:
028:        package gov.nist.siplite.stack;
029:
030:        /**
031:         * This class stores a message along with some other informations
032:         * Used to log messages.
033:         *
034:         * @version JAIN-SIP-1.1
035:         *
036:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
037:         *
038:         */
039:        class MessageLog {
040:            /** Message to be logged. */
041:            private String message;
042:            /** Originator of this mesage. */
043:            private String source;
044:            /** Target recipient for the message. */
045:            private String destination;
046:            /** Time of the logging event. */
047:            private long timeStamp;
048:            /** Flag indicating if we are the message sender. */
049:            private boolean isSender;
050:            /** First line from the message. */
051:            private String firstLine;
052:            /** Status line from the transaction. */
053:            private String statusMessage;
054:            /** Transaction identifier. */
055:            private String tid;
056:            /** Caller identification. */
057:            private String callId;
058:
059:            /**
060:             * Compares object for equivalence.
061:             * @param other object to be compared
062:             * @return true if the object matches
063:             */
064:            public boolean equals(Object other) {
065:                if (!(other instanceof  MessageLog)) {
066:                    return false;
067:                } else {
068:                    MessageLog otherLog = (MessageLog) other;
069:                    return otherLog.message.equals(message)
070:                            && otherLog.timeStamp == timeStamp;
071:                }
072:            }
073:
074:            /**
075:             * Constructor with initial parameters.
076:             * @param message the message to be logged
077:             * @param source the originator of the message
078:             * @param destination the target recipient
079:             * @param timeStamp the logging event timestamp
080:             * @param isSender true is we are the sender
081:             * @param firstLine the first line from the message
082:             * @param statusMessage the status line from the transaction
083:             * @param tid the transaction identifier
084:             * @param callId the caller identification
085:             * @exception IllegalArgumentException if the message is null,
086:             * or the timeStamp is not valid
087:             */
088:            public MessageLog(String message, String source,
089:                    String destination, String timeStamp, boolean isSender,
090:                    String firstLine, String statusMessage, String tid,
091:                    String callId) throws IllegalArgumentException {
092:                if (message == null || message.equals(""))
093:                    throw new IllegalArgumentException("null msg");
094:                this .message = message;
095:                this .source = source;
096:                this .destination = destination;
097:                try {
098:                    long ts = Long.parseLong(timeStamp);
099:                    if (ts < 0)
100:                        throw new IllegalArgumentException("Bad time stamp ");
101:                    this .timeStamp = ts;
102:                } catch (NumberFormatException ex) {
103:                    throw new IllegalArgumentException("Bad number format "
104:                            + timeStamp);
105:                }
106:                this .isSender = isSender;
107:                this .firstLine = firstLine;
108:                this .statusMessage = statusMessage;
109:                this .tid = tid;
110:                this .callId = callId;
111:            }
112:
113:            /**
114:             * Gets the logged timestamp.
115:             * @return the timestamp
116:             */
117:            protected long getTimeStamp() {
118:                return this .timeStamp;
119:            }
120:
121:            /**
122:             * Constructor with initial parameters.
123:             * @param message the message to be logged
124:             * @param source the originator of the message
125:             * @param destination the target recipient
126:             * @param timeStamp the logging event timestamp
127:             * @param isSender true is we are the sender
128:             * @param firstLine the first line from the message
129:             * @param statusMessage the status line from the transaction
130:             * @param tid the transaction identifier
131:             * @param callId the caller identification
132:             * @exception IllegalArgumentException if the message is null,
133:             * or the timeStamp is not valid
134:             */
135:            public MessageLog(String message, String source,
136:                    String destination, long timeStamp, boolean isSender,
137:                    String firstLine, String statusMessage, String tid,
138:                    String callId) throws IllegalArgumentException {
139:                if (message == null || message.equals(""))
140:                    throw new IllegalArgumentException("null msg");
141:                this .message = message;
142:                this .source = source;
143:                this .destination = destination;
144:                if (timeStamp < 0)
145:                    throw new IllegalArgumentException("negative ts");
146:                this .timeStamp = timeStamp;
147:                this .isSender = isSender;
148:                this .firstLine = firstLine;
149:                this .statusMessage = statusMessage;
150:                this .tid = tid;
151:                this .callId = callId;
152:            }
153:
154:            /**
155:             * Constructs an XML formatted log message.
156:             * @param startTime time of message output
157:             * @return the encode log message
158:             */
159:            public String flush(long startTime) {
160:                String log;
161:
162:                if (statusMessage != null) {
163:                    log = " <message\nfrom = \"" + source + "\" \nto = \""
164:                            + destination + "\" \ntime = \""
165:                            + (timeStamp - startTime) + "\" \nisSender = \""
166:                            + isSender + "\" \nstatusMessage = \""
167:                            + statusMessage + "\" \ntransactionId = \"" + tid
168:                            + "\" \ncallId = \"" + callId
169:                            + "\" \nfirstLine = \"" + firstLine.trim()
170:                            + "\" > \n";
171:                    log += "<![CDATA[";
172:                    log += message;
173:                    log += "]]>\n";
174:                    log += "</message>\n";
175:                } else {
176:                    log = " <message\nfrom = \"" + source + "\" \nto = \""
177:                            + destination + "\" \ntime = \""
178:                            + (timeStamp - startTime) + "\" \nisSender = \""
179:                            + isSender + "\" \ntransactionId = \"" + tid
180:                            + "\" \ncallId = \"" + callId
181:                            + "\" \nfirstLine = \"" + firstLine.trim()
182:                            + "\" > \n";
183:                    log += "<![CDATA[";
184:                    log += message;
185:                    log += "]]>\n";
186:                    log += "</message>\n";
187:                }
188:                return log;
189:            }
190:
191:            /**
192:             * Constructs an XML formatted log message.
193:             * @return the encode log message
194:             */
195:            public String flush() {
196:                String log;
197:
198:                if (statusMessage != null) {
199:                    log = " < message\nfrom = \"" + source + "\" \nto = \""
200:                            + destination + "\" \ntime = \"" + timeStamp
201:                            + "\" \nisSender = \"" + isSender
202:                            + "\" \nstatusMessage = \"" + statusMessage
203:                            + "\" \ntransactionId = \"" + tid
204:                            + "\" \nfirstLine = \"" + firstLine.trim()
205:                            + "\" \ncallId = \"" + callId + "\" \n > \n";
206:                    log += "<![CDATA[";
207:                    log += message;
208:                    log += "]]>\n";
209:                    log += "</message>\n";
210:                } else {
211:                    log = " < message\nfrom = \"" + source + "\" \nto = \""
212:                            + destination + "\" \ntime = \"" + timeStamp
213:                            + "\" \nisSender = \"" + isSender
214:                            + "\" \ntransactionId = \"" + tid
215:                            + "\" \ncallId = \"" + callId
216:                            + "\" \nfirstLine = \"" + firstLine.trim()
217:                            + "\" \n > \n";
218:                    log += "<![CDATA[";
219:                    log += message;
220:                    log += "]]>\n";
221:                    log += "</message>\n";
222:                }
223:                return log;
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.