Source Code Cross Referenced for MediaField.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.javax.sdp.*;
030:        import gov.nist.core.*;
031:        import java.util.*;
032:
033:        /**
034:         * Media field SDP header.
035:         * @version JSR141-PUBLIC-REVIEW (subject to change).
036:         *
037:         *
038:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
039:         *
040:         */
041:        public class MediaField extends SDPField {
042:            /** Type of media. */
043:            protected String media;
044:            /** Current port number. */
045:            protected int port;
046:            /** Number of ports. */
047:            protected int nports;
048:            /** Protocol used. */
049:            protected String proto;
050:            /** Media formats. */
051:            protected Vector formats;
052:
053:            /**
054:             * Copies the current instance.
055:             * @return the copy of this object
056:             */
057:            public Object clone() {
058:                MediaField retval = new MediaField();
059:                retval.media = media;
060:                retval.port = port;
061:                retval.nports = nports;
062:                retval.proto = proto;
063:                for (int i = 0; i < formats.size(); i++) {
064:                    retval.formats.addElement(formats.elementAt(i));
065:                }
066:                return retval;
067:            }
068:
069:            /** Default constructor. */
070:            public MediaField() {
071:                super (SDPFieldNames.MEDIA_FIELD);
072:                formats = new Vector();
073:            }
074:
075:            /**
076:             * Gets the media type.
077:             * @return the media type
078:             */
079:            public String getMedia() {
080:                return media;
081:            }
082:
083:            /**
084:             * Gets the port information.
085:             * @return the current port number
086:             */
087:            public int getPort() {
088:                return port;
089:            }
090:
091:            /**
092:             * Gets the number of ports.
093:             * @return the number of ports
094:             */
095:            public int getNports() {
096:                return nports;
097:            }
098:
099:            /**
100:             * Gets the protocl information.
101:             * @return the protocol
102:             */
103:            public String getProto() {
104:                return proto;
105:            }
106:
107:            /**
108:             * Gets the vector of media formats
109:             * @return the formats
110:             */
111:            public Vector getFormats() {
112:                return formats;
113:            }
114:
115:            /**
116:             * Sets the media member.
117:             * @param m the new media type
118:             */
119:            public void setMedia(String m) {
120:                media = m;
121:            }
122:
123:            /**
124:             * Sets the port member.
125:             * @param p the new port number
126:             */
127:            public void setPort(int p) {
128:                port = p;
129:            }
130:
131:            /**
132:             * Sets the number of ports member.
133:             * @param n the new number of ports
134:             */
135:            public void setNports(int n) {
136:                nports = n;
137:            }
138:
139:            /**
140:             * Sets the protocol type member.
141:             * @param p the protocol type
142:             */
143:            public void setProto(String p) {
144:                proto = p;
145:            }
146:
147:            /**
148:             * Sets the formats member.
149:             * @param formats the new vector of media formats
150:             */
151:            public void setFormats(Vector formats) {
152:                this .formats = formats;
153:            }
154:
155:            /** 
156:             * Returns the type (audio,video etc) of the 
157:             * media defined by this description.
158:             * @throws SdpParseException if a parsing erro occurs
159:             * @return the string media type.
160:             */
161:            public String getMediaType() throws SdpParseException {
162:                return getMedia();
163:            }
164:
165:            /**
166:             * Sets the type (audio,video etc) of the media defined by this description.
167:             * @param mediaType to set
168:             * @throws SdpException if mediaType is null
169:             */
170:            public void setMediaType(String mediaType) throws SdpException {
171:                if (mediaType == null)
172:                    throw new SdpException("The mediaType is null");
173:                else
174:                    setMedia(mediaType);
175:            }
176:
177:            /**
178:             * Returns the port of the media defined by this description
179:             * @throws SdpParseException if a parsing error occurs
180:             * @return the integer media port.
181:             */
182:            public int getMediaPort() throws SdpParseException {
183:                return getPort();
184:            }
185:
186:            /**
187:             * Sets the port of the media defined by this description
188:             * @param port to set
189:             * @throws SdpException if th eport is null
190:             */
191:            public void setMediaPort(int port) throws SdpException {
192:                if (port < 0)
193:                    throw new SdpException("The port is < 0");
194:                else
195:                    setPort(port);
196:            }
197:
198:            /**
199:             * Returns the number of ports associated with this media description
200:             * @throws SdpParseException if a parsing error occurs
201:             * @return the integer port count.
202:             */
203:            public int getPortCount() throws SdpParseException {
204:                return getNports();
205:            }
206:
207:            /** 
208:             * Sets the number of ports associated with this media description.
209:             * @param portCount portCount - the integer port count.
210:             * @throws SdpException if the count is less than zero
211:             */
212:            public void setPortCount(int portCount) throws SdpException {
213:                if (portCount < 0)
214:                    throw new SdpException("The port count is < 0");
215:                else
216:                    setNports(portCount);
217:            }
218:
219:            /**
220:             * Returns the protocol over which this media should be transmitted.
221:             * @throws SdpParseException if a parsing error occurs
222:             * @return the String protocol, e.g. RTP/AVP.
223:             */
224:            public String getProtocol() throws SdpParseException {
225:                return getProto();
226:            }
227:
228:            /**
229:             * Sets the protocol over which this media should be transmitted.
230:             * @param protocol - the String protocol, e.g. RTP/AVP.
231:             * @throws SdpException if the protocol is null
232:             */
233:            public void setProtocol(String protocol) throws SdpException {
234:                if (protocol == null)
235:                    throw new SdpException("The protocol is null");
236:                else
237:                    setProto(protocol);
238:            }
239:
240:            /**
241:             * Returns an Vector of the media formats supported by this description.
242:             * Each element in this Vector will be an String value which matches one of
243:             * the a=rtpmap: attribute fields of the media description.
244:             * @param create to set
245:             * @throws SdpException
246:             * @return the Vector.
247:             */
248:            public Vector getMediaFormats(boolean create)
249:                    throws SdpParseException {
250:
251:                if (!create && formats.size() == 0)
252:                    return null;
253:                else
254:                    return formats;
255:            }
256:
257:            /**
258:             * Adds a media format to the media description.
259:             * Each element in this Vector should be an String value which
260:             * matches one of the
261:             * a=rtpmap: attribute fields of the media description.
262:             * @param mediaFormats the format to add.
263:             * @throws SdpException if the vector is null
264:             */
265:            public void setMediaFormats(Vector mediaFormats)
266:                    throws SdpException {
267:                if (mediaFormats == null)
268:                    throw new SdpException("The mediaFormats is null");
269:                this .formats = mediaFormats;
270:            }
271:
272:            /** 
273:             * Gets the string encoded version of the media formats.
274:             * @return encoded string of media formats contents
275:             */
276:            private String encodeFormats() {
277:                String retval = "";
278:                for (int i = 0; i < formats.size(); i++) {
279:                    retval += formats.elementAt(i);
280:                    if (i < formats.size() - 1)
281:                        retval += Separators.SP;
282:                }
283:                return retval;
284:            }
285:
286:            /**
287:             * Gets the string encoded version of this object.
288:             * @return encoded string of instance contents
289:             * @since v1.0
290:             */
291:            public String encode() {
292:                String encoded_string;
293:                encoded_string = MEDIA_FIELD;
294:                if (media != null)
295:                    encoded_string += media + Separators.SP + port;
296:                // Leave out the nports parameter as this confuses the messenger.
297:                if (nports > 1)
298:                    encoded_string += Separators.SLASH + nports;
299:
300:                if (proto != null)
301:                    encoded_string += Separators.SP + proto;
302:
303:                if (formats != null)
304:                    encoded_string += Separators.SP + encodeFormats();
305:
306:                encoded_string += Separators.NEWLINE;
307:                return encoded_string;
308:            }
309:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.