while (execResult == null && canContinueToList(loadAllRecords, maxRecords)) execResult = nextList();

// #  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
// #  this program.  Users of this software do so entirely at their own risk.  #
// #  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
// #  software that it builds, deploys and maintains.                          #
// Template ver. 1.0.6 - Last modified on 25/05/2004 15:00 by Marius Mihalec
package ims.dto.client;

public final class Pal_sum_religion {

    private Pal_sum_religionFilter lastGetFilter = null;

    private final String serviceName = "PAL_SUM_RELIGION";

    private boolean listInProgress = false;

    /**
     * Represents the Data Transfer Object Connection used for this client object.
     */
    public ims.dto.Connection Connection = null;

    /**
     * Represents the filter used by the current Data Transfer Object.
     */
    public Pal_sum_religionFilter Filter = new Pal_sum_religionFilter();

    /**
     * Represents the filter used by the current Data Transfer Object to Insert/Update data.
     */
    public Pal_sum_religionEditFilter EditFilter = new Pal_sum_religionEditFilter();

    /**
     * Contains the data records for the current Data Transfer Object
     */
    public Pal_sum_religionCollection DataCollection = new Pal_sum_religionCollection();

    /**
     * Creates a new Pal_sum_religion Data Transfer Object.
     */
    public Pal_sum_religion(ims.dto.Connection connection) throws ims.dto.Exception {
        if (connection == null)
            throw new ims.dto.Exception("Invalid Data Transfer Object Connection");
        this.Connection = connection;
    }

    /**
     * Creates a new copy of the current Data Transfer Object
     */
    public Pal_sum_religion cloneObject() throws ims.dto.Exception {
        Pal_sum_religion cloneObject = new Pal_sum_religion(Connection);
        if (Filter != null)
            cloneObject.Filter = Filter.cloneObject();
        if (lastGetFilter != null)
            cloneObject.lastGetFilter = lastGetFilter.cloneObject();
        else
            cloneObject.lastGetFilter = null;
        for (int x = 0; x < DataCollection.count(); x++) {
            int index = cloneObject.DataCollection.add();
            cloneObject.DataCollection.get(index).Pal_sum_religion_id = DataCollection.get(x).Pal_sum_religion_id;
            cloneObject.DataCollection.get(index).Pkey = DataCollection.get(x).Pkey;
            cloneObject.DataCollection.get(index).Rdat = DataCollection.get(x).Rdat;
            cloneObject.DataCollection.get(index).Rtim = DataCollection.get(x).Rtim;
            cloneObject.DataCollection.get(index).Rhcp = DataCollection.get(x).Rhcp;
            cloneObject.DataCollection.get(index).Rusr = DataCollection.get(x).Rusr;
            cloneObject.DataCollection.get(index).Udat = DataCollection.get(x).Udat;
            cloneObject.DataCollection.get(index).Utim = DataCollection.get(x).Utim;
            cloneObject.DataCollection.get(index).Uhcp = DataCollection.get(x).Uhcp;
            cloneObject.DataCollection.get(index).Uusr = DataCollection.get(x).Uusr;
            cloneObject.DataCollection.get(index).Cdat = DataCollection.get(x).Cdat;
            cloneObject.DataCollection.get(index).Ctim = DataCollection.get(x).Ctim;
            cloneObject.DataCollection.get(index).Modu = DataCollection.get(x).Modu;
            cloneObject.DataCollection.get(index).Ccs_epid = DataCollection.get(x).Ccs_epid;
            cloneObject.DataCollection.get(index).Actind = DataCollection.get(x).Actind;
            cloneObject.DataCollection.get(index).Tstp = DataCollection.get(x).Tstp;
            cloneObject.DataCollection.get(index).Assess = DataCollection.get(x).Assess;
            cloneObject.DataCollection.get(index).Needsprior = DataCollection.get(x).Needsprior;
            cloneObject.DataCollection.get(index).Needsafter = DataCollection.get(x).Needsafter;
            cloneObject.DataCollection.get(index).Source = DataCollection.get(x).Source;
            for (int iSeqno1 = 0; iSeqno1 < DataCollection.get(x).Seqno1Collection.count(); iSeqno1++) {
                int rIndex = cloneObject.DataCollection.get(index).Seqno1Collection.add();
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Seqno1 = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Seqno1;
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Intorext = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Intorext;
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Fullname = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Fullname;
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Phone = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Phone;
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Contact24 = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Contact24;
                cloneObject.DataCollection.get(index).Seqno1Collection.get(rIndex).Actind_sq1 = DataCollection.get(x).Seqno1Collection.get(iSeqno1).Actind_sq1;
            }
        }
        return cloneObject;
    }

    /**
     * Returns the Imx version
     */
    public String getImxVersion() {
        return "$Revision: 1.1 $";
    }

    /**
     * Returns the Imx name
     */
    public String getImxName() {
        return "Pal_sum_religion.imx".toLowerCase();
    }

    /**
     * Returns the number of records using the specified filter. This method always returns a non null result. The ID field holds the count result (when greater or equal to zero) or the error number (when less than zero).
     */
    public ims.dto.Result count() {
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.Count");
        int result = Connection.count(serviceName, encodeNASFilter());
        if (result >= 0)
            return new ims.dto.Result(result, "No error detected. The count result is held in the ID field", "DTO.Client.Pal_sum_religion.Count");
        return Connection.getLastError();
    }

    /**
     * Returns the list of records using the specified filter. Use maxRecords to limit the number of records returned. If the result returned is not null an error occured.
     */
    public ims.dto.Result list(int maxRecords) {
        if (maxRecords <= 0)
            return list();
        return list(false, maxRecords);
    }

    /**
     * Returns the list of records using the specified filter. If the result returned is not null an error occured.
     */
    public ims.dto.Result list() {
        return list(true, 0);
    }

    /**
     * Returns one record using the specified filter. If the result returned is not null an error occured.
     */
    public ims.dto.Result get() {
        DataCollection.clear();
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.Get");
        ims.dto.Result result = Connection.get(serviceName, encodeNASFilter());
        if (result != null)
            return result;
        lastGetFilter = Filter.cloneObject();
        decodeNASMessageWithRepeatingGroups();
        return null;
    }

    /**
     * Returns one record using the specified filter. If the result returned is not null an error occured.
     */
    public ims.dto.Result getLast() {
        DataCollection.clear();
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.Get");
        ims.dto.Result result = Connection.getLast(serviceName, encodeNASFilter());
        if (result != null)
            return result;
        lastGetFilter = Filter.cloneObject();
        decodeNASMessageWithRepeatingGroups();
        return null;
    }

    /**
     * Performs data validation prior to update. If the result returned is not null an error occured.
     */
    public ims.dto.Result getForUpdate() {
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.GetForUpdate");
        if (lastGetFilter == null)
            return new ims.dto.Result("Last get method failed or not called", "DTO.Client.Pal_sum_religion.GetForUpdate");
        ims.dto.Result result = Connection.getForUpdate(serviceName, encodeNASFilter(lastGetFilter));
        if (result != null)
            return result;
        if (Connection.countResponseItems(Connection.getValueAt(6)) == 0)
            return null;
        DataCollection.clear();
        decodeNASMessageWithRepeatingGroups();
        return new ims.dto.Result("The data was changed by another user", "DTO.Client.Pal_sum_religion.GetForUpdate");
    }

    /**
     * Inserts a new record. This method always returns a non null result. The ID field holds the Unique ID for the inserted record (when greater than zero) or the error number (when less than zero). If the ID is zero, the record was inserted but the server did not returned the Unique ID.
     */
    public ims.dto.Result insert() {
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.Insert");
        if (DataCollection.count() == 0)
            return new ims.dto.Result("No data to insert", "DTO.Client.Pal_sum_religion.Insert");
        if (DataCollection.count() > 1)
            return new ims.dto.Result("Multiple object insert not allowed", "DTO.Client.Pal_sum_religion.Insert");
        ims.dto.Result result = Connection.insert(serviceName, encodeNASMessage());
        if (result != null)
            return result;
        int recordID = 0;
        try {
            recordID = new Integer(Connection.getValueAt(2)).intValue();
        } catch (NumberFormatException ex) {
            return new ims.dto.Result("Invalid record ID returned", "DTO.Client.Pal_sum_religion.Insert");
        }
        return new ims.dto.Result(recordID, "No error. The ID of the new record is in the ID field", "DTO.Client.Pal_sum_religion.Insert");
    }

    /**
     * Executes a specific action. This method always returns a non null result.
     */
    public ims.dto.Result executeAction(String action) {
        if (action.length() == 0)
            return new ims.dto.Result("Invalid action name", "DTO.Client.Pal_sum_religion.ExecuteAction");
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.ExecuteAction");
        if (DataCollection.count() == 0)
            return new ims.dto.Result("Data container is empty", "DTO.Client.Pal_sum_religion.ExecuteAction");
        if (DataCollection.count() > 1)
            return new ims.dto.Result("Multiple objects are not allowed", "DTO.Client.Pal_sum_religion.ExecuteAction");
        ims.dto.Result result = Connection.executeAction(serviceName, encodeNASMessage(), action);
        if (result != null)
            return result;
        try {
            return new ims.dto.Result(new Integer(Connection.getValueAt(2)).intValue(), "No error", "DTO.Client.Pal_sum_religion.ExecuteAction");
        } catch (NumberFormatException ex) {
            return new ims.dto.Result("Invalid server response", "DTO.Client.Pal_sum_religion.ExecuteAction");
        }
    }

    /**
     * Transfers a record. If the result returned is not null an error occured.
     */
    public ims.dto.Result transferData(String action) {
        if (action.length() == 0)
            return new ims.dto.Result("Invalid action name", "DTO.Client.Pal_sum_religion.TransferData");
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.TransferData");
        if (DataCollection.count() == 0)
            return new ims.dto.Result("No data to transfer", "DTO.Client.Pal_sum_religion.TransferData");
        if (DataCollection.count() > 1)
            return new ims.dto.Result("Multiple objects not allowed", "DTO.Client.Pal_sum_religion.TransferData");
        ims.dto.Result result = Connection.transferData(serviceName, encodeNASMessage(), action.toUpperCase());
        if (result != null)
            return result;
        DataCollection.clear();
        decodeNASMessageWithRepeatingGroups();
        return null;
    }

    /**
     * Updates a record. If the result returned is not null an error occured.
     */
    public ims.dto.Result update() {
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.Update");
        if (DataCollection.count() == 0)
            return new ims.dto.Result("No data to update", "DTO.Client.Pal_sum_religion.Update");
        if (DataCollection.count() > 1)
            return new ims.dto.Result("Multiple object update not allowed", "DTO.Client.Pal_sum_religion.Update");
        return Connection.update(serviceName, encodeNASMessage());
    }

    private ims.dto.Result stopList() {
        if (!listInProgress)
            return new ims.dto.Result("No active list running", "DTO.Client.Pal_sum_religion.StopList");
        listInProgress = false;
        return null;
    }

    private ims.dto.Result nextList() {
        ims.dto.Result result = Connection.nextList(serviceName);
        if (result != null)
            return result;
        decodeNASMessage();
        return null;
    }

    private boolean canContinueToList(boolean loadAllRecords, int maxRecords) {
        if (!listInProgress)
            return false;
        if (loadAllRecords)
            return true;
        return DataCollection.count() < maxRecords;
    }

    private ims.dto.Result list(boolean loadAllRecords, int maxRecords) {
        DataCollection.clear();
        ims.dto.Result reLoginResult = Connection.reLogin();
        if (reLoginResult != null)
            return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Pal_sum_religion.List");
        listInProgress = true;
        ims.dto.Result result = Connection.list(serviceName, encodeNASFilter());
        if (result != null) {
            listInProgress = false;
            if (// NAS list empty
            result.getId() == -2)
                return null;
            return result;
        }
        if (decodeNASMessage() == 0) {
            listInProgress = false;
            return null;
        }
        ims.dto.Result execResult = null;

        if (execResult != null) {
            if (execResult.getId() != -3) {
                listInProgress = false;
                return execResult;
            }
        } else // NAS next list empty
        {
            listInProgress = false;
            return null;
        }
        if (!loadAllRecords || !listInProgress) {
            listInProgress = false;
            return Connection.stopList(serviceName);
        }
        listInProgress = false;
        return null;
    }

    private String encodeNASFilter() {
        return encodeNASFilter(Filter);
    }

    private String encodeNASFilter(Pal_sum_religionFilter filter) {
        if (filter == null)
            return "";
        String filterString = "";
        if (Filter.Pal_sum_religion_id != null && filter.Pal_sum_religion_id.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "PAL_SUM_RELIGION_ID" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Pal_sum_religion_id;
        }
        if (Filter.Pkey != null && filter.Pkey.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "PKEY" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Pkey;
        }
        if (Filter.Rdat != null && filter.Rdat.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "RDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Rdat;
        }
        if (Filter.Rtim != null && filter.Rtim.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "RTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Rtim;
        }
        if (Filter.Rhcp != null && filter.Rhcp.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "RHCP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Rhcp;
        }
        if (Filter.Rusr != null && filter.Rusr.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "RUSR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Rusr;
        }
        if (Filter.Udat != null && filter.Udat.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "UDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Udat;
        }
        if (Filter.Utim != null && filter.Utim.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "UTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Utim;
        }
        if (Filter.Uhcp != null && filter.Uhcp.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "UHCP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Uhcp;
        }
        if (Filter.Uusr != null && filter.Uusr.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "UUSR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Uusr;
        }
        if (Filter.Cdat != null && filter.Cdat.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "CDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Cdat;
        }
        if (Filter.Ctim != null && filter.Ctim.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "CTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Ctim;
        }
        if (Filter.Modu != null && filter.Modu.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "MODU" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Modu;
        }
        if (Filter.Ccs_epid != null && filter.Ccs_epid.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "CCS_EPID" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Ccs_epid;
        }
        if (Filter.Actind != null && filter.Actind.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "ACTIND" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Actind;
        }
        if (Filter.Tstp != null && filter.Tstp.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "TSTP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Tstp;
        }
        if (Filter.Assess != null && filter.Assess.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "ASSESS" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Assess;
        }
        if (Filter.Needsprior != null && filter.Needsprior.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "NEEDSPRIOR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Needsprior;
        }
        if (Filter.Needsafter != null && filter.Needsafter.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "NEEDSAFTER" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Needsafter;
        }
        if (Filter.Source != null && filter.Source.length() > 0) {
            if (filterString.length() > 0)
                filterString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            filterString += "SOURCE" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + filter.Source;
        }
        return filterString;
    }

    private String encodeNASMessage() {
        String dataString = "";
        if (DataCollection.count() == 0)
            return dataString;
        Pal_sum_religionRecord data = (Pal_sum_religionRecord) DataCollection.get(0);
        if (EditFilter.IncludePal_sum_religion_id) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "PAL_SUM_RELIGION_ID" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Pal_sum_religion_id);
        }
        if (EditFilter.IncludePkey) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "PKEY" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Pkey);
        }
        if (EditFilter.IncludeRdat) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "RDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Rdat);
        }
        if (EditFilter.IncludeRtim) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "RTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Rtim);
        }
        if (EditFilter.IncludeRhcp) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "RHCP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Rhcp);
        }
        if (EditFilter.IncludeRusr) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "RUSR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Rusr);
        }
        if (EditFilter.IncludeUdat) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "UDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Udat);
        }
        if (EditFilter.IncludeUtim) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "UTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Utim);
        }
        if (EditFilter.IncludeUhcp) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "UHCP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Uhcp);
        }
        if (EditFilter.IncludeUusr) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "UUSR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Uusr);
        }
        if (EditFilter.IncludeCdat) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "CDAT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Cdat);
        }
        if (EditFilter.IncludeCtim) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "CTIM" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Ctim);
        }
        if (EditFilter.IncludeModu) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "MODU" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Modu);
        }
        if (EditFilter.IncludeCcs_epid) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "CCS_EPID" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Ccs_epid);
        }
        if (EditFilter.IncludeActind) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "ACTIND" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Actind);
        }
        if (EditFilter.IncludeTstp) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "TSTP" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Tstp);
        }
        if (EditFilter.IncludeAssess) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "ASSESS" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Assess);
        }
        if (EditFilter.IncludeNeedsprior) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "NEEDSPRIOR" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Needsprior);
        }
        if (EditFilter.IncludeNeedsafter) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "NEEDSAFTER" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Needsafter);
        }
        if (EditFilter.IncludeSource) {
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "SOURCE" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(data.Source);
        }
        for (int x = 0; x < data.Seqno1Collection.count(); x++) {
            Pal_sum_religionSeqno1Record rgRecord = (Pal_sum_religionSeqno1Record) data.Seqno1Collection.get(x);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "SEQNO1" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Seqno1);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "INTOREXT" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Intorext);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "FULLNAME" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Fullname);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "PHONE" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Phone);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "CONTACT24" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Contact24);
            if (dataString.length() > 0)
                dataString += ims.dto.NASMessageCodes.PAIRSEPARATOR;
            dataString += "ACTIND_SQ1" + ims.dto.NASMessageCodes.ATTRIBUTEVALUESEPARATOR + Connection.encodeFieldValue(rgRecord.Actind_sq1);
        }
        return dataString;
    }

    private int decodeNASMessage() {
        String[] items = Connection.getResponseItems(Connection.getValueAt(6));
        if (items == null)
            return 0;
        int records = items.length;
        if (records == 0)
            return 0;
        for (int x = 0; x < records; x++) {
            Pal_sum_religionRecord record = new Pal_sum_religionRecord();
            String[] valueItems = Connection.splitResponseItem(items[x]);
            record.Pal_sum_religion_id = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PAL_SUM_RELIGION_ID"));
            record.Pkey = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PKEY"));
            record.Rdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RDAT"));
            record.Rtim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RTIM"));
            record.Rhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RHCP"));
            record.Rusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RUSR"));
            record.Udat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UDAT"));
            record.Utim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UTIM"));
            record.Uhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UHCP"));
            record.Uusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UUSR"));
            record.Cdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CDAT"));
            record.Ctim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CTIM"));
            record.Modu = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "MODU"));
            record.Ccs_epid = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CCS_EPID"));
            record.Actind = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ACTIND"));
            record.Tstp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "TSTP"));
            record.Assess = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ASSESS"));
            record.Needsprior = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "NEEDSPRIOR"));
            record.Needsafter = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "NEEDSAFTER"));
            record.Source = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SOURCE"));
            DataCollection.add(record);
        }
        return records;
    }

    private int decodeNASMessageWithRepeatingGroups() {
        String[] items = Connection.getResponseItems(Connection.getValueAt(6));
        if (items == null)
            return 0;
        int records = items.length;
        if (records == 0)
            return 0;
        int recCount = 0;
        int rgCount = 0;
        for (int x = 0; x < records; x++) {
            Pal_sum_religionRecord record = new Pal_sum_religionRecord();
            String[] valueItems = Connection.splitResponseItem(items[x]);
            record.Pal_sum_religion_id = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PAL_SUM_RELIGION_ID"));
            record.Pkey = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "PKEY"));
            record.Rdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RDAT"));
            record.Rtim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RTIM"));
            record.Rhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RHCP"));
            record.Rusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "RUSR"));
            record.Udat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UDAT"));
            record.Utim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UTIM"));
            record.Uhcp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UHCP"));
            record.Uusr = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "UUSR"));
            record.Cdat = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CDAT"));
            record.Ctim = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CTIM"));
            record.Modu = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "MODU"));
            record.Ccs_epid = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "CCS_EPID"));
            record.Actind = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ACTIND"));
            record.Tstp = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "TSTP"));
            record.Assess = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "ASSESS"));
            record.Needsprior = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "NEEDSPRIOR"));
            record.Needsafter = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "NEEDSAFTER"));
            record.Source = Connection.decodeFieldValue(Connection.getValueFor(valueItems, "SOURCE"));
            for (int i = 0; i < valueItems.length; i++) if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("seqno1"))
                record.Seqno1Collection.add();
            rgCount = record.Seqno1Collection.count();
            if (rgCount > 0) {
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("seqno1")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Seqno1 = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("intorext")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Intorext = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("fullname")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Fullname = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("phone")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Phone = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("contact24")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Contact24 = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
                recCount = 0;
                for (int i = 0; i < valueItems.length; i++) {
                    if (Connection.getAttributeName(valueItems[i]).toLowerCase().equals("actind_sq1")) {
                        Pal_sum_religionSeqno1Record rgRecord = record.Seqno1Collection.get(recCount);
                        rgRecord.Actind_sq1 = Connection.getAttributeValue(valueItems[i]);
                        recCount++;
                    }
                    if (rgCount == recCount)
                        break;
                }
            }
            DataCollection.add(record);
        }
        return records;
    }

    public final class Pal_sum_religionCollection {

        private java.util.ArrayList recordCollection = new java.util.ArrayList();

        public int add() {
            Pal_sum_religionRecord newRecord = new Pal_sum_religionRecord();
            recordCollection.add(newRecord);
            return count() - 1;
        }

        public int add(Pal_sum_religionRecord record) {
            recordCollection.add(record);
            return count() - 1;
        }

        public void clear() {
            recordCollection.clear();
        }

        public int count() {
            return recordCollection.size();
        }

        public Pal_sum_religionRecord get(int index) {
            return (Pal_sum_religionRecord) recordCollection.get(index);
        }

        public void remove(int index) {
            recordCollection.remove(index);
        }
    }

    public final class Pal_sum_religionRecord {

        public String Pal_sum_religion_id = "";

        public String Pkey = "";

        public String Rdat = "";

        public String Rtim = "";

        public String Rhcp = "";

        public String Rusr = "";

        public String Udat = "";

        public String Utim = "";

        public String Uhcp = "";

        public String Uusr = "";

        public String Cdat = "";

        public String Ctim = "";

        public String Modu = "";

        public String Ccs_epid = "";

        public String Actind = "";

        public String Tstp = "";

        public String Assess = "";

        public String Needsprior = "";

        public String Needsafter = "";

        public String Source = "";

        public Pal_sum_religionSeqno1Collection Seqno1Collection = new Pal_sum_religionSeqno1Collection();

        public void clear() {
            Pal_sum_religion_id = "";
            Pkey = "";
            Rdat = "";
            Rtim = "";
            Rhcp = "";
            Rusr = "";
            Udat = "";
            Utim = "";
            Uhcp = "";
            Uusr = "";
            Cdat = "";
            Ctim = "";
            Modu = "";
            Ccs_epid = "";
            Actind = "";
            Tstp = "";
            Assess = "";
            Needsprior = "";
            Needsafter = "";
            Source = "";
            Seqno1Collection.clear();
        }
    }

    public final class Pal_sum_religionSeqno1Collection {

        private java.util.ArrayList recordCollection = new java.util.ArrayList();

        public int add() {
            Pal_sum_religionSeqno1Record newRecord = new Pal_sum_religionSeqno1Record();
            recordCollection.add(newRecord);
            return count() - 1;
        }

        public int add(Pal_sum_religionSeqno1Record record) {
            recordCollection.add(record);
            return count() - 1;
        }

        public void clear() {
            recordCollection.clear();
        }

        public int count() {
            return recordCollection.size();
        }

        public Pal_sum_religionSeqno1Record get(int index) {
            return (Pal_sum_religionSeqno1Record) recordCollection.get(index);
        }

        public void remove(int index) {
            recordCollection.remove(index);
        }
    }

    public final class Pal_sum_religionSeqno1Record {

        public String Seqno1 = "";

        public String Intorext = "";

        public String Fullname = "";

        public String Phone = "";

        public String Contact24 = "";

        public String Actind_sq1 = "";

        public void clear() {
            Seqno1 = "";
            Intorext = "";
            Fullname = "";
            Phone = "";
            Contact24 = "";
            Actind_sq1 = "";
        }
    }

    public final class Pal_sum_religionFilter {

        public String Pal_sum_religion_id = "";

        public String Pkey = "";

        public String Rdat = "";

        public String Rtim = "";

        public String Rhcp = "";

        public String Rusr = "";

        public String Udat = "";

        public String Utim = "";

        public String Uhcp = "";

        public String Uusr = "";

        public String Cdat = "";

        public String Ctim = "";

        public String Modu = "";

        public String Ccs_epid = "";

        public String Actind = "";

        public String Tstp = "";

        public String Assess = "";

        public String Needsprior = "";

        public String Needsafter = "";

        public String Source = "";

        public void clear() {
            Pal_sum_religion_id = "";
            Pkey = "";
            Rdat = "";
            Rtim = "";
            Rhcp = "";
            Rusr = "";
            Udat = "";
            Utim = "";
            Uhcp = "";
            Uusr = "";
            Cdat = "";
            Ctim = "";
            Modu = "";
            Ccs_epid = "";
            Actind = "";
            Tstp = "";
            Assess = "";
            Needsprior = "";
            Needsafter = "";
            Source = "";
        }

        public Pal_sum_religionFilter cloneObject() {
            Pal_sum_religionFilter newFilter = new Pal_sum_religionFilter();
            newFilter.Pal_sum_religion_id = this.Pal_sum_religion_id;
            newFilter.Pkey = this.Pkey;
            newFilter.Rdat = this.Rdat;
            newFilter.Rtim = this.Rtim;
            newFilter.Rhcp = this.Rhcp;
            newFilter.Rusr = this.Rusr;
            newFilter.Udat = this.Udat;
            newFilter.Utim = this.Utim;
            newFilter.Uhcp = this.Uhcp;
            newFilter.Uusr = this.Uusr;
            newFilter.Cdat = this.Cdat;
            newFilter.Ctim = this.Ctim;
            newFilter.Modu = this.Modu;
            newFilter.Ccs_epid = this.Ccs_epid;
            newFilter.Actind = this.Actind;
            newFilter.Tstp = this.Tstp;
            newFilter.Assess = this.Assess;
            newFilter.Needsprior = this.Needsprior;
            newFilter.Needsafter = this.Needsafter;
            newFilter.Source = this.Source;
            return newFilter;
        }
    }

    public final class Pal_sum_religionEditFilter {

        public boolean IncludePal_sum_religion_id = true;

        public boolean IncludePkey = true;

        public boolean IncludeRdat = true;

        public boolean IncludeRtim = true;

        public boolean IncludeRhcp = true;

        public boolean IncludeRusr = true;

        public boolean IncludeUdat = true;

        public boolean IncludeUtim = true;

        public boolean IncludeUhcp = true;

        public boolean IncludeUusr = true;

        public boolean IncludeCdat = true;

        public boolean IncludeCtim = true;

        public boolean IncludeModu = true;

        public boolean IncludeCcs_epid = true;

        public boolean IncludeActind = true;

        public boolean IncludeTstp = true;

        public boolean IncludeAssess = true;

        public boolean IncludeNeedsprior = true;

        public boolean IncludeNeedsafter = true;

        public boolean IncludeSource = true;

        public void includeAll() {
            IncludePal_sum_religion_id = true;
            IncludePkey = true;
            IncludeRdat = true;
            IncludeRtim = true;
            IncludeRhcp = true;
            IncludeRusr = true;
            IncludeUdat = true;
            IncludeUtim = true;
            IncludeUhcp = true;
            IncludeUusr = true;
            IncludeCdat = true;
            IncludeCtim = true;
            IncludeModu = true;
            IncludeCcs_epid = true;
            IncludeActind = true;
            IncludeTstp = true;
            IncludeAssess = true;
            IncludeNeedsprior = true;
            IncludeNeedsafter = true;
            IncludeSource = true;
        }

        public void excludeAll() {
            IncludePal_sum_religion_id = false;
            IncludePkey = false;
            IncludeRdat = false;
            IncludeRtim = false;
            IncludeRhcp = false;
            IncludeRusr = false;
            IncludeUdat = false;
            IncludeUtim = false;
            IncludeUhcp = false;
            IncludeUusr = false;
            IncludeCdat = false;
            IncludeCtim = false;
            IncludeModu = false;
            IncludeCcs_epid = false;
            IncludeActind = false;
            IncludeTstp = false;
            IncludeAssess = false;
            IncludeNeedsprior = false;
            IncludeNeedsafter = false;
            IncludeSource = false;
        }

        public Pal_sum_religionEditFilter cloneObject() {
            Pal_sum_religionEditFilter newEditFilter = new Pal_sum_religionEditFilter();
            newEditFilter.IncludePal_sum_religion_id = this.IncludePal_sum_religion_id;
            newEditFilter.IncludePkey = this.IncludePkey;
            newEditFilter.IncludeRdat = this.IncludeRdat;
            newEditFilter.IncludeRtim = this.IncludeRtim;
            newEditFilter.IncludeRhcp = this.IncludeRhcp;
            newEditFilter.IncludeRusr = this.IncludeRusr;
            newEditFilter.IncludeUdat = this.IncludeUdat;
            newEditFilter.IncludeUtim = this.IncludeUtim;
            newEditFilter.IncludeUhcp = this.IncludeUhcp;
            newEditFilter.IncludeUusr = this.IncludeUusr;
            newEditFilter.IncludeCdat = this.IncludeCdat;
            newEditFilter.IncludeCtim = this.IncludeCtim;
            newEditFilter.IncludeModu = this.IncludeModu;
            newEditFilter.IncludeCcs_epid = this.IncludeCcs_epid;
            newEditFilter.IncludeActind = this.IncludeActind;
            newEditFilter.IncludeTstp = this.IncludeTstp;
            newEditFilter.IncludeAssess = this.IncludeAssess;
            newEditFilter.IncludeNeedsprior = this.IncludeNeedsprior;
            newEditFilter.IncludeNeedsafter = this.IncludeNeedsafter;
            newEditFilter.IncludeSource = this.IncludeSource;
            return newEditFilter;
        }
    }
}


switch(element.getIndex()) {
                    case 0:
                        renderer.tex(d0, d1);
                        break;
                    case 1:
                        renderer.overlay(expandTextureCoord(d0, 0xF), expandTextureCoord(d1, 0xF));
                        break;
                    case 2:
                        renderer.lightmap(expandTextureCoord(d0, 0xF0), expandTextureCoord(d1, 0xF0));
                        break;
                }

package net.minecraftforge.client.model.pipeline;

import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper;

/**
 * Assumes VertexFormatElement is present in the BufferBuilder's vertex format.
 */
public class VertexBufferConsumer implements IVertexConsumer {

    private IVertexBuilder renderer;

    public VertexBufferConsumer() {
    }

    public VertexBufferConsumer(IVertexBuilder buffer) {
        setBuffer(buffer);
    }

    @Override
    public VertexFormat getVertexFormat() {
        return DefaultVertexFormats.BLOCK;
    }

    private int expandTextureCoord(final float c, final int max) {
        return (int) (MathHelper.clamp(c, 0, 1) * max);
    }

    @Override
    public void put(int e, float... data) {
        VertexFormat format = getVertexFormat();
        VertexFormatElement element = format.getElements().get(e);
        final float d0 = data.length <= 0 ? 0 : data[0];
        final float d1 = data.length <= 1 ? 0 : data[1];
        final float d2 = data.length <= 2 ? 0 : data[2];
        final float d3 = data.length <= 3 ? 0 : data[3];
        switch(element.getUsage()) {
            case POSITION:
                renderer.pos(d0, d1, d2);
                break;
            case NORMAL:
                renderer.normal(d0, d1, d2);
                break;
            case COLOR:
                renderer.color(d0, d1, d2, d3);
                break;
            case UV:

                break;
            default:
            case PADDING:
            case GENERIC:
                break;
        }
        if (e == format.getElements().size() - 1) {
            renderer.endVertex();
        }
    }

    public void setBuffer(IVertexBuilder buffer) {
        this.renderer = buffer;
    }

    @Override
    public void setQuadTint(int tint) {
    }

    @Override
    public void setQuadOrientation(Direction orientation) {
    }

    @Override
    public void setApplyDiffuseLighting(boolean diffuse) {
    }

    @Override
    public void setTexture(TextureAtlasSprite texture) {
    }
}


while (bytesLeft > 0) {
                int n = ((IFileInputStream) input).readWithChecksum(buf, 0, (int) Math.min(bytesLeft, BYTES_TO_READ));
                if (n < 0) {
                    throw new IOException("read past end of stream reading " + getMapId());
                }
                disk.write(buf, 0, n);
                bytesLeft -= n;
                metrics.inputBytes(n);
                reporter.progress();
            }

package org.apache.hadoop.mapreduce.task.reduce;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.mapred.IFileInputStream;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.MapOutputFile;
import org.apache.hadoop.mapreduce.TaskAttemptID;
import org.apache.hadoop.mapreduce.CryptoUtils;
import org.apache.hadoop.mapreduce.task.reduce.MergeManagerImpl.CompressAwarePath;
import com.google.common.annotations.VisibleForTesting;

@InterfaceAudience.Private
@InterfaceStability.Unstable
class OnDiskMapOutput<K, V> extends MapOutput<K, V> {

    private static final Log LOG = LogFactory.getLog(OnDiskMapOutput.class);

    private final FileSystem fs;

    private final Path tmpOutputPath;

    private final Path outputPath;

    private final MergeManagerImpl<K, V> merger;

    private final OutputStream disk;

    private long compressedSize;

    private final Configuration conf;

    public OnDiskMapOutput(TaskAttemptID mapId, TaskAttemptID reduceId, MergeManagerImpl<K, V> merger, long size, JobConf conf, MapOutputFile mapOutputFile, int fetcher, boolean primaryMapOutput) throws IOException {
        this(mapId, reduceId, merger, size, conf, mapOutputFile, fetcher, primaryMapOutput, FileSystem.getLocal(conf).getRaw(), mapOutputFile.getInputFileForWrite(mapId.getTaskID(), size));
    }

    @VisibleForTesting
    OnDiskMapOutput(TaskAttemptID mapId, TaskAttemptID reduceId, MergeManagerImpl<K, V> merger, long size, JobConf conf, MapOutputFile mapOutputFile, int fetcher, boolean primaryMapOutput, FileSystem fs, Path outputPath) throws IOException {
        super(mapId, size, primaryMapOutput);
        this.fs = fs;
        this.merger = merger;
        this.outputPath = outputPath;
        tmpOutputPath = getTempPath(outputPath, fetcher);
        disk = CryptoUtils.wrapIfNecessary(conf, fs.create(tmpOutputPath));
        this.conf = conf;
    }

    @VisibleForTesting
    static Path getTempPath(Path outPath, int fetcher) {
        return outPath.suffix(String.valueOf(fetcher));
    }

    @Override
    public void shuffle(MapHost host, InputStream input, long compressedLength, long decompressedLength, ShuffleClientMetrics metrics, Reporter reporter) throws IOException {
        input = new IFileInputStream(input, compressedLength, conf);
        // Copy data to local-disk
        long bytesLeft = compressedLength;
        try {
            final int BYTES_TO_READ = 64 * 1024;
            byte[] buf = new byte[BYTES_TO_READ];

            LOG.info("Read " + (compressedLength - bytesLeft) + " bytes from map-output for " + getMapId());
            disk.close();
        } catch (IOException ioe) {
            // Close the streams
            IOUtils.cleanup(LOG, input, disk);
            throw ioe;
        }
        // Sanity check
        if (bytesLeft != 0) {
            throw new IOException("Incomplete map output received for " + getMapId() + " from " + host.getHostName() + " (" + bytesLeft + " bytes missing of " + compressedLength + ")");
        }
        this.compressedSize = compressedLength;
    }

    @Override
    public void commit() throws IOException {
        fs.rename(tmpOutputPath, outputPath);
        CompressAwarePath compressAwarePath = new CompressAwarePath(outputPath, getSize(), this.compressedSize);
        merger.closeOnDiskFile(compressAwarePath);
    }

    @Override
    public void abort() {
        try {
            fs.delete(tmpOutputPath, false);
        } catch (IOException ie) {
            LOG.info("failure to clean up " + tmpOutputPath, ie);
        }
    }

    @Override
    public String getDescription() {
        return "DISK";
    }
}


while (running) {
                LOG.debug("Wait for next completed async stream element result.");
                AsyncResult streamElementEntry = streamElementQueue.peekBlockingly();
                output(streamElementEntry);
            }

package org.apache.flink.streaming.api.operators.async;

import org.apache.flink.annotation.Internal;
import org.apache.flink.streaming.api.operators.Output;
import org.apache.flink.streaming.api.operators.TimestampedCollector;
import org.apache.flink.streaming.api.operators.async.queue.AsyncCollectionResult;
import org.apache.flink.streaming.api.operators.async.queue.AsyncResult;
import org.apache.flink.streaming.api.operators.async.queue.AsyncWatermarkResult;
import org.apache.flink.streaming.api.operators.async.queue.StreamElementQueue;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
import org.apache.flink.util.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;

/**
 * Runnable responsible for consuming elements from the given queue and outputting them to the
 * given output/timestampedCollector.
 *
 * @param <OUT> Type of the output elements
 */
@Internal
public class Emitter<OUT> implements Runnable {

    private static final Logger LOG = LoggerFactory.getLogger(Emitter.class);

    /**
     * Lock to hold before outputting.
     */
    private final Object checkpointLock;

    /**
     * Output for the watermark elements.
     */
    private final Output<StreamRecord<OUT>> output;

    /**
     * Queue to consume the async results from.
     */
    private final StreamElementQueue streamElementQueue;

    private final OperatorActions operatorActions;

    /**
     * Output for stream records.
     */
    private final TimestampedCollector<OUT> timestampedCollector;

    private volatile boolean running;

    public Emitter(final Object checkpointLock, final Output<StreamRecord<OUT>> output, final StreamElementQueue streamElementQueue, final OperatorActions operatorActions) {
        this.checkpointLock = Preconditions.checkNotNull(checkpointLock, "checkpointLock");
        this.output = Preconditions.checkNotNull(output, "output");
        this.streamElementQueue = Preconditions.checkNotNull(streamElementQueue, "streamElementQueue");
        this.operatorActions = Preconditions.checkNotNull(operatorActions, "operatorActions");
        this.timestampedCollector = new TimestampedCollector<>(this.output);
        this.running = true;
    }

    @Override
    public void run() {
        try {

        } catch (InterruptedException e) {
            if (running) {
                operatorActions.failOperator(e);
            } else {
                // Thread got interrupted which means that it should shut down
                LOG.debug("Emitter thread got interrupted, shutting down.");
            }
        } catch (Throwable t) {
            operatorActions.failOperator(new Exception("AsyncWaitOperator's emitter caught an " + "unexpected throwable.", t));
        }
    }

    private void output(AsyncResult asyncResult) throws InterruptedException {
        if (asyncResult.isWatermark()) {
            synchronized (checkpointLock) {
                AsyncWatermarkResult asyncWatermarkResult = asyncResult.asWatermark();
                LOG.debug("Output async watermark.");
                output.emitWatermark(asyncWatermarkResult.getWatermark());
                // remove the peeked element from the async collector buffer so that it is no longer
                // checkpointed
                streamElementQueue.poll();
                // notify the main thread that there is again space left in the async collector
                // buffer
                checkpointLock.notifyAll();
            }
        } else {
            AsyncCollectionResult<OUT> streamRecordResult = asyncResult.asResultCollection();
            if (streamRecordResult.hasTimestamp()) {
                timestampedCollector.setAbsoluteTimestamp(streamRecordResult.getTimestamp());
            } else {
                timestampedCollector.eraseTimestamp();
            }
            synchronized (checkpointLock) {
                LOG.debug("Output async stream element collection result.");
                try {
                    Collection<OUT> resultCollection = streamRecordResult.get();
                    if (resultCollection != null) {
                        for (OUT result : resultCollection) {
                            timestampedCollector.collect(result);
                        }
                    }
                } catch (Exception e) {
                    operatorActions.failOperator(new Exception("An async function call terminated with an exception. " + "Failing the AsyncWaitOperator.", e));
                }
                // remove the peeked element from the async collector buffer so that it is no longer
                // checkpointed
                streamElementQueue.poll();
                // notify the main thread that there is again space left in the async collector
                // buffer
                checkpointLock.notifyAll();
            }
        }
    }

    public void stop() {
        running = false;
    }
}


switch(resource) {
            case NO_RESOURCE:
                return null;
            case TEXT_VIEW_ITEM_RESOURCE:
                return new TextView(context);
            default:
                return inflater.inflate(resource, parent, false);
        }

package android.wheel.wheel.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.dji.sdk.sample.R;

/**
 * Abstract wheel adapter provides common functionality for adapters.
 */
public abstract class AbstractWheelTextAdapter extends AbstractWheelAdapter {

    /**
     * Text view resource. Used as a default view for adapter.
     */
    public static final int TEXT_VIEW_ITEM_RESOURCE = -1;

    /**
     * No resource constant.
     */
    protected static final int NO_RESOURCE = 0;

    /**
     * Default text color
     */
    public static final int DEFAULT_TEXT_COLOR = 0xFF101010;

    /**
     * Default text color
     */
    public static final int LABEL_COLOR = 0xFF700070;

    /**
     * Default text size
     */
    public static final int DEFAULT_TEXT_SIZE = 24;

    // Text settings
    private int textColor = DEFAULT_TEXT_COLOR;

    private int textSize = DEFAULT_TEXT_SIZE;

    // Current context
    protected Context context;

    // Layout inflater
    protected LayoutInflater inflater;

    // Items resources
    protected int itemResourceId;

    protected int itemTextResourceId;

    // Empty items resources
    protected int emptyItemResourceId;

    int index = -1;

    protected boolean[] isSelected = null;

    /**
     * Constructor
     *
     * @param context
     *            the current context
     */
    protected AbstractWheelTextAdapter(Context context) {
        this(context, TEXT_VIEW_ITEM_RESOURCE);
    }

    /**
     * Constructor
     *
     * @param context
     *            the current context
     * @param itemResource
     *            the resource ID for a layout file containing a TextView to use
     *            when instantiating items views
     */
    protected AbstractWheelTextAdapter(Context context, int itemResource) {
        this(context, itemResource, NO_RESOURCE);
    }

    /**
     * Constructor
     *
     * @param context
     *            the current context
     * @param itemResource
     *            the resource ID for a layout file containing a TextView to use
     *            when instantiating items views
     * @param itemTextResource
     *            the resource ID for a text view in the item layout
     */
    protected AbstractWheelTextAdapter(Context context, int itemResource, int itemTextResource) {
        this.context = context;
        itemResourceId = itemResource;
        itemTextResourceId = itemTextResource;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    protected AbstractWheelTextAdapter(Context context, int itemResource, int itemTextResource, boolean[] isSelected) {
        this.context = context;
        itemResourceId = itemResource;
        itemTextResourceId = itemTextResource;
        this.isSelected = isSelected;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    /**
     * Gets text color
     *
     * @return the text color
     */
    public int getTextColor() {
        return textColor;
    }

    /**
     * Sets text color
     *
     * @param textColor
     *            the text color to set
     */
    public void setTextColor(int textColor) {
        this.textColor = textColor;
    }

    /**
     * Gets text size
     *
     * @return the text size
     */
    public int getTextSize() {
        return textSize;
    }

    /**
     * Sets text size
     *
     * @param textSize
     *            the text size to set
     */
    public void setTextSize(int textSize) {
        this.textSize = textSize;
    }

    /**
     * Gets resource Id for items views
     *
     * @return the item resource Id
     */
    public int getItemResource() {
        return itemResourceId;
    }

    /**
     * Sets resource Id for items views
     *
     * @param itemResourceId
     *            the resource Id to set
     */
    public void setItemResource(int itemResourceId) {
        this.itemResourceId = itemResourceId;
    }

    /**
     * Gets resource Id for text view in item layout
     *
     * @return the item text resource Id
     */
    public int getItemTextResource() {
        return itemTextResourceId;
    }

    /**
     * Sets resource Id for text view in item layout
     *
     * @param itemTextResourceId
     *            the item text resource Id to set
     */
    public void setItemTextResource(int itemTextResourceId) {
        this.itemTextResourceId = itemTextResourceId;
    }

    /**
     * Gets resource Id for empty items views
     *
     * @return the empty item resource Id
     */
    public int getEmptyItemResource() {
        return emptyItemResourceId;
    }

    /**
     * Sets resource Id for empty items views
     *
     * @param emptyItemResourceId
     *            the empty item resource Id to set
     */
    public void setEmptyItemResource(int emptyItemResourceId) {
        this.emptyItemResourceId = emptyItemResourceId;
    }

    /**
     * Returns text for specified item
     *
     * @param index
     *            the item index
     * @return the text of specified items
     */
    protected abstract CharSequence getItemText(int index);

    @Override
    public View getItem(int index, View convertView, ViewGroup parent) {
        if (index >= 0 && index < getItemsCount()) {
            if (convertView == null) {
                convertView = getView(itemResourceId, parent);
            }
            TextView textView = getTextView(convertView, itemTextResourceId);
            // 用于多选的时候 改变选中状态
            ImageView imageView = (ImageView) convertView.findViewById(R.id.flag);
            // DJILog.d("LWF", "Text at index " + index + " is " + textView.getText() + " itemTextResourceId " + itemTextResourceId);
            if (isSelected != null && index < isSelected.length) {
                if (isSelected[index]) {
                    imageView.setVisibility(View.VISIBLE);
                    textView.setTextColor(Color.RED);
                } else {
                    imageView.setVisibility(View.INVISIBLE);
                    textView.setTextColor(Color.BLACK);
                }
            }
            // 用于单选的时候 改变选中状态
            if (textView != null) {
                CharSequence text = getItemText(index);
                if (text == null) {
                    text = "";
                }
                textView.setText(text);
                if (itemResourceId == TEXT_VIEW_ITEM_RESOURCE) {
                    configureTextView(textView);
                }
            }
            return convertView;
        }
        return null;
    }

    @Override
    public View getEmptyItem(View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = getView(emptyItemResourceId, parent);
        }
        if (emptyItemResourceId == TEXT_VIEW_ITEM_RESOURCE && convertView instanceof TextView) {
            configureTextView((TextView) convertView);
        }
        return convertView;
    }

    /**
     * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
     *
     * @param view
     *            the text view to be configured
     */
    protected void configureTextView(TextView view) {
        view.setTextColor(textColor);
        view.setGravity(Gravity.CENTER);
        view.setTextSize(textSize);
        view.setLines(1);
        view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    }

    /**
     * Loads a text view from view
     *
     * @param view
     *            the text view or layout containing it
     * @param textResource
     *            the text resource Id in layout
     * @return the loaded text view
     */
    private TextView getTextView(View view, int textResource) {
        TextView text = null;
        try {
            if (textResource == NO_RESOURCE && view instanceof TextView) {
                text = (TextView) view;
            } else if (textResource != NO_RESOURCE) {
                text = (TextView) view.findViewById(textResource);
            }
        } catch (ClassCastException e) {
            // DJILog.e("AbstractWheelAdapter", "You must supply a resource ID for a TextView");
            throw new IllegalStateException("AbstractWheelAdapter requires the resource ID to be a TextView", e);
        }
        return text;
    }

    /**
     * Loads view from resources
     *
     * @param resource
     *            the resource Id
     * @return the loaded view or null if resource is not set
     */
    private View getView(int resource, ViewGroup parent) {

    }

    public void getChange(int index) {
        this.index = index;
        notifyDataChangedEvent();
    }

    public void setSelected(int index) {
        // No selection support by default in base class;
    }

    public void setChange(int index) {
        setSelected(index);
        notifyDataChangedEvent();
    }

    public void notifyDataChanged() {
        notifyDataChangedEvent();
    }
}


switch(item.getItemId()) {
            case R.id.action_add:
                SelectAlbumBuilder.with(getSupportFragmentManager()).title(getString(R.string.chose_folders)).exploreMode(true).force(true).onFolderSelected(path -> addFolder(new File(path))).show();
                return true;
            case R.id.action_toggle:
                loadFolders(isExcludedMode() ? HandlingAlbums.INCLUDED : HandlingAlbums.EXCLUDED);
                return true;
        }

package org.horaapps.leafpic.activities;

import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.OvershootInterpolator;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.SelectAlbumBuilder;
import org.horaapps.leafpic.activities.base.SharedMediaActivity;
import org.horaapps.leafpic.data.HandlingAlbums;
import org.horaapps.leafpic.data.filter.ImageFileFilter;
import org.horaapps.leafpic.util.AnimationUtils;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.util.preferences.Prefs;
import org.horaapps.liz.ui.ThemedIcon;
import java.io.File;
import java.util.ArrayList;
import jp.wasabeef.recyclerview.animators.LandingAnimator;
import static org.horaapps.leafpic.data.MediaHelper.scanFile;

/**
 * Created by dnld on 01/04/16.
 */
public class BlackWhiteListActivity extends SharedMediaActivity {

    public static final String EXTRA_TYPE = "typeExcluded";

    private RecyclerView mRecyclerView;

    private ItemsAdapter adapter;

    private Toolbar toolbar;

    private ArrayList<String> folders = new ArrayList<>();

    private boolean typeExcluded;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_black_white_list);
        toolbar = findViewById(R.id.toolbar);
        mRecyclerView = findViewById(R.id.excluded_albums);
        initUi();
        loadFolders(getIntent().getIntExtra(EXTRA_TYPE, HandlingAlbums.EXCLUDED));
    }

    private void loadFolders(int type) {
        typeExcluded = type == HandlingAlbums.EXCLUDED;
        folders = HandlingAlbums.getInstance(getApplicationContext()).getFolders(type);
        checkNothing();
        if (isExcludedMode())
            setTitle(getString(R.string.excluded_items));
        else
            setTitle(getString(R.string.white_list));
        adapter.notifyDataSetChanged();
        supportInvalidateOptionsMenu();
    }

    private boolean isExcludedMode() {
        return typeExcluded;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_black_white_list, menu);
        menu.findItem(R.id.action_add).setIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_add_circle));
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        if (isExcludedMode()) {
            menu.findItem(R.id.action_add).setVisible(false);
            menu.findItem(R.id.action_toggle).setTitle(R.string.white_list);
        } else {
            menu.findItem(R.id.action_add).setVisible(true);
            menu.findItem(R.id.action_toggle).setTitle(R.string.excluded_items);
        }
        return super.onPrepareOptionsMenu(menu);
    }

    private void addFolder(final File dir) {
        String[] list = dir.list(new ImageFileFilter(true));
        if (list != null && list.length > 0) {
            scanFile(getApplicationContext(), list);
            HandlingAlbums.getInstance(getApplicationContext()).addFolderToWhiteList(dir.getPath());
            folders.add(0, dir.getPath());
            adapter.notifyItemInserted(0);
            checkNothing();
        } else {
            Toast.makeText(getApplicationContext(), R.string.no_media_in_this_folder, Toast.LENGTH_SHORT).show();
            // TODO: 12/26/16 should i add or not?
        }
    }

    private void checkNothing() {
        findViewById(R.id.white_list_decription_card).setVisibility(showDescriptionCard() ? View.VISIBLE : View.GONE);
        findViewById(R.id.nothing_to_show_placeholder).setVisibility(showNothingToShowPlaceholder() ? View.VISIBLE : View.GONE);
        findViewById(R.id.ll_emoji_easter_egg).setVisibility(showEasterEgg() ? View.VISIBLE : View.GONE);
    }

    private boolean showDescriptionCard() {
        return !isExcludedMode() && Prefs.getToggleValue(getString(R.string.preference_show_tips), true);
    }

    private boolean showNothingToShowPlaceholder() {
        return folders.size() < 1 && isExcludedMode() && !Prefs.showEasterEgg();
    }

    private boolean showEasterEgg() {
        return folders.size() < 1 && isExcludedMode() && Prefs.showEasterEgg();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        return super.onOptionsItemSelected(item);
    }

    private void initUi() {
        setSupportActionBar(toolbar);
        toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
        toolbar.setNavigationOnClickListener(v -> onBackPressed());
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setAdapter((adapter = new ItemsAdapter()));
        mRecyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 1));
        mRecyclerView.setItemAnimator(AnimationUtils.getItemAnimator(new LandingAnimator(new OvershootInterpolator(1f))));
    }

    @CallSuper
    @Override
    public void updateUiElements() {
        super.updateUiElements();
        toolbar.setBackgroundColor(getPrimaryColor());
        mRecyclerView.setBackgroundColor(getBackgroundColor());
        setStatusBarColor();
        setNavBarColor();
        toolbar.setTitle(getTitle());
        setRecentApp(getTitle().toString());
        ((CardView) findViewById(R.id.white_list_decription_card)).setCardBackgroundColor(getCardBackgroundColor());
        ((TextView) findViewById(R.id.white_list_decription_txt)).setTextColor(getTextColor());
        // TODO: EMOJI EASTER EGG - THERE'S NOTHING TO SHOW
        ((TextView) findViewById(R.id.emoji_easter_egg)).setTextColor(getSubTextColor());
        ((TextView) findViewById(R.id.nothing_to_show_text_emoji_easter_egg)).setTextColor(getSubTextColor());
        findViewById(org.horaapps.leafpic.R.id.rl_ea).setBackgroundColor(getBackgroundColor());
    }

    private class ItemsAdapter extends RecyclerView.Adapter<ItemsAdapter.ViewHolder> {

        private View.OnClickListener listener = v -> {
            String path = (String) v.getTag();
            int i = folders.indexOf(path);
            HandlingAlbums.getInstance(getApplicationContext()).clearStatusFolder(path);
            folders.remove(i);
            notifyItemRemoved(i);
            checkNothing();
        };

        @NonNull
        public ItemsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_track_folder, parent, false);
            v.findViewById(R.id.remove_icon).setOnClickListener(listener);
            return new ItemsAdapter.ViewHolder(v);
        }

        @Override
        public void onBindViewHolder(@NonNull final ItemsAdapter.ViewHolder holder, final int position) {
            String itm = folders.get(position);
            holder.path.setText(itm);
            holder.name.setText(StringUtils.getName(itm));
            holder.imgRemove.setTag(itm);
            holder.name.setTextColor(getTextColor());
            holder.path.setTextColor(getSubTextColor());
            holder.imgFolder.setColor(getIconColor());
            holder.imgRemove.setColor(getIconColor());
            holder.layout.setBackgroundColor(getCardBackgroundColor());
        }

        public int getItemCount() {
            return folders.size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {

            LinearLayout layout;

            ThemedIcon imgFolder, imgRemove;

            TextView name, path;

            ViewHolder(View itemView) {
                super(itemView);
                layout = itemView.findViewById(R.id.linear_card_excluded);
                imgFolder = itemView.findViewById(R.id.folder_icon);
                imgRemove = itemView.findViewById(R.id.remove_icon);
                name = itemView.findViewById(R.id.folder_name);
                path = itemView.findViewById(R.id.folder_path);
            }
        }
    }
}