info.informatica.ui
Class DataViewMap

java.lang.Object
  extended by info.informatica.ui.DataViewMap
All Implemented Interfaces:
DataViewConfig
Direct Known Subclasses:
HTMLViewConfig

public class DataViewMap
extends Object
implements DataViewConfig

A Map-based DataViewConfig implementation.

Author:
amengual at informatica dot info

Constructor Summary
DataViewMap()
           
 
Method Summary
 void addMetadataName(String mdname)
           
 DataView createDataView(String viewname)
          Creates an instance of the DataView associated to this ViewConfig.
 String getControlClass(ControlName ui_name)
          Gets the class name that represents the UI element identified by ui_name
 Map<String,Object> getControlDefaults()
          Get the defaults of the fields, as specified in the View configuration.
 ControlName getControlName(FieldName field_name)
          Gets the control name associated to the given entity.
 Iterator<ControlName> getControlNames()
          Gets the names of the UI entity fields associated to UI items.
 FieldName getFieldName(ControlName ui_name)
          Gets the field name associated to the given control name.
 LocalLabels getLocalLabels()
          Gets the localized labels for the current view locale.
 String getViewClass()
          Gets the name of the DataView class associated to this ViewConfig.
 boolean isMetadataName(String name)
          Checks whether the given name is one of the datasource metadata names associated to the view.
 void loadDefaultConfig(Iterator<FieldName> names)
          Configure a basic DataViewConfig with UI name == field name, and the default UI class.
static void main(String[] args)
          Testdrive method used to read a UI spec from an XML file, and print it again.
 void parseXml(InputStream is)
          Fill this view config with an XML descriptor.
 String pickMetadataName()
           
 void putFieldView(FieldName fieldname, ControlName uiname, String uiclassname)
          Adds a fieldname/controlname/classname set to this view map.
 void setDefaultUIClass(String classname)
           
 void setLocalLabels(LocalLabels labels)
          Sets the localized labels for the current view locale.
 void setViewClass(String classname)
          Sets the name of the class used to produce the DataView
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataViewMap

public DataViewMap()
Method Detail

loadDefaultConfig

public void loadDefaultConfig(Iterator<FieldName> names)
Configure a basic DataViewConfig with UI name == field name, and the default UI class.


parseXml

public void parseXml(InputStream is)
              throws DataViewException,
                     IOException
Fill this view config with an XML descriptor.

Parameters:
is - the Stream with the XML descriptor.
Throws:
DataViewException - if anything wrong was found in the descriptor.
IOException - for I/O error when reading the descriptor.

putFieldView

public void putFieldView(FieldName fieldname,
                         ControlName uiname,
                         String uiclassname)
Adds a fieldname/controlname/classname set to this view map.

Parameters:
fieldname - the name of the field being aded.
uiname - the name of the user interface control being aded.
uiclassname - the name of the UI control class.

setDefaultUIClass

public void setDefaultUIClass(String classname)

getControlName

public ControlName getControlName(FieldName field_name)
Gets the control name associated to the given entity.

If there is none, returns null.

Specified by:
getControlName in interface DataViewConfig
Parameters:
field_name - the entity name.
Returns:
the associated control name, or null if none is associated.

getFieldName

public FieldName getFieldName(ControlName ui_name)
Gets the field name associated to the given control name.

Specified by:
getFieldName in interface DataViewConfig
Parameters:
ui_name - the control name.
Returns:
the associated entity name, or null if none.

getControlClass

public String getControlClass(ControlName ui_name)
Description copied from interface: DataViewConfig
Gets the class name that represents the UI element identified by ui_name

Specified by:
getControlClass in interface DataViewConfig

getControlNames

public Iterator<ControlName> getControlNames()
Description copied from interface: DataViewConfig
Gets the names of the UI entity fields associated to UI items.

Specified by:
getControlNames in interface DataViewConfig

getControlDefaults

public Map<String,Object> getControlDefaults()
Description copied from interface: DataViewConfig
Get the defaults of the fields, as specified in the View configuration.

Specified by:
getControlDefaults in interface DataViewConfig
Returns:
a Map with the field default values, as they were specified in the View configuration. An empty Map indicates no defaults were specified.

getViewClass

public String getViewClass()
Description copied from interface: DataViewConfig
Gets the name of the DataView class associated to this ViewConfig.

Specified by:
getViewClass in interface DataViewConfig
Returns:
the name of the DataView associated to this ViewConfig.

setViewClass

public void setViewClass(String classname)
Description copied from interface: DataViewConfig
Sets the name of the class used to produce the DataView

Specified by:
setViewClass in interface DataViewConfig
Parameters:
classname - Name of the DataView-inherited class associated to this ViewConfig.

createDataView

public DataView createDataView(String viewname)
                        throws DataViewException
Description copied from interface: DataViewConfig
Creates an instance of the DataView associated to this ViewConfig.

Specified by:
createDataView in interface DataViewConfig
Parameters:
viewname - the name of the view.
Returns:
a new DataView associated to this ViewConfig.
Throws:
DataViewException

setLocalLabels

public void setLocalLabels(LocalLabels labels)
Description copied from interface: DataViewConfig
Sets the localized labels for the current view locale.

Specified by:
setLocalLabels in interface DataViewConfig
Parameters:
labels - the local labels.

getLocalLabels

public LocalLabels getLocalLabels()
Description copied from interface: DataViewConfig
Gets the localized labels for the current view locale.

Specified by:
getLocalLabels in interface DataViewConfig
Returns:
the local labels, or null if not available.

addMetadataName

public void addMetadataName(String mdname)
Specified by:
addMetadataName in interface DataViewConfig

isMetadataName

public boolean isMetadataName(String name)
Description copied from interface: DataViewConfig
Checks whether the given name is one of the datasource metadata names associated to the view.

Specified by:
isMetadataName in interface DataViewConfig
Returns:
true if it is one of the datasource names associated to the view, or false if not.

pickMetadataName

public String pickMetadataName()
Specified by:
pickMetadataName in interface DataViewConfig

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)
Testdrive method used to read a UI spec from an XML file, and print it again.