com.tietoenator.trip.jxp.data

## Class TdbXmlRecord

- java.lang.Object
- - com.tietoenator.trip.jxp.session.TdbSessionObject
  - - com.tietoenator.trip.jxp.TdbMessageProvider
    - - com.tietoenator.trip.jxp.data.TdbRecord
      - - com.tietoenator.trip.jxp.data.TdbXmlRecord

- All Implemented Interfaces:
    com.tietoenator.trip.jxp.internal.utils.DOMSink

      public class TdbXmlRecord
      extends TdbRecord

  Container and manipulation logic for a record from a TRIPxml database.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `TdbXmlRecord.IOMode` The IOMode enum represents various ways that TRIPxml import and export operations can take place.
    `static class` | `TdbXmlRecord.XmlRecordType` For TRIPxml, indicates the type of document that is stored in the record.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TdbXmlRecord(TdbSession session)` Constructor, creates a blank TRIPxml record container.
    `TdbXmlRecord(TdbSession session, java.lang.String name, boolean createFields)` Constructor, associates the record with thenamed TRIPxml database.
    `TdbXmlRecord(TdbSession session, TdbDatabaseDesign design, boolean createFields)` Constructor, associates the record with the provided database design.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear(boolean all)` Clear any existing state from the TdbXmlRecord instance.
    `java.lang.String` | `getFileName()` Get the name of the exported file.
    `boolean` | `getHitMarkup()` Indicates if the exported XML document is to have hit markup applied.
    `TdbXmlRecord.IOMode` | `getInputOutputMode()` Get the IO mode to use with this record.
    `int` | `getNetworkStreamPort()` The number of the TCP port to use for network streaming based import and export TRIPxml operations.
    `java.io.OutputStream` | `getOutputStream()` Returns the stream that receives data from the XML record.
    `TdbXmlRecord.XmlRecordType` | `getRecordType()` Get the type of document this record contains.
    `boolean` | `getStoreCopy()` Determines if a binary copy of an imported XML document is to be stored, or only the parsed version of it.
    `java.lang.String` | `getUrlAlias()` Get the URL alias for the document.
    `java.lang.String` | `getUrlBase()` Returns the URL base of the document, i.e.
    `boolean` | `getValidate()` Determines if XML documents are to be validated upon import.
    `boolean` | `isXmlRecord()` Indicates if this record is a TRIPxml record.
    `void` | `prepareExport()` Prepares to export the contents of the record.
    `void` | `prepareExport(java.io.OutputStream os)` Prepares to export the contents of the record to the specified stream.
    `void` | `prepareExport(java.lang.String fileOrDir)` Prepares to export the contents of the record to a file.
    `void` | `prepareImport(java.io.InputStream stream, TdbXmlRecord.XmlRecordType type, java.lang.String fileName)` Prepare to import a document into a TRIPxml database.
    `void` | `setHitMarkup(boolean hitMarkup)` Indicates if the exported XML document is to have hit markup applied.
    `void` | `setInputOutputMode(TdbXmlRecord.IOMode mode)` Set the IO mode to use with this record.
    `void` | `setNetworkStreamPort(int port)` The number of the TCP port to use for network streaming based import and export TRIPxml operations.
    `void` | `setRecordType(TdbXmlRecord.XmlRecordType type)` Set the type of document to retrieve.
    `void` | `setStoreCopy(boolean enable)` Determines if a binary copy of an imported XML document is to be stored, or only the parsed version of it.
    `void` | `setUrlAlias(java.lang.String urlAlias)` Set the URL alias for the document.
    `void` | `setValidate(boolean enable)` Determines if XML documents are to be validated upon import.

    - ### Methods inherited from class com.tietoenator.trip.jxp.data.TdbRecord

      `addToTemplate, addToTemplate, addToTemplate, appendComponent, commit, copy, copy, delete, deleteComponent, deleteComponent, get, get, getCategories, getComponent, getComponent, getDatabaseName, getFieldTemplates, getHead, getIndexOnCommit, getNlpInfo, getRank, getRawRank, getRecordId, getRecordName, getTimeStamp, insertAseList, isChanged, isDeleted, isGraphRecord, lock, parts, removeFromTemplate, setDatabaseName, setIndexOnCommit, setPartId, setPartNameField, setRecordId, setRecordName, setRecordNameField, setRecordNumberField, setRetrieveHead, setRetrieveParts, setTemplateMarkup, unlock, updateAseList`

    - ### Methods inherited from class com.tietoenator.trip.jxp.TdbMessageProvider

      `codeList, getLastCode, getLastMessage, hasMessages, messageList, resetMessages`

    - ### Methods inherited from class com.tietoenator.trip.jxp.session.TdbSessionObject

      `cancel, getSession, isCancelable, setCancelable`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.tietoenator.trip.jxp.internal.utils.DOMSink

      `sinkNode`

- - ### Constructor Detail

    - #### TdbXmlRecord

          public TdbXmlRecord(TdbSession session)
                       throws TdbException

      Constructor, creates a blank TRIPxml record container.
      Parameters:
        `session` - Active session
      Throws:
        `TdbException`

    - #### TdbXmlRecord

          public TdbXmlRecord(TdbSession session,
                              TdbDatabaseDesign design,
                              boolean createFields)
                       throws TdbException

      Constructor, associates the record with the provided database design.
      Parameters:
        `session` - Active session
        `design` - Database design
        `createFields` - If true, the constructor will automatically create a retrieval template using all fields from the database design.
      Throws:
        `TdbException`

    - #### TdbXmlRecord

          public TdbXmlRecord(TdbSession session,
                              java.lang.String name,
                              boolean createFields)
                       throws TdbException

      Constructor, associates the record with thenamed TRIPxml database.
      Parameters:
        `session` - Active session
        `name` - Name of the TRIPxml database.
        `createFields` - If true, the constructor will automatically create a retrieval template using all fields from the database design.
      Throws:
        `TdbException`

  - ### Method Detail

    - #### getInputOutputMode

          public TdbXmlRecord.IOMode getInputOutputMode()

      Get the IO mode to use with this record.

    - #### setInputOutputMode

          public void setInputOutputMode(TdbXmlRecord.IOMode mode)

      Set the IO mode to use with this record.

    - #### getRecordType

          public TdbXmlRecord.XmlRecordType getRecordType()

      Get the type of document this record contains.

    - #### setRecordType

          public void setRecordType(TdbXmlRecord.XmlRecordType type)

      Set the type of document to retrieve. To retrieve a record contining JSON or XML data, this property should be set to the format to return the data as; either XML or JSON (regardless of the original format of the data). Assigning this property not applicable for records containing binary (NONXML) data.

    - #### getHitMarkup

          public boolean getHitMarkup()

      Indicates if the exported XML document is to have hit markup applied. This property is used when the TdbXmlRecord instance is applied as a retrieval template for a TdbRecordSet.

    - #### setHitMarkup

          public void setHitMarkup(boolean hitMarkup)

      Indicates if the exported XML document is to have hit markup applied. This property is used when the TdbXmlRecord instance is applied as a retrieval template for a TdbRecordSet.

    - #### getNetworkStreamPort

          public int getNetworkStreamPort()

      The number of the TCP port to use for network streaming based import and export TRIPxml operations. A value of 0 (zero) will cause a port number to be dynamically allocated.

    - #### setNetworkStreamPort

          public void setNetworkStreamPort(int port)

      The number of the TCP port to use for network streaming based import and export TRIPxml operations. A value of 0 (zero) will cause a port number to be dynamically allocated.
      Parameters:
        `port` - Port number to use with network streaming I/O. If there is a firewall between the client and the server, make sure that you specify a port number from a range that is enabled in the firewall. Remember to set the InputOutputMode property to IOMode.Stream in order to use network streaming. Also remember that in multithreaded situations, there may be multiple TdbXmlRecord exports and imports active simultaneously. Unless the port number is set to 0 (zero), the application is in such cases responsble for making sure that only available port numbers are used.

    - #### getFileName

          public java.lang.String getFileName()

      Get the name of the exported file. This property is only given usable values when record contents has been exported with IOMode set to IOMode.Stream when the Export(String) method has been called with a directory name. This property then contains the full name of the exported file.

    - #### getValidate

          public boolean getValidate()

      Determines if XML documents are to be validated upon import.
      Returns:
        True if validation is to take place.

    - #### setValidate

          public void setValidate(boolean enable)

      Determines if XML documents are to be validated upon import.
      Parameters:
        `enable` - Pass true if validation is to take place.

    - #### getStoreCopy

          public boolean getStoreCopy()

      Determines if a binary copy of an imported XML document is to be stored, or only the parsed version of it.
      Returns:
        True (default) if a binary copy is to be stored.

    - #### setStoreCopy

          public void setStoreCopy(boolean enable)

      Determines if a binary copy of an imported XML document is to be stored, or only the parsed version of it.
      Parameters:
        `enable` - Pass true to store a binary copy.

    - #### getUrlAlias

          public java.lang.String getUrlAlias()

      Get the URL alias for the document.

      The URL alias is the "real" URL of the document, i.e. the URL that is used to link two documents together via an XLink, for example. The URL alias is identical to the URL base and filename unless the URL alias has been explicitly specified to be something else during the import process.

    - #### setUrlAlias

          public void setUrlAlias(java.lang.String urlAlias)

      Set the URL alias for the document.

      The URL alias is the "real" URL of the document, i.e. the URL that is used to link two documents together via an XLink, for example. The URL alias is identical to the URL base and filename unless the URL alias has been explicitly specified to be something else during the import process.

    - #### getUrlBase

          public java.lang.String getUrlBase()
                                      throws TdbException

      Returns the URL base of the document, i.e. the URL without the actual file name.

      If the document was imported from a file (e.g. using the server-side txput tool), then this property will be empty.

      Throws:
        `TdbException`

    - #### getOutputStream

          public java.io.OutputStream getOutputStream()

      Returns the stream that receives data from the XML record.
      Returns:
        OutputStream with data from the XML record, or null if no stream is available. This is usually the stream as specified as argument to prepareExport(OutputStream). However, in certain circumstances (e.g. when no file and no stream has been specified) this property may return a ByteArrayOutputStream instance with the received data.

    - #### clear

          public void clear(boolean all)

      Clear any existing state from the TdbXmlRecord instance.
      Overrides:
        `clear` in class `TdbRecord`
      Parameters:
        `all` - If true, all state is cleared, including the database with which the record is associated, the record name/ID, etc. If false, the record structure is initialized, but the basic state of the record's association is maintained.

    - #### isXmlRecord

          public boolean isXmlRecord()

      Indicates if this record is a TRIPxml record.
      Overrides:
        `isXmlRecord` in class `TdbRecord`
      Returns:
        True if the record is an XML database record

    - #### prepareImport

          public void prepareImport(java.io.InputStream stream,
                                    TdbXmlRecord.XmlRecordType type,
                                    java.lang.String fileName)
                             throws TdbException

      Prepare to import a document into a TRIPxml database.
      Parameters:
        `stream` - The stream from which to load the data to import.
        `type` - The type of the file (if known)
        `fileName` - The name of the file (if known)
      Throws:
        `TdbException` -

        This method does not perform the actual import operation. This is done when the Commit method is called. This allows for other data to be sent as well (e.g. assigning values to custom TRIPxml database fields).

        If the 'type' parameter is XmlRecordType.UNKNOWN, then this method will try to ascertain the type from the provided file name. If the file name is not specified and the type is XmlRecordType.UNKNOWN, this method will throw an exception.

        Direct file import is possible if the stream parameter is set to null, the filename refers to an existing local file and the TRIPjxp application is running on the same machine as the TRIP server the current session is connected to. Also remember to call setInputOutputMode with IOMode.File as argument before calling Commit.

    - #### prepareExport

          public void prepareExport()

      Prepares to export the contents of the record.

      This method does not perform the actual export operation. This is done when the get() method is called.

      The method getOutputStream() returns a ByteArrayOutputStream with the receieved data when the get() method has completed successfully.

      This method is only compatible with the IOMode.Inline I/O mode. Do not try to override this by assigning any other value the InputOutputMode property.

    - #### prepareExport

          public void prepareExport(java.io.OutputStream os)

      Prepares to export the contents of the record to the specified stream.
      Parameters:
        `os` - Stream to export to.

        This method does not perform the actual export operation. This is done when the get() method is called.

        This method is not compatible with the file-based I/O. Avoid IOMode.File as argument when calling the setInputOutputMode() method.

    - #### prepareExport

          public void prepareExport(java.lang.String fileOrDir)
                             throws TdbException

      Prepares to export the contents of the record to a file.
      Parameters:
        `fileOrDir` - Name of file or directory

        If the 'fileOrDir' parameter is a directory, the name of the file (minus the path) will be read from the D_DOCNAME field and created in the specified directory. In any other case, the 'fileOrDir' parameter MUST refer to a file (which does not have to exist yet, of course).

      Throws:
        `TdbException`