X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2FCard.java;h=0a405bee47d744e6545b3360579343fdc5466806;hb=59597d59aa262e31c2e1b7f66b4cb299f88ebd1b;hp=d2567a496237c159546fa40f46015cebc241223b;hpb=e4444b0bc462544629d9e7e7ab62b96a4d9cab10;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/Card.java b/src/be/nikiroo/jvcard/Card.java index d2567a4..0a405be 100644 --- a/src/be/nikiroo/jvcard/Card.java +++ b/src/be/nikiroo/jvcard/Card.java @@ -22,7 +22,6 @@ public class Card extends BaseClass { private String name; private Format format; private long lastModified; - private boolean remote; /** * Create a new {@link Card} from the given {@link File} and {@link Format}. @@ -73,7 +72,7 @@ public class Card extends BaseClass { * @throws InvalidParameterException * if format is NULL */ - public Card(List contacts) throws IOException { + public Card(List contacts) { super(contacts); lastModified = -1; @@ -98,7 +97,7 @@ public class Card extends BaseClass { return false; BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - writer.append(toString(format)); + Parser.write(writer, format, this); writer.close(); if (this.file != null @@ -141,24 +140,6 @@ public class Card extends BaseClass { return true; } - /** - * 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) { - StringBuilder builder = new StringBuilder(); - for (String line : Parser.toStrings(this, format)) { - builder.append(line); - builder.append("\r\n"); - } - return builder.toString(); - } - /** * Return the name of this card (the name of the {@link File} which it was * opened from). @@ -187,6 +168,15 @@ public class Card extends BaseClass { return file; } + /** + * Break the link between this {@link Card} and he {@link File} which was + * used to open it if any. + */ + public void unlink() { + file = null; + lastModified = -1; + } + /** * Return the date of the last modification for this {@link Card} (or -1 if * unknown/new). @@ -197,28 +187,9 @@ public class Card extends BaseClass { return lastModified; } - /** - * Check if this {@link Card} is remote. - * - * @return TRUE if this {@link Card} is remote - */ - public boolean isRemote() { - return remote; - } - - /** - * Set the remote option on this {@link Card}. - * - * @param remote - * TRUE if this {@link Card} is remote - */ - public void setRemote(boolean remote) { - this.remote = remote; - } - @Override public String toString() { - return toString(Format.VCard21); + return "[Card: " + name + "]"; } @Override