com.edustructures.sifworks.tools.mapping
Class ValueSet

java.lang.Object
  extended by com.edustructures.sifworks.tools.mapping.ValueSet
All Implemented Interfaces:
java.io.Serializable, java.util.Comparator

public class ValueSet
extends java.lang.Object
implements java.util.Comparator, java.io.Serializable

A ValueSet is an arbitrary mapping table used to map an application's proprietary codes and constants to SIF codes and constants. For example, an agent might define a ValueSet to map grade levels, ethnicity codes, english proficiency codes, and so on.

ValueSet stores its data in a HashMap. For each entry in the map, the key is a value defined by the application and the value is a ValueSetEntry object that encapsulates the associated SIF value and other fields like a display title for user interfaces.

For example, a ValueSet that maps grade levels might be comprised of the following entries:

KeyValue
PREKPK
K0K
101
202
303
404
505
606
707
808
909

To translate an application-defined value to its SIF equivalent, call the translate method. To translate a SIF-defined value to its application-defined equivalent, call the translateReverse method.

Version:
ADK 1.0
See Also:
Serialized Form

Constructor Summary
ValueSet(java.lang.String id)
          Constructs a ValueSet with an ID
ValueSet(java.lang.String id, java.lang.String title)
          Constructs a ValueSet with an ID and display title
ValueSet(java.lang.String id, java.lang.String title, org.w3c.dom.Node node)
          Constructs a ValueSet with an ID, display title, and associated DOM Node
 
Method Summary
 void clear()
          Clears the table
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two ValueSetEntry objects for order
 ValueSet copy(Mappings newParent)
           
 void define(java.lang.String appValue, java.lang.String sifValue, java.lang.String title)
          Sets a value
 void define(java.lang.String appValue, java.lang.String sifValue, java.lang.String title, org.w3c.dom.Node node)
          Sets a value
 ValueSetEntry[] getEntries()
          Return a sorted array of the ValueSet's entries
 java.lang.String getId()
           
 java.util.Map getMap()
           
 org.w3c.dom.Node getNode()
           
 java.util.Map getReverseMap()
           
 java.lang.String getTitle()
           
 java.lang.String lookup(java.lang.String appValue)
          Gets a value
 void remove(java.lang.String appValue)
          Removes a value
 void setAppDefault(java.lang.String appValue, boolean renderIfNull)
          Sets the default application value that will be returned if no match is found during a valueset translation
 void setId(java.lang.String id)
           
 void setNode(org.w3c.dom.Node node)
           
 void setSifDefault(java.lang.String sifValue, boolean renderIfNull)
          Sets the default SIF value that will be returned if no match is found during a valueset translation
 void setTitle(java.lang.String title)
           
 java.lang.String toString()
           
 void toXml(org.w3c.dom.Element element)
          Writes this valueset to an XML element.
 java.lang.String translate(java.lang.String appValue)
          Translates a value.
 java.lang.String translate(java.lang.String appValue, java.lang.String defaultValue)
          Translates a value.
 java.lang.String translateReverse(java.lang.String sifValue)
          Performs a reverse translation.
 java.lang.String translateReverse(java.lang.String sifValue, java.lang.String defaultValue)
          Performs a reverse translation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ValueSet

public ValueSet(java.lang.String id)
Constructs a ValueSet with an ID


ValueSet

public ValueSet(java.lang.String id,
                java.lang.String title)
Constructs a ValueSet with an ID and display title


ValueSet

public ValueSet(java.lang.String id,
                java.lang.String title,
                org.w3c.dom.Node node)
Constructs a ValueSet with an ID, display title, and associated DOM Node

Method Detail

copy

public ValueSet copy(Mappings newParent)

getId

public java.lang.String getId()

setId

public void setId(java.lang.String id)

getTitle

public java.lang.String getTitle()

setTitle

public void setTitle(java.lang.String title)

getNode

public org.w3c.dom.Node getNode()

setNode

public void setNode(org.w3c.dom.Node node)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEntries

public ValueSetEntry[] getEntries()
Return a sorted array of the ValueSet's entries

Returns:
An array of ValueSetEntry objects sorted by display order

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares two ValueSetEntry objects for order

Specified by:
compare in interface java.util.Comparator

define

public void define(java.lang.String appValue,
                   java.lang.String sifValue,
                   java.lang.String title)
Sets a value


define

public void define(java.lang.String appValue,
                   java.lang.String sifValue,
                   java.lang.String title,
                   org.w3c.dom.Node node)
Sets a value


lookup

public java.lang.String lookup(java.lang.String appValue)
Gets a value


translate

public java.lang.String translate(java.lang.String appValue)
Translates a value.

This method differs from lookup in that it returns a default value if it is available and no mapping is defined in the ValueSet. If there is no default value, the appValue passed in is returned. The lookup method returns null if no mapping is defined.

Parameters:
appValue - An application-defined value
Returns:
The corresponding SIF-defined value

translate

public java.lang.String translate(java.lang.String appValue,
                                  java.lang.String defaultValue)
Translates a value.

If there is no mapping defined, the default value passed in is returned. If, however, the default value passed in is NULL, the valueset will be searched for a default value and that value will be returned. If there is no default, the appValue passed in is returned. The lookup method returns null if no mapping is defined.

Parameters:
appValue - An application-defined value
Returns:
The corresponding SIF-defined value

translateReverse

public java.lang.String translateReverse(java.lang.String sifValue)
Performs a reverse translation.

If there is no match found, but there is a default value found that applies to inbound mappings, the default value will be returned. If no default value is found, the sifValue will be returned

Parameters:
sifValue - An SIF-defined value
Returns:
The corresponding application-defined value

translateReverse

public java.lang.String translateReverse(java.lang.String sifValue,
                                         java.lang.String defaultValue)
Performs a reverse translation.

If there is no match found, the defaultValue is returned. If, however, the defaultValue is NULL, the Valueset's outbound default value will be used. If the valueset does not have a default outbound value, the sifValue will be returned

Parameters:
sifValue - An SIF-defined value
Returns:
The corresponding application-defined value

setAppDefault

public void setAppDefault(java.lang.String appValue,
                          boolean renderIfNull)
                   throws ADKMappingException
Sets the default application value that will be returned if no match is found during a valueset translation

Parameters:
appValue - The value to return if there is no match
renderIfNull - True if the default value should be returned even if the SIF Value being translated is NULL. If false, NULL will be returned.
Throws:
ADKMappingException - Thrown if the value has not yet been defined in this valueset by calling define

setSifDefault

public void setSifDefault(java.lang.String sifValue,
                          boolean renderIfNull)
                   throws ADKMappingException
Sets the default SIF value that will be returned if no match is found during a valueset translation

Parameters:
sifValue - The value to return if there is no match
renderIfNull - True if the default value should be returned even if the app value being translated is null. If false, NULL will be returned.
Throws:
ADKMappingException - Thrown if the value has not yet been defined in this valueset by calling define
See Also:
define(String, String, String), define(String, String, String, Node)

clear

public void clear()
Clears the table


remove

public void remove(java.lang.String appValue)
Removes a value


getMap

public java.util.Map getMap()

getReverseMap

public java.util.Map getReverseMap()

toXml

public void toXml(org.w3c.dom.Element element)
Writes this valueset to an XML element.

Parameters:
element -


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.