Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jdaemon/era/SimpleCubeDescriptor.java


1   /*
2    * SimpleCubeDescriptor.java
3    *
4    *  Copyright (C) 2002 Jan Stanger
5    *  This program is distributed under the terms of the Lesser GNU General Public
6    *  License (v2 or later) per the included COPYING.txt file, or see www.fsf.org.
7    *
8    * Created on July 25, 2002
9    */
10  
11  package org.jdaemon.era;
12  
13  import org.jdaemon.era.*;
14  import org.jdaemon.util.Accessor;
15  import org.jdaemon.util.AttributeList;
16  
17  import java.util.*;
18  
19  /**
20   * Simple Cube Descriptor class to be used for Cubes other than xml, java or sql
21   * Cubes, e.g. for existing Business Object classes that extend the Cube interface.
22   * <i>(Adapted from JavaCubeDescriptor)</i>
23   *
24   * @author Jan Stanger
25   */
26  public class SimpleCubeDescriptor implements CubeDescriptor {
27      
28      /** Object which actually does the work of retrieving named attributes from an object */
29      private Accessor attributeAccessor;
30      
31      private Map attributeMap = new HashMap();
32      
33      /** 
34       * Allow subclasses read-only access to the accessor 
35       */
36      protected Accessor getAccessor() {
37          return attributeAccessor;
38      }
39      
40      /** 
41       * Creates a new instance of SimpleCubeDescriptor
42       */
43      public SimpleCubeDescriptor(Accessor attributeAccessor) {
44          this.attributeAccessor = attributeAccessor;
45      }
46      
47      /**
48       * Get attribute value for named attribute
49       *
50       * @param attributeName Name of attribute
51       * @param datum Object that we want to retrieve the attribute value from
52       */
53      public Object getAttribute(String attributeName, Object datum) {
54          return attributeAccessor.getAttribute(attributeName, datum);
55      }
56      
57      /** 
58       * Get the names of all attributes of this descriptor  
59       */
60      public Iterator getAttributeNames() {
61          return attributeAccessor.getAttributeNames();
62      }
63  
64      /**
65       * Not supported by SimpleCube
66       */
67      public Cube makeCube() {
68          if (true) throw new UnsupportedCubeOperationException(this, "makeCube()");
69          return null; //dummy return to satisfy compiler
70      }
71      
72      /** Get metadata attributes for a given cube attribute  */
73      public AttributeList getMetadata(String attributeName) {
74          return AttributeList.EMPTY;
75      }
76      
77      /**
78       * E.g. attributeName = 'Currency' and values = ('total-dependency', {'Market Value Local', 'Fee Local')}
79       */
80      public void setMetadata(String attributeName, AttributeList values) {
81          attributeMap.put(attributeName, values);
82      }   
83  
84      /**
85       * This method is a stopgap measure to allow the FilteredXMLCube to obtain the entire
86       * meta data map at once and hand it off to the GenericTotal component. Needs
87       * refactoring (specifically in GenericTotal).
88       */
89      public Map getAllMetadata() {
90          return attributeMap;
91      }
92      
93  }