statoolinfosweb/src/fr/devinsy/statoolinfos/crawl/CrawlLogs.java

143 lines
2.9 KiB
Java
Raw Normal View History

/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
* StatoolInfos 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.
*
* StatoolInfos 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 StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.crawl;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
/**
* The Class CrawlLogs.
*/
public class CrawlLogs extends ArrayList<CrawlLog>
{
private static final long serialVersionUID = -8749217049690008582L;
/**
* Instantiates a new crawl logs.
*/
public CrawlLogs()
{
super();
}
/**
* Adds the.
*
* @param url
* the url
* @param status
* the status
*/
public void add(final URL url, final CrawlStatus status)
{
this.add(new CrawlLog(url, status));
}
/**
* Find by software.
*
* @param softwareName
* the software name
* @return the category
*/
public CrawlLogs findByUrl(final URL url)
{
CrawlLogs result;
result = new CrawlLogs();
for (CrawlLog log : this)
{
if (StringUtils.equals(log.getUrl().toString(), url.toString()))
{
result.add(log);
}
}
//
return result;
}
/**
* Gets the errors.
*
* @return the errors
*/
public CrawlLogs getErrors()
{
CrawlLogs result;
result = new CrawlLogs();
for (CrawlLog log : this)
{
if (log.getStatus().isError())
{
result.add(log);
}
}
//
return result;
}
/**
* Gets the success.
*
* @return the success
*/
public CrawlLogs getSuccess()
{
CrawlLogs result;
result = new CrawlLogs();
for (CrawlLog log : this)
{
if (!log.getStatus().isError())
{
result.add(log);
}
}
//
return result;
}
/**
* Reverse.
*
* @return the categories
*/
public CrawlLogs reverse()
{
CrawlLogs result;
Collections.reverse(this);
result = this;
//
return result;
}
}