org.mmbase.util.xml
Class BuilderReader

java.lang.Object
  extended byorg.mmbase.util.xml.DocumentReader
      extended byorg.mmbase.util.xml.BuilderReader

public class BuilderReader
extends DocumentReader

Used to parse and retrieve data from a builder configuration file. The parser support builders for builder dtd 1.1.

Since:
MMBase 1.7
Version:
$Id: BuilderReader.java,v 1.72 2006/07/06 16:35:19 pierre Exp $
Author:
Case Roole, Rico Jansen, Pierre van Rooden, Michiel Meeuwissen

Field Summary
static String DTD_BUILDER
          DTD respource filename of the most recent Builder DTD
static String DTD_BUILDER_1_0
          DTD resource filename of the Builder DTD version 1.0
static String DTD_BUILDER_1_1
          DTD resource filename of the Builder DTD version 1.1
static String NAMESPACE_BUILDER
           
static String NAMESPACE_BUILDER_2_0
           
static String PUBLIC_ID_BUILDER
          Public ID of the most recent Builder DTD
static String PUBLIC_ID_BUILDER_1_0
          Public ID of the Builder DTD version 1.0
static String PUBLIC_ID_BUILDER_1_1
          Public ID of the Builder DTD version 1.1
static String XSD_BUILDER_2_0
           
 
Fields inherited from class org.mmbase.util.xml.DocumentReader
document, DTD_ERROR, DTD_ERROR_1_0, FILENOTFOUND, PUBLIC_ID_ERROR, PUBLIC_ID_ERROR_1_0
 
Constructor Summary
BuilderReader(Document doc, MMBase mmb)
           
BuilderReader(InputSource source, MMBase mmb)
           
 
Method Summary
protected  DataType decodeDataType(MMObjectBuilder builder, DataTypeCollector collector, String fieldName, Element field, int type, int listItemType, boolean forceInstance)
          Determine a data type instance based on the given gui element
 boolean equals(Object o)
          
 String getClassName()
          Get the class name to use for instantiating this builder.
 Map getDataTypes(DataTypeCollector collector)
          Get the datatypes defined for this builder.
 Hashtable getDescriptions()
          Get the descriptions of this builder
 String getExtends()
          Get the name of the builder that this builder extends
 List getFields()
          Get the field definitions of this builder.
 List getFields(MMObjectBuilder builder, DataTypeCollector collector)
          Get the field definitions of this builder.
 Set getFunctions()
           
 List getIndices(MMObjectBuilder builder)
          Get the named indices of this builder.
 String getMaintainer()
          Retrieve the name of the maintainer of this builder
 MMObjectBuilder getParentBuilder()
          Get the builder that this builder extends
 Hashtable getPluralNames()
          Get the plural names of this builder
 Hashtable getProperties()
          Get the properties of this builder
 int getSearchAge()
          Retrieves the Search Age.
 Hashtable getSingularNames()
          Get the singular (GUI) names of this builder
 String getStatus()
          Get the status of this builder.
 int getVersion()
          Retrieve the (major) version number of this builder
 boolean isInheritanceResolved()
          Detremines if inheritance is resolved.
static void main(String[] argv)
          For testing only
static void registerPublicIDs()
          Register the Public Ids for DTDs used by BuilderReader This method is called by XMLEntityResolver.
static void registerSystemIDs()
          Register the namespace and XSD used by DataTypeConfigurer This method is called by XMLEntityResolver.
protected  boolean resolveInheritance()
          Resolves inheritance.
 boolean storageEquals(BuilderReader f)
          Whether this builderreader object is equal to another for storage purposes (so, ignoring gui and documentation fields)
 
Methods inherited from class org.mmbase.util.xml.DocumentReader
appendChild, getAttribute, getChildElements, getChildElements, getChildElements, getChildElements, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getElementAttributeValue, getElementAttributeValue, getElementByPath, getElementByPath, getElementName, getElementValue, getElementValue, getNodeTextValue, getRootElement, getSystemId, hasAttribute, setNodeTextValue, setSystemId, toDocument, validate, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_ID_BUILDER_1_0

public static final String PUBLIC_ID_BUILDER_1_0
Public ID of the Builder DTD version 1.0

See Also:
Constant Field Values

PUBLIC_ID_BUILDER_1_1

public static final String PUBLIC_ID_BUILDER_1_1
Public ID of the Builder DTD version 1.1

See Also:
Constant Field Values

DTD_BUILDER_1_0

public static final String DTD_BUILDER_1_0
DTD resource filename of the Builder DTD version 1.0

See Also:
Constant Field Values

DTD_BUILDER_1_1

public static final String DTD_BUILDER_1_1
DTD resource filename of the Builder DTD version 1.1

See Also:
Constant Field Values

PUBLIC_ID_BUILDER

public static final String PUBLIC_ID_BUILDER
Public ID of the most recent Builder DTD

See Also:
Constant Field Values

DTD_BUILDER

public static final String DTD_BUILDER
DTD respource filename of the most recent Builder DTD

See Also:
Constant Field Values

XSD_BUILDER_2_0

public static final String XSD_BUILDER_2_0
See Also:
Constant Field Values

NAMESPACE_BUILDER_2_0

public static final String NAMESPACE_BUILDER_2_0
See Also:
Constant Field Values

NAMESPACE_BUILDER

public static final String NAMESPACE_BUILDER
See Also:
Constant Field Values
Constructor Detail

BuilderReader

public BuilderReader(InputSource source,
                     MMBase mmb)
Since:
MMBase-1.7

BuilderReader

public BuilderReader(Document doc,
                     MMBase mmb)
Since:
MMBase-1.8
Method Detail

registerSystemIDs

public static void registerSystemIDs()
Register the namespace and XSD used by DataTypeConfigurer This method is called by XMLEntityResolver.


registerPublicIDs

public static void registerPublicIDs()
Register the Public Ids for DTDs used by BuilderReader This method is called by XMLEntityResolver.


resolveInheritance

protected boolean resolveInheritance()
Resolves inheritance. If a builder 'extends' another builder, the parser attempts to retrieve a reference to this builder (using getParentBuilder). Note that if inheritance cannot be resolved, the builder cannot be activated. This method returns false if the builder to extend from is inactive. It throws a RuntimeException is the builder to extend from is not allowed as an parent builder.

Returns:
true if inheritance could be resolved, false if the .
Throws:
RuntimeException - when the builder to extend from is not allowed as parent
Since:
MMBase-1.6
See Also:
isInheritanceResolved()

isInheritanceResolved

public boolean isInheritanceResolved()
Detremines if inheritance is resolved. This method returns true if a call to resolveInheritance succeeded. it returns false if resolveInheritance failed (returned false or threw an exception)

Returns:
true if inheritance could be resolved
Since:
MMBase-1.6
See Also:
resolveInheritance()

getStatus

public String getStatus()
Get the status of this builder. Note that if inheritance cannot be resolved, this method always returns "inactive".

Returns:
a String decribing the status ("active" or "inactive")

getSearchAge

public int getSearchAge()
Retrieves the Search Age. The search age may be used by editors or search forms to determine the maximum age in days of an object to be searched (limiting the resultset of a search)

Returns:
the search age in days

getClassName

public String getClassName()
Get the class name to use for instantiating this builder. Note that it is possible to specify a short-hand format in the builder configuration file. If only the classname (withoput package name) is given, the classname is expanded to fall into the org.mmbase.module.builders package.

Returns:
the classname to use.

getDataTypes

public Map getDataTypes(DataTypeCollector collector)
Get the datatypes defined for this builder.

Parameters:
collector - A DataTypeCollector to which the newly found DataTypes will be added.
Returns:
Returns the data-types of the given collector after adding the ones which are configured
Since:
MMBase-1.8

getFields

public List getFields()
Get the field definitions of this builder. If applicable, this includes the fields inherited from a parent builder.

Returns:
a List of all Fields as CoreField
Since:
MMBase-1.8

getFields

public List getFields(MMObjectBuilder builder,
                      DataTypeCollector collector)
Get the field definitions of this builder. If applicable, this includes the fields inherited from a parent builder.

Parameters:
builder - the MMObjectBuilder to which the fields will be added
collector - the datatype collector used to access the datatypes available for the fields to read.
Returns:
a List of all Fields as CoreField
Since:
MMBase-1.8

getIndices

public List getIndices(MMObjectBuilder builder)
Get the named indices of this builder. Note that the 'default' index (set with the 'key' attribute) is also included in this list (with the name Index.MAIN).

Parameters:
builder - the MMObjectBuilder to which the fields will be added
Returns:
a List of all Indices

getFunctions

public Set getFunctions()
Since:
MMBase-1.8

decodeDataType

protected DataType decodeDataType(MMObjectBuilder builder,
                                  DataTypeCollector collector,
                                  String fieldName,
                                  Element field,
                                  int type,
                                  int listItemType,
                                  boolean forceInstance)
Determine a data type instance based on the given gui element

Parameters:
builder - the MMObjectBuilder to which the field belongs
collector - The DataTypeCollector of the bulider.
fieldName - the name of the field (used in log messages)
field - The 'field' element of the builder xml
type - The database type of the field
listItemType - If the database type is a List, there is also a type of its element
forceInstance - If true, it will never return null, but will return (a clone) of the DataType associated with the database type.
Since:
MMBase-1.8
To Do:
'guitype' may become deprecated in favour of the 'datatype' element

getProperties

public Hashtable getProperties()
Get the properties of this builder

Returns:
the properties in a Hashtable (as name-value pairs)

getDescriptions

public Hashtable getDescriptions()
Get the descriptions of this builder

Returns:
the descriptions in a Hashtable, accessible by language

getPluralNames

public Hashtable getPluralNames()
Get the plural names of this builder

Returns:
the plural names in a Hashtable, accessible by language

getSingularNames

public Hashtable getSingularNames()
Get the singular (GUI) names of this builder

Returns:
the singular names in a Hashtable, accessible by language

getParentBuilder

public MMObjectBuilder getParentBuilder()
Get the builder that this builder extends

Returns:
the parent as an MMObjectBuilder, or null if not specified or unresolved
Since:
MMBase-1.6

getExtends

public String getExtends()
Get the name of the builder that this builder extends

Returns:
the name of the parent builder
Since:
MMBase-1.8

getVersion

public int getVersion()
Retrieve the (major) version number of this builder

Returns:
the version as an integer.
Since:
MMBase-1.8

getMaintainer

public String getMaintainer()
Retrieve the name of the maintainer of this builder

Returns:
the name fo the maintainer as a String
Since:
MMBase-1.8

equals

public boolean equals(Object o)

Since:
MMBase-1.7

storageEquals

public boolean storageEquals(BuilderReader f)
Whether this builderreader object is equal to another for storage purposes (so, ignoring gui and documentation fields)

Since:
MMBase-1.7

main

public static void main(String[] argv)
                 throws Exception
For testing only

Throws:
Exception


MMBase build 1.8.1.20060716