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

Quick Search    Search Deep

jbreport.core
Class RepositoryImpl  view RepositoryImpl download RepositoryImpl.java

java.lang.Object
  extended byjbreport.core.AbstractReportElement
      extended byjbreport.core.ReportCompositeImpl
          extended byjbreport.core.RepositoryImpl
All Implemented Interfaces:
java.lang.Cloneable, jbreport.ReportComposite, jbreport.ReportElement, jbreport.Repository, Traversable, XMLAware

public class RepositoryImpl
extends ReportCompositeImpl
implements jbreport.Repository

This represents a storage area for a bunch of other element types, including but not limited to, datasources, queries, documents, etc.

As many repositories are allowed, this class provides methods to search for repositories. It should be noted that a repository forms its' own namespace, and that elements such as queries can be obtained by referring to a given namespace. ie. should a Query x be required from Repository y, we can either get Repository y, and then call getQuery("x") on it, or if we already have a Repository z, then the call getQuery("y.x") will return the same Query element.

Version:
$Revision: 1.1 $

Field Summary
private static java.lang.String DATASOURCES
          Used as a key into the namedTypes map for the named datasources
private static java.lang.String DOCUMENTS
          Used as a key into the namedTypes map for the named documents
private static java.lang.String FRAGMENTS
          Used as a key into the namedTypes map for the named fragments
private  java.util.Map namedTypes
          This provides a map which contains other maps.
private static java.lang.String QUERIES
          Used as a key into the namedTypes map for the named queries
private static java.util.Map repositories
          The repositories that have been defined
private static java.lang.String STYLESHEETS
          Used as a key into the namedTypes map for the named stylesheets
 
Fields inherited from class jbreport.core.ReportCompositeImpl
 
Fields inherited from class jbreport.core.AbstractReportElement
attrType, cdata, className, elementType, factory, name, xmlHandler
 
Fields inherited from interface jbreport.ReportElement
DEEP, SHALLOW
 
Constructor Summary
RepositoryImpl()
           
 
Method Summary
 void accept(ReportVisitor visitor, ReportVisitorState state)
          This defines the operation that the Traversable instance must perform at each node in the traversal.
 java.util.Iterator documentNames()
          Returns an iterator over the available document names within this repository, although the caller should check the iterator.hasNext () method is not false on return.
static boolean exists(java.lang.String name)
           
 jbreport.data.Datasource fetchDatasource(java.lang.String name)
           
 jbreport.ReportSection fetchDocument(java.lang.String name)
          Returns the document for the given name, if one exists.
 jbreport.ReportElement fetchFragment(java.lang.String name)
          Returns the fragment for the given name, if one exists.
private  jbreport.ReportElement fetchNamedElement(java.lang.String name, java.lang.String map, java.lang.Class cls)
           
 jbreport.data.Query fetchQuery(java.lang.String name)
           
static jbreport.Repository fetchRepository(java.lang.String name)
           
 jbreport.ReportStylesheet fetchStylesheet(java.lang.String name)
          Returns the stylesheet for the given name, if one exists.
private  void insertNamedElement(jbreport.ReportElement elem, java.lang.String map)
           
 void xmlEndChild(jbreport.ReportElement elem)
          This method is called for every child element that is defined during xml tree traversal.
 void xmlInitialize(java.lang.String localName, org.xml.sax.Attributes attributes)
          This should initialize the instance with data obtained during the traversal of an xml tree.
 
Methods inherited from class jbreport.core.ReportCompositeImpl
addElement, clearElements, copy, getList, loadData, updateData
 
Methods inherited from class jbreport.core.AbstractReportElement
assert, assertNotNull, boundParameters, breakEventNotify, clone, copy, getBoundParamValue, getElement, getFactory, getName, getParent, getRepository, getString, getStylesheet, getType, inOrderIterator, inOrderTraverse, postOrderIterator, postOrderTraverse, preLoadData, preOrderIterator, preOrderTraverse, setParent, setString, xmlEnd
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jbreport.ReportComposite
addElement
 
Methods inherited from interface jbreport.ReportElement
boundParameters, copy, copy, getBoundParamValue, getElement, getFactory, getList, getName, getParent, getRepository, getString, getStylesheet, getType, loadData, setParent, setString, xmlEnd
 

Field Detail

QUERIES

private static final java.lang.String QUERIES
Used as a key into the namedTypes map for the named queries

See Also:
Constant Field Values

DATASOURCES

private static final java.lang.String DATASOURCES
Used as a key into the namedTypes map for the named datasources

See Also:
Constant Field Values

DOCUMENTS

private static final java.lang.String DOCUMENTS
Used as a key into the namedTypes map for the named documents

See Also:
Constant Field Values

FRAGMENTS

private static final java.lang.String FRAGMENTS
Used as a key into the namedTypes map for the named fragments

See Also:
Constant Field Values

STYLESHEETS

private static final java.lang.String STYLESHEETS
Used as a key into the namedTypes map for the named stylesheets

See Also:
Constant Field Values

repositories

private static java.util.Map repositories
The repositories that have been defined


namedTypes

private java.util.Map namedTypes
This provides a map which contains other maps. This map is keyed by contained map type, while the contained maps are keyed by name. ie. (map type, (name, [query|datasource|document])).

Constructor Detail

RepositoryImpl

public RepositoryImpl()
Method Detail

fetchRepository

public static jbreport.Repository fetchRepository(java.lang.String name)
                                           throws jbreport.ReportException

exists

public static boolean exists(java.lang.String name)

fetchQuery

public jbreport.data.Query fetchQuery(java.lang.String name)
                               throws jbreport.ReportException

fetchDatasource

public jbreport.data.Datasource fetchDatasource(java.lang.String name)
                                         throws jbreport.ReportException

fetchDocument

public jbreport.ReportSection fetchDocument(java.lang.String name)
                                     throws jbreport.ReportException
Description copied from interface: jbreport.Repository
Returns the document for the given name, if one exists. The name can be in a different namespace, in which case the appropriate lookup will be performed by the framework.

Specified by:
fetchDocument in interface jbreport.Repository

documentNames

public java.util.Iterator documentNames()
Description copied from interface: jbreport.Repository
Returns an iterator over the available document names within this repository, although the caller should check the iterator.hasNext () method is not false on return. This would indicate that there are no defined documents in this repository.

The iterator returned does not support the remove() method.

Specified by:
documentNames in interface jbreport.Repository

fetchFragment

public jbreport.ReportElement fetchFragment(java.lang.String name)
                                     throws jbreport.ReportException
Description copied from interface: jbreport.Repository
Returns the fragment for the given name, if one exists. The name can be in a different namespace, in which case the appropriate lookup will be performed by the framework.

Specified by:
fetchFragment in interface jbreport.Repository

fetchStylesheet

public jbreport.ReportStylesheet fetchStylesheet(java.lang.String name)
                                          throws jbreport.ReportException
Description copied from interface: jbreport.Repository
Returns the stylesheet for the given name, if one exists. The name can be in a different namespace, in which case the appropriate lookup will be performed by the framework.

Specified by:
fetchStylesheet in interface jbreport.Repository

xmlInitialize

public void xmlInitialize(java.lang.String localName,
                          org.xml.sax.Attributes attributes)
                   throws jbreport.ReportException
Description copied from interface: jbreport.ReportElement
This should initialize the instance with data obtained during the traversal of an xml tree. The child-parent relationship is catered for with the xmlEndChild() method.

Specified by:
xmlInitialize in interface jbreport.ReportElement
Overrides:
xmlInitialize in class AbstractReportElement

xmlEndChild

public void xmlEndChild(jbreport.ReportElement elem)
                 throws jbreport.ReportException
Description copied from interface: jbreport.ReportElement
This method is called for every child element that is defined during xml tree traversal. In order to preserve the tree, it will only be called at the end of the child definition.

Specified by:
xmlEndChild in interface jbreport.ReportElement
Overrides:
xmlEndChild in class ReportCompositeImpl

accept

public void accept(ReportVisitor visitor,
                   ReportVisitorState state)
            throws jbreport.ReportException
Description copied from interface: Traversable
This defines the operation that the Traversable instance must perform at each node in the traversal. It should be coded such that it calls an appropriate method on the ReportVisitor instance. Should an appropriate method not exist, one should be coded.

The accept method should not recurse into its children, it is the contract of the iterator to perform that function.

eg:- For node type Section the method on this node should be as follows.

   public void accept(ReportVisitor visitor, ReportVisitorState state) 
      throws ReportException {
      visitor.visitSection(this, state);
   }

Specified by:
accept in interface Traversable
Overrides:
accept in class ReportCompositeImpl

fetchNamedElement

private jbreport.ReportElement fetchNamedElement(java.lang.String name,
                                                 java.lang.String map,
                                                 java.lang.Class cls)
                                          throws jbreport.ReportException

insertNamedElement

private void insertNamedElement(jbreport.ReportElement elem,
                                java.lang.String map)