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
Remote: jdoc + description + some fixes:
[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 948fd8447965a87d06663db2b4513d6bea022d92..08c2a515e563cdfb39aadc7ab84795b1ec1153c6 100644
(file)
--- a/
src/be/nikiroo/jvcard/Contact.java
+++ b/
src/be/nikiroo/jvcard/Contact.java
@@
-7,10
+7,11
@@
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import be.nikiroo.jvcard.parsers.Format;
import be.nikiroo.jvcard.parsers.Parser;
import be.nikiroo.jvcard.parsers.Format;
import be.nikiroo.jvcard.parsers.Parser;
-import be.nikiroo.jvcard.
tui
.StringUtils;
+import be.nikiroo.jvcard.
resources
.StringUtils;
/**
* A contact is the information that represent a contact person or organisation.
/**
* A contact is the information that represent a contact person or organisation.
@@
-102,7
+103,14
@@
public class Contact extends BaseClass<Data> {
*/
public String toString(Format format, int startingBKey) {
updateBKeys(false);
*/
public String toString(Format format, int startingBKey) {
updateBKeys(false);
- return Parser.toString(this, format, startingBKey);
+
+ StringBuilder builder = new StringBuilder();
+ for (String line : Parser.toStrings(this, format, startingBKey)) {
+ builder.append(line);
+ builder.append("\r\n");
+ }
+
+ return builder.toString();
}
/**
}
/**
@@
-403,6
+411,16
@@
public class Contact extends BaseClass<Data> {
this.nextBKey = vc.nextBKey;
}
this.nextBKey = vc.nextBKey;
}
+ @Override
+ public String getId() {
+ return "" + getPreferredDataValue("UID");
+ }
+
+ @Override
+ public String getState() {
+ return getId();
+ }
+
/**
* Return a {@link String} representation of this contact, in vCard 2.1,
* without BKeys.
/**
* Return a {@link String} representation of this contact, in vCard 2.1,
* without BKeys.
@@
-455,12
+473,15
@@
public class Contact extends BaseClass<Data> {
boolean fn = false;
boolean n = false;
boolean fn = false;
boolean n = false;
+ boolean uid = false;
if (content != null) {
for (Data data : content) {
if (data.getName().equals("N")) {
n = true;
} else if (data.getName().equals("FN")) {
fn = true;
if (content != null) {
for (Data data : content) {
if (data.getName().equals("N")) {
n = true;
} else if (data.getName().equals("FN")) {
fn = true;
+ } else if (data.getName().equals("UID")) {
+ uid = true;
}
if (!data.getName().equals("VERSION")) {
}
if (!data.getName().equals("VERSION")) {
@@
-470,12
+491,12
@@
public class Contact extends BaseClass<Data> {
}
// required fields:
}
// required fields:
- if (!n)
{
+ if (!n)
// required since vCard 3.0, supported in 2.1
datas.add(new Data(null, "N", "", null));
datas.add(new Data(null, "N", "", null));
- }
- if (!fn) {
+ if (!fn) // not required anymore but still supported in 4.0
datas.add(new Data(null, "FN", "", null));
datas.add(new Data(null, "FN", "", null));
- }
+ if (!uid) // supported by vCard, required by this program
+ datas.add(new Data(null, "UID", UUID.randomUUID().toString(), null));
return datas;
}
return datas;
}