Class Registry

  • All Implemented Interfaces:
    IRegistry

    public class Registry
    extends java.lang.Object
    implements IRegistry
    Registry implementation, verifies and registers external and internal model components, languages, detection types.

    Caches data about these classes which is provided to the UI for display

    • Method Detail

      • getAdvancedPostProcessorForLanguage

        public ITuple<java.lang.Class<? extends IAdvancedPreProcessor>,​java.lang.Class<? extends org.antlr.v4.runtime.Lexer>> getAdvancedPostProcessorForLanguage​(java.lang.Class<? extends IAdvancedPreProcessorGroup> group,
                                                                                                                                                                        java.lang.String language)
        Fetches a tuple containing the correct AdvancedPreProcessor and Lexer implementations for this group/language combination
        Specified by:
        getAdvancedPostProcessorForLanguage in interface IRegistry
        Parameters:
        group - the group to find a valid preprocessor for
        language - the language string in use, should have been already validated to work with this group
        Returns:
        the tuple
      • getDetectorAdjustableParameters

        public java.util.List<AdjustableParameterObj> getDetectorAdjustableParameters​(java.lang.Class<? extends IDetector> det)
        Get the adjustable parameters for a detector
        Specified by:
        getDetectorAdjustableParameters in interface IRegistry
        Parameters:
        det - detector class
        Returns:
        adjustable parameters for the detector class
      • getDetectorDescription

        public java.lang.String getDetectorDescription​(java.lang.Class<? extends IDetector> det)
        Get the description of a detector
        Specified by:
        getDetectorDescription in interface IRegistry
        Parameters:
        det - detector class
        Returns:
        description of the detector
      • getDetectorDisplayName

        public java.lang.String getDetectorDisplayName​(java.lang.Class<? extends IDetector> det)
        Get the display name of the detector
        Specified by:
        getDetectorDisplayName in interface IRegistry
        Parameters:
        det - detector class
        Returns:
        display name of the detector
      • getDetectorLanguages

        public java.util.Set<java.lang.String> getDetectorLanguages​(java.lang.Class<? extends IDetector> det)
        Get the languages supported by the detector
        Specified by:
        getDetectorLanguages in interface IRegistry
        Parameters:
        det - detector class
        Returns:
        languages supported by the detector
      • getDetectors

        public java.util.Set<java.lang.Class<? extends IDetector>> getDetectors()
        Fetch the set of all detectors registered to Sherlock
        Specified by:
        getDetectors in interface IRegistry
        Returns:
        a set of all detectors registered
      • getDetectors

        public java.util.Set<java.lang.Class<? extends IDetector>> getDetectors​(java.lang.String language)
        Returns a set of all detectors registered which support the language specified
        Specified by:
        getDetectors in interface IRegistry
        Parameters:
        language - the language string to search
        Returns:
        the set of detectors
      • getLanguages

        public java.util.Set<java.lang.String> getLanguages()
        Returns the set of registered languages
        Specified by:
        getLanguages in interface IRegistry
        Returns:
        set of languages
      • getLexerForStrategy

        public java.lang.Class<? extends org.antlr.v4.runtime.Lexer> getLexerForStrategy​(PreProcessingStrategy strategy,
                                                                                         java.lang.String language)
        Finds and returns a valid lexer for the preprocessing stragety, if one cannot be found returns null
        Specified by:
        getLexerForStrategy in interface IRegistry
        Parameters:
        strategy - the PreProcessingStrategy
        language - the language string to prcess
        Returns:
        valid lexer or null
      • getPostProcessorAdjustableParametersFromDetector

        public java.util.List<AdjustableParameterObj> getPostProcessorAdjustableParametersFromDetector​(java.lang.Class<? extends IDetector> det)
        Gets the adjustable parameters for the corresponding post processor for a detector
        Specified by:
        getPostProcessorAdjustableParametersFromDetector in interface IRegistry
        Parameters:
        det - detector class
        Returns:
        the list of adjustable parameters
      • getPostProcessorInstance

        public IPostProcessor getPostProcessorInstance​(java.lang.Class<? extends AbstractModelTaskRawResult> rawClass)
        Get correct instance of IPostProcessor to process an AbstractModelTaskRawResult object
        Specified by:
        getPostProcessorInstance in interface IRegistry
        Parameters:
        rawClass - class
        Returns:
        new instance of correct postprocessor
      • registerAdvancedPreProcessorGroup

        public boolean registerAdvancedPreProcessorGroup​(java.lang.Class<? extends IAdvancedPreProcessorGroup> preProcessorGroup)
        Registers a grouping for IAdvancedPreProcessor to Sherlock. These groups of multiple Advanced PreProcessors all perform the same function, for different languages, laxers and parsers
        Specified by:
        registerAdvancedPreProcessorGroup in interface IRegistry
        Parameters:
        preProcessorGroup - the group
        Returns:
        was successful?
      • registerAdvancedPreProcessorImplementation

        public boolean registerAdvancedPreProcessorImplementation​(java.lang.String groupClassPath,
                                                                  java.lang.Class<? extends IAdvancedPreProcessor> preProcessor)
        Registers an IAdvancedPreProcessor implementation to a group
        Specified by:
        registerAdvancedPreProcessorImplementation in interface IRegistry
        Parameters:
        groupClassPath - the ClassPath for the group object to register to. The preProcessor MUST perform the groups assigned function, this cannot be checked!!!
        preProcessor - the implementation
        Returns:
        was successful?
      • registerDetectionType

        public boolean registerDetectionType​(DetectionType detectionType)
        Registers a detection type
        Specified by:
        registerDetectionType in interface IRegistry
        Parameters:
        detectionType - object for the new detection type
        Returns:
        was successful?
      • registerDetector

        public boolean registerDetector​(java.lang.Class<? extends IDetector> detector)
        Registers an IDetector implementation to Sherlock. The presence of any dependencies should ideally tested before calling this method, one way to do this is to use the SherlockEngine.isModulePresent(String)
        Specified by:
        registerDetector in interface IRegistry
        Parameters:
        detector - the implementation
        Returns:
        was successful?
      • registerLanguage

        public boolean registerLanguage​(java.lang.String name,
                                        java.lang.Class<? extends org.antlr.v4.runtime.Lexer> lexer)
        Register a lexer to the language of the name passed, creating the language if the name is not recognised
        Specified by:
        registerLanguage in interface IRegistry
        Parameters:
        name - Name of the language, not case sensitive
        lexer - Lexer implementation for the language
        Returns:
        was successful?