1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.search.solr.internal.api

File SolrFieldNameEncoder.java

 

Code metrics

0
0
0
1
57
8
0
-
-
0
-

Classes

Class Line # Actions
SolrFieldNameEncoder 40 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.search.solr.internal.api;
21   
22    import org.xwiki.component.annotation.Role;
23   
24    /**
25    * Encodes and decodes Solr field names so that they can be used in various Solr components. This is needed because not
26    * all characters are allowed inside a field name. The Solr schema specifies this:
27    * <p>
28    * <blockquote>field names should consist of alphanumeric or underscore characters only and not start with a digit. This
29    * is not currently strictly enforced, but other field names will not have first class support from all components and
30    * back compatibility is not guaranteed. Names with both leading and trailing underscores (e.g. _version_) are
31    * reserved.</blockquote>
32    * <p>
33    * Note that the Solr query syntax supports escaping special characters using backslash, but only in the field value,
34    * not in the field name, so we still need to encode the names of dynamic fields we add (e.g. for XClass properties).
35    *
36    * @version $Id: dcba0a1c0a2e0b4c413a57b54c419a2521a7ba02 $
37    * @since 5.3RC1
38    */
39    @Role
 
40    public interface SolrFieldNameEncoder
41    {
42    /**
43    * Encodes the given string so that it can be used as a field name.
44    *
45    * @param fieldName the raw field name that needs to be encoded
46    * @return the encoded field name
47    */
48    String encode(String fieldName);
49   
50    /**
51    * Decodes the raw field name from the given string.
52    *
53    * @param fieldName the encoded field name
54    * @return the raw field name
55    */
56    String decode(String fieldName);
57    }