1 13 package com.tonbeller.jpivot.olap.model.impl; 14 15 import java.util.ArrayList ; 16 import java.util.Collections ; 17 import java.util.List ; 18 19 import javax.servlet.ServletContext ; 20 21 import com.tonbeller.jpivot.core.ModelSupport; 22 import com.tonbeller.jpivot.olap.model.Axis; 23 import com.tonbeller.jpivot.olap.model.Dimension; 24 import com.tonbeller.jpivot.olap.model.Hierarchy; 25 import com.tonbeller.jpivot.olap.model.Member; 26 import com.tonbeller.jpivot.olap.model.OlapException; 27 import com.tonbeller.jpivot.olap.model.OlapModel; 28 import com.tonbeller.jpivot.olap.model.Result; 29 import com.tonbeller.jpivot.olap.model.Visitor; 30 31 37 public class Empty { 38 public static final OlapModel EMPTY_MODEL = new EmptyModel(); 39 public static final Result EMPTY_RESULT = new EmptyResult(false); 40 public static final Result OVERFLOW_RESULT = new EmptyResult(true); 41 public static final Axis EMPTY_AXIS = new EmptyAxis(); 42 43 private Empty() { 44 } 45 46 public static class EmptyModel extends ModelSupport implements OlapModel { 47 private String ID = null; 48 49 public String getID() { 50 return ID; 51 } 52 53 public void setID(String ID) { 54 this.ID = ID; 55 } 56 57 public Result getResult() throws OlapException { 58 return EMPTY_RESULT; 59 } 60 61 public Dimension[] getDimensions() { 62 return new Dimension[0]; 63 } 64 65 public Member[] getMeasures() { 66 return new Member[0]; 67 } 68 69 public void initialize() { 70 } 71 72 public void destroy() { 73 } 74 75 public void setServletContext(ServletContext servletContext) { 76 } 77 78 } 79 80 static class EmptyResult implements Result { 81 static List cells; 82 boolean overflow; 83 public EmptyResult(boolean overflow) { 84 this.overflow = overflow; 85 cells = new ArrayList (); 86 } 88 89 public List getCells() { 90 return cells; 91 } 92 93 public Axis[] getAxes() { 94 return new Axis[0]; 95 } 96 97 public Axis getSlicer() { 98 return EMPTY_AXIS; 99 } 100 101 public void accept(Visitor visitor) { 102 visitor.visitResult(this); 103 } 104 105 public Object getRootDecoree() { 106 return this; 107 } 108 109 public boolean isOverflowOccured() { 110 return overflow; 111 } 112 } 113 114 static class EmptyAxis implements Axis { 115 public List getPositions() { 116 return Collections.EMPTY_LIST; 117 } 118 119 public Hierarchy[] getHierarchies() { 120 return new Hierarchy[0]; 121 } 122 123 public void accept(Visitor visitor) { 124 visitor.visitAxis(this); 125 } 126 127 public Object getRootDecoree() { 128 return this; 129 } 130 } 131 } | Popular Tags |