Class GlossaryManager

  • All Implemented Interfaces:
    DirectoryMonitor.Callback

    public class GlossaryManager
    extends java.lang.Object
    implements DirectoryMonitor.Callback
    Class that loads glossary files and adds glossary entries to strings of the source files. This class don't need any threads synchronization code, since it only set and clear 'glossaryEntries' var.
    • Method Detail

      • createNewWritableGlossaryFile

        public static boolean createNewWritableGlossaryFile​(java.io.File file)
                                                     throws java.io.IOException
        Create new default writable glossary file.
        Parameters:
        file - a file to be created.
        Returns:
        true if the file was successfully created
        Throws:
        java.io.IOException - when there is a problem to create file.
      • addGlossaryProvider

        public void addGlossaryProvider​(IGlossary provider)
      • start

        public void start()
      • stop

        public void stop()
      • forceReloadTBX

        public void forceReloadTBX()
      • forceUpdateGlossary

        public void forceUpdateGlossary()
      • getGlossaryEntries

        public java.util.List<GlossaryEntry> getGlossaryEntries​(java.lang.String src)
        Get glossary entries.
        Parameters:
        src -
        Returns:
        all entries
      • getLocalEntries

        public java.util.List<GlossaryEntry> getLocalEntries()
        Get glossary entries for search operation. Almost the same as getGlossaryEntries(), except search usually executed for every segment in project, i.e. should work enough fast. Then, search should be produced by local files only.
        Returns:
        all entries
      • searchSourceMatches

        public java.util.List<GlossaryEntry> searchSourceMatches​(SourceTextEntry ste)
        Get all glossary entries with source terms found in the provided string.
        Returns:
        A list of matching glossary entries
      • searchSourceMatchTokens

        public java.util.List<Token[]> searchSourceMatchTokens​(SourceTextEntry ste,
                                                               GlossaryEntry entry)
        Get tokens of the source text that match the supplied glossary entry.
        Parameters:
        ste - The entry to search
        Returns:
        A list of tokens matching the supplied glossary entry
      • searchTargetMatches

        public java.util.List<java.lang.String> searchTargetMatches​(java.lang.String trg,
                                                                    ProtectedPart[] protectedParts,
                                                                    GlossaryEntry entry)
        Get all target terms for the provided glossary entry that can be found in the provided string.
        Parameters:
        trg - The text to search
        protectedParts - A list of protected parts from which matches should be disregarded (can be null)
        entry - The glossary entry whose target terms should be searched
        Returns:
        A list of matching target terms