Skip to content

Commit 4f2527a

Browse files
committed
[refactor] reformat code
1 parent 4f10647 commit 4f2527a

15 files changed

+593
-609
lines changed

exist-core/src/main/java/org/exist/validation/GrammarPool.java

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -30,108 +30,107 @@
3030
import org.exist.Namespaces;
3131

3232
/**
33-
* Wrapper around the Xerces XMLGrammarPoolImpl, so debugging of
33+
* Wrapper around the Xerces XMLGrammarPoolImpl, so debugging of
3434
* actions can be monitored. Javadoc copied from xml.apache.org.
3535
*
3636
* @author Dannes Wessels ([email protected])
37-
*
3837
* @see org.apache.xerces.xni.grammars.XMLGrammarPool
3938
* @see org.apache.xerces.util.XMLGrammarPoolImpl
4039
* @see org.apache.xerces.xni.grammars.Grammar
4140
* @see org.apache.xerces.xni.grammars.XMLGrammarDescription
4241
*/
4342
public class GrammarPool implements XMLGrammarPool {
44-
43+
4544
private final static Logger logger = LogManager.getLogger(GrammarPool.class);
46-
45+
4746
private final XMLGrammarPool pool;
48-
47+
4948
/**
50-
* Constructs a grammar pool with a default number of buckets.
49+
* Constructs a grammar pool with a default number of buckets.
5150
*/
5251
public GrammarPool() {
53-
if (logger.isInfoEnabled())
54-
{logger.info("Initializing GrammarPool.");}
52+
if (logger.isInfoEnabled()) {
53+
logger.info("Initializing GrammarPool.");
54+
}
5555
pool = new XMLGrammarPoolImpl();
5656
}
57-
58-
/**
57+
58+
/**
5959
* Constructs a grammar pool with a default number of buckets using pool.
60-
*
60+
*
6161
* @param pool The supplied grammar pool is reused.
6262
*/
63-
public GrammarPool(XMLGrammarPool pool) {
64-
if (logger.isInfoEnabled())
65-
{logger.info("Initializing GrammarPool using supplied pool.");}
66-
this.pool=pool;
63+
public GrammarPool(final XMLGrammarPool pool) {
64+
if (logger.isInfoEnabled()) {
65+
logger.info("Initializing GrammarPool using supplied pool.");
66+
}
67+
this.pool = pool;
6768
}
68-
69+
6970
/**
70-
* Retrieve the initial known set of grammars. this method is called
71-
* by a validator before the validation starts. the application can provide
71+
* Retrieve the initial known set of grammars. this method is called
72+
* by a validator before the validation starts. the application can provide
7273
* an initial set of grammars available to the current validation attempt.
7374
*
75+
* @param type The type of the grammar, from the
76+
* org.apache.xerces.xni.grammars.Grammar interface.
77+
* @return The set of grammars the validator may put in its "bucket"
7478
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#retrieveInitialGrammarSet(String)
75-
*
76-
* @param type The type of the grammar, from the
77-
* org.apache.xerces.xni.grammars.Grammar interface.
78-
* @return The set of grammars the validator may put in its "bucket"
7979
*/
80-
public Grammar[] retrieveInitialGrammarSet(String type) {
81-
if (logger.isDebugEnabled())
82-
{
83-
logger.debug("Retrieve initial grammarset ({}).", type);}
84-
80+
public Grammar[] retrieveInitialGrammarSet(final String type) {
81+
if (logger.isDebugEnabled()) {
82+
logger.debug("Retrieve initial grammarset ({}).", type);
83+
}
84+
8585
final Grammar[] grammars = pool.retrieveInitialGrammarSet(type);
86-
if (logger.isDebugEnabled())
87-
{
88-
logger.debug("Found {} grammars.", grammars.length);}
86+
if (logger.isDebugEnabled()) {
87+
logger.debug("Found {} grammars.", grammars.length);
88+
}
8989
return grammars;
9090
}
91-
91+
9292
/**
93-
* Return the final set of grammars that the validator ended up with.
93+
* Return the final set of grammars that the validator ended up with.
9494
*
95-
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#cacheGrammars(String,Grammar[])
96-
*
97-
* @param type The type of the grammars being returned
98-
* @param grammar an array containing the set of grammars being
99-
* returned; order is not significant.
95+
* @param type The type of the grammars being returned
96+
* @param grammar an array containing the set of grammars being
97+
* returned; order is not significant.
98+
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#cacheGrammars(String, Grammar[])
10099
*/
101-
public void cacheGrammars(String type, Grammar[] grammar) {
102-
if (logger.isDebugEnabled())
103-
{
104-
logger.debug("Cache {} grammars ({}).", grammar.length, type);}
100+
public void cacheGrammars(final String type, final Grammar[] grammar) {
101+
if (logger.isDebugEnabled()) {
102+
logger.debug("Cache {} grammars ({}).", grammar.length, type);
103+
}
105104
pool.cacheGrammars(type, grammar);
106105
}
107-
106+
108107
/**
109-
* Allows the XMLGrammarPool to store grammars when its
110-
* cacheGrammars(String, Grammar[]) method is called. This is the default
108+
* Allows the XMLGrammarPool to store grammars when its
109+
* cacheGrammars(String, Grammar[]) method is called. This is the default
111110
* state of the object.
112111
*
113112
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#unlockPool
114113
*/
115114
public void unlockPool() {
116-
if (logger.isDebugEnabled())
117-
{logger.debug("Unlock grammarpool.");}
115+
if (logger.isDebugEnabled()) {
116+
logger.debug("Unlock grammarpool.");
117+
}
118118
pool.unlockPool();
119119
}
120-
120+
121121
/**
122-
* This method requests that the application retrieve a grammar
123-
* corresponding to the given GrammarIdentifier from its cache. If it
124-
* cannot do so it must return null; the parser will then call the
125-
* EntityResolver. An application must not call its EntityResolver itself
122+
* This method requests that the application retrieve a grammar
123+
* corresponding to the given GrammarIdentifier from its cache. If it
124+
* cannot do so it must return null; the parser will then call the
125+
* EntityResolver. An application must not call its EntityResolver itself
126126
* from this method; this may result in infinite recursions.
127127
*
128+
* @param xgd The description of the Grammar being requested.
129+
* @return the Grammar corresponding to this description or null
130+
* if no such Grammar is known.
128131
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#retrieveGrammar(XMLGrammarDescription)
129-
*
130-
* @param xgd The description of the Grammar being requested.
131-
* @return the Grammar corresponding to this description or null
132-
* if no such Grammar is known.
133132
*/
134-
public Grammar retrieveGrammar(XMLGrammarDescription xgd) {
133+
public Grammar retrieveGrammar(final XMLGrammarDescription xgd) {
135134

136135
if (xgd == null) {
137136
if (logger.isDebugEnabled()) {
@@ -154,53 +153,55 @@ public Grammar retrieveGrammar(XMLGrammarDescription xgd) {
154153

155154
return pool.retrieveGrammar(xgd);
156155
}
157-
156+
158157
/**
159-
* Causes the XMLGrammarPool not to store any grammars when the
158+
* Causes the XMLGrammarPool not to store any grammars when the
160159
* cacheGrammars(String, Grammar[[]) method is called.
161160
*
162161
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#lockPool
163162
*/
164163
public void lockPool() {
165-
if (logger.isDebugEnabled())
166-
{logger.debug("Lock grammarpool.");}
164+
if (logger.isDebugEnabled()) {
165+
logger.debug("Lock grammarpool.");
166+
}
167167
pool.lockPool();
168168
}
169-
169+
170170
/**
171-
* Removes all grammars from the pool.
171+
* Removes all grammars from the pool.
172172
*
173173
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#clear
174174
*/
175175
public void clear() {
176-
if (logger.isDebugEnabled())
177-
{logger.debug("Clear grammarpool.");}
176+
if (logger.isDebugEnabled()) {
177+
logger.debug("Clear grammarpool.");
178+
}
178179
pool.clear();
179180
}
180-
181+
181182
/**
182-
* Removes all DTD grammars from the pool. Workaround for Xerces bug.
183+
* Removes all DTD grammars from the pool. Workaround for Xerces bug.
183184
*
184185
* @see org.apache.xerces.xni.grammars.XMLGrammarPool#clear
185186
*/
186187
public void clearDTDs() {
187188
//if (logger.isDebugEnabled())
188189
// logger.debug("Removing DTD's from grammarpool.");
189190

190-
final Grammar dtds[] = retrieveInitialGrammarSet(Namespaces.DTD_NS);
191+
final Grammar[] dtds = retrieveInitialGrammarSet(Namespaces.DTD_NS);
191192
if (dtds.length > 0) {
192193
if (logger.isDebugEnabled()) {
193194
logger.debug("Removing {} DTDs.", dtds.length);
194195
}
195-
final Grammar schemas[] = retrieveInitialGrammarSet(Namespaces.SCHEMA_NS);
196+
final Grammar[] schemas = retrieveInitialGrammarSet(Namespaces.SCHEMA_NS);
196197
clear();
197198
cacheGrammars(Namespaces.SCHEMA_NS, schemas);
198-
199+
199200
} else {
200201
//if (logger.isDebugEnabled())
201202
// logger.debug("No DTDs to be removed.");
202203
}
203204
}
204-
205-
205+
206+
206207
}

exist-core/src/main/java/org/exist/validation/ValidationContentHandler.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,36 @@
2727
import org.xml.sax.helpers.DefaultHandler;
2828

2929
/**
30-
* Simple contenthandler to determine the NamespaceUri of
30+
* Simple contenthandler to determine the NamespaceUri of
3131
* the document root node.
32-
*
32+
*
3333
* @author Dannes Wessels
3434
*/
3535
public class ValidationContentHandler extends DefaultHandler {
3636

3737
private boolean isFirstElement = true;
3838
private String namespaceUri = null;
39-
40-
39+
40+
4141
/**
42-
* @see org.xml.sax.helpers.DefaultHandler#startElement(String,String,String,Attributes)
42+
* @see org.xml.sax.helpers.DefaultHandler#startElement(String, String, String, Attributes)
4343
*/
4444
@Override
45-
public void startElement(String uri, String localName, String qName,
46-
Attributes attributes) throws SAXException {
47-
48-
if(isFirstElement){
49-
namespaceUri=uri;
50-
isFirstElement=false;
45+
public void startElement(final String uri, final String localName, final String qName,
46+
final Attributes attributes) throws SAXException {
47+
48+
if (isFirstElement) {
49+
namespaceUri = uri;
50+
isFirstElement = false;
5151
}
5252
}
53-
53+
5454
/**
55-
* Get namespace of root element. To be used for reporting.
56-
*
55+
* Get namespace of root element. To be used for reporting.
56+
*
5757
* @return Namespace of root element.
5858
*/
59-
public String getNamespaceUri(){
59+
public String getNamespaceUri() {
6060
return namespaceUri;
6161
}
6262
}

0 commit comments

Comments
 (0)