1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema.parsers;
21
22
23 import java.text.ParseException;
24
25 import org.apache.directory.api.i18n.I18n;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import antlr.RecognitionException;
30 import antlr.TokenStreamException;
31
32
33
34
35
36
37
38 public class LdapComparatorDescriptionSchemaParser extends AbstractSchemaParser
39 {
40
41 protected static final Logger LOG = LoggerFactory.getLogger( LdapComparatorDescriptionSchemaParser.class );
42
43
44
45
46
47 public LdapComparatorDescriptionSchemaParser()
48 {
49 super();
50 }
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 public LdapComparatorDescription parseComparatorDescription( String comparatorDescription )
78 throws ParseException
79 {
80 LOG.debug( "Parsing a Comparator : {}", comparatorDescription );
81
82 if ( comparatorDescription == null )
83 {
84 LOG.error( I18n.err( I18n.ERR_04236 ) );
85 throw new ParseException( "Null", 0 );
86 }
87
88 synchronized ( parser )
89 {
90 reset( comparatorDescription );
91
92 try
93 {
94 LdapComparatorDescription ldapComparatorDescription = parser.ldapComparator();
95 LOG.debug( "Parsed a LdapComparator : {}", ldapComparatorDescription );
96
97
98 updateSchemaName( ldapComparatorDescription );
99
100 return ldapComparatorDescription;
101 }
102 catch ( RecognitionException re )
103 {
104 String msg = I18n.err( I18n.ERR_04273, comparatorDescription, re.getMessage(), re.getColumn() );
105 LOG.error( msg );
106 throw new ParseException( msg, re.getColumn() );
107 }
108 catch ( TokenStreamException tse )
109 {
110 String msg = I18n.err( I18n.ERR_04238, comparatorDescription, tse.getMessage() );
111 LOG.error( msg );
112 throw new ParseException( msg, 0 );
113 }
114 }
115 }
116
117
118
119
120
121
122
123
124
125 public LdapComparatorDescription parse( String schemaDescription ) throws ParseException
126 {
127 return parseComparatorDescription( schemaDescription );
128 }
129 }