/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/ContactsCache.java

  • Committer: Tim Marston
  • Date: 2013-05-10 12:16:15 UTC
  • Revision ID: tim@ed.am-20130510121615-g8qhsu0h3t0ymrt6
Tags: 1.3.2
fix spacing in NEWS

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * ContactsCache.java
3
3
 *
4
 
 * Copyright (C) 2011 to 2013 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2011 to 2012 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
 
 * to as "this program").  For more information, see
 
7
 * to as "this program"). For more information, see
8
8
 * http://ed.am/dev/android/import-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
45
45
                 * Obtain a cache identifier.  This routine is designed to be as robust
46
46
                 * as possible (in terms of bad or null detail values), and to return
47
47
                 * null when a cache identifier can not be created.
48
 
                 *
49
48
                 * @param type the detail type
50
49
                 * @param detail the detail
51
50
                 * @return the cache identifier, or null
68
67
                 * Obtain a cache identifier from contact data.  This routine is
69
68
                 * designed to be as robust as possible and may return null when a cache
70
69
                 * identifier can not be created.
71
 
                 *
72
70
                 * @param contact the contact data
73
71
                 * @return the cache identifier, or null
74
72
                 */
137
135
                = new HashMap< Long, HashSet< String > >();
138
136
        private HashMap< Long, HashSet< String > > _contactNotes
139
137
                = new HashMap< Long, HashSet< String > >();
140
 
        private HashMap< Long, String > _contactBirthdays
141
 
                = new HashMap< Long, String >();
142
138
 
143
139
        public boolean canLookup( CacheIdentifier identifier )
144
140
        {
148
144
        /**
149
145
         * Retrieve the contact id of a contact identified by the specified cache
150
146
         * identifier, if it exists.
151
 
         *
152
147
         * @param identifier the cache identifier
153
148
         * @return a contact id, or null
154
149
         */
170
165
 
171
166
        /**
172
167
         * Remove any cache entry that is identified by the cache identifier.
173
 
         *
174
168
         * @param identifier the cache identifier
175
169
         * @return the contact id of the contact that was removed, or null
176
170
         */
192
186
 
193
187
        /**
194
188
         * Add a lookup from a contact identifier to a contact id to the cache.
195
 
         *
196
189
         * @param identifier the cache identifier
197
190
         * @param id teh contact id
198
191
         */
217
210
 
218
211
        /**
219
212
         * Remove any data that is associated with an contact id.
220
 
         *
221
213
         * @param id
222
214
         */
223
215
        public void removeAssociatedData( Long id )
339
331
                set.add( note );
340
332
        }
341
333
 
342
 
        public boolean hasAssociatedBirthday( Long id, String birthday )
343
 
        {
344
 
                birthday = normaliseBirthday( birthday );
345
 
                if( birthday == null ) return false;
346
 
 
347
 
                String found = _contactBirthdays.get( id );
348
 
                return found != null && found.equalsIgnoreCase( birthday );
349
 
        }
350
 
 
351
 
        public void addAssociatedBirthday( Long id, String birthday )
352
 
        {
353
 
                birthday = normaliseBirthday( birthday );
354
 
                if( birthday == null ) return;
355
 
 
356
 
                _contactBirthdays.put( id, birthday );
357
 
        }
358
 
 
359
334
        static public String normaliseName( String name )
360
335
        {
361
336
                if( name == null ) return null;
397
372
                note = note.trim();
398
373
                return note.length() > 0? note : null;
399
374
        }
400
 
 
401
 
        static public String normaliseBirthday( String birthday )
402
 
        {
403
 
                if( birthday == null ) return null;
404
 
                birthday = birthday.trim();
405
 
                return birthday.length() > 0? birthday : null;
406
 
        }
407
375
}