/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.xwiki.model.internal.reference;

import java.util.HashMap;
import java.util.Map;

import org.xwiki.model.EntityType;

/**
 * Define string separators for string reference serializer and resolver.
 *
 * @version $Id$
 * @since 3.3M2
 */
final class StringReferenceSeparators
{
    /**
     * A backslash string.
     */
    static final char CESCAPE = '\\';

    /**
      * A colon string. Colon is used to separate wiki name.
      */
    static final char CWIKISEP = ':';

    /**
     * A dot string. Dot is used to separate space names and document name.
     */
    static final char CSPACESEP = '.';

    /**
     * An at-sign string. At sign is used to separate attachment name.
     */
    static final char CATTACHMENTSEP = '@';

    /**
     * An hat sign string. Hat sign is used to separate object name.
     */
    static final char COBJECTSEP = '^';

    /**
     * An dot is used to separate object property name.
     */
    static final char CPROPERTYSEP = CSPACESEP;

    /**
     * An hat sign is used to separate class name.
     */
    static final char CCLASSPROPSEP = COBJECTSEP;

    /**
     * A backslash string.
     */
    static final String ESCAPE = Character.toString(CESCAPE);

    /**
     * A double backslash string.
     */
    static final String DBLESCAPE = ESCAPE + ESCAPE;

    /**
      * A colon string. Colon is used to separate wiki name.
      */
    static final String WIKISEP = Character.toString(CWIKISEP);

    /**
     * A dot string. Dot is used to separate space names and document name.
     */
    static final String SPACESEP = Character.toString(CSPACESEP);

    /**
     * An at-sign string. At sign is used to separate attachment name.
     */
    static final String ATTACHMENTSEP = Character.toString(CATTACHMENTSEP);

    /**
     * An hat sign string. Hat sign is used to separate object name.
     */
    static final String OBJECTSEP = Character.toString(COBJECTSEP);

    /**
     * An dot is used to separate object property name.
     */
    static final String PROPERTYSEP = Character.toString(CPROPERTYSEP);

    /**
     * An hat sign is used to separate class property name.
     */
    static final String CLASSPROPSEP = Character.toString(CCLASSPROPSEP);

    /**
     * The list of strings to escape for each type of entity.
     */
    static final Map<EntityType, String[]> ESCAPES = new HashMap<EntityType, String[]>()
    {
        {
            put(EntityType.ATTACHMENT, new String[] {ATTACHMENTSEP, ESCAPE});
            put(EntityType.DOCUMENT, new String[] {SPACESEP, ESCAPE});
            put(EntityType.SPACE, new String[] {SPACESEP, WIKISEP, ESCAPE});
            put(EntityType.OBJECT, new String[] {OBJECTSEP, ESCAPE});
            put(EntityType.OBJECT_PROPERTY, new String[] {PROPERTYSEP, ESCAPE});
            put(EntityType.CLASS_PROPERTY, new String[] {CLASSPROPSEP, SPACESEP, ESCAPE});
        }
    };

    /**
     * The replacement list corresponding to the list in {@link #ESCAPES} map.
     */
    static final Map<EntityType, String[]> REPLACEMENTS = new HashMap<EntityType, String[]>()
    {
        {
            put(EntityType.ATTACHMENT, new String[] {ESCAPE + ATTACHMENTSEP, DBLESCAPE});
            put(EntityType.DOCUMENT, new String[] {ESCAPE + SPACESEP, DBLESCAPE});
            put(EntityType.SPACE, new String[] {ESCAPE + SPACESEP, ESCAPE + WIKISEP, DBLESCAPE});
            put(EntityType.OBJECT, new String[] {ESCAPE + OBJECTSEP, DBLESCAPE});
            put(EntityType.OBJECT_PROPERTY, new String[] {ESCAPE + PROPERTYSEP, DBLESCAPE});
            put(EntityType.CLASS_PROPERTY, new String[] {ESCAPE + CLASSPROPSEP, ESCAPE + SPACESEP, DBLESCAPE});
        }
    };

    /**
     * Map defining syntax separators for each type of reference.
     */
    static final Map<EntityType, char[]> SEPARATORS = new HashMap<EntityType, char[]>()
    {
        {
            put(EntityType.DOCUMENT, new char[] {CSPACESEP, CWIKISEP});
            put(EntityType.ATTACHMENT, new char[] {CATTACHMENTSEP, CSPACESEP, CWIKISEP});
            put(EntityType.SPACE, new char[] {CWIKISEP});
            put(EntityType.OBJECT, new char[] {COBJECTSEP, CSPACESEP, CWIKISEP});
            put(EntityType.OBJECT_PROPERTY, new char[] {CPROPERTYSEP, COBJECTSEP, CSPACESEP, CWIKISEP});
            put(EntityType.CLASS_PROPERTY, new char[] {CCLASSPROPSEP, CSPACESEP, CWIKISEP});
        }
    };

    /**
     * Utility class, never create an instance.
     */
    private StringReferenceSeparators() { }
}

@@ -1140,19 +1140,18 @@
  */%0A
-final class
+%0Ainterface
  Str
@@ -1218,37 +1218,24 @@
      */%0A    
-static final 
 char CESCAPE
@@ -1322,37 +1322,24 @@
      */%0A    
-static final 
 char CWIKISE
@@ -1440,37 +1440,24 @@
      */%0A    
-static final 
 char CSPACES
@@ -1554,37 +1554,24 @@
      */%0A    
-static final 
 char CATTACH
@@ -1671,37 +1671,24 @@
      */%0A    
-static final 
 char COBJECT
@@ -1771,37 +1771,24 @@
      */%0A    
-static final 
 char CPROPER
@@ -1878,29 +1878,16 @@
  */%0A    
-static final 
 char CCL
@@ -1955,36 +1955,24 @@
      */%0A    
-static final
  String ESCA
@@ -2056,37 +2056,24 @@
      */%0A    
-static final 
 String DBLES
@@ -2175,37 +2175,24 @@
      */%0A    
-static final 
 String WIKIS
@@ -2319,37 +2319,24 @@
      */%0A    
-static final 
 String SPACE
@@ -2460,37 +2460,24 @@
      */%0A    
-static final 
 String ATTAC
@@ -2609,37 +2609,24 @@
      */%0A    
-static final 
 String OBJEC
@@ -2737,37 +2737,24 @@
      */%0A    
-static final 
 String PROPE
@@ -2877,29 +2877,16 @@
  */%0A    
-static final 
 String C
@@ -3013,37 +3013,24 @@
      */%0A    
-static final 
 Map%3CEntityTy
@@ -3686,37 +3686,24 @@
      */%0A    
-static final 
 Map%3CEntityTy
@@ -4449,21 +4449,8 @@
     
-static final 
 Map%3C
@@ -5052,116 +5052,7 @@
   %7D;
-%0A%0A    /**%0A     * Utility class, never create an instance.%0A     */%0A    private StringReferenceSeparators() %7B %7D
 %0A%7D%0A

improve codestyle