Source Code Cross Referenced for VCardSupport.java in  » 6.0-JDK-Modules » j2me » com » sun » kvem » midp » pim » formats » 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.kvem.midp.pim.formats 
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.kvem.midp.pim.formats;
028:
029:        import javax.microedition.pim.Contact;
030:
031:        /**
032:         * Helper methods for vCard implementations.
033:         *
034:         */
035:        public class VCardSupport {
036:            /**
037:             * Gets the field label.
038:             * @param field identifier for field
039:             * @return label of requested field
040:             */
041:            public static String getFieldLabel(int field) {
042:                switch (field) {
043:                case Contact.FORMATTED_NAME:
044:                    return "FN";
045:                case Contact.ADDR:
046:                    return "ADR";
047:                case Contact.BIRTHDAY:
048:                    return "BDAY";
049:                case Contact.NAME:
050:                    return "N";
051:                case Contact.PHOTO:
052:                    return "PHOTO;ENCODING=BASE64";
053:                case Contact.PHOTO_URL:
054:                    return "PHOTO;VALUE=URL";
055:                case Contact.TEL:
056:                    return "TEL";
057:                case Contact.TITLE:
058:                    return "TITLE";
059:                case Contact.REVISION:
060:                    return "REV";
061:                case Contact.URL:
062:                    return "URL";
063:                case Contact.UID:
064:                    return "UID";
065:                case Contact.PUBLIC_KEY:
066:                    return "KEY;ENCODING=BASE64";
067:                case Contact.FORMATTED_ADDR:
068:                    return "LABEL";
069:                case Contact.NICKNAME:
070:                    return "NICKNAME";
071:                case Contact.NOTE:
072:                    return "NOTE";
073:                case Contact.PUBLIC_KEY_STRING:
074:                    return "KEY";
075:                case Contact.EMAIL:
076:                    return "EMAIL";
077:                case Contact.ORG:
078:                    return "ORG";
079:                default:
080:                    return null;
081:                }
082:            }
083:
084:            /**
085:             * Lookup the field identifier byte name.
086:             * @param fieldName label for field
087:             * @return identifier for requested field
088:             */
089:            public static int getFieldCode(String fieldName) {
090:                if (fieldName.equals("FN"))
091:                    return Contact.FORMATTED_NAME;
092:                else if (fieldName.equals("LABEL"))
093:                    return Contact.FORMATTED_ADDR;
094:                else if (fieldName.equals("ADR"))
095:                    return Contact.ADDR;
096:                else if (fieldName.equals("BDAY"))
097:                    return Contact.BIRTHDAY;
098:                else if (fieldName.equals("N"))
099:                    return Contact.NAME;
100:                else if (fieldName.equals("PHOTO"))
101:                    return Contact.PHOTO;
102:                else if (fieldName.equals("TEL"))
103:                    return Contact.TEL;
104:                else if (fieldName.equals("TITLE"))
105:                    return Contact.TITLE;
106:                else if (fieldName.equals("REV"))
107:                    return Contact.REVISION;
108:                else if (fieldName.equals("URL"))
109:                    return Contact.URL;
110:                else if (fieldName.equals("UID"))
111:                    return Contact.UID;
112:                else if (fieldName.equals("KEY"))
113:                    return Contact.PUBLIC_KEY;
114:                else if (fieldName.equals("NICKNAME"))
115:                    return Contact.NICKNAME;
116:                else if (fieldName.equals("NOTE"))
117:                    return Contact.NOTE;
118:                else if (fieldName.equals("EMAIL"))
119:                    return Contact.EMAIL;
120:                else if (fieldName.equals("ORG"))
121:                    return Contact.ORG;
122:                else
123:                    return -1;
124:            }
125:
126:            /**
127:             * Lookup the attribute name from identifier.
128:             * @param attr the field identifier
129:             * @return the name of the attribute
130:             */
131:            public static String getAttributeLabel(int attr) {
132:                switch (attr) {
133:                case Contact.ATTR_ASST:
134:                    return "X-J2MEWTK-ASST";
135:                case Contact.ATTR_AUTO:
136:                    return "CAR";
137:                case Contact.ATTR_FAX:
138:                    return "FAX";
139:                case Contact.ATTR_HOME:
140:                    return "HOME";
141:                case Contact.ATTR_MOBILE:
142:                    return "CELL";
143:                case Contact.ATTR_OTHER:
144:                    return "X-J2MEWTK-OTHER";
145:                case Contact.ATTR_PAGER:
146:                    return "PAGER";
147:                case Contact.ATTR_PREFERRED:
148:                    return "PREF";
149:                case Contact.ATTR_SMS:
150:                    return "MSG";
151:                case Contact.ATTR_WORK:
152:                    return "WORK";
153:                default:
154:                    return Extensions.getContactAttributeLabel(attr);
155:                }
156:            }
157:
158:            /**
159:             * Lookup the attribute identifier.
160:             * @param label the name of the attribute
161:             * @param defaultValue default value to return if
162:             * the attribute identifier is not found
163:             * @return identifier for requested attribute
164:             */
165:            public static int getAttributeCode(String label, int defaultValue) {
166:                if (label.equals("CAR"))
167:                    return Contact.ATTR_AUTO;
168:                else if (label.equals("FAX"))
169:                    return Contact.ATTR_FAX;
170:                else if (label.equals("HOME"))
171:                    return Contact.ATTR_HOME;
172:                else if (label.equals("CELL"))
173:                    return Contact.ATTR_MOBILE;
174:                else if (label.equals("X-J2MEWTK-OTHER"))
175:                    return Contact.ATTR_OTHER;
176:                else if (label.equals("PAGER"))
177:                    return Contact.ATTR_PAGER;
178:                else if (label.equals("PREF"))
179:                    return Contact.ATTR_PREFERRED;
180:                else if (label.equals("MSG"))
181:                    return Contact.ATTR_SMS;
182:                else if (label.equals("WORK"))
183:                    return Contact.ATTR_WORK;
184:                else if (label.equals("X-J2MEWTK-ASST"))
185:                    return Contact.ATTR_ASST;
186:                else
187:                    return Extensions.getContactAttributeCode(label,
188:                            defaultValue);
189:            }
190:
191:            /**
192:             * Gets the value of the vCard CLASS field for the given
193:             * value of the Contact.CLASS field.
194:             * This method encapsulates the following mapping:
195:             * Contact.CLASS_PUBLIC -> "PUBLIC"
196:             * Contact.CLASS_PRIVATE -> "PRIVATE"
197:             * Contact.CLASS_CONFIDENTIAL -> "CONFIDENTIAL"
198:             *
199:             * @param fieldValue the value of the Contact.CLASS field
200:             * @return a string describing the class for the field value, or null if
201:             *  fieldValue is out of range
202:             */
203:            public static String getClassType(int fieldValue) {
204:                switch (fieldValue) {
205:                case Contact.CLASS_CONFIDENTIAL:
206:                    return "CONFIDENTIAL";
207:                case Contact.CLASS_PRIVATE:
208:                    return "PRIVATE";
209:                case Contact.CLASS_PUBLIC:
210:                    return "PUBLIC";
211:                }
212:                return null;
213:            }
214:
215:            /**
216:             * Gets the value of the Contact.CLASS field for the given
217:             * value of the vCard CLASS property.
218:             * This method encapsulates the following mapping:
219:             * Contact.CLASS_PUBLIC <- "PUBLIC"
220:             * Contact.CLASS_PRIVATE <- "PRIVATE"
221:             * Contact.CLASS_CONFIDENTIAL <- "CONFIDENTIAL"
222:             *
223:             * @param s the value of the CLASS property
224:             * @return the corresponding field of Contact, or -1 if s is not recognized
225:             */
226:            public static int getClassCode(String s) {
227:                switch (s.length()) {
228:                case 6:
229:                    if (s.equals("PUBLIC")) {
230:                        return Contact.CLASS_PUBLIC;
231:                    }
232:                    break;
233:                case 7:
234:                    if (s.equals("PRIVATE")) {
235:                        return Contact.CLASS_PRIVATE;
236:                    }
237:                    break;
238:                case 12:
239:                    if (s.equals("CONFIDENTIAL")) {
240:                        return Contact.CLASS_CONFIDENTIAL;
241:                    }
242:                    break;
243:                }
244:                return -1;
245:            }
246:
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.