Example usage for java.util ListIterator remove

List of usage examples for java.util ListIterator remove

Introduction

In this page you can find the example usage for java.util ListIterator remove.

Prototype

void remove();

Source Link

Document

Removes from the list the last element that was returned by #next or #previous (optional operation).

Usage

From source file:storm.mesos.schedulers.StormSchedulerImpl.java

/**
 * Schedule function looks in the "mesosWorkerSlotMap" to determine which topology owns the particular
 * WorkerSlot and assigns the executors accordingly.
 *///from w  w  w .j  a v  a  2  s  .  com
@Override
public void schedule(Topologies topologies, Cluster cluster) {
    List<WorkerSlot> workerSlots = cluster.getAvailableSlots();
    String info = "";

    if (!workerSlots.isEmpty()) {
        info = "Scheduling the following worker slots from cluster.getAvailableSlots: ";
        List<String> workerSlotsStrings = new ArrayList<String>();
        for (WorkerSlot ws : workerSlots) {
            workerSlotsStrings.add(ws.toString());
        }
        info += String.format("[%s]", StringUtils.join(workerSlotsStrings, ", "));
        log.info(info);
    }

    Map<String, List<MesosWorkerSlot>> perTopologySlotList = getMesosWorkerSlotPerTopology(workerSlots);
    if (perTopologySlotList.isEmpty()) {
        return;
    }
    info = "Schedule the per-topology slots:";
    for (String topo : perTopologySlotList.keySet()) {
        List<String> mwsAssignments = new ArrayList<>();
        for (MesosWorkerSlot mws : perTopologySlotList.get(topo)) {
            mwsAssignments.add(mws.getNodeId() + ":" + mws.getPort());
        }
        info += String.format(" {%s, [%s]}", topo, StringUtils.join(mwsAssignments, ", "));
    }
    log.info(info);

    // So far we know how many MesosSlots each of the topologies have got. Let's assign executors for each of them
    for (String topologyId : perTopologySlotList.keySet()) {
        TopologyDetails topologyDetails = topologies.getById(topologyId);
        List<MesosWorkerSlot> mesosWorkerSlots = perTopologySlotList.get(topologyId);

        int slotsRequested = topologyDetails.getNumWorkers();
        int slotsAssigned = cluster.getAssignedNumWorkers(topologyDetails);
        int slotsAvailable = mesosWorkerSlots.size();

        if (slotsAvailable == 0) {
            log.warn("No slots found for topology {} while scheduling", topologyId);
            continue;
        }

        log.info("topologyId: {}, slotsRequested: {}, slotsAssigned: {}, slotsAvailable: {}", topologyId,
                slotsRequested, slotsAssigned, slotsAvailable);

        List<List<ExecutorDetails>> executorsPerWorkerList = executorsPerWorkerList(cluster, topologyDetails,
                slotsRequested, slotsAssigned, slotsAvailable);
        if (executorsPerWorkerList == null || executorsPerWorkerList.isEmpty()) {
            continue;
        }

        info = "schedule: Cluster assignment for " + topologyId + "." + " Requesting " + slotsRequested
                + " slots, with " + slotsAvailable + " slots available, and " + slotsAssigned
                + " currently assigned." + " Setting new assignment (node:port, executorsPerWorkerList) as: ";
        List<String> slotAssignmentStrings = new ArrayList<String>();
        ListIterator<List<ExecutorDetails>> iterator = executorsPerWorkerList.listIterator();
        while (iterator.hasNext()) {
            List<ExecutorDetails> executorsPerWorker = iterator.next();
            slotAssignmentStrings.add("(" + mesosWorkerSlots.get(0).getNodeId() + ":"
                    + mesosWorkerSlots.get(0).getPort() + ", " + executorsPerWorker.toString() + ")");
            iterator.remove();
            cluster.assign(mesosWorkerSlots.remove(0), topologyId, executorsPerWorker);
        }
        if (slotsAvailable == 0) {
            info += "[]";
        } else {
            info += StringUtils.join(slotAssignmentStrings, ", ");
        }
        log.info(info);
    }
    mesosWorkerSlotMap.clear();
}

From source file:org.squashtest.tm.service.internal.repository.hibernate.TestCaseDaoImpl.java

/**
 * @param userSorting/*  w  w w  . j a  v a  2s.c  o  m*/
 * @return
 */
/*
 * Issue #1629
 *
 * Observed problem : test cases sorted by references are indeed sorted by reference, but no more by name. Actual
 * problem : We always want them to be sorted by reference and name, even when we want primarily sort them by
 * project or execution type or else. Solution : The resultset will be sorted on all the attributes (ascending), and
 * the Sorting specified by the user will have an higher priority.
 *
 * See #createEffectiveSorting(Sorting sorting), just below
 */

private List<Sorting> createEffectiveSorting(Sorting userSorting) {

    LinkedList<Sorting> sortings = new LinkedList<Sorting>(defaultVerifiedTcSorting);

    // from that list we filter out the redundant element, considering the argument.
    // note that the sorting order is irrelevant here.
    ListIterator<Sorting> iterator = sortings.listIterator();
    while (iterator.hasNext()) {
        Sorting defaultSorting = iterator.next();
        if (defaultSorting.getSortedAttribute().equals(userSorting.getSortedAttribute())) {
            iterator.remove();
            break;
        }
    }

    // now we can set the Sorting specified by the user in first position
    sortings.addFirst(userSorting);

    return sortings;
}

From source file:org.springframework.yarn.support.statemachine.AbstractStateMachine.java

private void processDeferList() {
    log.debug("Process defer list");
    ListIterator<Message<E>> iterator = deferList.listIterator();
    while (iterator.hasNext()) {
        Message<E> event = iterator.next();
        for (Transition<S, E> transition : transitions) {
            State<S, E> source = transition.getSource();
            State<S, E> target = transition.getTarget();
            Trigger<S, E> trigger = transition.getTrigger();
            if (source.equals(currentState)) {
                if (trigger != null && trigger.evaluate(event.getPayload())) {
                    transition.transit(event.getHeaders());
                    if (transition.getKind() != TransitionKind.INTERNAL) {
                        switchToState(target);
                    }//from www  . j a va2s .co m
                    iterator.remove();
                }
            }
        }
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.dao.filtering.IndividualFiltering.java

@Override
public List<DataProperty> getDataPropertyList() {
    List<DataProperty> dprops = _innerIndividual.getDataPropertyList();
    LinkedList<DataProperty> outdProps = new LinkedList<DataProperty>();
    if (dprops == null)
        return outdProps;
    Filter.filter(dprops, _filters.getDataPropertyFilter(), outdProps);

    ListIterator<DataProperty> it = outdProps.listIterator();
    while (it.hasNext()) {
        DataProperty dp = it.next();/* www . j  ava 2s  . com*/
        List<DataPropertyStatement> filteredStmts = new LinkedList<DataPropertyStatement>();
        Filter.filter(dp.getDataPropertyStatements(), _filters.getDataPropertyStatementFilter(), filteredStmts);
        if (filteredStmts.size() == 0) {
            it.remove();
        } else {
            dp.setDataPropertyStatements(filteredStmts);
        }
    }
    return outdProps;
}

From source file:org.sparkcommerce.openadmin.server.service.AdminEntityServiceImpl.java

@Override
public PersistenceResponse addSubCollectionEntity(EntityForm entityForm, ClassMetadata mainMetadata,
        Property field, Entity parentEntity, List<SectionCrumb> sectionCrumbs)
        throws ServiceException, ClassNotFoundException {
    // Assemble the properties from the entity form
    List<Property> properties = new ArrayList<Property>();
    for (Entry<String, Field> entry : entityForm.getFields().entrySet()) {
        Property p = new Property();
        p.setName(entry.getKey());//from w ww .ja  v  a 2 s  . co  m
        p.setValue(entry.getValue().getValue());
        properties.add(p);
    }

    FieldMetadata md = field.getMetadata();

    PersistencePackageRequest ppr = PersistencePackageRequest.fromMetadata(md, sectionCrumbs)
            .withEntity(new Entity());

    if (md instanceof BasicCollectionMetadata) {
        BasicCollectionMetadata fmd = (BasicCollectionMetadata) md;
        ppr.getEntity().setType(new String[] { entityForm.getEntityType() });

        // If we're looking up an entity instead of trying to create one on the fly, let's make sure 
        // that we're not changing the target entity at all and only creating the association to the id
        if (fmd.getAddMethodType().equals(AddMethodType.LOOKUP)) {
            List<String> fieldsToRemove = new ArrayList<String>();

            String idProp = getIdProperty(mainMetadata);
            for (String key : entityForm.getFields().keySet()) {
                if (!idProp.equals(key)) {
                    fieldsToRemove.add(key);
                }
            }

            for (String key : fieldsToRemove) {
                ListIterator<Property> li = properties.listIterator();
                while (li.hasNext()) {
                    if (li.next().getName().equals(key)) {
                        li.remove();
                    }
                }
            }

            ppr.setValidateUnsubmittedProperties(false);
        }

        Property fp = new Property();
        fp.setName(ppr.getForeignKey().getManyToField());
        fp.setValue(getContextSpecificRelationshipId(mainMetadata, parentEntity, field.getName()));
        properties.add(fp);
    } else if (md instanceof AdornedTargetCollectionMetadata) {
        ppr.getEntity().setType(new String[] { ppr.getAdornedList().getAdornedTargetEntityClassname() });

        String[] maintainedFields = ((AdornedTargetCollectionMetadata) md).getMaintainedAdornedTargetFields();
        if (maintainedFields == null || maintainedFields.length == 0) {
            ppr.setValidateUnsubmittedProperties(false);
        }
    } else if (md instanceof MapMetadata) {
        ppr.getEntity().setType(new String[] { entityForm.getEntityType() });

        Property p = new Property();
        p.setName("symbolicId");
        p.setValue(getContextSpecificRelationshipId(mainMetadata, parentEntity, field.getName()));
        properties.add(p);
    } else {
        throw new IllegalArgumentException(
                String.format("The specified field [%s] for class [%s] was" + " not a collection field.",
                        field.getName(), mainMetadata.getCeilingType()));
    }

    ppr.setCeilingEntityClassname(ppr.getEntity().getType()[0]);
    String sectionField = field.getName();
    if (sectionField.contains(".")) {
        sectionField = sectionField.substring(0, sectionField.lastIndexOf("."));
    }
    ppr.setSectionEntityField(sectionField);

    Property parentNameProp = parentEntity.getPMap().get(AdminMainEntity.MAIN_ENTITY_NAME_PROPERTY);
    if (parentNameProp != null) {
        ppr.setRequestingEntityName(parentNameProp.getValue());
    }

    Property[] propArr = new Property[properties.size()];
    properties.toArray(propArr);
    ppr.getEntity().setProperties(propArr);

    return add(ppr);
}

From source file:com.kunze.androidlocaltodo.TaskListActivity.java

private void LoadAstrid() {
    // Look for a zip file in the proper location
    String loc = Environment.getExternalStorageDirectory() + "/AstridImport/";
    AlertDialog.Builder errorBuilder = new AlertDialog.Builder(this);
    errorBuilder.setTitle("Error reading Astrid Import!");
    ZipInputStream zipStream = null;
    InputStream stream = null;/*from   w  w w  . j a  v  a  2 s. co m*/
    try {
        // Try to safely open the file
        String errText = "Cannot find Astrid file in " + loc;
        File astridDir = new File(loc);
        if (!astridDir.isDirectory()) {
            throw new Exception(errText);
        }

        File[] files = astridDir.listFiles();
        if (files.length != 1) {
            throw new Exception(errText);
        }

        File astridFile = files[0];
        if (!astridFile.isFile()) {
            throw new Exception(errText);
        }

        // Try to unzip the file and unpack the tasks
        errText = "Could not unzip file " + astridFile.getAbsolutePath();
        stream = new FileInputStream(astridFile);
        zipStream = new ZipInputStream(stream);

        ZipEntry tasksEntry = null;
        while ((tasksEntry = zipStream.getNextEntry()) != null) {
            if (tasksEntry.getName().equals("tasks.csv")) {
                break;
            }
        }
        if (tasksEntry == null) {
            throw new Exception(errText);
        }

        int size = (int) tasksEntry.getSize();
        byte tasksContent[] = new byte[size];
        int offset = 0;
        while (size != 0) {
            int read = zipStream.read(tasksContent, offset, size);
            if (read == 0) {
                throw new Exception(errText);
            }
            offset += read;
            size -= read;
        }

        String tasksString = new String(tasksContent, "UTF-8");

        // Parse the tasks in the task list
        errText = "Could not parse task list";
        List<String> taskLines = new LinkedList<String>(Arrays.asList(tasksString.split("\n")));
        // Remove the header row
        taskLines.remove(0);
        // Some tasks have newlines in quotes, so we have to adjust for that.
        ListIterator<String> it = taskLines.listIterator();
        while (it.hasNext()) {
            String task = it.next();
            while (CountQuotes(task) % 2 == 1) {
                it.remove();
                task += it.next();
            }
            it.set(task);
        }
        for (String taskLine : taskLines) {
            List<String> taskFields = new LinkedList<String>(Arrays.asList(taskLine.split(",", -1)));
            // Some tasks have commas in quotes, so we have to adjust for that.
            it = taskFields.listIterator();
            while (it.hasNext()) {
                String field = it.next();
                while (CountQuotes(field) % 2 == 1) {
                    it.remove();
                    field += it.next();
                }
                it.set(field);
            }

            Task taskElement = new Task();
            taskElement.mName = taskFields.get(0);
            taskElement.mDescription = taskFields.get(8);

            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);

            taskElement.mDueDate = Calendar.getInstance();
            taskElement.mDueDate.setTime(dateFormat.parse(taskFields.get(4)));
            String completedString = taskFields.get(9);
            taskElement.mCompletedDate = Calendar.getInstance();
            if (completedString.equals("")) {
                taskElement.mCompletedDate.setTimeInMillis(0);
            } else {
                taskElement.mCompletedDate.setTime(dateFormat.parse(completedString));
            }
            taskElement.mRepeatUnit = Task.RepeatUnit.NONE;
            taskElement.mRepeatTime = 0;
            taskElement.mRepeatFromComplete = false;
            String repeatString = taskFields.get(6);
            String repeatFields[] = repeatString.split(":");
            if (repeatFields[0].equals("RRULE")) {
                repeatFields = repeatFields[1].split(";");
                String freqFields[] = repeatFields[0].split("=");
                if (freqFields[0].equals("FREQ")) {
                    if (freqFields[1].equals("YEARLY")) {
                        taskElement.mRepeatUnit = Task.RepeatUnit.YEARS;
                    } else if (freqFields[1].equals("MONTHLY")) {
                        taskElement.mRepeatUnit = Task.RepeatUnit.MONTHS;
                    } else if (freqFields[1].equals("WEEKLY")) {
                        taskElement.mRepeatUnit = Task.RepeatUnit.WEEKS;
                    } else if (freqFields[1].equals("DAILY")) {
                        taskElement.mRepeatUnit = Task.RepeatUnit.DAYS;
                    }
                }
                freqFields = repeatFields[1].split("=");
                if (freqFields[0].equals("INTERVAL")) {
                    taskElement.mRepeatTime = Integer.valueOf(freqFields[1]);
                }
                if (repeatFields.length > 2 && repeatFields[2] != null) {
                    freqFields = repeatFields[2].split("=");
                    if (freqFields[0].equals("FROM") && freqFields[1].equals("COMPLETION")) {
                        taskElement.mRepeatFromComplete = true;
                    }
                }
            }
            mDB.AddTask(taskElement);
        }

        RefreshView();
    } catch (Exception e) {
        AlertDialog dlg = errorBuilder.setMessage(e.getMessage()).create();
        dlg.show();
    } finally {

        try {
            if (zipStream != null) {
                zipStream.close();
            }
            if (stream != null) {
                stream.close();
            }
        } catch (Exception e) {
            AlertDialog dlg = errorBuilder.setMessage(e.getMessage()).create();
            dlg.show();
        }
    }
}

From source file:edu.umd.cfar.lamp.viper.geometry.BoundingBox.java

/**
 * Call this after changing the rectangle in any way. It removes rectangles
 * of size less than 1, and it also converts "composed" rectangles with
 * only one rectangle to uncomposed; it also updates the polygon.
 *//*from ww  w.ja v a 2s  .  c o  m*/
private void simplify() {
    boolean startedComposed = composed;
    if (composed) {
        if (pieces.size() == 0) {
            pieces = null;
            composed = false;
            rect = new Rectangle();
        } else if (pieces.size() == 1) {
            BoundingBox child = (BoundingBox) pieces.getFirst();
            composed = false;
            if (child != null)
                setTo(child);
            else
                pieces.clear();
        } else if (pieces.size() > 1) {
            boolean changed = false;
            ListIterator iter = pieces.listIterator(0);
            while (iter.hasNext())
                if (!(((BoundingBox) iter.next()).area()).greaterThan(0)) {
                    iter.remove();
                    changed = true;
                }
            if (changed)
                simplify();
        }
    }
    if (startedComposed && !composed)
        initPoly();
}

From source file:com.alvermont.terraj.stargen.dole.DoleAccrete.java

/**
 * Creates a solar system. On return a list of
 * planets will be available that can be obtained with getPlanets()
 *
 * @param star The star in the solar system.
 *//*from  w w w.  j a  v a2  s  .  c  om*/
public void createSystem(Primary star) {
    short i;

    // fill in luminosity and ecosphere if not already set
    if (star.getLuminosity() == 0) {
        star.setLuminosity(EnviroUtils.getLuminosity(star.getMass()));
    }

    star.setREcosphere(Math.sqrt(star.getLuminosity()));

    star.setREcosphereInner(star.getREcosphere() * 0.93);
    star.setREcosphereOuter(star.getREcosphere() * 1.1);

    // done
    this.nNucleus = 0;

    /* A little initialization . . . */
    this.A = DoleConstants.AO * Math.sqrt(star.getMass());

    minRadius = DoleConstants.MINRADIUS * Math.pow(star.getMass(), 0.33);
    maxRadius = DoleConstants.MAXRADIUS * Math.pow(star.getMass(), 0.33);

    initBands();

    /* . . . and we're off to play God. */
    while (!list0.isEmpty()) {
        final DolePlanetRecord p = createPlanet(star);

        if (p == null) {
            break;
        }

        evolvePlanet(star, p);

        checkCoalesence(star, p);
    }

    freeBands();

    i = 1;

    final ListIterator<Planet> li = star.getPlanets().listIterator();

    while (li.hasNext()) {
        final Planet pl = (Planet) li.next();

        if (pl.getMass() > 2e-8) {
            pl.setNumber(++i);

            planetStats.computePlanetStats(star, pl);
        } else {
            li.remove();
        }
    }
}

From source file:eu.europa.esig.dss.asic.validation.ASiCContainerValidator.java

private void analyseEntries() throws DSSException {

    ZipInputStream asicsInputStream = null;
    try {/*from w ww  .  j  a v  a2s. c om*/

        MimeType asicEntryMimeType = null;
        asicsInputStream = new ZipInputStream(asicContainer.openStream()); // The underlying stream is closed by the parent (asicsInputStream).

        for (ZipEntry entry = asicsInputStream.getNextEntry(); entry != null; entry = asicsInputStream
                .getNextEntry()) {

            String entryName = entry.getName();
            if (isCAdES(entryName)) {

                if (xadesSigned) {
                    throw new DSSNotETSICompliantException(
                            DSSNotETSICompliantException.MSG.DIFFERENT_SIGNATURE_FORMATS);
                }
                addEntryElement(entryName, signatures, asicsInputStream);
                cadesSigned = true;
            } else if (isXAdES(entryName)) {

                if (cadesSigned) {
                    throw new DSSNotETSICompliantException(
                            DSSNotETSICompliantException.MSG.DIFFERENT_SIGNATURE_FORMATS);
                }
                addEntryElement(entryName, signatures, asicsInputStream);
                xadesSigned = true;
            } else if (isTimestamp(entryName)) {

                addEntryElement(entryName, signatures, asicsInputStream);
                timestamped = true;
            } else if (isASiCManifest(entryName)) {

                addAsicManifestEntryElement(entryName, detachedContents, asicsInputStream);
            } else if (isManifest(entryName)) {

                addEntryElement(entryName, detachedContents, asicsInputStream);
            } else if (isContainer(entryName)) {

                addEntryElement(entryName, detachedContents, asicsInputStream);
            } else if (isMetadata(entryName)) {

                addEntryElement(entryName, detachedContents, asicsInputStream);
            } else if (isMimetype(entryName)) {

                final DSSDocument mimeType = addEntryElement(entryName, detachedContents, asicsInputStream);
                asicEntryMimeType = getMimeType(mimeType);
            } else if (entryName.indexOf("/") == -1) {

                addEntryElement(entryName, detachedContents, asicsInputStream);
            } else if (entryName.endsWith("/")) { // Folder
                continue;
            } else {

                addEntryElement(entryName, detachedContents, asicsInputStream);
            }
        }
        asicMimeType = determinateAsicMimeType(asicContainer.getMimeType(), asicEntryMimeType);
        if (MimeType.ASICS == asicMimeType) {

            final ListIterator<DSSDocument> dssDocumentListIterator = detachedContents.listIterator();
            while (dssDocumentListIterator.hasNext()) {

                final DSSDocument dssDocument = dssDocumentListIterator.next();
                final String detachedContentName = dssDocument.getName();
                if ("mimetype".equals(detachedContentName)) {
                    dssDocumentListIterator.remove();
                } else if (detachedContentName.indexOf('/') != -1) {
                    dssDocumentListIterator.remove();
                }
            }
        }
    } catch (Exception e) {
        if (e instanceof DSSException) {
            throw (DSSException) e;
        }
        throw new DSSException(e);
    } finally {
        IOUtils.closeQuietly(asicsInputStream);
    }
}

From source file:org.apache.cloudstack.api.response.QuotaResponseBuilderImpl.java

@Override
public QuotaBalanceResponse createQuotaBalanceResponse(List<QuotaBalanceVO> quotaBalance, Date startDate,
        Date endDate) {// w  w  w  .ja va 2 s.c  o m
    if (quotaBalance == null || quotaBalance.isEmpty()) {
        throw new InvalidParameterValueException("The request period does not contain balance entries.");
    }
    Collections.sort(quotaBalance, new Comparator<QuotaBalanceVO>() {
        public int compare(QuotaBalanceVO o1, QuotaBalanceVO o2) {
            o1 = o1 == null ? new QuotaBalanceVO() : o1;
            o2 = o2 == null ? new QuotaBalanceVO() : o2;
            return o2.getUpdatedOn().compareTo(o1.getUpdatedOn()); // desc
        }
    });

    boolean have_balance_entries = false;
    //check that there is at least one balance entry
    for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator(); it.hasNext();) {
        QuotaBalanceVO entry = it.next();
        if (entry.isBalanceEntry()) {
            have_balance_entries = true;
            break;
        }
    }
    //if last entry is a credit deposit then remove that as that is already
    //accounted for in the starting balance after that entry, note the sort is desc
    if (have_balance_entries) {
        ListIterator<QuotaBalanceVO> li = quotaBalance.listIterator(quotaBalance.size());
        // Iterate in reverse.
        while (li.hasPrevious()) {
            QuotaBalanceVO entry = li.previous();
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("createQuotaBalanceResponse: Entry=" + entry);
            }
            if (entry.getCreditsId() > 0) {
                li.remove();
            } else {
                break;
            }
        }
    }

    int quota_activity = quotaBalance.size();
    QuotaBalanceResponse resp = new QuotaBalanceResponse();
    BigDecimal lastCredits = new BigDecimal(0);
    boolean consecutive = true;
    for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator(); it.hasNext();) {
        QuotaBalanceVO entry = it.next();
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("createQuotaBalanceResponse: All Credit Entry=" + entry);
        }
        if (entry.getCreditsId() > 0) {
            if (consecutive) {
                lastCredits = lastCredits.add(entry.getCreditBalance());
            }
            resp.addCredits(entry);
            it.remove();
        } else {
            consecutive = false;
        }
    }

    if (quota_activity > 0 && quotaBalance.size() > 0) {
        // order is desc last item is the start item
        QuotaBalanceVO startItem = quotaBalance.get(quotaBalance.size() - 1);
        QuotaBalanceVO endItem = quotaBalance.get(0);
        resp.setStartDate(startDate);
        resp.setStartQuota(startItem.getCreditBalance());
        resp.setEndDate(endDate);
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("createQuotaBalanceResponse: Start Entry=" + startItem);
            s_logger.debug("createQuotaBalanceResponse: End Entry=" + endItem);
        }
        resp.setEndQuota(endItem.getCreditBalance().add(lastCredits));
    } else if (quota_activity > 0) {
        // order is desc last item is the start item
        resp.setStartDate(startDate);
        resp.setStartQuota(new BigDecimal(0));
        resp.setEndDate(endDate);
        resp.setEndQuota(new BigDecimal(0).add(lastCredits));
    } else {
        resp.setStartDate(startDate);
        resp.setEndDate(endDate);
        resp.setStartQuota(new BigDecimal(0));
        resp.setEndQuota(new BigDecimal(0));
    }
    resp.setCurrency(QuotaConfig.QuotaCurrencySymbol.value());
    resp.setObjectName("balance");
    return resp;
}