Package io.kojan.xml

Interface XMLParser

All Known Implementing Classes:
XMLParserImpl

public interface XMLParser
A facility to deserialize data in in XML format. Allows deserialization of entities and reading of any other data.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether at the current parser position there is an XML element opening tag.
    boolean
    Determines whether at the current parser position there is an XML element opening tag with specified tag name.
    void
    Reads XML element closing tag with specified tag name.
    <Type, Bean>
    void
    parseEntity(Entity<Type,Bean> entity, Bean bean)
    Deserializes given Entity from XML form.
    Reads XML element opening tag.
    void
    Reads XML element opening tag with specified tag name.
    Reads XML text content.
  • Method Details

    • parseText

      String parseText() throws XMLException
      Reads XML text content.

      If there is no XML text content at given parser position, then empty String is returned.

      Comments within the text are skipped.

      Returns:
      text content that was read
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • hasStartElement

      boolean hasStartElement() throws XMLException
      Determines whether at the current parser position there is an XML element opening tag.

      Comments and whitespace text preceding the XML tag are skipped.

      Returns:
      true iff at the current parser position there is an XML element
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • hasStartElement

      boolean hasStartElement(String tag) throws XMLException
      Determines whether at the current parser position there is an XML element opening tag with specified tag name.

      Comments and whitespace text preceding the XML tag are skipped.

      Parameters:
      tag - XML element tag name
      Returns:
      true iff at the current parser position there is an XML element with specified tag name
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • parseStartElement

      String parseStartElement() throws XMLException
      Reads XML element opening tag.

      Comments and whitespace text preceding the XML tag are skipped.

      XMLException is thrown if at the current position there is no XML element (but, for example, text data or element closing tag).

      Returns:
      XML element tag name
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • parseStartElement

      void parseStartElement(String tag) throws XMLException
      Reads XML element opening tag with specified tag name.

      Comments and whitespace text preceding the XML tag are skipped.

      XMLException is thrown if at the current position there is no XML element opening tag with specified tag (but, for example, text data, element closing tag or element opening tag with a different tag name).

      Parameters:
      tag - XML element tag name
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • parseEndElement

      void parseEndElement(String tag) throws XMLException
      Reads XML element closing tag with specified tag name.

      Comments and whitespace text preceding the XML tag are skipped.

      XMLException is thrown if at the current position there is no XML element closing tag with specified tag (but, for example, text data, element opening tag or XML element closing tag with a different tag name).

      Parameters:
      tag - XML element tag name
      Throws:
      XMLException - in case exception occurs during XML deserialization
    • parseEntity

      <Type, Bean> void parseEntity(Entity<Type,Bean> entity, Bean bean) throws XMLException
      Deserializes given Entity from XML form.
      Type Parameters:
      Type - data type of entity
      Bean - type of bean associated with the entity
      Parameters:
      entity - the entity type to deserialize
      bean - the entity bean to deserialize data into
      Throws:
      XMLException - in case exception occurs during XML deserialization