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.apache.directory.api.ldap.model.schema.DitStructureRule;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 import antlr.RecognitionException;
31 import antlr.TokenStreamException;
32
33
34
35
36
37
38
39 public class DitStructureRuleDescriptionSchemaParser extends AbstractSchemaParser
40 {
41
42 protected static final Logger LOG = LoggerFactory.getLogger( DitStructureRuleDescriptionSchemaParser.class );
43
44
45
46
47
48 public DitStructureRuleDescriptionSchemaParser()
49 {
50 super();
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 public synchronized DitStructureRule parseDITStructureRuleDescription( String ditStructureRuleDescription )
77 throws ParseException
78 {
79 LOG.debug( "Parsing a DitStructureRule : {}", ditStructureRuleDescription );
80
81 if ( ditStructureRuleDescription == null )
82 {
83 LOG.error( I18n.err( I18n.ERR_04233 ) );
84 throw new ParseException( "Null", 0 );
85 }
86
87 reset( ditStructureRuleDescription );
88
89 try
90 {
91 DitStructureRule ditStructureRule = parser.ditStructureRuleDescription();
92
93
94 updateSchemaName( ditStructureRule );
95
96 return ditStructureRule;
97 }
98 catch ( RecognitionException re )
99 {
100 String msg = I18n.err( I18n.ERR_04234, ditStructureRuleDescription, re.getMessage(), re.getColumn() );
101 LOG.error( msg );
102 throw new ParseException( msg, re.getColumn() );
103 }
104 catch ( TokenStreamException tse )
105 {
106 String msg = I18n.err( I18n.ERR_04235, ditStructureRuleDescription, tse.getMessage() );
107 LOG.error( msg );
108 throw new ParseException( msg, 0 );
109 }
110
111 }
112
113
114
115
116
117
118
119
120
121 public DitStructureRule parse( String schemaDescription ) throws ParseException
122 {
123 return parseDITStructureRuleDescription( schemaDescription );
124 }
125 }