jdoc + some fixes
authorNiki Roo <niki@nikiroo.be>
Tue, 1 Mar 2016 15:45:07 +0000 (16:45 +0100)
committerNiki Roo <niki@nikiroo.be>
Tue, 1 Mar 2016 15:45:07 +0000 (16:45 +0100)
src/be/nikiroo/jvcard/Card.java
src/be/nikiroo/jvcard/Contact.java
src/be/nikiroo/jvcard/Data.java
src/be/nikiroo/jvcard/DataPart.java [deleted file]
src/be/nikiroo/jvcard/TypeInfo.java
src/be/nikiroo/jvcard/parsers/AbookParser.java
src/be/nikiroo/jvcard/parsers/Vcard21Parser.java
src/be/nikiroo/jvcard/tui/panes/ContactDetails.java
src/be/nikiroo/jvcard/tui/panes/ContactDetailsRaw.java
src/be/nikiroo/jvcard/tui/panes/ContactList.java

index f3e07733528f50d4ce121b67eecdba8243205ac4..4c4e5d174e419bb47c9037e2f4477a08438a3b73 100644 (file)
@@ -4,11 +4,10 @@ import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.util.ArrayList;
+import java.security.InvalidParameterException;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -30,13 +29,25 @@ public class Card {
        private String name;
        private Format format;
 
+       /**
+        * Create a new {@link Card} from the given {@link File} and {@link Format}.
+        * 
+        * @param file
+        *            the file containing the {@link Card} data, must not be NULL
+        * @param format
+        *            the {@link Format} to use to parse it
+        * 
+        * @throws IOException
+        *             in case of IO error
+        * @throws NullPointerException
+        *             if file is NULL
+        * @throws InvalidParameterException
+        *             if format is NULL
+        */
        public Card(File file, Format format) throws IOException {
                this.file = file;
                this.format = format;
-
-               if (file != null) {
-                       name = file.getName();
-               }
+               this.name = file.getName();
 
                BufferedReader buffer = new BufferedReader(new InputStreamReader(
                                new FileInputStream(file), "UTF-8"));
@@ -53,34 +64,43 @@ public class Card {
        }
 
        /**
-        * Return the full list of {@link Contact}s. Please use responsibly (this is
-        * the original list, do not modify the list itself).
+        * Return the number of {@link Contact} present in this {@link Card}.
         * 
-        * @return the list of {@link Contact}s
+        * @return the number of {@link Contact}s
         */
-       public List<Contact> getContactsList() {
-               return contacts;
+       public int size() {
+               return contacts.size();
        }
 
        /**
-        * Return the list of {@link Contact}s. Note that this list is a copy.
+        * Return the {@link Contact} at index <i>index</i>.
         * 
-        * @return the list of {@link Contact}s
+        * @param index
+        *            the index of the {@link Contact} to find
+        * 
+        * @return the {@link Contact}
+        * 
+        * @throws IndexOutOfBoundsException
+        *             if the index is < 0 or >= {@link Card#size()}
         */
-       public List<Contact> getContacts() {
-               ArrayList<Contact> list = new ArrayList<Contact>(size());
-               list.addAll(contacts);
-               return list;
-       }
-
-       public int size() {
-               return contacts.size();
-       }
-
        public Contact get(int index) {
                return contacts.get(index);
        }
 
+       /**
+        * Save the {@link Card} to the given {@link File} with the given
+        * {@link Format}.
+        * 
+        * @param file
+        *            the {@link File} to save to
+        * @param format
+        *            the {@link Format} to use
+        * 
+        * @return TRUE if it was saved
+        * 
+        * @throws IOException
+        *             in case of IO errors
+        */
        public boolean saveAs(File file, Format format) throws IOException {
                if (file == null)
                        return false;
@@ -96,24 +116,77 @@ public class Card {
                return true;
        }
 
+       /**
+        * Save the {@link Card} to the original {@link File} it was open from.
+        * 
+        * @return TRUE if it was saved
+        * 
+        * @throws IOException
+        *             in case of IO errors
+        */
        public boolean save() throws IOException {
                return saveAs(file, format);
        }
 
+       /**
+        * Return a {@link String} representation of this {@link Card} in the given
+        * {@link Format}.
+        * 
+        * @param format
+        *            the {@link Format} to use
+        * 
+        * @return the {@link String}
+        */
        public String toString(Format format) {
                return Parser.toString(this, format);
        }
 
+       /**
+        * Check if this {@link Card} has unsaved changes.
+        * 
+        * @return TRUE if it has
+        */
+       public boolean isDirty() {
+               return dirty;
+       }
+
+       /**
+        * Return the name of this card (the name of the {@link File} which it was
+        * opened from).
+        * 
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       @Override
        public String toString() {
                return toString(Format.VCard21);
        }
 
+       /**
+        * Load the given data from the given {@link Format} in this {@link Card}.
+        * 
+        * @param serializedContent
+        *            the data
+        * @param format
+        *            the {@link Format}
+        */
        protected void load(String serializedContent, Format format) {
                // note: fixed size array
                List<String> lines = Arrays.asList(serializedContent.split("\n"));
                load(lines, format);
        }
 
+       /**
+        * Load the given data from the given {@link Format} in this {@link Card}.
+        * 
+        * @param lines
+        *            the data
+        * @param format
+        *            the {@link Format}
+        */
        protected void load(List<String> lines, Format format) {
                this.contacts = Parser.parse(lines, format);
                setDirty();
@@ -123,17 +196,14 @@ public class Card {
                }
        }
 
-       public boolean isDirty() {
-               return dirty;
-       }
-
        /**
-        * Return the name of this card.
+        * Return the full list of {@link Contact}s. Please use responsibly (this is
+        * the original list).
         * 
-        * @return the name
+        * @return the list of {@link Contact}s
         */
-       public String getName() {
-               return name;
+       List<Contact> getContactsList() {
+               return contacts;
        }
 
        /**
index 553ca7680f486f34b1a38e9753dff0b4f06edb99..8142c29a830c4d6dfc82c6a01f0dddc718e62c62 100644 (file)
@@ -58,12 +58,27 @@ public class Contact {
        }
 
        /**
-        * Return the informations (note: this is the actual list, be careful).
+        * Return the number of {@link Data} present in this {@link Contact}.
         * 
-        * @return the list of data anout this contact
+        * @return the number of {@link Data}s
         */
-       public List<Data> getContent() {
-               return datas;
+       public int size() {
+               return datas.size();
+       }
+
+       /**
+        * Return the {@link Data} at index <i>index</i>.
+        * 
+        * @param index
+        *            the index of the {@link Data} to find
+        * 
+        * @return the {@link Data}
+        * 
+        * @throws IndexOutOfBoundsException
+        *             if the index is < 0 or >= {@link Contact#size()}
+        */
+       public Data get(int index) {
+               return datas.get(index);
        }
 
        /**
@@ -78,7 +93,8 @@ public class Contact {
                for (Data data : getData(name)) {
                        if (first == null)
                                first = data;
-                       for (TypeInfo type : data.getTypes()) {
+                       for (int index = 0; index < data.size(); index++) {
+                               TypeInfo type = data.get(index);
                                if (type.getName().equals("TYPE")
                                                && type.getValue().equals("pref")) {
                                        return data;
@@ -407,48 +423,6 @@ public class Contact {
                return str.toArray(new String[] {});
        }
 
-       /**
-        * Add a {@link String} to the given {@link List}, but make sure it does not
-        * exceed the maximum size, and truncate it if needed to fit.
-        * 
-        * @param list
-        * @param add
-        * @param currentSize
-        * @param maxSize
-        * @return
-        */
-       static private int addToList(List<String> list, String add,
-                       int currentSize, int maxSize) {
-               if (add == null || add.length() == 0) {
-                       if (add != null)
-                               list.add(add);
-                       return 0;
-               }
-
-               if (maxSize > -1) {
-                       if (currentSize < maxSize) {
-                               if (currentSize + add.length() >= maxSize) {
-                                       add = add.substring(0, maxSize - currentSize);
-                               }
-                       } else {
-                               add = "";
-                       }
-               }
-
-               list.add(add);
-               return add.length();
-       }
-
-       /**
-        * Return a {@link String} representation of this contact, in vCard 2.1,
-        * without BKeys.
-        * 
-        * @return the {@link String} representation
-        */
-       public String toString() {
-               return toString(Format.VCard21, -1);
-       }
-
        /**
         * Update the information from this contact with the information in the
         * given contact. Non present fields will be removed, new fields will be
@@ -479,6 +453,46 @@ public class Contact {
                setDirty();
        }
 
+       /**
+        * Delete this {@link Contact} from its parent {@link Card} if any.
+        * 
+        * @return TRUE in case of success
+        */
+       public boolean delete() {
+               if (parent != null) {
+                       List<Contact> list = parent.getContactsList();
+                       for (int i = 0; i < list.size(); i++) {
+                               if (list.get(i) == this) {
+                                       list.remove(i);
+                                       parent.setDirty();
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+
+       /**
+        * Check if this {@link Contact} has unsaved changes.
+        * 
+        * @return TRUE if it has
+        */
+       public boolean isDirty() {
+               return dirty;
+       }
+
+       /**
+        * Return a {@link String} representation of this contact, in vCard 2.1,
+        * without BKeys.
+        * 
+        * @return the {@link String} representation
+        */
+       @Override
+       public String toString() {
+               return toString(Format.VCard21, -1);
+       }
+
        /**
         * Mark all the binary fields with a BKey number.
         * 
@@ -503,10 +517,6 @@ public class Contact {
                }
        }
 
-       public boolean isDirty() {
-               return dirty;
-       }
-
        /**
         * Notify that this element has unsaved changes, and notify its parent of
         * the same if any.
@@ -517,6 +527,23 @@ public class Contact {
                        this.parent.setDirty();
        }
 
+       /**
+        * Notify this element <i>and all its descendants</i> that it is in pristine
+        * state (as opposed to dirty).
+        */
+       void setPristine() {
+               dirty = false;
+               for (Data data : datas) {
+                       data.setPristine();
+               }
+       }
+
+       /**
+        * Set the parent of this {@link Contact} <i>and all its descendants</i>.
+        * 
+        * @param parent
+        *            the new parent
+        */
        void setParent(Card parent) {
                this.parent = parent;
                for (Data data : datas) {
@@ -525,33 +552,35 @@ public class Contact {
        }
 
        /**
-        * Delete this {@link Contact} from its parent {@link Card} if any.
+        * Add a {@link String} to the given {@link List}, but make sure it does not
+        * exceed the maximum size, and truncate it if needed to fit.
         * 
-        * @return TRUE in case of success
+        * @param list
+        * @param add
+        * @param currentSize
+        * @param maxSize
+        * @return
         */
-       public boolean delete() {
-               if (parent != null) {
-                       List<Contact> list = parent.getContactsList();
-                       for (int i = 0; i < list.size(); i++) {
-                               if (list.get(i) == this) {
-                                       list.remove(i);
-                                       parent.setDirty();
-                                       return true;
+       static private int addToList(List<String> list, String add,
+                       int currentSize, int maxSize) {
+               if (add == null || add.length() == 0) {
+                       if (add != null)
+                               list.add(add);
+                       return 0;
+               }
+
+               if (maxSize > -1) {
+                       if (currentSize < maxSize) {
+                               if (currentSize + add.length() >= maxSize) {
+                                       add = add.substring(0, maxSize - currentSize);
                                }
+                       } else {
+                               add = "";
                        }
                }
 
-               return false;
+               list.add(add);
+               return add.length();
        }
 
-       /**
-        * Notify this element <i>and all its descendants</i> that it is in pristine
-        * state (as opposed to dirty).
-        */
-       void setPristine() {
-               dirty = false;
-               for (Data data : datas) {
-                       data.setPristine();
-               }
-       }
 }
index 3f62b7e8f0f6158aff806a4baa06ff2b59ef8dc2..f2bb4080f6d770776e1824e0cf7cfd7495c20433 100644 (file)
@@ -4,7 +4,22 @@ import java.security.InvalidParameterException;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * A data is a piece of information present in a {@link Contact}. It is
+ * basically a key/value pair with optional types and an optional group name.
+ * 
+ * @author niki
+ *
+ */
 public class Data {
+       public enum DataPart {
+               FN_FAMILY, FN_GIVEN, FN_ADDITIONAL, // Name
+               FN_PRE, FN_POST, // Pre/Post
+               BDAY_YYYY, BDAY_MM, BDAY_DD, // BDay
+               ADR_PBOX, ADR_EXTENDED, ADR_STREET, ADR_CITY, ADR_REGION, ADR_POSTAL_CODE, ADR_COUNTRY
+               // Address
+       }
+
        private String name;
        private String value;
        private String group;
@@ -13,6 +28,18 @@ public class Data {
        private boolean dirty;
        private Contact parent;
 
+       /**
+        * Create a new {@link Data} with the given values.
+        * 
+        * @param types
+        *            the types of this {@link Data}
+        * @param name
+        *            its name
+        * @param value
+        *            its value
+        * @param group
+        *            its group if any
+        */
        public Data(List<TypeInfo> types, String name, String value, String group) {
                if (types == null) {
                        types = new LinkedList<TypeInfo>();
@@ -25,6 +52,7 @@ public class Data {
 
                b64 = -1;
                for (TypeInfo type : types) {
+                       type.setParent(this);
                        if (type.getName().equals("ENCODING")
                                        && type.getValue().equals("b")) {
                                b64 = 0;
@@ -33,18 +61,54 @@ public class Data {
                }
        }
 
-       public List<TypeInfo> getTypes() {
-               return types;
+       /**
+        * Return the number of {@link TypeInfo} present in this {@link Data}.
+        * 
+        * @return the number of {@link TypeInfo}s
+        */
+       public int size() {
+               return types.size();
        }
 
+       /**
+        * Return the {@link TypeInfo} at index <i>index</i>.
+        * 
+        * @param index
+        *            the index of the {@link TypeInfo} to find
+        * 
+        * @return the {@link TypeInfo}
+        * 
+        * @throws IndexOutOfBoundsException
+        *             if the index is < 0 or >= {@link Data#size()}
+        */
+       public TypeInfo get(int index) {
+               return types.get(index);
+       }
+
+       /**
+        * Return the name of this {@link Data}
+        * 
+        * @return the name
+        */
        public String getName() {
                return name;
        }
 
+       /**
+        * Return the value of this {@link Data}
+        * 
+        * @return the value
+        */
        public String getValue() {
                return value;
        }
 
+       /**
+        * Change the value of this {@link Data}
+        * 
+        * @param value
+        *            the new value
+        */
        public void setValue(String value) {
                if ((value == null && this.value != null)
                                || (value != null && !value.equals(this.value))) {
@@ -53,14 +117,33 @@ public class Data {
                }
        }
 
+       /**
+        * Return the group of this {@link Data}
+        * 
+        * @return the group
+        */
        public String getGroup() {
                return group;
        }
 
+       /**
+        * Return the bkey number of this {@link Data} or -1 if it is not binary.
+        * 
+        * @return the bkey or -1
+        */
        public int getB64Key() {
                return b64;
        }
 
+       /**
+        * Change the bkey of this {@link Data}
+        * 
+        * @param i
+        *            the new bkey
+        * 
+        * @throw InvalidParameterException if the {@link Data} is not binary or if
+        *        it is but you try to set a negative bkey
+        */
        void resetB64Key(int i) {
                if (!isBinary())
                        throw new InvalidParameterException(
@@ -72,10 +155,20 @@ public class Data {
                b64 = i;
        }
 
+       /**
+        * Check if this {@link Data} is binary
+        * 
+        * @return TRUE if it is
+        */
        public boolean isBinary() {
                return b64 >= 0;
        }
 
+       /**
+        * Check if this {@link Data} has unsaved changes.
+        * 
+        * @return TRUE if it has
+        */
        public boolean isDirty() {
                return dirty;
        }
@@ -97,12 +190,17 @@ public class Data {
        void setPristine() {
                dirty = false;
                for (TypeInfo type : types) {
-                       // TODO ?
+                       type.setPristine();
                }
        }
 
+       /**
+        * Set the parent of this {@link Data}.
+        * 
+        * @param parent
+        *            the new parent
+        */
        void setParent(Contact parent) {
                this.parent = parent;
        }
-
 }
diff --git a/src/be/nikiroo/jvcard/DataPart.java b/src/be/nikiroo/jvcard/DataPart.java
deleted file mode 100644 (file)
index 4d26697..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package be.nikiroo.jvcard;
-
-public enum DataPart {
-       FN_FAMILY, FN_GIVEN, FN_ADDITIONAL, // Name
-       FN_PRE, FN_POST, // Pre/Post
-       BDAY_YYYY, BDAY_MM, BDAY_DD, // BDay
-       ADR_PBOX, ADR_EXTENDED, ADR_STREET, ADR_CITY, ADR_REGION, ADR_POSTAL_CODE, ADR_COUNTRY
-       // Address
-}
index b3851b20e5cbca48437185c71696bd0857bc5407..26314fa48a016603a9b3d9066a8d6d59f13a2c90 100644 (file)
@@ -3,6 +3,8 @@ package be.nikiroo.jvcard;
 public class TypeInfo {
        private String name;
        private String value;
+       private Data parent;
+       private boolean dirty;
 
        public TypeInfo(String name, String value) {
                this.name = name;
@@ -16,4 +18,41 @@ public class TypeInfo {
        public String getValue() {
                return value;
        }
+
+       /**
+        * Check if this {@link TypeInfo} has unsaved changes.
+        * 
+        * @return TRUE if it has
+        */
+       public boolean isDirty() {
+               return dirty;
+       }
+
+       /**
+        * Notify that this element has unsaved changes, and notify its parent of
+        * the same if any.
+        */
+       protected void setDirty() {
+               this.dirty = true;
+               if (this.parent != null)
+                       this.parent.setDirty();
+       }
+
+       /**
+        * Notify this element <i>and all its descendants</i> that it is in pristine
+        * state (as opposed to dirty).
+        */
+       void setPristine() {
+               dirty = false;
+       }
+
+       /**
+        * Set the parent of this {@link TypeInfo}.
+        * 
+        * @param parent
+        *            the new parent
+        */
+       void setParent(Data parent) {
+               this.parent = parent;
+       }
 }
\ No newline at end of file
index 2fd0ca2f15a61e1e92833d4a373364b6c4ccde05..913db9b70528066c08ee990f392c66285f348302 100644 (file)
@@ -10,7 +10,7 @@ import be.nikiroo.jvcard.Data;
 public class AbookParser {
        public static List<Contact> parse(List<String> lines) {
                List<Contact> contacts = new LinkedList<Contact>();
-               
+
                for (String line : lines) {
                        List<Data> content = new LinkedList<Data>();
 
@@ -83,15 +83,15 @@ public class AbookParser {
 
                // note: save as pine means normal LN, nor CRLN
                builder.append('\n');
-               
+
                return builder.toString();
        }
 
        public static String toString(Card card) {
                StringBuilder builder = new StringBuilder();
 
-               for (Contact contact : card.getContactsList()) {
-                       builder.append(toString(contact, -1));
+               for (int index = 0; index < card.size(); index++) {
+                       builder.append(toString(card.get(index), -1));
                }
 
                return builder.toString();
index cc7421672d62ec3b74d3f74ad92ece2f65478a1a..f2fd07c5aef8a750bce8db49074113bfadb1ce72 100644 (file)
@@ -109,13 +109,15 @@ public class Vcard21Parser {
                builder.append("\r\n");
                builder.append("VERSION:2.1");
                builder.append("\r\n");
-               for (Data data : contact.getContent()) {
+               for (int indexData = 0; indexData < contact.size(); indexData++) {
+                       Data data = contact.get(indexData);
                        if (data.getGroup() != null && !data.getGroup().trim().equals("")) {
                                builder.append(data.getGroup().trim());
                                builder.append('.');
                        }
                        builder.append(data.getName());
-                       for (TypeInfo type : data.getTypes()) {
+                       for (int indexType = 0; indexType < data.size(); indexType++) {
+                               TypeInfo type = data.get(indexType);
                                builder.append(';');
                                builder.append(type.getName());
                                if (type.getValue() != null
@@ -139,10 +141,10 @@ public class Vcard21Parser {
        public static String toString(Card card) {
                StringBuilder builder = new StringBuilder();
 
-               for (Contact contact : card.getContactsList()) {
-                       builder.append(toString(contact, -1));
+               for (int index = 0; index < card.size(); index++) {
+                       builder.append(toString(card.get(index), -1));
                }
-               
+
                builder.append("\r\n");
 
                return builder.toString();
index b2bb5626c91e5296ce9962f65051b8c36b1812bd..0814ed06a7db6ed207a5b1c38a9f3a4d808a4093 100644 (file)
@@ -48,7 +48,8 @@ public class ContactDetails extends MainContent {
                        if (photo != null) {
                                TypeInfo encoding = null;
                                TypeInfo type = null;
-                               for (TypeInfo info : photo.getTypes()) {
+                               for (int index = 0; index < photo.size(); index++) {
+                                       TypeInfo info = photo.get(index);
                                        if (info.getName() != null) {
                                                if (info.getName().equalsIgnoreCase("ENCODING"))
                                                        encoding = info;
index 1fc83c7765be41644c5e506014cdc0f86d0168fe..1347b0ee11698d94a18180142e28ea605c44b99c 100644 (file)
@@ -3,19 +3,19 @@ package be.nikiroo.jvcard.tui.panes;
 import java.util.LinkedList;
 import java.util.List;
 
-import com.googlecode.lanterna.input.KeyType;
-
 import be.nikiroo.jvcard.Contact;
 import be.nikiroo.jvcard.Data;
 import be.nikiroo.jvcard.TypeInfo;
 import be.nikiroo.jvcard.i18n.Trans;
 import be.nikiroo.jvcard.tui.KeyAction;
-import be.nikiroo.jvcard.tui.UiColors;
 import be.nikiroo.jvcard.tui.KeyAction.DataType;
 import be.nikiroo.jvcard.tui.KeyAction.Mode;
 import be.nikiroo.jvcard.tui.StringUtils;
+import be.nikiroo.jvcard.tui.UiColors;
 import be.nikiroo.jvcard.tui.UiColors.Element;
 
+import com.googlecode.lanterna.input.KeyType;
+
 public class ContactDetailsRaw extends MainContentList {
        private Contact contact;
        private int mode;
@@ -26,7 +26,7 @@ public class ContactDetailsRaw extends MainContentList {
                this.contact = contact;
                this.mode = 0;
 
-               for (int i = 0; i < contact.getContent().size(); i++) {
+               for (int i = 0; i < contact.size(); i++) {
                        addItem("[detail line]");
                }
        }
@@ -44,7 +44,7 @@ public class ContactDetailsRaw extends MainContentList {
                Element elDirty = (focused && selected) ? Element.CONTACT_LINE_DIRTY_SELECTED
                                : Element.CONTACT_LINE_DIRTY;
 
-               Data data = contact.getContent().get(index);
+               Data data = contact.get(index);
 
                List<TextPart> parts = new LinkedList<TextPart>();
                if (data.isDirty()) {
@@ -67,7 +67,8 @@ public class ContactDetailsRaw extends MainContentList {
                        }
                        break;
                case 1:
-                       for (TypeInfo type : data.getTypes()) {
+                       for (int indexType = 0; indexType < data.size(); indexType++) {
+                               TypeInfo type = data.get(indexType);
                                if (valueBuilder.length() > 1)
                                        valueBuilder.append(", ");
                                valueBuilder.append(type.getName());
@@ -105,11 +106,11 @@ public class ContactDetailsRaw extends MainContentList {
                List<KeyAction> actions = new LinkedList<KeyAction>();
 
                // TODO: add, remove
-               actions.add(new KeyAction(Mode.ASK_USER , KeyType.Enter,
+               actions.add(new KeyAction(Mode.ASK_USER, KeyType.Enter,
                                Trans.StringId.DUMMY) {
                        @Override
                        public Object getObject() {
-                               return contact.getContent().get(getSelectedIndex());
+                               return contact.get(getSelectedIndex());
                        }
 
                        @Override
index 078d38e89438a038c33d92513a34b5b4d521f6ae..bbd1f77a73f267d286d5ec93165161511e3ab066 100644 (file)
@@ -51,8 +51,8 @@ public class ContactList extends MainContentList {
                this.contacts = new LinkedList<Contact>();
 
                if (card != null) {
-                       for (int i = 0; i < card.getContacts().size(); i++) {
-                               Contact c = card.getContacts().get(i);
+                       for (int i = 0; i < card.size(); i++) {
+                               Contact c = card.get(i);
                                if (filter == null
                                                || c.toString(format).toLowerCase()
                                                                .contains(filter.toLowerCase())) {