Class EPPXMLByteArray


  • public class EPPXMLByteArray
    extends java.lang.Object
    EPPXMLByteArray is a utility class for reading and writing EPP messages to/from byte arrays. DOM Document is converted to and from byte arrays. An XML parser is required when reading from the stream. There is one constructor that will create an XML parser per call to read(InputStream) and one that will use a parser pool. Use of a parser pool is recommended.
    • Constructor Summary

      Constructors 
      Constructor Description
      EPPXMLByteArray()
      Default constructor for EPPXMLByteArray.
      EPPXMLByteArray​(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool)
      Construct EPPXMLByteArray to use a parser pool and a default transformer pool.
      EPPXMLByteArray​(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool, org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.transform.Transformer> aTransformerPool)
      Construct EPPXMLByteArray to use a parser pool and a transformer pool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.w3c.dom.Document decode​(byte[] aPacket)
      Decodes(parses) and validates the aPacket parameter and returns the associated DOM Document.
      byte[] encode​(org.w3c.dom.Document aDoc)
      Encodes(converts) a DOM Document to a byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EPPXMLByteArray

        public EPPXMLByteArray()
        Default constructor for EPPXMLByteArray. When using this constructor, a parser instance will be created on each call to decode(byte[]) and a transformer instance will be created on each call to encode(). .
      • EPPXMLByteArray

        public EPPXMLByteArray​(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool)
        Construct EPPXMLByteArray to use a parser pool and a default transformer pool. The aParserPoolName parameter has to be a pool of EPPParserPool subclasses. When using this constructor, a parser instance will be checked out and checked in as needed on each call to decode(byte[]). The EPPTransformerPool is used by default for the transformer pool when using encode(Document).
        Parameters:
        aParserPool - Parser pool to use
      • EPPXMLByteArray

        public EPPXMLByteArray​(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool,
                               org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.transform.Transformer> aTransformerPool)
        Construct EPPXMLByteArray to use a parser pool and a transformer pool. When using this constructor, a parser instance will be checked out and checked in as needed on each call to decode(byte[]) and a transformer instance will be checked out and checked in as needed on each call to encode(Document).
        Parameters:
        aParserPool - Parser pool to use
        aTransformerPool - Transformer pool to use
    • Method Detail

      • decode

        public org.w3c.dom.Document decode​(byte[] aPacket)
                                    throws EPPAssemblerException,
                                           EPPException,
                                           java.io.IOException
        Decodes(parses) and validates the aPacket parameter and returns the associated DOM Document. The XML parser is either created per call or is retrieved from a parser pool. Use of a parser pool is recommended.
        Parameters:
        aPacket - The byte array containing the EPP packet.
        Returns:
        Parsed DOM Document of packet
        Throws:
        EPPException - Error with received packet or end of stream. It is recommended that the stream be closed.
        EPPAssemblerException - Error parsing packet
        java.io.IOException - Error reading packet from stream
      • encode

        public byte[] encode​(org.w3c.dom.Document aDoc)
                      throws EPPException
        Encodes(converts) a DOM Document to a byte array. The DOM Document will be serialized to XML and converted into a byte array.
        Parameters:
        aDoc - DOM Document to convert to byte array.
        Returns:
        Encoded XML as a byte[] from the DOM Document.
        Throws:
        EPPException - Error writing to stream. It is recommended that the stream be closed.