Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractTabularComponent |
|
| 1.0;1 | ||||
AbstractTabularComponent$Alignment |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright (c) 2012, University of Konstanz, Distributed Systems Group | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions are met: | |
7 | * * Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * * Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * * Neither the name of the University of Konstanz nor the | |
13 | * names of its contributors may be used to endorse or promote products | |
14 | * derived from this software without specific prior written permission. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 | * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | |
27 | package org.perfidix.ouput.asciitable; | |
28 | ||
29 | /** | |
30 | * This abstract class represents all drawable items in this {@link NiceTable}. | |
31 | * | |
32 | * @author Alexander Onea, neue Couch | |
33 | */ | |
34 | public abstract class AbstractTabularComponent { | |
35 | ||
36 | /** Alignment in the cells. */ | |
37 | 25 | public enum Alignment { |
38 | /** Left alignement. */ | |
39 | 5 | Left, |
40 | /** Right alignement. */ | |
41 | 5 | Right, |
42 | /** Center alignement. */ | |
43 | 5 | Center |
44 | }; | |
45 | ||
46 | /** | |
47 | * Constant for the newline-symbol. | |
48 | */ | |
49 | protected static final String NEWLINE = "\n"; | |
50 | ||
51 | /** | |
52 | * Border symbol, can be changed in the runtime. | |
53 | */ | |
54 | protected static final char BORDER = '|'; | |
55 | ||
56 | /** | |
57 | * Constant for the space between data and border. | |
58 | */ | |
59 | protected static final String SPACE = " "; | |
60 | ||
61 | /** Instance to draw to. */ | |
62 | private transient final NiceTable table; | |
63 | ||
64 | /** | |
65 | * Constructor. | |
66 | * | |
67 | * @param paramTable | |
68 | * to be drawn | |
69 | */ | |
70 | 500 | protected AbstractTabularComponent(final NiceTable paramTable) { |
71 | 500 | table = paramTable; |
72 | 500 | } |
73 | ||
74 | /** | |
75 | * Drawing this item. | |
76 | * | |
77 | * @return a string representation to draw this line. | |
78 | */ | |
79 | protected abstract String draw(); | |
80 | ||
81 | /** | |
82 | * Getter for member table. | |
83 | * | |
84 | * @return the table | |
85 | */ | |
86 | protected final NiceTable getTable() { | |
87 | 43695 | return table; |
88 | } | |
89 | ||
90 | } |