aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/forms/FormFieldFactory.java
blob: 5a30e35a50155c9af8b3e5eefab03f61346e0bb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package de.pixart.messenger.ui.forms;

import android.content.Context;

import java.util.Hashtable;

import de.pixart.messenger.xmpp.forms.Field;


public class FormFieldFactory {

    private static final Hashtable<String, Class> typeTable = new Hashtable<>();

    static {
        typeTable.put("text-single", FormTextFieldWrapper.class);
        typeTable.put("text-multi", FormTextFieldWrapper.class);
        typeTable.put("text-private", FormTextFieldWrapper.class);
        typeTable.put("jid-single", FormJidSingleFieldWrapper.class);
        typeTable.put("boolean", FormBooleanFieldWrapper.class);
    }

    protected static FormFieldWrapper createFromField(Context context, Field field) {
        Class clazz = typeTable.get(field.getType());
        if (clazz == null) {
            clazz = FormTextFieldWrapper.class;
        }
        return FormFieldWrapper.createFromField(clazz, context, field);
    }
}