mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 12:37:58 +01:00
[formtypes] Introduce LOOKASIDE_FIELD_REGISTRY
Some field's like stream-method of XEP-0096, which is of type list-single, need to be pre-registered.
This commit is contained in:
parent
73941629f3
commit
adc159186c
1 changed files with 8 additions and 3 deletions
|
@ -36,6 +36,8 @@ public class FormFieldRegistry {
|
|||
|
||||
private static final Map<String, FormField.Type> CLARK_NOTATION_FIELD_REGISTRY = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Map<String, FormField.Type> LOOKASIDE_FIELD_REGISTRY = new ConcurrentHashMap<>();
|
||||
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public static void register(DataForm dataForm) {
|
||||
// TODO: Also allow forms of type 'result'?
|
||||
|
@ -98,11 +100,11 @@ public class FormFieldRegistry {
|
|||
|
||||
public static FormField.Type lookup(String formType, String fieldName) {
|
||||
if (formType == null) {
|
||||
if (!XmlUtil.isClarkNotation(fieldName)) {
|
||||
return null;
|
||||
if (XmlUtil.isClarkNotation(fieldName)) {
|
||||
return CLARK_NOTATION_FIELD_REGISTRY.get(fieldName);
|
||||
}
|
||||
|
||||
return CLARK_NOTATION_FIELD_REGISTRY.get(fieldName);
|
||||
return LOOKASIDE_FIELD_REGISTRY.get(fieldName);
|
||||
}
|
||||
|
||||
synchronized (REGISTRY) {
|
||||
|
@ -122,4 +124,7 @@ public class FormFieldRegistry {
|
|||
return lookup(null, fieldName);
|
||||
}
|
||||
|
||||
public static void addLookasideFieldRegistryEntry(String fieldName, FormField.Type formFieldType) {
|
||||
LOOKASIDE_FIELD_REGISTRY.put(fieldName, formFieldType);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue