Class EPPCodec

java.lang.Object
com.verisign.epp.codec.gen.EPPCodec

public class EPPCodec extends Object
Singleton class to encode and decode EPPMessage instances to and from DOM Documents. EPPCodec encapsulates the details of the EPP and is capable of handling new EPP Command Mappings through the use of EPPFactory.

Utility methods are provided for decoding specific concrete EPPMessages including:
  • EPPCommand - EPP Command encoded by client and decoded by server
  • EPPResponse - EPP Response encoded by server and decoded by client
  • EPPGreeting - EPP Greeting encoded by server and decoded by client
  • EPPHello - EPP Hello encoded by client and decoded by server
See Also:
  • Field Details

  • Constructor Details

    • EPPCodec

      protected EPPCodec()
      allocates the Singleton EPPCodec instance. The XML Parser used to construct the DOM Document is initialized to be namespace aware and to not validate. JAXP is used to instantiate the concrete XML Parser, and the XML Parser is only used during an encode operation.
  • Method Details

    • getInstance

      public static EPPCodec getInstance()
      gets the Singleton instance of EPPCodec. EPPCodec follows the Singleton Design Pattern.
      Returns:
      Singleton instance of EPPCodec.
    • init

      public void init(Vector<String> someFactories) throws EPPCodecException
      Initialize the Singleton instance. This method initializes all of the components used by EPPCodec.
      A Vector of concrete EPPMapFactory fully qualified class names are specified to initialize the EPPCodec with the supported EPP Command Mappings. For example, support for the Domain Command Mapping is added to EPPCodec by included the class name "com.verisign.epp.codec.domain.EPPDomainMapFactory" in the someFactories argument. The following code shows the steps to include the Domain Command Mapping and the Host Command Mapping in the EPPCodec.
       Vector theFactories = new Vector();
       theFactories.addElement("com.verisign.epp.codec.domain.EPPDomainMapFactory");
       theFactories.addElement("com.verisign.epp.codec.host.HostMapFactory");
       EPPCodec.getInstance().init(theFactories);
       
      Parameters:
      someFactories - a Vector of concrete EPPMapFactory fully qualified class names.
      Throws:
      EPPCodecException - Error initializing the EPPCodec
    • init

      public void init(Vector<String> someFactories, Vector<String> extensionFactories) throws EPPCodecException
      Initialize the Singleton instance. This method initializes all of the components used by EPPCodec. AVector of concrete EPPCommandResponseExtension of fully qualified class names are specified to initialize the EPPCodec with the supported Command Response Extensions. For example support for the Protocol Level Extensiosn and CommanResponse Extensions is added to EPPCodec by including the class names namely "com.verisign.epp.codec.gen.EPPProtocolExtensions", "com.verisign.epp.codec.gen.EPPCommandResponseExtensions" in the extensionFactories argument.The follwoign code shows the steps to the ProtcolExtensions and CommandResponse Extensions in the EPPCodec.
        Vector protocolExts = EPPEnv.getProtocolExtensions();
        Vector commandExts=EPPEnv.getCmdResponseExtensions();
        Vector extensionsVector=new Vector()
        extensionsVector.addElement((String)protocolExts.elementAt(i));
        extensionsVector.addElement((String)commandExts.elementAt(j));
        Now instantiate the Codec instance with both the mapfactories and extension factories
        EPPCodec.getInstance().init(EPPEnv.getMapFactories(),extensionsVector);
       
      Parameters:
      someFactories - a Vector of concrete EPPMapFactory fully qualified class names.
      extensionFactories - a Vector of concrete EPPProtocolExtension and EPPCommandResponseExtesnsions
      Throws:
      EPPCodecException - Error initializing the EPPCodec
    • encode

      public Document encode(EPPMessage aMessage) throws EPPEncodeException
      encodes a concrete EPPMessage into a DOM Document.
      Parameters:
      aMessage - Concrete EPPMessage to encode.
      Returns:
      Encoded DOM Document of representing the EPPMessage
      Throws:
      EPPEncodeException - Error encoding the EPPMessage.
    • decode

      public EPPMessage decode(Document aDocument) throws EPPDecodeException
      decodes a DOM Document into a concrete EPPMessage.
      Parameters:
      aDocument - DOM Document to decode into a concrete EPPMessage.
      Returns:
      Encoded concrete EPPMessage.
      Throws:
      EPPDecodeException - Error decoding the DOM Document.
    • decode

      decodes a DOM Element tree into a concrete EPPMessage.
      Parameters:
      root - Root EPP element to decode from
      Returns:
      Encoded concrete EPPMessage.
      Throws:
      EPPDecodeException - Error decoding the DOM Document.
      EPPComponentNotFoundException - A component could not be found which could be a command, response, or extension component.
    • decodeCommand

      public EPPCommand decodeCommand(Document aDocument) throws EPPDecodeException
      utility method that will decode a DOM Document and return an EPPCommand instance. An EPPDecodeException will be thrown if the decoded EPPMessage is not an EPPCommand.
      Parameters:
      aDocument - DOM Document to decode into an EPPCommand.
      Returns:
      Encoded concrete EPPCommand.
      Throws:
      EPPDecodeException - Error decoding the DOM Document or EPPMessage is not an EPPCommand
    • decodeResponse

      public EPPResponse decodeResponse(Document aDocument) throws EPPDecodeException
      utility method that will decode a DOM Document and return an EPPResponse instance. An EPPDecodeException will be thrown if the decoded EPPMessage is not an EPPResponse.
      Parameters:
      aDocument - DOM Document to decode into an EPPResponse.
      Returns:
      Encoded concrete EPPResponse.
      Throws:
      EPPDecodeException - Error decoding the DOM Document or EPPMessage is not an EPPResponse
    • decodeGreeting

      public EPPGreeting decodeGreeting(Document aDocument) throws EPPDecodeException
      utility method that will decode a DOM Document and return an EPPGreeting instance. An EPPDecodeException will be thrown if the decoded EPPMessage is not an EPPGreeting.
      Parameters:
      aDocument - DOM Document to decode into an EPPGreeting.
      Returns:
      Encoded concrete EPPGreeting.
      Throws:
      EPPDecodeException - Error decoding the DOM Document or EPPMessage is not an EPPGreeting
    • decodeHello

      public EPPHello decodeHello(Document aDocument) throws EPPDecodeException
      utility method that will decode a DOM Document and return an EPPHello instance. An EPPDecodeException will be thrown if the decoded EPPMessage is not an EPPHello.
      Parameters:
      aDocument - DOM Document to decode into an EPPHello.
      Returns:
      Encoded concrete EPPHello.
      Throws:
      EPPDecodeException - Error decoding the DOM Document or EPPMessage is not an EPPHello