Java tutorial
/* * Copyright (C) 2014 Arnaud PETIT <arnaud.petit@minesdedouai.fr> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ package edu.jdomengine.core.attr; import org.apache.commons.lang.StringEscapeUtils; import edu.jdomengine.interfaces.IJDom; import edu.jdomengine.interfaces.IJDomNode; /** * Class representing a many attribute, i.e. an attribute that may have a list * of elements, separated by any character (default is space) */ abstract public class JDomManyAttribute extends JDomPromptAttribute { private static final long serialVersionUID = 1L; /** * Constructor for attributes with many values. * @param node {@link IJDomNode} the parent node of this one */ protected JDomManyAttribute(IJDomNode node) { super(node); } protected String separator = IJDom.SPACE; /** * Adds a new token to the list. * @param token the string to add to the list */ public void add(String token) { if (!(this.value == null || token.equals(IJDom.EMPTY_STRING) || this.value.equals(IJDom.EMPTY_STRING))) { this.value += this.separator + StringEscapeUtils.escapeHtml(token); } } }