Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CloudNote.java « model « shared « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cf6c51e8a6b8dadc5c59f9140bfb4309f72d7f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package it.niedermann.owncloud.notes.shared.model;

import androidx.annotation.NonNull;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

import it.niedermann.owncloud.notes.shared.util.NoteUtil;

/**
 * CloudNote represents a remote note from an OwnCloud server.
 * It can be directly generated from the JSON answer from the server.
 */
public class CloudNote implements Serializable {
    private long remoteId;
    private String title = "";
    private Calendar modified;
    private String content = "";
    private boolean favorite = false;
    private String category = "";
    private String etag = "";
    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public CloudNote(long remoteId, Calendar modified, String title, String content, boolean favorite, String category, String etag) {
        this.remoteId = remoteId;
        setTitle(title);
        setContent(content);
        setFavorite(favorite);
        setCategory(category);
        setEtag(etag);
        this.modified = modified;
    }

    public long getRemoteId() {
        return remoteId;
    }

    public void setRemoteId(long remoteId) {
        this.remoteId = remoteId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = NoteUtil.removeMarkDown(title);
    }

    public Calendar getModified() {
        return modified;
    }

    public String getModified(String format) {
        if (modified == null)
            return null;
        return new SimpleDateFormat(format, Locale.GERMANY).format(this.getModified().getTimeInMillis());
    }

    public void setModified(Calendar modified) {
        this.modified = modified;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public boolean isFavorite() {
        return favorite;
    }

    public void setFavorite(boolean favorite) {
        this.favorite = favorite;
    }

    public String getEtag() {
        return etag;
    }

    public void setEtag(String etag) {
        this.etag = etag;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category == null ? "" : category;
    }

    @NonNull
    @Override
    public String toString() {
        return "R" + getRemoteId() + " " + (isFavorite() ? " (*) " : "     ") + getCategory() + " / " + getTitle() + " (" + getModified(DATE_FORMAT) + " / " + getEtag() + ")";
    }
}