001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap/DelegatingRole.java#6 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2002-2002 Kana Software, Inc. 007 // Copyright (C) 2002-2008 Julian Hyde and others 008 // All Rights Reserved. 009 // You must accept the terms of that agreement to use this software. 010 // 011 // jhyde, Oct 5, 2002 012 */ 013 014 package mondrian.olap; 015 016 /** 017 * <code>DelegatingRole</code> implements {@link Role} by 018 * delegating all methods to an underlying {@link Role}. 019 * 020 * It is a convenient base class if you want to override just a few of 021 * {@link Role}'s methods. 022 * 023 * @author Richard M. Emberson 024 * @since Mar 29 2007 025 * @version $Id: //open/mondrian/src/main/mondrian/olap/DelegatingRole.java#6 $ 026 */ 027 public class DelegatingRole implements Role { 028 protected final Role role; 029 030 public DelegatingRole(Role role) { 031 assert role != null; 032 this.role = role; 033 } 034 035 public Access getAccess(Schema schema) { 036 return role.getAccess(schema); 037 } 038 039 public Access getAccess(Cube cube) { 040 return role.getAccess(cube); 041 } 042 043 public Access getAccess(Dimension dimension) { 044 return role.getAccess(dimension); 045 } 046 047 public Access getAccess(Hierarchy hierarchy) { 048 return role.getAccess(hierarchy); 049 } 050 051 public static class DelegatingHierarchyAccess 052 implements HierarchyAccess 053 { 054 protected final HierarchyAccess hierarchyAccess; 055 056 public DelegatingHierarchyAccess(HierarchyAccess hierarchyAccess) { 057 assert hierarchyAccess != null; 058 this.hierarchyAccess = hierarchyAccess; 059 } 060 061 public Access getAccess(Member member) { 062 return hierarchyAccess.getAccess(member); 063 } 064 065 public int getTopLevelDepth() { 066 return hierarchyAccess.getTopLevelDepth(); 067 } 068 069 public int getBottomLevelDepth() { 070 return hierarchyAccess.getBottomLevelDepth(); 071 } 072 073 public RollupPolicy getRollupPolicy() { 074 return hierarchyAccess.getRollupPolicy(); 075 } 076 077 public boolean hasInaccessibleDescendants(Member member) { 078 return hierarchyAccess.hasInaccessibleDescendants(member); 079 } 080 } 081 082 public HierarchyAccess getAccessDetails(Hierarchy hierarchy) { 083 return new DelegatingHierarchyAccess(role.getAccessDetails(hierarchy)); 084 } 085 086 public Access getAccess(Level level) { 087 return role.getAccess(level); 088 } 089 090 public Access getAccess(Member member) { 091 return role.getAccess(member); 092 } 093 094 public Access getAccess(NamedSet set) { 095 return role.getAccess(set); 096 } 097 098 public boolean canAccess(OlapElement olapElement) { 099 return role.canAccess(olapElement); 100 } 101 } 102 103 // End DelegatingRole.java