Update nikiroo-utils, remove Instance.syserr/trace
[nikiroo-utils.git] / src / be / nikiroo / fanfix / data / Paragraph.java
CommitLineData
08fe2e33
NR
1package be.nikiroo.fanfix.data;
2
3import java.net.URL;
4
5/**
6 * A paragraph in a chapter of the story.
7 *
8 * @author niki
9 */
10public class Paragraph {
11 /**
12 * A paragraph type, that will dictate how the paragraph will be handled.
13 *
14 * @author niki
15 */
16 public enum ParagraphType {
17 /** Normal paragraph (text) */
18 NORMAL,
19 /** Blank line */
20 BLANK,
21 /** A Break paragraph, i.e.: HR (Horizontal Line) or '* * *' or whatever */
22 BREAK,
23 /** Quotation (dialogue) */
24 QUOTE,
25 /** An image (no text) */
26 IMAGE,
27 }
28
29 private ParagraphType type;
30 private String content;
793f1071 31 private long words;
08fe2e33 32
b0e88ebd
NR
33 /**
34 * Empty constructor, not to use.
35 */
211f7ddb 36 @SuppressWarnings("unused")
b0e88ebd
NR
37 private Paragraph() {
38 // for serialisation purposes
39 }
40
08fe2e33
NR
41 /**
42 * Create a new {@link Paragraph} with the given image.
43 *
0efd25e3
NR
44 * @param imageUrl
45 * the image as an URL
08fe2e33
NR
46 */
47 public Paragraph(URL imageUrl) {
c8faa52a 48 this(ParagraphType.IMAGE, imageUrl.toString(), 1);
793f1071
NR
49 }
50
51 /**
52 * Create a new {@link Paragraph} with the given values.
53 *
54 * @param type
55 * the {@link ParagraphType}
56 * @param content
57 * the content of this paragraph
58 * @param words
c8faa52a 59 * the number of words (or images)
793f1071
NR
60 */
61 public Paragraph(ParagraphType type, String content, long words) {
62 this.type = type;
63 this.content = content;
64 this.words = words;
08fe2e33
NR
65 }
66
67 /**
68 * The {@link ParagraphType}.
69 *
70 * @return the type
71 */
72 public ParagraphType getType() {
73 return type;
74 }
75
76 /**
77 * The {@link ParagraphType}.
78 *
79 * @param type
80 * the type to set
81 */
82 public void setType(ParagraphType type) {
83 this.type = type;
84 }
85
86 /**
87 * The content of this {@link Paragraph}.
88 *
89 * @return the content
90 */
91 public String getContent() {
92 return content;
93 }
94
95 /**
96 * The content of this {@link Paragraph}.
97 *
98 * @param content
99 * the content to set
100 */
101 public void setContent(String content) {
102 this.content = content;
103 }
104
793f1071 105 /**
c8faa52a 106 * The number of words (or images) in this {@link Paragraph}.
793f1071
NR
107 *
108 * @return the number of words
109 */
110 public long getWords() {
111 return words;
112 }
113
114 /**
c8faa52a 115 * The number of words (or images) in this {@link Paragraph}.
793f1071
NR
116 *
117 * @param words
118 * the number of words to set
119 */
120 public void setWords(long words) {
121 this.words = words;
122 }
123
08fe2e33
NR
124 /**
125 * Display a DEBUG {@link String} representation of this object.
126 */
127 @Override
128 public String toString() {
129 return String.format("%s: [%s]", "" + type, "" + content);
130 }
131}