Source Code Cross Referenced for TimeField.java in  » 6.0-JDK-Modules » j2me » gov » nist » javax » sdp » fields » 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.javax.sdp.fields 
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:        package gov.nist.javax.sdp.fields;
028:
029:        import gov.nist.core.*;
030:        import java.util.*;
031:        import gov.nist.javax.sdp.*;
032:
033:        /**
034:         * Time Field.
035:         * @version JSR141-PUBLIC-REVIEW (subject to change).
036:         *
037:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
038:         *
039:         */
040:        public class TimeField extends SDPField {
041:            /** Start time. */
042:            protected long startTime;
043:            /** Stop time. */
044:            protected long stopTime;
045:
046:            /** Default constructor. */
047:            public TimeField() {
048:                super (TIME_FIELD);
049:            }
050:
051:            /** 
052:             * Gets the start time.
053:             * @return start time
054:             */
055:            public long getStartTime() {
056:                return startTime;
057:            }
058:
059:            /** 
060:             * Gets the stop time.
061:             * @return start stop time
062:             */
063:            public long getStopTime() {
064:                return stopTime;
065:            }
066:
067:            /**
068:             * Sets the start time member.
069:             * @param startTime tthe new start time
070:             */
071:            public void setStartTime(long startTime) {
072:                this .startTime = startTime;
073:            }
074:
075:            /**
076:             * Sets the stop time member.
077:             * @param stopTime the new stop mtime
078:             */
079:            public void setStopTime(long stopTime) {
080:                this .stopTime = stopTime;
081:            }
082:
083:            /**
084:             * Returns the start time of the conference/session.
085:             * @throws SdpParseException if a parsing error occurs
086:             * @return the date
087:             */
088:            public Date getStart() throws SdpParseException {
089:                return new Date(startTime * 1000 + SdpConstants.NTP_CONST);
090:            }
091:
092:            /**
093:             * Returns the stop time of the session.
094:             * @throws SdpParseException if a parsing error occurs
095:             * @return the stop time of the session.
096:             */
097:            public Date getStop() throws SdpParseException {
098:                return new Date(stopTime * 1000 + SdpConstants.NTP_CONST);
099:            }
100:
101:            /**
102:             * Sets the stop time of the session.
103:             * @param stop the new stop time
104:             * @throws SdpException if the date is null
105:             */
106:            public void setStop(Date stop) throws SdpException {
107:                if (stop == null)
108:                    throw new SdpException("The date is null");
109:                else {
110:                    this .stopTime = stop.getTime() / 1000
111:                            - SdpConstants.NTP_CONST;
112:                }
113:            }
114:
115:            /**
116:             * Sets the start time of the conference/session.
117:             * @param start the new start time for the session.
118:             * @throws SdpException if the date is null
119:             */
120:            public void setStart(Date start) throws SdpException {
121:                if (start == null)
122:                    throw new SdpException("The date is null");
123:                else {
124:                    this .startTime = start.getTime() / 1000
125:                            - SdpConstants.NTP_CONST;
126:                }
127:            }
128:
129:            /**
130:             * Returns whether the field will be output as a typed time 
131:             * or a integer value.
132:             *
133:             * Typed time is formatted as an integer followed by a unit character.
134:             * The unit indicates an appropriate multiplier for
135:             * the integer.
136:             *
137:             * The following unit types are allowed.
138:             * <pre>
139:             * d - days (86400 seconds)
140:             * h - hours (3600 seconds)
141:             * m - minutes (60 seconds)
142:             * s - seconds ( 1 seconds)
143:             * </pre>
144:             * @return true, if the field will be output as a 
145:             * typed time; false, if as an integer value.
146:             */
147:            public boolean getTypedTime() {
148:                return false;
149:            }
150:
151:            /** 
152:             * Sets whether the field will be output as a typed time or a integer value.
153:             *
154:             * Typed time is formatted as an integer followed by a unit character. 
155:             * The unit indicates an appropriate multiplier for
156:             * the integer.
157:             *
158:             * The following unit types are allowed.
159:             * <pre>
160:             * d - days (86400 seconds)
161:             * h - hours (3600 seconds)
162:             * m - minutes (60 seconds)
163:             * s - seconds ( 1 seconds)
164:             * </pre>
165:             * @param typedTime if set true, the start and stop times will
166:             * be output in an optimal typed time format; if false, the
167:             * times will be output as integers.
168:             */
169:            public void setTypedTime(boolean typedTime) {
170:
171:            }
172:
173:            /**
174:             * Returns whether the start and stop times were set to zero (in NTP).
175:             * @return true if tsrat or stop time are zero
176:             */
177:            public boolean isZero() {
178:                long stopTime = getStopTime();
179:                long startTime = getStartTime();
180:                if (stopTime == 0 && startTime == 0)
181:                    return true;
182:                else
183:                    return false;
184:            }
185:
186:            /**
187:             * Sets the start and stop times to zero (in NTP).
188:             */
189:            public void setZero() {
190:                setStopTime(0);
191:                setStartTime(0);
192:            }
193:
194:            /**
195:             * Gets the string encoded version of this object.
196:             * @return encoded string of object contents
197:             * @since v1.0
198:             */
199:            public String encode() {
200:                return new StringBuffer().append(TIME_FIELD).append(startTime)
201:                        .append(Separators.SP).append(stopTime).append(
202:                                Separators.NEWLINE).toString();
203:            }
204:
205:            /**
206:             * Copies the current instance.
207:             * @return the copy of this object
208:             */
209:            public Object clone() {
210:                TimeField retval = new TimeField();
211:                retval.startTime = this.startTime;
212:                retval.stopTime = this.stopTime;
213:                return retval;
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.