1 13 package com.tonbeller.jpivot.table.span; 14 15 import org.apache.log4j.Logger; 16 17 import com.tonbeller.jpivot.olap.model.Axis; 18 import com.tonbeller.jpivot.olap.model.Displayable; 19 import com.tonbeller.jpivot.olap.model.Member; 20 import com.tonbeller.jpivot.olap.model.Position; 21 22 23 26 27 public class Span implements Cloneable { 28 int positionSpan = 1; 29 int hierarchySpan = 1; 30 int positionIndex; 31 int hierarchyIndex; 32 boolean significant = true; 33 int indent; 34 private static final Logger logger = Logger.getLogger(Span.class); 35 36 Axis axis; 37 Position position; 38 Displayable object; 39 40 public Span(Axis axis, Position position, Displayable object) { 41 this.axis = axis; 42 this.position = position; 43 this.object = object; 44 } 45 46 public Span(Displayable object) { 47 this.object = object; 48 } 49 50 public String toString() { 51 StringBuffer sb = new StringBuffer ("Span["); 52 if (object == null) 53 sb.append("null "); 54 else 55 sb.append(object.getLabel()); 56 sb.append(" positionSpan=").append(positionSpan); 57 sb.append(" hierarchySpan=").append(hierarchySpan); 58 sb.append(" positionIndex=").append(positionIndex); 59 sb.append(" hierarchyIndex=").append(hierarchyIndex); 60 sb.append(" significant=").append(significant); 61 sb.append(" indent=").append(indent); 62 sb.append("]"); 63 return sb.toString(); 64 } 65 66 67 70 void initialize(int posIndex, int hierIndex) { 71 this.positionIndex = posIndex; 72 this.hierarchyIndex = hierIndex; 73 this.positionSpan = 1; 74 this.hierarchySpan = 1; 75 this.significant = true; 76 } 77 78 82 public int getHierarchySpan() { 83 return hierarchySpan; 84 } 85 86 91 public Displayable getObject() { 92 return object; 93 } 94 95 99 public void setObject(Displayable object) { 100 this.object = object; 101 } 102 103 107 public int getPositionSpan() { 108 return positionSpan; 109 } 110 111 115 public Axis getAxis() { 116 return axis; 117 } 118 119 123 public Position getPosition() { 124 return position; 125 } 126 127 130 public Member getMember() { 131 return (Member)object; 132 } 133 134 138 public int getHierarchyIndex() { 139 return hierarchyIndex; 140 } 141 142 146 public int getPositionIndex() { 147 return positionIndex; 148 } 149 150 153 public boolean isMember() { 154 return object instanceof Member; 155 } 156 157 160 public Object clone() { 161 try { 162 return super.clone(); 163 } catch (CloneNotSupportedException e) { 164 logger.error("exception caught", e); 165 throw new RuntimeException (e.toString()); 166 } 167 } 168 169 173 public boolean isSignificant() { 174 return significant; 175 } 176 177 181 public void setAxis(Axis axis) { 182 this.axis = axis; 183 } 184 185 186 190 public void setPosition(Position position) { 191 this.position = position; 192 } 193 194 197 public int getIndent() { 198 return indent; 199 } 200 201 204 public void setIndent(int i) { 205 indent = i; 206 } 207 208 } 209 210 | Popular Tags |