Source Code Cross Referenced for ContactImpl.java in  » 6.0-JDK-Modules » j2me » com » sun » kvem » midp » pim » 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 
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;
028:
029:        import com.sun.kvem.midp.pim.formats.VCard30Format;
030:        import javax.microedition.pim.Contact;
031:        import javax.microedition.pim.PIM;
032:
033:        /**
034:         * Implementation of a PIM contact.
035:         *
036:         */
037:        public class ContactImpl extends AbstractPIMItem implements  Contact {
038:            /**
039:             * Constructs a Contact list.
040:             * @param list handle for Contact List implementation
041:             */
042:            public ContactImpl(AbstractPIMList list) {
043:                super (list, PIM.CONTACT_LIST);
044:                if (list != null && !(list instanceof  ContactListImpl)) {
045:                    throw new RuntimeException("Wrong list passed");
046:                }
047:            }
048:
049:            /**
050:             * Constructs a Contact list from a handler and base Contact
051:             * record.
052:             * @param list Contact List implementation handler
053:             * @param base Contact record template
054:             */
055:            ContactImpl(AbstractPIMList list, Contact base) {
056:                super (list, base);
057:                if (!(list instanceof  ContactListImpl)) {
058:                    throw new RuntimeException("Wrong list passed");
059:                }
060:            }
061:
062:            /**
063:             * Gets preferred index for requested field.
064:             * @param field requested element
065:             * @return preferred index for requested field
066:             */
067:            public int getPreferredIndex(int field) {
068:                int indices = countValues(field);
069:                for (int i = 0; i < indices; i++) {
070:                    int attributes = getAttributes(field, i);
071:                    if ((attributes & ATTR_PREFERRED) != 0) {
072:                        return i;
073:                    }
074:                }
075:                return -1;
076:            }
077:
078:            /**
079:             * Gets encoding format for this contact record.
080:             * @return handle for encoding format
081:             */
082:            PIMFormat getEncodingFormat() {
083:                return new VCard30Format();
084:            }
085:
086:            /**
087:             * Ensures valid field.
088:             * @param field identifier to validate
089:             * @return <code>true</code> if contact field identifier is
090:             * supported
091:             */
092:            static boolean isValidPIMField(int field) {
093:                switch (field) {
094:                case Contact.ADDR:
095:                case Contact.BIRTHDAY:
096:                case Contact.CLASS:
097:                case Contact.EMAIL:
098:                case Contact.FORMATTED_ADDR:
099:                case Contact.FORMATTED_NAME:
100:                case Contact.NAME:
101:                case Contact.NICKNAME:
102:                case Contact.NOTE:
103:                case Contact.ORG:
104:                case Contact.PHOTO:
105:                case Contact.PHOTO_URL:
106:                case Contact.PUBLIC_KEY:
107:                case Contact.PUBLIC_KEY_STRING:
108:                case Contact.REVISION:
109:                case Contact.TEL:
110:                case Contact.TITLE:
111:                case Contact.UID:
112:                case Contact.URL:
113:                    return true;
114:                default:
115:                    return false;
116:                }
117:            }
118:
119:            /**
120:             * Adds a binary value to the current Contact.
121:             * @param field identifier for current element
122:             * @param attributes property to insert
123:             * @param value binary value to be recorded
124:             * @param offset index into value array
125:             * @param length size of data to copy
126:             */
127:            public void addBinary(int field, int attributes, byte[] value,
128:                    int offset, int length) {
129:                super .addBinary(field, attributes, value, offset, length);
130:                if (field == PUBLIC_KEY) {
131:                    // remove any values from PUBLIC_KEY_STRING
132:                    while (countValues(PUBLIC_KEY_STRING) > 0) {
133:                        removeValue(PUBLIC_KEY_STRING, 0);
134:                    }
135:                }
136:            }
137:
138:            /**
139:             * Adds a string to the current Contact.
140:             * @param field identifier for current element
141:             * @param attributes property to insert
142:             * @param value string to be recorded
143:             */
144:            public void addString(int field, int attributes, String value) {
145:                super .addString(field, attributes, value);
146:                if (field == PUBLIC_KEY_STRING) {
147:                    // remove any values from PUBLIC_KEY
148:                    while (countValues(PUBLIC_KEY) > 0) {
149:                        removeValue(PUBLIC_KEY, 0);
150:                    }
151:                }
152:            }
153:
154:            /**
155:             * Gets the revision field identifier.
156:             * @return revision field identifier
157:             */
158:            protected int getRevisionField() {
159:                return REVISION;
160:            }
161:
162:            /**
163:             * Gets the UID field identifier.
164:             * @return UID field identifier
165:             */
166:            protected int getUIDField() {
167:                return UID;
168:            }
169:
170:            /**
171:             * Converts the Contact to a printable format.
172:             * @return formatted Contact record
173:             */
174:            protected String toDisplayableString() {
175:                return "Contact[" + formatData() + "]";
176:            }
177:
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.