104 lines
2.5 KiB
Java
104 lines
2.5 KiB
Java
/*
|
|
* Copyright (C) 2020 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.htmlize;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import fr.devinsy.strings.StringList;
|
|
import fr.devinsy.xidyn.utils.XidynUtils;
|
|
|
|
/**
|
|
* The Class BreadcrumbTrail.
|
|
*/
|
|
public class BreadcrumbTrail extends ArrayList<Breadcrumb>
|
|
{
|
|
private static final long serialVersionUID = -2688444486042912675L;
|
|
|
|
/**
|
|
* Instantiates a new breadcrumb trail.
|
|
*/
|
|
public BreadcrumbTrail()
|
|
{
|
|
this("🏡", "index.xhtml");
|
|
}
|
|
|
|
/**
|
|
* Instantiates a new breadcrumb trail.
|
|
*
|
|
* @param label
|
|
* the label
|
|
* @param link
|
|
* the link
|
|
*/
|
|
public BreadcrumbTrail(final String label, final String link)
|
|
{
|
|
super();
|
|
add(label, link);
|
|
}
|
|
|
|
/**
|
|
* Adds the.
|
|
*
|
|
* @param label
|
|
* the label
|
|
* @param link
|
|
* the link
|
|
*/
|
|
public BreadcrumbTrail add(final String label, final String link)
|
|
{
|
|
BreadcrumbTrail result;
|
|
|
|
Breadcrumb crumb = new Breadcrumb(label, link);
|
|
|
|
add(crumb);
|
|
|
|
result = this;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* To string.
|
|
*
|
|
* @return the string
|
|
*/
|
|
@Override
|
|
public String toString()
|
|
{
|
|
String result;
|
|
|
|
StringList buffer = new StringList();
|
|
|
|
for (Breadcrumb crumb : this)
|
|
{
|
|
buffer.append(String.format("<a href=\"%s\" style=\"text-decoration: none; padding: 5px;\">%s</a>", crumb.getLink(), XidynUtils.escapeXmlBlank(crumb.getLabel())));
|
|
buffer.append(" > ");
|
|
}
|
|
if (buffer.size() > 2)
|
|
{
|
|
buffer.removeLast();
|
|
}
|
|
|
|
result = buffer.toString();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
}
|