Changeset 7162 for FCSSimpleEndpoint


Ignore:
Timestamp:
01/17/18 15:44:00 (6 years ago)
Author:
Oliver Schonefeld
Message:
  • add some convenience helper methods
Location:
FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/parser/Expression.java

    r7057 r7162  
    7676
    7777    /**
    78      * Get the layer identifier qualifier.
    79      *
    80      * @return the layer identifier qualifier or <code>null</code> if none
     78     * Check if the expression used a given <em>Layer Type Identifier</em>.
     79     *
     80     * @param identifier
     81     *            the Layer Type Identifier to check against
     82     * @return <code>true</code> if this identifier was used, <code>false</code>
     83     *         otherwise
     84     */
     85    public boolean hasLayerIdentifier(String identifier) {
     86        if (identifier == null) {
     87            throw new NullPointerException("identifier == null");
     88        }
     89        return this.identifier.equals(identifier);
     90    }
     91
     92
     93    /**
     94     * Get the Layer Type Identifier qualifier.
     95     *
     96     * @return the Layer Type Identifier qualifier or <code>null</code> if none
     97     *         was used in this expression
    8198     */
    8299    public String getLayerQualifier() {
     
    86103
    87104    /**
     105     * Check if the Layer Type Identifier qualifier is empty.
     106     *
     107     * @return <code>true</code> if no Layer Type Identifier qualifier was set,
     108     *         <code>false</code> otherwise
     109     */
     110    public boolean isLayerQualifierEmpty() {
     111        return (qualifier == null);
     112    }
     113
     114
     115    /**
     116     * Check if the expression used a given qualifier for the Layer Type
     117     * Identifier.
     118     *
     119     * @param qualifier
     120     *            the qualifier to check against
     121     * @return <code>true</code> if this identifier was used, <code>false</code>
     122     *         otherwise
     123     */
     124    public boolean hasLayerQualifier(String qualifier) {
     125        if (qualifier == null) {
     126            throw new NullPointerException("qualifier == null");
     127        }
     128        if (this.qualifier != null) {
     129            return this.qualifier.equals(qualifier);
     130        } else {
     131            return false;
     132        }
     133    }
     134
     135
     136    /**
    88137     * Get the operator.
    89138     *
     
    96145
    97146    /**
     147     * Check if expression used a given operator.
     148     *
     149     * @param operator
     150     *            the operator to check
     151     * @return <code>true</code> if the given operator was used,
     152     *         <code>false</code> otherwise
     153     */
     154    public boolean hasOperator(Operator operator) {
     155        if (operator == null) {
     156            throw new NullPointerException("operator == null");
     157        }
     158        return this.operator == operator;
     159    }
     160
     161
     162    /**
    98163     * Get the regex value.
    99164     *
     
    108173     * Get the regex flags set.
    109174     *
    110      * @return the regex flags set or <code>null</code> if none
     175     * @return the regex flags set or <code>null</code> if no flags were used
     176     *         in this expression
    111177     */
    112178    public Set<RegexFlag> getRegexFlags() {
    113179        return regex_flags;
     180    }
     181
     182
     183    /**
     184     * Check if a regex flag set is empty.
     185     *
     186     * @return <code>true</code> if no regex flags where set, <code>false</code>
     187     *         otherwise
     188     */
     189    public boolean isRegexFlagsEmpty() {
     190        return (regex_flags == null);
     191    }
     192
     193
     194    /**
     195     * Check if a regex flag is set.
     196     *
     197     * @param flag
     198     *            the flag to be checked
     199     * @return <code>true</code> if the flag is set, <code>false</code>
     200     *         otherwise
     201     */
     202    public boolean hasRegexFlag(RegexFlag flag) {
     203        if (flag == null) {
     204            throw new NullPointerException("flag == null");
     205        }
     206        if (regex_flags != null) {
     207            return regex_flags.contains(flag);
     208        } else {
     209            return false;
     210        }
    114211    }
    115212
  • FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/parser/QueryNode.java

    r7159 r7162  
    9090    public QueryNodeType getNodeType() {
    9191        return nodeType;
     92    }
     93
     94
     95    /**
     96     * Check, if node if of given type.
     97     *
     98     * @param nodeType
     99     *            type to check against
     100     * @return <code>true</code> if node is of given type, <code>false</code>
     101     *         otherwise
     102     */
     103    public boolean hasNodeType(QueryNodeType nodeType) {
     104        if (nodeType == null) {
     105            throw new NullPointerException("nodeType == null");
     106        }
     107        return this.nodeType == nodeType;
    92108    }
    93109
Note: See TracChangeset for help on using the changeset viewer.