Class Stax2Source

  • All Implemented Interfaces:
    javax.xml.transform.Source
    Direct Known Subclasses:
    Stax2BlockSource, Stax2ReferentialSource

    public abstract class Stax2Source
    extends java.lang.Object
    implements javax.xml.transform.Source
    This is the base class for additional input sources (implementations of Source) that Stax2 XMLInputFactory2 implementations should support.

    Note about usage by the parser factory implementations: the expectation is that at least one of methods constructReader() and constructInputStream() will succeed, but not necessarily both. This generally depends on type of resource being represented: for example, if the source is a String or character array, it is most naturally represent via Reader. For a byte array, on the other hand, an InputStream is the most natural access method.

    Other things to note about using result Readers and InputStreams:

    • Caller is responsible for closing any Reader and InputStream instances requested. That is, caller owns these accessor objects.
    • Source objects are only required to return a non-null object once: after this, if new non-null instances are returned, they must not be the same objects as returned earlier. Implementations can choose to construct new instances to the same backing data structure or resource; if so, they should document this behavior.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String mEncoding  
      protected java.lang.String mPublicId  
      protected java.lang.String mSystemId  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Stax2Source()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.io.InputStream constructInputStream()
      This method creates an InputStream via which underlying input source can be accessed.
      abstract java.io.Reader constructReader()
      This method creates a Reader via which underlying input source can be accessed.
      java.lang.String getEncoding()  
      java.lang.String getPublicId()  
      abstract java.net.URL getReference()  
      java.lang.String getSystemId()  
      void setEncoding​(java.lang.String enc)  
      void setPublicId​(java.lang.String id)  
      void setSystemId​(java.lang.String id)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.xml.transform.Source

        isEmpty
    • Field Detail

      • mSystemId

        protected java.lang.String mSystemId
      • mPublicId

        protected java.lang.String mPublicId
      • mEncoding

        protected java.lang.String mEncoding
    • Constructor Detail

      • Stax2Source

        protected Stax2Source()
    • Method Detail

      • getSystemId

        public java.lang.String getSystemId()
        Specified by:
        getSystemId in interface javax.xml.transform.Source
      • setSystemId

        public void setSystemId​(java.lang.String id)
        Specified by:
        setSystemId in interface javax.xml.transform.Source
      • getPublicId

        public java.lang.String getPublicId()
      • setPublicId

        public void setPublicId​(java.lang.String id)
      • getEncoding

        public java.lang.String getEncoding()
      • setEncoding

        public void setEncoding​(java.lang.String enc)
      • getReference

        public abstract java.net.URL getReference()
        Returns:
        URL that can be used to resolve references originating from the content read via this source; may be null if not known (which is the case for most non-referential sources)
      • constructReader

        public abstract java.io.Reader constructReader()
                                                throws java.io.IOException
        This method creates a Reader via which underlying input source can be accessed. Note that caller is responsible for closing that Reader when it is done reading it.
        Throws:
        java.io.IOException
      • constructInputStream

        public abstract java.io.InputStream constructInputStream()
                                                          throws java.io.IOException
        This method creates an InputStream via which underlying input source can be accessed. Note that caller is responsible for closing that InputSource when it is done reading it
        Throws:
        java.io.IOException