XBinder C# Runtime Library  2.8
Static Public Member Functions | List of all members
com.objsys.xbinder.runtime.XMLStreamHelper Class Reference

Helper methods. A number of these may be moved into a stream class, when I get to the point of reorganizing the stream interfaces. More...

Static Public Member Functions

static void assertEmptyElement (XmlTextReader reader)
 Throw an exception if the current element contains a child element or character data. More...
 
static void assertEvent (XmlTextReader reader, XmlNodeType assumedEvent)
 Check that the current event is of the given type. If not, throw an exception. More...
 
static void assertStartElement (XmlTextReader reader, System.String elemNamespaceURI, System.String elemName)
 Check that the current event is a START_ELEMENT for the given element. If not, throw an exception. More...
 
static void beginDocumentDecode (XmlTextReader reader)
 Begin document decoding by skipping all input up to the first start element. More...
 
static System.String nameForEvent (XmlNodeType event_Renamed)
 
static long getElementLong (XmlTextReader reader)
 Return the element text as a long. More...
 
static long getValueAsLong (System.String value_Renamed)
 Return value as a long. More...
 
static bool isElementNilled (XmlTextReader reader)
 Return true if the current element has a nil attribute set to "true". Current position must be start element. More...
 
static bool isEndContent (XmlTextReader reader)
 Returns true if the reader is at an EndElement or the end of the document. More...
 
static bool moveToContentElement (XmlTextReader reader)
 This tries to locate the next content element, ie, the next element at the current level. It begins by locating the next tag or end of document, skipping over non-content events (PI, comments, whitespace). If it encounters an end tag or end document before finding a start tag, it returns false (no more content at this level). If it encounters something other than a non-content event, start or end tag, or end of document, it throws an exception. Otherwise, it returns true, indicating the desired element was located. More...
 
static XmlNodeType nextTagOrEndDocument (XmlTextReader reader)
 Skip comments, processing instructions, and whitespace until the next Element, EndElement, or the end of the document is found. More...
 
static string readContent (XmlTextReader reader)
 Read content for the current element into a raw XML string. More...
 
static string readElementAndContent (XmlTextReader reader)
 Read the current element and all of its content into a string. This method effectively round-trips the XML, so that the XML returned may not exactly match the XML read. More...
 
static XBQualifiedName readXsiType (XmlTextReader reader)
 Return the qualified name (or null) for the xsi:type attribute. More...
 
static void skipToEndElement (XmlReader reader)
 Skip all events until an unmatched end element is found. For every start element, the next end element is matched, and is likewise skipped. The first end element that is not matched in this way becomes the current event. More...
 
static bool checkEmptyElement (XmlTextReader reader)
 Checks to see if the element the reader is position on is an empty element. More...
 

Detailed Description

Helper methods. A number of these may be moved into a stream class, when I get to the point of reorganizing the stream interfaces.

<author> Kevin/Doug

</author>

Member Function Documentation

◆ assertEmptyElement()

static void com.objsys.xbinder.runtime.XMLStreamHelper.assertEmptyElement ( XmlTextReader  reader)
static

Throw an exception if the current element contains a child element or character data.

◆ assertEvent()

static void com.objsys.xbinder.runtime.XMLStreamHelper.assertEvent ( XmlTextReader  reader,
XmlNodeType  assumedEvent 
)
static

Check that the current event is of the given type. If not, throw an exception.

This method helps standardize error messages.

Parameters
reader

<throws> XBException </throws>

◆ assertStartElement()

static void com.objsys.xbinder.runtime.XMLStreamHelper.assertStartElement ( XmlTextReader  reader,
System.String  elemNamespaceURI,
System.String  elemName 
)
static

Check that the current event is a START_ELEMENT for the given element. If not, throw an exception.

Parameters
reader
elemNamespaceURInamespace URI of element
elemNameshort name for element

<throws> XBException </throws>

◆ beginDocumentDecode()

static void com.objsys.xbinder.runtime.XMLStreamHelper.beginDocumentDecode ( XmlTextReader  reader)
static

Begin document decoding by skipping all input up to the first start element.

Parameters
reader

◆ checkEmptyElement()

static bool com.objsys.xbinder.runtime.XMLStreamHelper.checkEmptyElement ( XmlTextReader  reader)
static

Checks to see if the element the reader is position on is an empty element.

Parameters
readerThe reader instance.
Returns
true if the reader is positioned on an empty element false otherwise

◆ getElementLong()

static long com.objsys.xbinder.runtime.XMLStreamHelper.getElementLong ( XmlTextReader  reader)
static

Return the element text as a long.

Reports a nice error message if the value is not legal.

Returns

◆ getValueAsLong()

static long com.objsys.xbinder.runtime.XMLStreamHelper.getValueAsLong ( System.String  value_Renamed)
static

Return value as a long.

Value should be a valid lexical representation for an XML Schema integer.

Returns

<throws> FormatException if the value is not a legal number. OverflowException if the value does not fit inside a long.</throws>

◆ isElementNilled()

static bool com.objsys.xbinder.runtime.XMLStreamHelper.isElementNilled ( XmlTextReader  reader)
static

Return true if the current element has a nil attribute set to "true". Current position must be start element.

Parameters
reader
Returns

◆ isEndContent()

static bool com.objsys.xbinder.runtime.XMLStreamHelper.isEndContent ( XmlTextReader  reader)
static

Returns true if the reader is at an EndElement or the end of the document.

Parameters
readerThe XmlTextReader instance.
Returns
True of the reader is at an EndElement or the end of the document.

◆ moveToContentElement()

static bool com.objsys.xbinder.runtime.XMLStreamHelper.moveToContentElement ( XmlTextReader  reader)
static

This tries to locate the next content element, ie, the next element at the current level. It begins by locating the next tag or end of document, skipping over non-content events (PI, comments, whitespace). If it encounters an end tag or end document before finding a start tag, it returns false (no more content at this level). If it encounters something other than a non-content event, start or end tag, or end of document, it throws an exception. Otherwise, it returns true, indicating the desired element was located.

Parameters
reader

◆ nextTagOrEndDocument()

static XmlNodeType com.objsys.xbinder.runtime.XMLStreamHelper.nextTagOrEndDocument ( XmlTextReader  reader)
static

Skip comments, processing instructions, and whitespace until the next Element, EndElement, or the end of the document is found.

Parameters
readerThe XML text reader instance.
Returns
The XmlNodeType value that describes the event.

◆ readContent()

static string com.objsys.xbinder.runtime.XMLStreamHelper.readContent ( XmlTextReader  reader)
static

Read content for the current element into a raw XML string.

The reader should be at the Element event of the element whose content should be read.

This method effectively round-trips the XML, so that the XML returned may not exactly match the XML read.

Parameters
readerThe reader to read from.
Returns
A string containing the formatted XML

◆ readElementAndContent()

static string com.objsys.xbinder.runtime.XMLStreamHelper.readElementAndContent ( XmlTextReader  reader)
static

Read the current element and all of its content into a string. This method effectively round-trips the XML, so that the XML returned may not exactly match the XML read.

Parameters
readerThe reader to read from. Current event must be Element
Returns
A string containing the formatted XML

◆ readXsiType()

static XBQualifiedName com.objsys.xbinder.runtime.XMLStreamHelper.readXsiType ( XmlTextReader  reader)
static

Return the qualified name (or null) for the xsi:type attribute.

Parameters
readerThe XML reader instance
Returns
The qualified name of the xsi:type attribute.

◆ skipToEndElement()

static void com.objsys.xbinder.runtime.XMLStreamHelper.skipToEndElement ( XmlReader  reader)
static

Skip all events until an unmatched end element is found. For every start element, the next end element is matched, and is likewise skipped. The first end element that is not matched in this way becomes the current event.

Parameters
reader