| 1 | package be.nikiroo.gofetch.output; |
| 2 | |
| 3 | import be.nikiroo.gofetch.data.Story; |
| 4 | import be.nikiroo.gofetch.support.BasicSupport.Type; |
| 5 | |
| 6 | /** |
| 7 | * Base class for output operations. |
| 8 | * |
| 9 | * @author niki |
| 10 | */ |
| 11 | public abstract class Output { |
| 12 | /** |
| 13 | * The type of source, can be NULL for no-type. |
| 14 | */ |
| 15 | protected Type type; |
| 16 | |
| 17 | /** |
| 18 | * The gopher hostname to use. |
| 19 | */ |
| 20 | protected String hostname; |
| 21 | |
| 22 | /** |
| 23 | * The sub directory and (pre-)selector to use for the resources. |
| 24 | */ |
| 25 | protected String preselector; |
| 26 | |
| 27 | /** |
| 28 | * The Gopher port to use. |
| 29 | */ |
| 30 | protected int port; |
| 31 | |
| 32 | /** |
| 33 | * Create a new {@link Output} class for the given type (which can be NULL). |
| 34 | * |
| 35 | * @param type |
| 36 | * the type or NULL for no type |
| 37 | * @param hostname |
| 38 | * the gopher hostname to use |
| 39 | * @param preselector |
| 40 | * the sub directory and (pre-)selector to use for the resources |
| 41 | * @param port |
| 42 | * the Gopher port to use |
| 43 | */ |
| 44 | public Output(Type type, String hostname, String preselector, int port) { |
| 45 | this.type = type; |
| 46 | this.hostname = hostname; |
| 47 | this.preselector = preselector; |
| 48 | this.port = port; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get the header to use in the index file. |
| 53 | * |
| 54 | * @return the header |
| 55 | */ |
| 56 | abstract public String getIndexHeader(); |
| 57 | |
| 58 | /** |
| 59 | * Get the footer to use in the index file. |
| 60 | * |
| 61 | * @return the footer |
| 62 | */ |
| 63 | abstract public String getIndexFooter(); |
| 64 | |
| 65 | /** |
| 66 | * Export the header of a story (a <i>resume</i> mode). |
| 67 | * |
| 68 | * @param story |
| 69 | * the story |
| 70 | * |
| 71 | * @return the resume |
| 72 | */ |
| 73 | abstract public String exportHeader(Story story); |
| 74 | |
| 75 | /** |
| 76 | * Export a full story with comments. |
| 77 | * |
| 78 | * @param story |
| 79 | * the story |
| 80 | * |
| 81 | * @return the story |
| 82 | */ |
| 83 | abstract public String export(Story story); |
| 84 | } |