Package com.nexirius.multimail.datamodel

Source Code of com.nexirius.multimail.datamodel.ImportModel

package com.nexirius.multimail.datamodel;

import com.nexirius.framework.datamodel.*;
import com.nexirius.util.StringVector;

public class ImportModel extends StructModel {
    ArrayModel lines;
    public static final String FIELD_removeDoubleQuotes = "removeDoubleQuotes";
    //protected BooleanModel removeDoubleQuotes;

    public ImportModel() {
        super("Import");
        init();
    }

    private void init() {
        lines = new ArrayModel((FullFieldName)null, "Lines");
        append(lines);
//        removeDoubleQuotes = new BooleanModel(true, FIELD_removeDoubleQuotes);
//        append(removeDoubleQuotes);
    }

    public void setMaxAttributes(int maxFields) {
        StringVector sv = new StringVector();

        for (int i = 0; i < maxFields; ++i) {
            sv.append("field_" + i);
        }

        SimpleArrayModel fieldAttributes = new SimpleArrayModel(sv.getArray());
        for (int i = 0; i < MailModel.MAIL_FIELDS.length; i++) {
            String attribute = MailModel.MAIL_FIELDS[i];

            append(new ComboBoxModel(i, fieldAttributes, attribute));
        }
    }

    public ArrayModel getLines() {
        return lines;
    }

    public MailArrayModel getAll() throws Exception {
        MailArrayModel ret = new MailArrayModel();
        DataModelEnumeration en = lines.getEnumeration();
        String[] lineAttributes = new String[MailModel.MAIL_FIELDS.length];
        for (int i = 0; i < MailModel.MAIL_FIELDS.length; i++) {
            String attribute = MailModel.MAIL_FIELDS[i];
            lineAttributes[i] = "field_" + ((IntModel)getChild(attribute)).getInt();
        }

        while (en.hasMore()) {
            DataModel line = en.next();
            MailModel mailModel = new MailModel();
            for (int i = 0; i < MailModel.MAIL_FIELDS.length; i++) {
                String attribute = MailModel.MAIL_FIELDS[i];
                mailModel.setChildText(attribute, line.getChildText(lineAttributes[i]));
            }
            ret.append(mailModel);
        }

        return ret;
    }
}
TOP

Related Classes of com.nexirius.multimail.datamodel.ImportModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.