@@ -114,12 +114,12 @@ public IContext getContext(String className) {
114
114
115
115
String getRecognisedNamespace (String className ) {
116
116
if (className != null ) {
117
+ String normalizedClassName = normalize (className );
117
118
// If both "a" and "a.b" namespaces are registered,
118
119
// iText should consider the context of "a.b" for an "a.b" event,
119
120
// that's why the contexts are sorted by the length of the namespace
120
121
for (String namespace : contextMappings .keySet ()) {
121
- //Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
122
- if (className .toLowerCase ().startsWith (namespace )) {
122
+ if (normalizedClassName .startsWith (namespace )) {
123
123
return namespace ;
124
124
}
125
125
}
@@ -129,7 +129,7 @@ String getRecognisedNamespace(String className) {
129
129
130
130
void unregisterContext (Collection <String > namespaces ) {
131
131
for (String namespace : namespaces ) {
132
- contextMappings .remove (namespace );
132
+ contextMappings .remove (normalize ( namespace ) );
133
133
}
134
134
}
135
135
@@ -143,11 +143,15 @@ private IContext getNamespaceMapping(String namespace) {
143
143
void registerGenericContext (Collection <String > namespaces , Collection <String > products ) {
144
144
final GenericContext context = new GenericContext (products );
145
145
for (String namespace : namespaces ) {
146
- //Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
147
- contextMappings .put (namespace .toLowerCase (), context );
146
+ contextMappings .put (normalize (namespace ), context );
148
147
}
149
148
}
150
149
150
+ private static String normalize (String namespace ) {
151
+ // Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
152
+ return namespace .toLowerCase ();
153
+ }
154
+
151
155
private static class LengthComparator implements Comparator <String > {
152
156
@ Override
153
157
public int compare (String o1 , String o2 ) {
0 commit comments