2020-01-21 20:07:49 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
|
|
|
|
*
|
|
|
|
* This file is part of AgirStatool, simple key value database.
|
|
|
|
*
|
|
|
|
* AgirStatool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* AgirStatool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with AgirStatool. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package org.april.agirstatool.charts;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2020-01-22 10:39:44 +01:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
2020-01-21 20:07:49 +01:00
|
|
|
import fr.devinsy.strings.StringList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class Projects.
|
|
|
|
*/
|
|
|
|
public class DateCountList extends ArrayList<DateCount>
|
|
|
|
{
|
|
|
|
private static final long serialVersionUID = -5526492552751712533L;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new date count map.
|
|
|
|
*/
|
|
|
|
public DateCountList()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2020-01-24 13:15:24 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new date count list.
|
|
|
|
*
|
|
|
|
* @param capacity
|
|
|
|
* the capacity
|
|
|
|
*/
|
|
|
|
public DateCountList(final int capacity)
|
|
|
|
{
|
|
|
|
super(capacity);
|
|
|
|
}
|
|
|
|
|
2020-01-22 10:39:44 +01:00
|
|
|
/**
|
|
|
|
* Indexof.
|
|
|
|
*
|
|
|
|
* @param dateToken
|
|
|
|
* the date token
|
|
|
|
* @return the int
|
|
|
|
*/
|
|
|
|
public int indexOf(final String dateToken)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
boolean ended = false;
|
|
|
|
result = -1;
|
|
|
|
int index = 0;
|
|
|
|
while (!ended)
|
|
|
|
{
|
|
|
|
if (index < this.size())
|
|
|
|
{
|
|
|
|
DateCount current = get(index);
|
|
|
|
if (StringUtils.equals(current.getDate(), dateToken))
|
|
|
|
{
|
|
|
|
ended = true;
|
|
|
|
result = index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
index += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ended = true;
|
|
|
|
result = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-21 20:07:49 +01:00
|
|
|
/**
|
|
|
|
* To value list.
|
|
|
|
*
|
|
|
|
* @return the string list
|
|
|
|
*/
|
|
|
|
public StringList toValueList()
|
|
|
|
{
|
|
|
|
StringList result;
|
|
|
|
|
|
|
|
result = new StringList();
|
|
|
|
|
|
|
|
for (DateCount item : this)
|
|
|
|
{
|
|
|
|
result.append(item.getCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|