git://git.nikiroo.be
/
jvcard.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New option: save/load contacts' photos
[jvcard.git]
/
src
/
be
/
nikiroo
/
jvcard
/
Contact.java
diff --git
a/src/be/nikiroo/jvcard/Contact.java
b/src/be/nikiroo/jvcard/Contact.java
index ce701a26a60ad88031881a13b71291b72c1ef627..779b60a3c596ee6ee9bcbc20b09bcf66e3d4edfd 100644
(file)
--- a/
src/be/nikiroo/jvcard/Contact.java
+++ b/
src/be/nikiroo/jvcard/Contact.java
@@
-47,13
+47,9
@@
public class Contact extends BaseClass<Data> {
for (Data data : getData(name)) {
if (first == null)
first = data;
for (Data data : getData(name)) {
if (first == null)
first = data;
- for (int index = 0; index < data.size(); index++) {
- TypeInfo type = data.get(index);
- if (type.getName().equals("TYPE")
- && type.getValue().equals("pref")) {
- return data;
- }
- }
+
+ if (data.isPreferred())
+ return data;
}
return first;
}
return first;
@@
-117,6
+113,7
@@
public class Contact extends BaseClass<Data> {
* Return a {@link String} representation of this contact formated
* accordingly to the given format.
*
* Return a {@link String} representation of this contact formated
* accordingly to the given format.
*
+ * <p>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
@@
-124,31
+121,48
@@
public class Contact extends BaseClass<Data> {
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
+ * </p>
+ *
+ * <p>
+ * You can also add a fixed text if it starts with a simple-quote (').
+ * </p>
*
*
- * Example: "N@10|FN@20|NICK@+|PHOTO@x"
+ * <p>
+ * Example: "'Contact: |N@10|FN@20|NICK@+|PHOTO@x"
+ * </p>
*
* @param format
* the format to use
*
* @param format
* the format to use
+ * @param separator
+ * the separator {@link String} to use between fields
*
* @return the {@link String} representation
*/
*
* @return the {@link String} representation
*/
- public String toString(String format) {
- return toString(format,
"|"
, null, -1, true, false);
+ public String toString(String format
, String separator
) {
+ return toString(format,
separator
, null, -1, true, false);
}
/**
* Return a {@link String} representation of this contact formated
* accordingly to the given format.
*
}
/**
* Return a {@link String} representation of this contact formated
* accordingly to the given format.
*
+ * <p>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
- * <li>@x:
(the 'x' is the letter 'x')
show only a present/not present info</li>
+ * <li>@x: show only a present/not present info</li>
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
+ * </p>
*
*
- * Example: "N@10|FN@20|NICK@+|PHOTO@x"
+ * <p>
+ * You can also add a fixed text if it starts with a simple-quote (').
+ * </p>
+ *
+ * <p>
+ * Example: "'Contact: |N@10|FN@20|NICK@+|PHOTO@x"
+ * </p>
*
* @param format
* the format to use
*
* @param format
* the format to use
@@
-180,6
+194,7
@@
public class Contact extends BaseClass<Data> {
* Return a {@link String} representation of this contact formated
* accordingly to the given format, part by part.
*
* Return a {@link String} representation of this contact formated
* accordingly to the given format, part by part.
*
+ * <p>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
@@
-187,8
+202,15
@@
public class Contact extends BaseClass<Data> {
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
+ * </p>
+ *
+ * <p>
+ * You can also add a fixed text if it starts with a simple-quote (').
+ * </p>
*
*
- * Example: "N@10|FN@20|NICK@+|PHOTO@x"
+ * <p>
+ * Example: "'Contact: |N@10|FN@20|NICK@+|PHOTO@x"
+ * </p>
*
* @param format
* the format to use
*
* @param format
* the format to use
@@
-240,6
+262,7
@@
public class Contact extends BaseClass<Data> {
* Return a {@link String} representation of this contact formated
* accordingly to the given format, part by part.
*
* Return a {@link String} representation of this contact formated
* accordingly to the given format, part by part.
*
+ * <p>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
* The format is basically a list of field names separated by a pipe and
* optionally parametrised. The parameters allows you to:
* <ul>
@@
-247,8
+270,15
@@
public class Contact extends BaseClass<Data> {
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
* <li>@n: limit the size to a fixed value 'n'</li>
* <li>@+: expand the size of this field as much as possible</li>
* </ul>
+ * </p>
*
*
- * Example: "N@10|FN@20|NICK@+|PHOTO@x"
+ * <p>
+ * You can also add a fixed text if it starts with a simple-quote (').
+ * </p>
+ *
+ * <p>
+ * Example: "'Contact: |N@10|FN@20|NICK@+|PHOTO@x"
+ * </p>
*
* @param format
* the format to use
*
* @param format
* the format to use
@@
-284,7
+314,8
@@
public class Contact extends BaseClass<Data> {
boolean binary = false;
boolean expand = false;
boolean binary = false;
boolean expand = false;
- if (field.contains("@")) {
+ if (field.length() > 0 && field.charAt(0) != '\''
+ && field.contains("@")) {
String[] opts = field.split("@");
if (opts.length > 0)
field = opts[0];
String[] opts = field.split("@");
if (opts.length > 0)
field = opts[0];
@@
-304,7
+335,13
@@
public class Contact extends BaseClass<Data> {
}
}
}
}
- String value = getPreferredDataValue(field);
+ String value = null;
+ if (field.length() > 0 && field.charAt(0) == '\'') {
+ value = field.substring(1);
+ } else {
+ value = getPreferredDataValue(field);
+ }
+
if (value == null) {
value = "";
} else {
if (value == null) {
value = "";
} else {
@@
-418,7
+455,7
@@
public class Contact extends BaseClass<Data> {
@Override
public String getState() {
@Override
public String getState() {
- return
"" + getPreferredDataValue("UID"
);
+ return
getId(
);
}
/**
}
/**