Class XLIFFDocument


  • public class XLIFFDocument
    extends Object
    Represents a complete parsed XLIFF document in memory.
    • Constructor Detail

      • XLIFFDocument

        public XLIFFDocument()
      • XLIFFDocument

        public XLIFFDocument​(String sourceLang,
                             String version)
        Creates a new XLIFFDocument() with given source and version.
        Parameters:
        sourceLang - the source language.
        version - version of the XLIFF document (use null for the default).
    • Method Detail

      • load

        public void load​(File file)
        Loads a document from a given file, with maximum validation.
        Parameters:
        file - the file to load.
      • load

        public void load​(File file,
                         int validation)
        Loads a document from a given File.
        Parameters:
        file - the file to load.
        validation - one of the VALIDATION_* constants or a ORed combination.
      • load

        public void load​(URI inputURI,
                         int validation)
        Loads a document from a given URI.
        Parameters:
        inputURI - the URI to load from.
        validation - one of the VALIDATION_* constants or a ORed combination.
      • load

        public void load​(String input,
                         int validation)
        Loads a document from a string.
        Parameters:
        input - the content of the document to load.
        validation - one of the VALIDATION_* constants or a ORed combination.
      • saveAs

        public void saveAs​(File outputFile)
        Saves this document to a specified file. If needed directories are created.
        Parameters:
        outputFile - the output file.
        See Also:
        save()
      • save

        public void save​(Writer outputWriter)
        Saves this document to a writer. The writer must use an encoding that supports all Unicode characters without escaping (e.g. UTF-8)
        Parameters:
        outputWriter - the output writer.
      • getStartXliffData

        public StartXliffData getStartXliffData()
        Gets the document-level data for this document.
        Returns:
        the document-level data of this document.
      • getFileNode

        public FileNode getFileNode​(String id)
        Gets the FileNode from a given file id.
        Parameters:
        id - the id of the file to lookup.
        Returns:
        the FileNode object or null if not found.
      • getFileNodeIds

        public List<String> getFileNodeIds()
        Gets the IDs of all FileNode in this XLIFF document. The order of IDs is the insertion order of files.
        Returns:
        the list of IDs.
      • getGroupNode

        public GroupNode getGroupNode​(String fileId,
                                      String groupId)
        Gets the GroupNode from a given file id and a given group id.
        Parameters:
        fileId - the id of the file where the group is.
        groupId - the id of the group to lookup.
        Returns:
        the GroupNode or null if not found.
      • getUnitNode

        public UnitNode getUnitNode​(String fileId,
                                    String unitId)
        Gets the UnitNode from a given file id and a given unit id.
        Parameters:
        fileId - the id of the file where the unit is.
        unitId - the id of the unit to lookup.
        Returns:
        the UnitNode or null if not found.
      • createEventIterator

        public Iterator<Event> createEventIterator()
        Creates an iterator for the events of this document.
        Returns:
        a new iterator for the events of this document.
      • fetchReference

        public Object fetchReference​(URIParser up)
        Retrieves the object corresponding to a given URI fragment.
        Parameters:
        up - the URIParser representing the fragment to resolve.
        Returns:
        the object found, or null if the object was not found or is external to this document.
      • getUnits

        public List<Unit> getUnits()
        Gets a list of all the units in this document.
        Returns:
        the list of all units in this document.
      • getFile

        public File getFile()
        Gets the File object associated with this document. It can be null if the document we not read from a File. This object is automatically set when you call load(File), load(File, int) and saveAs(File).
        Returns:
        the File object for this document (or null if none is associated.
      • addFileNode

        public FileNode addFileNode​(String id)
        Adds a FileNode object to this document.
        Parameters:
        id - the ID of the file to add.
        Returns:
        the new FileNode object.
      • setLineBreak

        public void setLineBreak​(String lineBreak)
        Sets the line break to use when writing out this document. By default the line-break used is the one of the OS.
        Parameters:
        lineBreak - the line break to use for this document.