Package org.dspace.app.rest.model.query
Enum RestSearchOperator
- java.lang.Object
-
- java.lang.Enum<RestSearchOperator>
-
- org.dspace.app.rest.model.query.RestSearchOperator
-
- All Implemented Interfaces:
Serializable,Comparable<RestSearchOperator>
public enum RestSearchOperator extends Enum<RestSearchOperator>
This enum defines the different operators that can be used with DSpace They've been given a regex and the string value of the operator that is used within DSpace. The purpose of this class is so that the front-end can use these specifications to send queries using just a search String as defined by the regexes instead of having to pass on the String value of the operator separately.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTHORITYThe authority operator can be used by adding an id: infront of the search query It then becomes id:VALUE to call for a search on the authority operator for VALUECONTAINSThe contains operator can be used by adding a * behind the search query It then becomes VALUE* to call for a search on the contains operator for VALUEEQUALSThe equals operator is default and will be used if none of the above are matchedNOTAUTHORITYThe notauthority operator can be used by adding a -id: infront of the search query It then becomes -id:VALUE to call for a search on the notauthority operator for VALUENOTCONTAINSThe notcontains operator can be used by adding a - (minus) infront of the search query and a * at the end It then becomes -VALUE* to call for a search on the notcontains operator for VALUENOTEQUALSThe notequals operator can be used by adding a - infront of the search query It then becomes -VALUE to call for a search on the notequals operator for VALUE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringextractValue(String query)This method extracts the value from the query.static RestSearchOperatorforQuery(String query)This method will return the correct RestSearchOperator that's bound to the query given in the parameter.StringgetDspaceOperator()static List<String>getListOfAllowedSearchOperatorStrings()Returns a list of dspace operators of this enum's values, plus "query" which is also allowed, but will be transformed inSearchQueryConverterto any of the othersPatterngetRegex()static RestSearchOperatorvalueOf(String name)Returns the enum constant of this type with the specified name.static RestSearchOperator[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NOTCONTAINS
public static final RestSearchOperator NOTCONTAINS
The notcontains operator can be used by adding a - (minus) infront of the search query and a * at the end It then becomes -VALUE* to call for a search on the notcontains operator for VALUE
-
NOTAUTHORITY
public static final RestSearchOperator NOTAUTHORITY
The notauthority operator can be used by adding a -id: infront of the search query It then becomes -id:VALUE to call for a search on the notauthority operator for VALUE
-
NOTEQUALS
public static final RestSearchOperator NOTEQUALS
The notequals operator can be used by adding a - infront of the search query It then becomes -VALUE to call for a search on the notequals operator for VALUE
-
CONTAINS
public static final RestSearchOperator CONTAINS
The contains operator can be used by adding a * behind the search query It then becomes VALUE* to call for a search on the contains operator for VALUE
-
AUTHORITY
public static final RestSearchOperator AUTHORITY
The authority operator can be used by adding an id: infront of the search query It then becomes id:VALUE to call for a search on the authority operator for VALUE
-
EQUALS
public static final RestSearchOperator EQUALS
The equals operator is default and will be used if none of the above are matched
-
-
Method Detail
-
values
public static RestSearchOperator[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RestSearchOperator c : RestSearchOperator.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RestSearchOperator valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
extractValue
public String extractValue(String query)
This method extracts the value from the query. It effectively removes the operator parts and returns only the VALUE- Parameters:
query- The full query that was used- Returns:
- The value that was passed along in the query without the search operator logic
-
forQuery
public static RestSearchOperator forQuery(String query)
This method will return the correct RestSearchOperator that's bound to the query given in the parameter. This method will check if the query matches the patterns specified above.- Parameters:
query- The query for which we'll return the appropriate RestSearchOperator- Returns:
- The RestSearchOperator that matches with the query
-
getRegex
public Pattern getRegex()
-
getDspaceOperator
public String getDspaceOperator()
-
getListOfAllowedSearchOperatorStrings
public static List<String> getListOfAllowedSearchOperatorStrings()
Returns a list of dspace operators of this enum's values, plus "query" which is also allowed, but will be transformed inSearchQueryConverterto any of the others- Returns:
- List of dspace operators of this enum's values, plus "query"
-
-