org.mmbase.util.xml
Class AbstractBuilderReader<F extends Field>

java.lang.Object
  extended by org.mmbase.util.xml.DocumentReader
      extended by org.mmbase.util.xml.AbstractBuilderReader<F>
Direct Known Subclasses:
BuilderReader, ParentBuilderReader

public abstract class AbstractBuilderReader<F extends Field>
extends DocumentReader

Abstraction of BuilderReader with no dependencies on core classes.

Since:
MMBase 1.9.2
Version:
$Id: AbstractBuilderReader.java 42558 2010-06-15 09:21:38Z michiel $
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
protected  boolean inheritanceResolved
          If false, the parent builder could not be resolved.
protected  SortedSet<Integer> inputPositions
           
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
protected  SortedSet<Integer> searchPositions
          searchPositions and inputPositions are used to adminstrate 'occupied' positions (from editor/positions), which is used to find defaults if not specified.
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, utilProperties
 
Constructor Summary
protected AbstractBuilderReader(Document doc)
           
protected AbstractBuilderReader(InputSource source)
           
 
Method Summary
protected  void decodeDataType(DataTypeSetter setter, String builder, DataTypeCollector collector, String fieldName, Element fieldElement, boolean forceInstance)
          Determine a data type instance based on the given gui element
protected  void decodeDataTypeLater(DataTypeSetter setter, String builder, DataTypeCollector collector, String fieldName, Element fieldElement, boolean forceInstance)
           
 boolean equals(Object o)
          
static ResourceLoader getBuilderLoader()
           
 String getClassName()
          Get the class name to use for instantiating this builder.
 Map<String,BasicDataType<?>> getDataTypes(DataTypeCollector collector)
          Get the datatypes defined for this builder.
 Map<String,String> getDescriptions()
          Deprecated. use getLocalizedDescription()
protected  int getEditorPos(Element elm)
          Determine an integer value from an elements body.
 String getExtends()
          Get the name of the builder that this builder extends
abstract  List<F> getFields()
          Get the field definitions of this builder.
 LocalizedString getLocalizedDescription(LocalizedString description)
          Get the descriptions of this module.
 LocalizedString getLocalizedPluralName(LocalizedString guiName)
          Get the (gui) names of this module.
 LocalizedString getLocalizedSingularName(LocalizedString guiName)
          Get the (gui) names of this module.
 String getMaintainer()
          Retrieve the name of the maintainer of this builder
 String getName()
          Get the name of the builder that this builder extends
protected abstract  String getParentClassName()
           
protected abstract  String getParentMaintainer()
           
protected abstract  Map<String,String> getParentProperties()
           
protected abstract  int getParentSearchAge()
           
protected abstract  int getParentVersion()
           
 Map<String,String> getPluralNames()
          Deprecated. use getLocalizedPluralName()
 Map<String,String> getProperties()
          Get the properties of this builder
 int getSearchAge()
          Retrieves the Search Age.
 Map<String,String> getSingularNames()
          Deprecated. use getLocalizedSingularName()
 String getStatus()
          Get the status of this builder.
 int getVersion()
          Retrieve the (major) version number of this builder
 int hashCode()
           
protected abstract  boolean hasParent()
           
 boolean isInheritanceResolved()
          Determines if inheritance is resolved.
protected static void mergeElementLists(Document doc, Document overrides, String list, String item, String attr, boolean replace)
          Copy a list of elements, identified by an attribute, from overrides to doc.
static void registerPublicIDs()
          Register the Public Ids for DTDs used by BuilderReader This method is called by EntityResolver.
static void registerSystemIDs()
          Register the namespace and XSD used by DataTypeConfigurer This method is called by EntityResolver.
protected abstract  boolean resolveInheritance()
          Resolves inheritance.
protected static void resolveInheritanceByXML(Document doc, Document overrides)
          Copy everything from overrides to doc.
 String toString()
           
 
Methods inherited from class org.mmbase.util.xml.DocumentReader
appendChild, getAttribute, getChildElements, getChildElements, getChildElements, getChildElements, getDocument, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getDocumentBuilder, getElementAttributeValue, getElementAttributeValue, getElementByPath, getElementByPath, getElementName, getElementValue, getElementValue, getNodeTextValue, getNodeTextValue, getRootElement, getSystemId, hasAttribute, main, setNodeTextValue, setPrefix, setSystemId, toDocument, validate, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, 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

inheritanceResolved

protected boolean inheritanceResolved
If false, the parent builder could not be resolved. A builder with an unresolved parent is set to 'inactive', regardless of actual status The default value is false, as resolving Inheritance is mandatory when loading builders.

Since:
MMbase-1.6

searchPositions

protected final SortedSet<Integer> searchPositions
searchPositions and inputPositions are used to adminstrate 'occupied' positions (from editor/positions), which is used to find defaults if not specified.

Since:
MMBase-1.7

inputPositions

protected final SortedSet<Integer> inputPositions
Constructor Detail

AbstractBuilderReader

protected AbstractBuilderReader(InputSource source)

AbstractBuilderReader

protected AbstractBuilderReader(Document doc)
Method Detail

registerSystemIDs

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


registerPublicIDs

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


getBuilderLoader

public static ResourceLoader getBuilderLoader()

resolveInheritanceByXML

protected static void resolveInheritanceByXML(Document doc,
                                              Document overrides)
Copy everything from overrides to doc. Note that the resulting document will not obey the correct order of elements, but that does not matter, because the java code in the rest of this class does not depend on that.

Parameters:
doc - The receiving builder xml document. This one will be changed.
overrides - The builder xml document that provided overriding information. This one will only be read.
Since:
MMBase-1.9

mergeElementLists

protected static void mergeElementLists(Document doc,
                                        Document overrides,
                                        String list,
                                        String item,
                                        String attr,
                                        boolean replace)
Copy a list of elements, identified by an attribute, from overrides to doc. Replace or merge those elements if they already exist in doc under that attribute. Merging an element means either adding or replacing the sub tags of that element.

Parameters:
doc - The receiving builder xml document. This one will be changed.
overrides - The builder xml document that provided overriding information. This one will only be read.
list - The tagname of list element(s) containign the items
item - The tagname of the list item element
attr - The attribute identifying the item (i.e. "name" or "xml:lang")
replace - if true, the item is entirely replaced. If false, it is merged.
Since:
MMBase-1.9.3

resolveInheritance

protected abstract 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()
Determines 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")

getParentSearchAge

protected abstract int getParentSearchAge()

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

getParentClassName

protected abstract String getParentClassName()

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<String,BasicDataType<?>> 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 abstract List<F> 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

getEditorPos

protected int getEditorPos(Element elm)
Determine an integer value from an elements body. Used for the List, Search, and Edit position values.

Parameters:
elm - The element containing the value.
Returns:
the parsed integer

decodeDataTypeLater

protected void decodeDataTypeLater(DataTypeSetter setter,
                                   String builder,
                                   DataTypeCollector collector,
                                   String fieldName,
                                   Element fieldElement,
                                   boolean forceInstance)

decodeDataType

protected void decodeDataType(DataTypeSetter setter,
                              String builder,
                              DataTypeCollector collector,
                              String fieldName,
                              Element fieldElement,
                              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

getParentProperties

protected abstract Map<String,String> getParentProperties()

getProperties

public Map<String,String> getProperties()
Get the properties of this builder

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

getLocalizedDescription

public LocalizedString getLocalizedDescription(LocalizedString description)
Get the descriptions of this module.

Returns:
the descriptions as a LocalizedString

getLocalizedSingularName

public LocalizedString getLocalizedSingularName(LocalizedString guiName)
Get the (gui) names of this module.

Returns:
the names as a LocalizedString

getLocalizedPluralName

public LocalizedString getLocalizedPluralName(LocalizedString guiName)
Get the (gui) names of this module.

Returns:
the names as a LocalizedString

getDescriptions

public Map<String,String> getDescriptions()
Deprecated. use getLocalizedDescription()

Get the descriptions of this builder

Returns:
the descriptions in a Map, accessible by language

getPluralNames

public Map<String,String> getPluralNames()
Deprecated. use getLocalizedPluralName()

Get the plural names of this builder

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

getSingularNames

public Map<String,String> getSingularNames()
Deprecated. use getLocalizedSingularName()

Get the singular (GUI) names of this builder

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

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

getName

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

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

hasParent

protected abstract boolean hasParent()

getParentVersion

protected abstract int getParentVersion()

getVersion

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

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

getParentMaintainer

protected abstract String getParentMaintainer()

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)

Overrides:
equals in class Object
Since:
MMBase-1.7

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


MMBase 2.0-SNAPSHOT - null