|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.queryParser.ext.Extensions
public class Extensions
The Extensions
class represents an extension mapping to associate
ParserExtension
instances with extension keys. An extension key is a
string encoded into a Lucene standard query parser field symbol recognized by
ExtendableQueryParser
. The query parser passes each extension field
token to splitExtensionField(String, String)
to separate the
extension key from the field identifier.
In addition to the key to extension mapping this class also defines the field
name overloading scheme. ExtendableQueryParser
uses the given
extension to split the actual field name and extension key by calling
splitExtensionField(String, String)
. To change the order or the key
/ field name encoding scheme users can subclass Extensions
to
implement their own.
ExtendableQueryParser
,
ParserExtension
Nested Class Summary | |
---|---|
static class |
Extensions.Pair<Cur,Cud>
This class represents a generic pair. |
Field Summary | |
---|---|
static char |
DEFAULT_EXTENSION_FIELD_DELIMITER
The default extension field delimiter character. |
Constructor Summary | |
---|---|
Extensions()
Creates a new Extensions instance with the
DEFAULT_EXTENSION_FIELD_DELIMITER as a delimiter character. |
|
Extensions(char extensionFieldDelimiter)
Creates a new Extensions instance |
Method Summary | |
---|---|
void |
add(String key,
ParserExtension extension)
Adds a new ParserExtension instance associated with the given key. |
String |
buildExtensionField(String extensionKey)
Builds an extension field string from a given extension key and the default query field. |
String |
buildExtensionField(String extensionKey,
String field)
Builds an extension field string from a given extension key and the extensions field. |
String |
escapeExtensionField(String extfield)
Escapes an extension field. |
ParserExtension |
getExtension(String key)
Returns the ParserExtension instance for the given key or
null if no extension can be found for the key. |
char |
getExtensionFieldDelimiter()
Returns the extension field delimiter |
Extensions.Pair<String,String> |
splitExtensionField(String defaultField,
String field)
Splits a extension field and returns the field / extension part as a Extensions.Pair . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_EXTENSION_FIELD_DELIMITER
Constructor Detail |
---|
public Extensions()
Extensions
instance with the
DEFAULT_EXTENSION_FIELD_DELIMITER
as a delimiter character.
public Extensions(char extensionFieldDelimiter)
Extensions
instance
extensionFieldDelimiter
- the extensions field delimiter characterMethod Detail |
---|
public void add(String key, ParserExtension extension)
ParserExtension
instance associated with the given key.
key
- the parser extension keyextension
- the parser extensionpublic final ParserExtension getExtension(String key)
ParserExtension
instance for the given key or
null
if no extension can be found for the key.
key
- the extension key
ParserExtension
instance for the given key or
null
if no extension can be found for the key.public char getExtensionFieldDelimiter()
public Extensions.Pair<String,String> splitExtensionField(String defaultField, String field)
Extensions.Pair
. This method tries to split on the first occurrence of the
extension field delimiter, if the delimiter is not present in the string
the result will contain a null
value for the extension key and
the given field string as the field value. If the given extension field
string contains no field identifier the result pair will carry the given
default field as the field value.
defaultField
- the default query fieldfield
- the extension field string
Extensions.Pair
with the field name as the Extensions.Pair.cur
and the
extension key as the Extensions.Pair.cud
public String escapeExtensionField(String extfield)
QueryParser.escape(String)
.
extfield
- the extension field identifier
public String buildExtensionField(String extensionKey)
Note: Extensions
subclasses must maintain the contract between
buildExtensionField(String)
and
splitExtensionField(String, String)
where the latter inverts the
former.
public String buildExtensionField(String extensionKey, String field)
Note: Extensions
subclasses must maintain the contract between
buildExtensionField(String, String)
and
splitExtensionField(String, String)
where the latter inverts the
former.
extensionKey
- the extension keyfield
- the field to apply the extension on.
to use the default query field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |