1 28 package net.sf.jasperreports.olap.mapping; 29 30 import net.sf.jasperreports.olap.result.JROlapMember; 31 32 36 public class Member 37 { 38 private final TuplePosition pos; 39 private final MemberDepth depth; 40 41 public Member(TuplePosition pos, MemberDepth depth) 42 { 43 this.pos = pos; 44 this.depth = depth; 45 } 46 47 public Axis getAxis() 48 { 49 return pos.getAxis(); 50 } 51 52 public MemberDepth getDepth() 53 { 54 return depth; 55 } 56 57 public TuplePosition getPosition() 58 { 59 return pos; 60 } 61 62 public boolean matches(JROlapMember member) 63 { 64 boolean match; 65 int memberDepth = member.getDepth(); 66 67 if (depth == null) 68 { 69 match = true; 70 } 71 else 72 { 73 match = memberDepth == depth.getDepth(); 74 } 75 return match; 76 } 77 78 public JROlapMember ancestorMatch(JROlapMember member) 79 { 80 JROlapMember ancestor; 81 int memberDepth = member.getDepth(); 82 83 if (depth == null) 84 { 85 ancestor = member; 86 } 87 else if (depth.getDepth() <= memberDepth) 88 { 89 ancestor = member; 90 for (int i = depth.getDepth(); i < memberDepth; ++i) 91 { 92 ancestor = ancestor.getParentMember(); 93 } 94 } 95 else 96 { 97 ancestor = null; 98 } 99 100 return ancestor; 101 } 102 } 103 | Popular Tags |