com.edustructures.sifworks
Class SIFFormatter

java.lang.Object
  extended by com.edustructures.sifworks.SIFFormatter

public abstract class SIFFormatter
extends java.lang.Object

A class that converts native datatypes supported by SIF to their textual representation.

Version:
2.0

Constructor Summary
SIFFormatter()
           
 
Method Summary
 SIFElement addChild(SIFElement contentParent, SIFElement content, SIFVersion version)
          Adds a SIFElement parsed from a specific version of SIF to the parent.
 java.nio.charset.Charset getCharset()
           
 java.util.List<Element> getContent(SIFElement element, SIFVersion version)
          Gets the content from the SIFElement for the specified version of SIF.
 java.lang.String getContentType()
           
static javax.xml.datatype.DatatypeFactory getDataTypeFactory()
           
 java.util.List<SimpleField> getFields(SIFElement element, SIFVersion version)
          Gets the fields from the SIFElement for the specified version of SIF.
static java.util.UUID RefIDToUUID(java.lang.String sifRefId)
          Converts a SIF RefId to a Java UUID
 void setField(SIFElement contentParent, ElementDef fieldDef, SIFSimpleType data, SIFVersion version)
          Adds a SimpleField parsed from a specific version of SIF to the parent.
abstract  boolean supportsNamespaces()
          Returns true if the formatter supports XML Namespaces.
abstract  java.lang.Boolean toBoolean(java.lang.String inValue)
          Converts an a SIF XML boolean value to a Java Boolean value
abstract  java.util.Calendar toDate(java.lang.String dateValue)
          Converts an a SIF XML date value to a Java Calendar value
abstract  java.lang.String toDateString(java.util.Calendar date)
          Converts a Java Calendar value to a SIF data value
abstract  java.util.Calendar toDateTime(java.lang.String xmlValue)
          Parses a datetime value from the provided string.
abstract  java.lang.String toDateTimeString(java.util.Calendar date)
          Converts a Java Calendar value to a SIF datetime value
abstract  java.math.BigDecimal toDecimal(java.lang.String intValue)
          Converts an a SIF XML decimal value to a Java int value
abstract  javax.xml.datatype.Duration toDuration(java.lang.String xmlValue)
          Converts an a SIF XML duration value to a Java Duration value
abstract  java.lang.Integer toInteger(java.lang.String intValue)
          Converts an a SIF XML int value to a Java int value
abstract  java.lang.String toString(java.math.BigDecimal decimalValue)
          Converts a Java BigDecimal value to a SIF int value
abstract  java.lang.String toString(java.lang.Boolean boolValue)
          Converts a Java Boolean value to a SIF boolean value
abstract  java.lang.String toString(javax.xml.datatype.Duration d)
          Converts a Java Duration value to a SIF duration value
abstract  java.lang.String toString(java.lang.Integer intValue)
          Converts a Java int value to a SIF int value
abstract  java.util.Calendar toTime(java.lang.String xmlValue)
          Parses a time value from the provided string.
abstract  java.lang.String toTimeString(java.util.Calendar time)
          Converts a Java Calendar value to a SIF time value
static java.lang.String UUIDToRefID(java.util.UUID guid)
          Converts a UUID to a string using the SIF format
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SIFFormatter

public SIFFormatter()
Method Detail

toDateString

public abstract java.lang.String toDateString(java.util.Calendar date)
Converts a Java Calendar value to a SIF data value

Parameters:
date -
Returns:
The date formatted as a string, using SIF formatting requirements

toDateTimeString

public abstract java.lang.String toDateTimeString(java.util.Calendar date)
Converts a Java Calendar value to a SIF datetime value

Parameters:
date -
Returns:
The datetime formatted as a string, using SIF formatting requirements

toTimeString

public abstract java.lang.String toTimeString(java.util.Calendar time)
Converts a Java Calendar value to a SIF time value

Parameters:
time -
Returns:
The time formatted as a string, using SIF formatting requirements

toString

public abstract java.lang.String toString(java.lang.Integer intValue)
Converts a Java int value to a SIF int value

Parameters:
intValue -
Returns:
The int formatted as a string, using SIF formatting requirements

toString

public abstract java.lang.String toString(java.math.BigDecimal decimalValue)
Converts a Java BigDecimal value to a SIF int value

Parameters:
decimalValue -
Returns:
The BigDecimal formatted as a string, using SIF formatting requirements

toString

public abstract java.lang.String toString(java.lang.Boolean boolValue)
Converts a Java Boolean value to a SIF boolean value

Parameters:
boolValue -
Returns:
The boolean formatted as a string, using SIF formatting requirements

toDate

public abstract java.util.Calendar toDate(java.lang.String dateValue)
Converts an a SIF XML date value to a Java Calendar value

Parameters:
dateValue -
Returns:
A Calendar that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

toDateTime

public abstract java.util.Calendar toDateTime(java.lang.String xmlValue)
Parses a datetime value from the provided string. NOTE: SIF 1.x does not support datetime values.

Parameters:
xmlValue -
Returns:
A Calendar that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the date cannot be parsed

toTime

public abstract java.util.Calendar toTime(java.lang.String xmlValue)
Parses a time value from the provided string. NOTE: SIF 1.x does not support time values.

Parameters:
xmlValue -
Returns:
A Calendar that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

toInteger

public abstract java.lang.Integer toInteger(java.lang.String intValue)
Converts an a SIF XML int value to a Java int value

Parameters:
intValue -
Returns:
An Integer that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

toDecimal

public abstract java.math.BigDecimal toDecimal(java.lang.String intValue)
Converts an a SIF XML decimal value to a Java int value

Parameters:
intValue -
Returns:
A Decimal that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

toDuration

public abstract javax.xml.datatype.Duration toDuration(java.lang.String xmlValue)
Converts an a SIF XML duration value to a Java Duration value

Parameters:
xmlValue - A Duration formatted as a String or NULL
Returns:
An XML Duration that has been parsed from the SIF String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

toString

public abstract java.lang.String toString(javax.xml.datatype.Duration d)
Converts a Java Duration value to a SIF duration value

Parameters:
d -
Returns:
The Duration formatted as a string, using SIF formatting requirements
Throws:
java.lang.IllegalArgumentException - If the duration cannot be parsed
java.lang.UnsupportedOperationException - in SIF 1.1, since Durations are not used

toBoolean

public abstract java.lang.Boolean toBoolean(java.lang.String inValue)
Converts an a SIF XML boolean value to a Java Boolean value

Parameters:
inValue - A boolean formatted as a String or NULL
Returns:
A Boolean that has been parsed from the String representation
Throws:
java.lang.IllegalArgumentException - If the value cannot be parsed

getContentType

public java.lang.String getContentType()
Returns:
The Content-Type HttpHeader that should be used

getCharset

public java.nio.charset.Charset getCharset()
Returns:
the Charset used by SIF to encode XML to a binary transport

supportsNamespaces

public abstract boolean supportsNamespaces()
Returns true if the formatter supports XML Namespaces. If this value returns true, XML Namespaces will be declared when writing SIF Elements, and the xsi:nil attribute will be enabled

Returns:
true if the formatter supports namespaces

addChild

public SIFElement addChild(SIFElement contentParent,
                           SIFElement content,
                           SIFVersion version)
Adds a SIFElement parsed from a specific version of SIF to the parent. The formatter instance may use version-specific rules to ensure that the hierarchy is properly maintained when the source of the content is from this version of SIF

Parameters:
contentParent - The element to add content to
content - The element to add
version - The version of SIF that the SIFElement is being constructed from
Returns:
Returns the child that has been added to the parent

setField

public void setField(SIFElement contentParent,
                     ElementDef fieldDef,
                     SIFSimpleType data,
                     SIFVersion version)
Adds a SimpleField parsed from a specific version of SIF to the parent.

Parameters:
contentParent - The element to add content to
fieldDef - The metadata definition of the field to set
data - The value to set to the field
version - The version of SIF that the SIFElement is being constructed from

getContent

public java.util.List<Element> getContent(SIFElement element,
                                          SIFVersion version)
Gets the content from the SIFElement for the specified version of SIF. Only elements that apply to the requested version of SIF will be returned.

Parameters:
element - The element to retrieve content from
version -
Returns:
The content of the specified parent

getFields

public java.util.List<SimpleField> getFields(SIFElement element,
                                             SIFVersion version)
Gets the fields from the SIFElement for the specified version of SIF. Only the fields that apply to the requested version of SIF will be returned.

Parameters:
element -
version -
Returns:
Returns the fields of the SIFElement

UUIDToRefID

public static java.lang.String UUIDToRefID(java.util.UUID guid)
Converts a UUID to a string using the SIF format

Parameters:
guid - the UUID to convert
Returns:
the UUID formatted as a SIFRefId

RefIDToUUID

public static java.util.UUID RefIDToUUID(java.lang.String sifRefId)
Converts a SIF RefId to a Java UUID

Parameters:
sifRefId - the string formatted as a SIF refId
Returns:
a UUID
Throws:
java.lang.IllegalArgumentException - if sifRefid does not conform to the string representation of a SIF RefId

getDataTypeFactory

public static javax.xml.datatype.DatatypeFactory getDataTypeFactory()


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.