Commit | Line | Data |
---|---|---|
08fe2e33 NR |
1 | package be.nikiroo.fanfix.data; |
2 | ||
3 | import java.net.URL; | |
4 | ||
5 | /** | |
6 | * A paragraph in a chapter of the story. | |
7 | * | |
8 | * @author niki | |
9 | */ | |
10 | public 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 NR |
32 | |
33 | /** | |
34 | * Create a new {@link Paragraph} with the given image. | |
35 | * | |
0efd25e3 NR |
36 | * @param imageUrl |
37 | * the image as an URL | |
08fe2e33 NR |
38 | */ |
39 | public Paragraph(URL imageUrl) { | |
793f1071 NR |
40 | this(ParagraphType.IMAGE, imageUrl.toString(), 0); |
41 | } | |
42 | ||
43 | /** | |
44 | * Create a new {@link Paragraph} with the given values. | |
45 | * | |
46 | * @param type | |
47 | * the {@link ParagraphType} | |
48 | * @param content | |
49 | * the content of this paragraph | |
50 | * @param words | |
51 | * the number of words | |
52 | */ | |
53 | public Paragraph(ParagraphType type, String content, long words) { | |
54 | this.type = type; | |
55 | this.content = content; | |
56 | this.words = words; | |
08fe2e33 NR |
57 | } |
58 | ||
59 | /** | |
60 | * The {@link ParagraphType}. | |
61 | * | |
62 | * @return the type | |
63 | */ | |
64 | public ParagraphType getType() { | |
65 | return type; | |
66 | } | |
67 | ||
68 | /** | |
69 | * The {@link ParagraphType}. | |
70 | * | |
71 | * @param type | |
72 | * the type to set | |
73 | */ | |
74 | public void setType(ParagraphType type) { | |
75 | this.type = type; | |
76 | } | |
77 | ||
78 | /** | |
79 | * The content of this {@link Paragraph}. | |
80 | * | |
81 | * @return the content | |
82 | */ | |
83 | public String getContent() { | |
84 | return content; | |
85 | } | |
86 | ||
87 | /** | |
88 | * The content of this {@link Paragraph}. | |
89 | * | |
90 | * @param content | |
91 | * the content to set | |
92 | */ | |
93 | public void setContent(String content) { | |
94 | this.content = content; | |
95 | } | |
96 | ||
793f1071 NR |
97 | /** |
98 | * The number of words in this {@link Paragraph}. | |
99 | * | |
100 | * @return the number of words | |
101 | */ | |
102 | public long getWords() { | |
103 | return words; | |
104 | } | |
105 | ||
106 | /** | |
107 | * The number of words in this {@link Paragraph}. | |
108 | * | |
109 | * @param words | |
110 | * the number of words to set | |
111 | */ | |
112 | public void setWords(long words) { | |
113 | this.words = words; | |
114 | } | |
115 | ||
08fe2e33 NR |
116 | /** |
117 | * Display a DEBUG {@link String} representation of this object. | |
118 | */ | |
119 | @Override | |
120 | public String toString() { | |
121 | return String.format("%s: [%s]", "" + type, "" + content); | |
122 | } | |
123 | } |