40
40
41
41
class SerializationParameters {
42
42
43
- static private class ParameterInfo {
43
+ private static class ParameterInfo {
44
44
final String defaultValue ;
45
45
final boolean hasMany ;
46
46
final List <Integer > types ;
@@ -84,26 +84,33 @@ static String asValue(final Sequence sequence, final String defaultValue) throws
84
84
}
85
85
}
86
86
87
+ static final String ABSENT = "absent" ;
88
+ static final String NONE = "none" ;
89
+ static final String YES = "yes" ;
90
+ static final String NO = "no" ;
91
+
92
+ static final String USE_CHARACTER_MAPS = "use-character-maps" ;
93
+
87
94
enum Param {
88
- ALLOW_DUPLICATE_NAMES (Type .BOOLEAN , "no" ),
89
- BYTE_ORDER_MARK (Type .BOOLEAN , "no" ),
95
+ ALLOW_DUPLICATE_NAMES (Type .BOOLEAN , NO ),
96
+ BYTE_ORDER_MARK (Type .BOOLEAN , NO ),
90
97
CDATA_SECTION_ELEMENTS (Type .QNAME , "()" , true ),
91
- DOCTYPE_PUBLIC (Type .STRING , "absent" ),
92
- DOCTYPE_SYSTEM (Type .STRING , "absent" ),
98
+ DOCTYPE_PUBLIC (Type .STRING , ABSENT ),
99
+ DOCTYPE_SYSTEM (Type .STRING , ABSENT ),
93
100
ENCODING (Type .STRING ,"utf-8" ),
94
- ESCAPE_URI_ATTRIBUTES (Type .BOOLEAN , "yes" ),
101
+ ESCAPE_URI_ATTRIBUTES (Type .BOOLEAN , YES ),
95
102
HTML_VERSION (Type .DECIMAL , "5" ),
96
- INCLUDE_CONTENT_TYPE (Type .BOOLEAN , "yes" ),
97
- INDENT (Type .BOOLEAN , "no" ),
98
- ITEM_SEPARATOR (Type .STRING , "absent" ),
103
+ INCLUDE_CONTENT_TYPE (Type .BOOLEAN , YES ),
104
+ INDENT (Type .BOOLEAN , NO ),
105
+ ITEM_SEPARATOR (Type .STRING , ABSENT ),
99
106
//JSON_NODE_OUTPUT_METHOD
100
107
MEDIA_TYPE (Type .STRING , "" ),
101
108
METHOD (Type .STRING , "xml" ),
102
- NORMALIZATION_FORM (Type .STRING , "none" ),
103
- OMIT_XML_DECLARATION (Type .BOOLEAN , "yes" ),
109
+ NORMALIZATION_FORM (Type .STRING , NONE ),
110
+ OMIT_XML_DECLARATION (Type .BOOLEAN , YES ),
104
111
STANDALONE (Type .BOOLEAN , "omit" ),
105
112
SUPPRESS_INDENTATION (Type .QNAME , "()" , true ),
106
- UNDECLARE_PREFIXES (Type .BOOLEAN , "no" ),
113
+ UNDECLARE_PREFIXES (Type .BOOLEAN , NO ),
107
114
USE_CHARACTER_MAPS (Type .MAP , "map{}" ),
108
115
VERSION (Type .STRING , "1.0" );
109
116
@@ -120,7 +127,7 @@ enum Param {
120
127
}
121
128
}
122
129
123
- static private String getKeyValue (final IEntry <AtomicValue , Sequence > entry ,
130
+ private static String getKeyValue (final IEntry <AtomicValue , Sequence > entry ,
124
131
final BiFunction <ErrorCodes .ErrorCode , String , XPathException > errorBuilder ) throws XPathException {
125
132
if (!Type .subTypeOf (entry .key ().getType (), Type .STRING )) {
126
133
throw errorBuilder .apply (ErrorCodes .XPTY0004 ,
@@ -129,7 +136,7 @@ static private String getKeyValue(final IEntry<AtomicValue, Sequence> entry,
129
136
return entry .key ().getStringValue ();
130
137
}
131
138
132
- static private Sequence getEntryValue (final IEntry <AtomicValue , Sequence > entry ,
139
+ private static Sequence getEntryValue (final IEntry <AtomicValue , Sequence > entry ,
133
140
final ParameterInfo parameterInfo ,
134
141
final BiFunction <ErrorCodes .ErrorCode , String , XPathException > errorBuilder ) throws XPathException {
135
142
@@ -160,7 +167,7 @@ static private Sequence getEntryValue(final IEntry<AtomicValue, Sequence> entry,
160
167
"The value: " + entry .key () + " has multiple values in the sequence, and is required to have none or one." );
161
168
}
162
169
163
- static private Tuple3 <String , Sequence , Param > getEntry (
170
+ private static Tuple3 <String , Sequence , Param > getEntry (
164
171
final IEntry <AtomicValue , Sequence > entry ,
165
172
final BiFunction <ErrorCodes .ErrorCode , String , XPathException > errorBuilder ) throws XPathException {
166
173
@@ -258,7 +265,7 @@ static SerializationProperties combinePropertiesAndCharacterMaps(
258
265
final SerializationProperties combinedProperties = overrideProperties .combineWith (baseProperties );
259
266
260
267
final List <String > baseCharacterMapKeys = new ArrayList <>();
261
- final Optional <String []> baseCharacterMapString = Optional .ofNullable (baseProperties .getProperty ("use-character-maps" )).map (s -> s .split (" " ));
268
+ final Optional <String []> baseCharacterMapString = Optional .ofNullable (baseProperties .getProperty (USE_CHARACTER_MAPS )).map (s -> s .split (" " ));
262
269
if (baseCharacterMapString .isPresent ()) {
263
270
for (final String s : baseCharacterMapString .get ()) {
264
271
if (!s .isEmpty ()) {
@@ -267,7 +274,7 @@ static SerializationProperties combinePropertiesAndCharacterMaps(
267
274
}
268
275
}
269
276
270
- final Optional <String > combinedCharacterMapKey = Optional .ofNullable (combinedProperties .getProperty ("use-character-maps" )).map (String ::trim );
277
+ final Optional <String > combinedCharacterMapKey = Optional .ofNullable (combinedProperties .getProperty (USE_CHARACTER_MAPS )).map (String ::trim );
271
278
if (combinedCharacterMapKey .isPresent ()) {
272
279
final List <CharacterMap > allMaps = new ArrayList <>();
273
280
for (final String baseCharacterMapKey : baseCharacterMapKeys ) {
@@ -280,7 +287,7 @@ static SerializationProperties combinePropertiesAndCharacterMaps(
280
287
combinedProperties .getCharacterMapIndex ().putCharacterMap (
281
288
qNameCharacterMap ,
282
289
repairedCombinedMap );
283
- combinedProperties .setProperty ("use-character-maps" , qNameCharacterMap .getClarkName ());
290
+ combinedProperties .setProperty (USE_CHARACTER_MAPS , qNameCharacterMap .getClarkName ());
284
291
}
285
292
286
293
return combinedProperties ;
0 commit comments