Class SimpleQlt

  • All Implemented Interfaces:
    Querylet

    public final class SimpleQlt
    extends TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
    A Simple querylet for matching one field or concatenated string values of several fields.
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleQlt​(int[] fieldIndexes, double[] fieldWeights, java.util.List<java.lang.String> allFields)
      Creates simple querylet with given parameters.
      SimpleQlt​(int[] fieldIndexes, java.util.List<java.lang.String> allFields)
      Default field weights 1.0 are used.
      SimpleQlt​(int fieldIndex, java.util.List<java.lang.String> allFields)
      A single field with default field weight is used.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String asJavaCode​(java.lang.String qltVarName, java.lang.String valuesVarName, java.lang.String fieldNamesVarName)
      Converts the querylet to a Java code string.
      java.util.List<java.lang.String> getFieldNames()  
      double getFieldWeight​(int fieldIndex)  
      com.netrics.likeit.NetricsQuery getNetricsQlt​(java.lang.String[] values)
      Constructs a NetricsQuery querylet from the stored XML structure and the given field values.
      java.lang.String getThesaurusName()  
      double getThesaurusWeight()  
      boolean hasThesaurus()  
      java.lang.Boolean isMatchEmpty()  
      void setFields​(int[] fieldIndexes, double[] fieldWeights)
      Replaces the list of fields in the querylet.
      void setFieldWeight​(int fieldIndex, double weight)
      Sets the weight of the given field.
      void setMatchEmpty​(boolean value)
      Sets the Match Empty parameter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SimpleQlt

        public SimpleQlt​(int[] fieldIndexes,
                         double[] fieldWeights,
                         java.util.List<java.lang.String> allFields)
        Creates simple querylet with given parameters.
        Parameters:
        fieldIndexes - must contain only indexes from the list of all fields (which was passed to constructor). A fieldIndex parameter in other methods refers to the number and order of the fields given here in fieldIndexes.
        fieldWeights - - the weights for each field in the querylet. may be null to set default weight 1.0.
        allFields - - all non-key fields in the data table.
        Throws:
        java.lang.IllegalArgumentException - if field indexes are not provided, or if an incorrect number of field weights is provided, or a weight value is invalid, or if no fields are specified in allFields.
      • SimpleQlt

        public SimpleQlt​(int[] fieldIndexes,
                         java.util.List<java.lang.String> allFields)
        Default field weights 1.0 are used.
        See Also:
        SimpleQlt(int[], double[], List)
      • SimpleQlt

        public SimpleQlt​(int fieldIndex,
                         java.util.List<java.lang.String> allFields)
        A single field with default field weight is used.
        Parameters:
        fieldIndex - - index in the list of all fields (which was passed to constructor)
        See Also:
        SimpleQlt(int[], double[], List)
    • Method Detail

      • setFields

        public void setFields​(int[] fieldIndexes,
                              double[] fieldWeights)
        Replaces the list of fields in the querylet.
        Specified by:
        setFields in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Parameters:
        fieldIndexes - must contain only indexes from the list of all fields (which was passed to the constructor). A fieldIndex parameter in other methods refers to the number and order of the fields given here in fieldIndexes.
        fieldWeights - - the weights for each field in the querylet. may be null to set default weight 1.0.
        Throws:
        java.lang.IllegalArgumentException - if field indexes are not provided, or if an incorrect number of field weights is provided, or a weight value is invalid.
      • getNetricsQlt

        public com.netrics.likeit.NetricsQuery getNetricsQlt​(java.lang.String[] values)
        Description copied from interface: Querylet
        Constructs a NetricsQuery querylet from the stored XML structure and the given field values. The NetricsQuery can then be used to obtain a feature score from the Patterns server. The querylet must use symmetric score type (if it is supported by the NetricsQuery type that it constructs).
        Parameters:
        values - - The values of all non-key fields in the record. The index of the field value to be used is determined by the field name that is read from the list of all fields stored in XML querylet structure.
        Returns:
        the constructed NetricsQuery querylet.
        Throws:
        java.lang.IllegalArgumentException - if incorrect number of table field values is provided.
      • getFieldNames

        public java.util.List<java.lang.String> getFieldNames()
        Returns:
        a list with names of all fields used in the querylet.
      • asJavaCode

        public java.lang.String asJavaCode​(java.lang.String qltVarName,
                                           java.lang.String valuesVarName,
                                           java.lang.String fieldNamesVarName)
        Description copied from interface: Querylet
        Converts the querylet to a Java code string. Parameters are variable names in Java code. The new querylet must be assigned to qltVarName, then additional Java statements can be added to configure the querylet. The generated querylet must use symmetric score type (if it is supported by the NetricsQuery type that it constructs).
        Parameters:
        qltVarName - - the name of the variable to which the querylet is assigned.
        valuesVarName - - name of variable of type String[] that stores field values.
        fieldNamesVarName - - name of variable of type List<String> that stores all field names in the data table.
        Returns:
        a string with Java code that creates the given querylet.
      • setFieldWeight

        public void setFieldWeight​(int fieldIndex,
                                   double weight)
        Description copied from class: TextQlt
        Sets the weight of the given field.
        Specified by:
        setFieldWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Parameters:
        fieldIndex - - index of the field in the list of fields assigned to this querylet.
        weight - - the new field weight.
      • getFieldWeight

        public double getFieldWeight​(int fieldIndex)
        Specified by:
        getFieldWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Parameters:
        fieldIndex - - index of the field in the list of fields assigned to this querylet.
        Returns:
        the weight of the given field.
      • setMatchEmpty

        public void setMatchEmpty​(boolean value)
        Description copied from class: TextQlt
        Sets the Match Empty parameter. If this is true, matching two empty strings results in an exact match score. If false (default), this results in an empty score.
        Specified by:
        setMatchEmpty in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Parameters:
        value - - the value of the Match Empty parameter.
      • isMatchEmpty

        public java.lang.Boolean isMatchEmpty()
        Specified by:
        isMatchEmpty in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Returns:
        the Match Empty parameter, or null if it was not set and the default is used.
        See Also:
        TextQlt.setMatchEmpty(boolean)
      • hasThesaurus

        public boolean hasThesaurus()
        Specified by:
        hasThesaurus in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Returns:
        true if thesaurus has been assigned to this querylet.
      • getThesaurusName

        public java.lang.String getThesaurusName()
        Specified by:
        getThesaurusName in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Returns:
        thesaurus name, or null if thesaurus is not assigned
      • getThesaurusWeight

        public double getThesaurusWeight()
        Specified by:
        getThesaurusWeight in class TextQlt<com.tibco.patterns.learn.jaxb.model.SimpleQueryType>
        Returns:
        thesaurus weight, or default weight if thesaurus is not assigned. getThesaurusName() should be used first to check if the thesaurus is assigned.