PicketLink Federation Core 2.1.6.Final-redhat-2

org.picketlink.identity.federation.core.parsers.util
Class StaxParserUtil

java.lang.Object
  extended by org.picketlink.identity.federation.core.parsers.util.StaxParserUtil

public class StaxParserUtil
extends Object

Utility for the stax based parser

Since:
Feb 8, 2010
Author:
Anil.Saldhana@redhat.com

Field Summary
protected static Validator validator
           
 
Constructor Summary
StaxParserUtil()
           
 
Method Summary
static void bypassElementBlock(XMLEventReader xmlEventReader, String tag)
          Bypass an entire XML element block from startElement to endElement
static String getAttributeValue(Attribute attribute)
          Given an Attribute, get its trimmed value
static String getAttributeValue(StartElement startElement, String tag)
          Get the Attribute value
static Element getDOMElement(XMLEventReader xmlEventReader)
          Given that the XMLEventReader is in XMLStreamConstants.START_ELEMENT mode, we parse into a DOM Element
static String getElementText(XMLEventReader xmlEventReader)
          Get the element text.
static String getEndElementName(EndElement endElement)
          Return the name of the end element
static String getLineColumnNumber(Location location)
          Given a Location, return a formatted string [lineNum,colNum]
static EndElement getNextEndElement(XMLEventReader xmlEventReader)
          Get the next EndElement
static XMLEvent getNextEvent(XMLEventReader xmlEventReader)
          Get the next xml event
static StartElement getNextStartElement(XMLEventReader xmlEventReader)
          Get the next StartElement
static Validator getSchemaValidator()
          Get the Validator for JAXP Validation
static String getStartElementName(StartElement startElement)
          Return the name of the start element
static XMLEventReader getXMLEventReader(InputStream is)
          Get the XML event reader
static String getXSITypeValue(StartElement startElement)
          Given a start element, obtain the xsi:type defined
static boolean hasTextAhead(XMLEventReader xmlEventReader)
          Return whether the next event is going to be text
static boolean matches(EndElement endElement, String tag)
          Match that the end element with the expected tag
static boolean matches(StartElement startElement, String tag)
          Match that the start element with the expected tag
static XMLEvent peek(XMLEventReader xmlEventReader)
          Peek at the next event
static EndElement peekNextEndElement(XMLEventReader xmlEventReader)
          Peek the next EndElement
static StartElement peekNextStartElement(XMLEventReader xmlEventReader)
          Peek the next StartElement
static String trim(String str)
          Given a string, trim it
static void validate(EndElement endElement, String tag)
          Validate that the end element has the expected tag
static void validate(StartElement startElement, String tag)
          Validate that the start element has the expected tag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validator

protected static Validator validator
Constructor Detail

StaxParserUtil

public StaxParserUtil()
Method Detail

bypassElementBlock

public static void bypassElementBlock(XMLEventReader xmlEventReader,
                                      String tag)
                               throws ParsingException
Bypass an entire XML element block from startElement to endElement

Parameters:
xmlEventReader -
tag - Tag of the XML element that we need to bypass
Throws:
ParsingException

getAttributeValue

public static String getAttributeValue(Attribute attribute)
Given an Attribute, get its trimmed value

Parameters:
attribute -
Returns:

getAttributeValue

public static String getAttributeValue(StartElement startElement,
                                       String tag)
Get the Attribute value

Parameters:
startElement -
tag - localpart of the qname of the attribute
Returns:

getDOMElement

public static Element getDOMElement(XMLEventReader xmlEventReader)
                             throws ParsingException
Given that the XMLEventReader is in XMLStreamConstants.START_ELEMENT mode, we parse into a DOM Element

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

getElementText

public static String getElementText(XMLEventReader xmlEventReader)
                             throws ParsingException
Get the element text.

Parameters:
xmlEventReader -
Returns:
A trimmed string value
Throws:
ParsingException

getXMLEventReader

public static XMLEventReader getXMLEventReader(InputStream is)
Get the XML event reader

Parameters:
is -
Returns:

getLineColumnNumber

public static String getLineColumnNumber(Location location)
Given a Location, return a formatted string [lineNum,colNum]

Parameters:
location -
Returns:

getNextEvent

public static XMLEvent getNextEvent(XMLEventReader xmlEventReader)
                             throws ParsingException
Get the next xml event

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

getNextStartElement

public static StartElement getNextStartElement(XMLEventReader xmlEventReader)
                                        throws ParsingException
Get the next StartElement

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

getNextEndElement

public static EndElement getNextEndElement(XMLEventReader xmlEventReader)
                                    throws ParsingException
Get the next EndElement

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

getStartElementName

public static String getStartElementName(StartElement startElement)
Return the name of the start element

Parameters:
startElement -
Returns:

getEndElementName

public static String getEndElementName(EndElement endElement)
Return the name of the end element

Parameters:
endElement -
Returns:

getXSITypeValue

public static String getXSITypeValue(StartElement startElement)
Given a start element, obtain the xsi:type defined

Parameters:
startElement -
Returns:
Throws:
RuntimeException - if xsi:type is missing

hasTextAhead

public static boolean hasTextAhead(XMLEventReader xmlEventReader)
                            throws ParsingException
Return whether the next event is going to be text

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

matches

public static boolean matches(StartElement startElement,
                              String tag)
Match that the start element with the expected tag

Parameters:
startElement -
tag -
Returns:
boolean if the tags match

matches

public static boolean matches(EndElement endElement,
                              String tag)
Match that the end element with the expected tag

Parameters:
endElement -
tag -
Returns:
boolean if the tags match

peek

public static XMLEvent peek(XMLEventReader xmlEventReader)
                     throws ParsingException
Peek at the next event

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

peekNextStartElement

public static StartElement peekNextStartElement(XMLEventReader xmlEventReader)
                                         throws ParsingException
Peek the next StartElement

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

peekNextEndElement

public static EndElement peekNextEndElement(XMLEventReader xmlEventReader)
                                     throws ParsingException
Peek the next EndElement

Parameters:
xmlEventReader -
Returns:
Throws:
ParsingException

trim

public static final String trim(String str)
Given a string, trim it

Parameters:
str -
Returns:
Throws:
{@code - IllegalArgumentException} if the passed str is null

validate

public static void validate(StartElement startElement,
                            String tag)
Validate that the start element has the expected tag

Parameters:
startElement -
tag -
Throws:
RuntimeException - mismatch

validate

public static void validate(EndElement endElement,
                            String tag)
Validate that the end element has the expected tag

Parameters:
endElement -
tag -
Throws:
RuntimeException - mismatch

getSchemaValidator

public static Validator getSchemaValidator()
                                    throws SAXException,
                                           IOException
Get the Validator for JAXP Validation

Returns:
Throws:
SAXException
IOException

PicketLink Federation Core 2.1.6.Final-redhat-2

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.