File:  [Public] / java / classes / org / w3c / tools / resources / ArrayAttribute.java
Revision 1.5: download - view: text, annotated - select for diffs
Fri Oct 18 13:42:25 2013 UTC (12 years, 2 months ago) by ylafon
Branches: MAIN
CVS tags: HEAD
generics + raw types + serializer

// ArrayAttribute.java
// $Id: ArrayAttribute.java,v 1.5 2013/10/18 13:42:25 ylafon Exp $
// (c) COPYRIGHT MIT, INRIA and Keio, 1999.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.tools.resources;

/**
 * @author Beno�t Mah� (bmahe@w3.org)
 * @version $Revision: 1.5 $
 */
abstract public class ArrayAttribute extends Attribute {

    private static final long serialVersionUID = 3452520932010700646L;

    /**
     * Unpickle an attribute array from a string array.
     *
     * @param array the String array
     * @return a Object array
     */
    public abstract Object unpickle(String array[]);

    /**
     * Pickle an attribute array into a String array.
     *
     * @param array the attribute array
     * @return a String array
     */
    public abstract String[] pickle(Object array);

    public String stringify(Object value) {
        String array[] = pickle(value);
        StringBuilder sb = new StringBuilder();
        boolean addSeparator = false;
        for (String arrayVal : array) {
            if (addSeparator) {
                sb.append(" | ");
            } else {
                addSeparator = true;
            }
            sb.append(arrayVal);
        }
        return sb.toString();
    }

    public ArrayAttribute(String name, Object def, int flags) {
        super(name, def, flags);
    }

    public ArrayAttribute() {
        super();
    }

}

Webmaster