Split Restconf implementations (draft02 and RFC) - move
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / utils / parser / builder / ParserBuilderConstants.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.utils.parser.builder;
9
10 import com.google.common.base.CharMatcher;
11 import java.util.Arrays;
12 import org.opendaylight.restconf.parser.builder.YangInstanceIdentifierDeserializer;
13 import org.opendaylight.restconf.parser.builder.YangInstanceIdentifierSerializer;
14
15 /**
16  * Util class of constants of {@link YangInstanceIdentifierSerializer} and
17  * {@link YangInstanceIdentifierDeserializer}.
18  *
19  * @deprecated move to splitted module restconf-nb-rfc8040
20  */
21 @Deprecated
22 public final class ParserBuilderConstants {
23
24     private ParserBuilderConstants() {
25         throw new UnsupportedOperationException("Util class");
26     }
27
28     /**
29      * Constants for {@link YangInstanceIdentifierSerializer}.
30      *
31      */
32     public static final class Serializer {
33
34         private Serializer() {
35             throw new UnsupportedOperationException("Util class");
36         }
37
38         public static final String DISABLED_CHARS = Arrays.toString(new char[] { ':', '/', '?', '#', '[', ']', '@' })
39                 .concat(Arrays.toString(new char[] { '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' }));
40
41         public static final CharMatcher PERCENT_ENCODE_CHARS = CharMatcher.anyOf(DISABLED_CHARS).precomputed();
42     }
43
44     /**
45      * Constants for {@link YangInstanceIdentifierSerializer}.
46      *
47      */
48     public static final class Deserializer {
49
50         private Deserializer() {
51             throw new UnsupportedOperationException("Util class");
52         }
53
54         public static final CharMatcher BASE = CharMatcher.inRange('a', 'z').or(CharMatcher.inRange('A', 'Z'))
55                 .precomputed();
56
57         public static final CharMatcher IDENTIFIER_FIRST_CHAR = BASE.or(CharMatcher.is('_')).precomputed();
58
59         public static final CharMatcher IDENTIFIER = IDENTIFIER_FIRST_CHAR.or(CharMatcher.inRange('0', '9'))
60                 .or(CharMatcher.anyOf(".-")).precomputed();
61
62         public static final CharMatcher IDENTIFIER_HEXA = CharMatcher.inRange('a', 'f')
63                 .or(CharMatcher.inRange('A', 'F')).or(CharMatcher.inRange('0', '9')).precomputed();
64
65         public static final char COLON = ':';
66         public static final char EQUAL = '=';
67         public static final char COMMA = ',';
68         public static final char HYPHEN = '-';
69         public static final char PERCENT_ENCODING = '%';
70
71         public static final CharMatcher IDENTIFIER_PREDICATE = CharMatcher.noneOf(
72                 Serializer.DISABLED_CHARS).precomputed();
73
74         public static final String EMPTY_STRING = "";
75
76         // position of the first encoded char after percent sign in percent encoded string
77         public static final int FIRST_ENCODED_CHAR = 1;
78         // position of the last encoded char after percent sign in percent encoded string
79         public static final int LAST_ENCODED_CHAR = 3;
80         // percent encoded radix for parsing integers
81         public static final int PERCENT_ENCODED_RADIX = 16;
82     }
83 }