68a5ae747512bd986b0970f1675fb2e98b95638a
1 package be
.nikiroo
.jvcard
.launcher
;
3 import java
.io
.IOException
;
5 import be
.nikiroo
.jvcard
.Card
;
8 * This class is a placeholder for a {@link Card} result and some information
14 public class CardResult
{
16 * This interface represents the merge callback when the {@link Card}
17 * synchronisation is not able to process fully automatically.
22 public interface MergeCallback
{
24 * This method will be called when the local cache and the server both
25 * have changes. You need to review the proposed changes, or do your own
26 * merge, and return the final result. You can also cancel the merge
27 * operation by returning NULL.
30 * the previous version of the {@link Card}
32 * the local cache version of the {@link Card}
34 * the remote server version of the {@link Card}
36 * the automatic merge result you should manually check
38 * @return the final merged result, or NULL for cancel
40 public Card
merge(Card previous
, Card local
, Card server
,
45 private boolean remote
;
46 private boolean synced
;
47 private boolean changed
;
48 private IOException exception
;
51 * Create a new {@link CardResult}.
54 * the target {@link Card}
56 * TRUE if it is linked to a remote server
58 * TRUE if it was synchronised
60 public CardResult(Card card
, boolean remote
, boolean synced
, boolean changed
) {
63 this.changed
= changed
;
67 * Create a new {@link CardResult}.
70 * the synchronisation exception that occurred
72 public CardResult(IOException exception
) {
73 this(null, true, false, false);
74 this.exception
= exception
;
78 * Check if this {@link Card} is linked to a remote jVCard server.
80 * @return TRUE if it is
82 public boolean isRemote() {
87 * Check if the {@link Card} was synchronised.
89 * @return TRUE if it was
91 public boolean isSynchronised() {
96 * Check if this {@link Card} changed after the synchronisation.
98 * @return TRUE if it has
100 public boolean isChanged() {
101 return remote
&& changed
;
105 * Return the {@link Card}
107 * @return the {@link Card}
109 * @throws IOException
110 * in case of synchronisation issues
112 public Card
getCard() throws IOException
{
113 if (exception
!= null)