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
) {
64 this.changed
= changed
;
68 * Create a new {@link CardResult}.
71 * the synchronisation exception that occurred
73 public CardResult(IOException exception
) {
74 this(null, true, false, false);
75 this.exception
= exception
;
79 * Check if this {@link Card} is linked to a remote jVCard server.
81 * @return TRUE if it is
83 public boolean isRemote() {
88 * Check if the {@link Card} was synchronised.
90 * @return TRUE if it was
92 public boolean isSynchronised() {
97 * Check if this {@link Card} changed after the synchronisation.
99 * @return TRUE if it has
101 public boolean isChanged() {
102 return remote
&& changed
;
106 * Return the {@link Card}
108 * @return the {@link Card}
110 * @throws IOException
111 * in case of synchronisation issues
113 public Card
getCard() throws IOException
{
114 if (exception
!= null)