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 | * | |
36 | * @param support | |
37 | * the support that will be used to fetch the image via | |
38 | * {@link Paragraph#getContentImage()}. | |
39 | * @param content | |
40 | * the content image of this paragraph | |
41 | */ | |
42 | public Paragraph(URL imageUrl) { | |
793f1071 NR |
43 | this(ParagraphType.IMAGE, imageUrl.toString(), 0); |
44 | } | |
45 | ||
46 | /** | |
47 | * Create a new {@link Paragraph} with the given values. | |
48 | * | |
49 | * @param type | |
50 | * the {@link ParagraphType} | |
51 | * @param content | |
52 | * the content of this paragraph | |
53 | * @param words | |
54 | * the number of words | |
55 | */ | |
56 | public Paragraph(ParagraphType type, String content, long words) { | |
57 | this.type = type; | |
58 | this.content = content; | |
59 | this.words = words; | |
08fe2e33 NR |
60 | } |
61 | ||
62 | /** | |
63 | * The {@link ParagraphType}. | |
64 | * | |
65 | * @return the type | |
66 | */ | |
67 | public ParagraphType getType() { | |
68 | return type; | |
69 | } | |
70 | ||
71 | /** | |
72 | * The {@link ParagraphType}. | |
73 | * | |
74 | * @param type | |
75 | * the type to set | |
76 | */ | |
77 | public void setType(ParagraphType type) { | |
78 | this.type = type; | |
79 | } | |
80 | ||
81 | /** | |
82 | * The content of this {@link Paragraph}. | |
83 | * | |
84 | * @return the content | |
85 | */ | |
86 | public String getContent() { | |
87 | return content; | |
88 | } | |
89 | ||
90 | /** | |
91 | * The content of this {@link Paragraph}. | |
92 | * | |
93 | * @param content | |
94 | * the content to set | |
95 | */ | |
96 | public void setContent(String content) { | |
97 | this.content = content; | |
98 | } | |
99 | ||
793f1071 NR |
100 | /** |
101 | * The number of words in this {@link Paragraph}. | |
102 | * | |
103 | * @return the number of words | |
104 | */ | |
105 | public long getWords() { | |
106 | return words; | |
107 | } | |
108 | ||
109 | /** | |
110 | * The number of words in this {@link Paragraph}. | |
111 | * | |
112 | * @param words | |
113 | * the number of words to set | |
114 | */ | |
115 | public void setWords(long words) { | |
116 | this.words = words; | |
117 | } | |
118 | ||
08fe2e33 NR |
119 | /** |
120 | * Display a DEBUG {@link String} representation of this object. | |
121 | */ | |
122 | @Override | |
123 | public String toString() { | |
124 | return String.format("%s: [%s]", "" + type, "" + content); | |
125 | } | |
126 | } |