| 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; |
| 31 | |
| 32 | /** |
| 33 | * Create a new {@link Paragraph} with the given values. |
| 34 | * |
| 35 | * @param type |
| 36 | * the {@link ParagraphType} |
| 37 | * @param content |
| 38 | * the content of this paragraph |
| 39 | */ |
| 40 | public Paragraph(ParagraphType type, String content) { |
| 41 | this.type = type; |
| 42 | this.content = content; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Create a new {@link Paragraph} with the given image. |
| 47 | * |
| 48 | * @param support |
| 49 | * the support that will be used to fetch the image via |
| 50 | * {@link Paragraph#getContentImage()}. |
| 51 | * @param content |
| 52 | * the content image of this paragraph |
| 53 | */ |
| 54 | public Paragraph(URL imageUrl) { |
| 55 | this.type = ParagraphType.IMAGE; |
| 56 | this.content = imageUrl.toString(); |
| 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 | |
| 97 | /** |
| 98 | * Display a DEBUG {@link String} representation of this object. |
| 99 | */ |
| 100 | @Override |
| 101 | public String toString() { |
| 102 | return String.format("%s: [%s]", "" + type, "" + content); |
| 103 | } |
| 104 | } |