/**
 * Class ListOfAttributeNames
 * The class holding the attributes that can be used in the namespace axsvg
 * and their meaning (ie the short english sentence to be
 * printed when interpreting an axsvg Element node that has such attributes
 * in a textual mode).
 * Of course, it implements some methods that allow the access to such names
 * and meanings.
 * Such a class is somehow temporary: Soon, the possible attributes and 
 * their meaning should be included in the RDF Schema corresponding
 * to the namespace axsvg, as well as for properties.
 * However, it's quite easy to add a new attribute, by adding an entry in
 * the array defined in the constructor method.
 **/

package axsvg;

import java.util.*;


public class ListOfAttributeNames {
    private final Hashtable attributeMeanings;
    private final String nameToMeaning[][];
    private int index = 0;

    /**
     * Method ListOfAttributeNames
     * The constructor of the class.
     * It sets the 2 dimensions String array that contains the name and
     * meaning (both in a row) of each attribute that can be used
     * in the axsvg namespace.
     * On the basis of  this array, it builds the Hashtable that allows the
     * access to any attribute meaning given its name.
     * As one can see, it's easy to add a new attribute: just add the
     * appropriate entry in the name2meaning array, within this method.
     **/
    public ListOfAttributeNames() {
	Hashtable atrMeanings = new Hashtable();
	int i = 0;

	String name2meaning[][] = {{"value","with a value of"},
				   {"start","that starts at"},
				   {"end","that ends at"},
				   {"range","with a range of"},
				   {"min","with a minimum of"},
				   {"max","with a maximum of"},
				   {"shape","whose general shape is"},
				   {"coord","with coordinates:"}};
	
	nameToMeaning = name2meaning;
	while(getNextAttributeName() != null) {
	    String name = nameToMeaning[i][0];
	    String meaning = nameToMeaning[i][1];
	    atrMeanings.put(name, meaning);
	    i++;
	}
	attributeMeanings = atrMeanings;
	    
    }

    /**
     * Method getNextAttributeName
     * @return the name of the next possible attribute (or the first one,
     * if being called for the first time since construction) in the axsvg
     * namespace. Returns null if there is no more attribute, and resets
     * its count (next call will return the first one again).
     **/
    public String getNextAttributeName() {
	try {
	    String name = nameToMeaning[index][0];
	    index++;
	    return(name);
	} catch(Exception e) {
	    index = 0;
	    return(null);
	}
    }


    /**
     * Method getMeaning
     * @param the name of an attribute
     * @return the meaning of the attribute whose name has been given
     * as a parameter. Returns null if such a name does not belong to
     * the axsvg namespace possible attributes (defined in this class
     * constructor).
     **/
    public String getMeaning(String name) {
	return((String)attributeMeanings.get(name));
    }

    /**
     * Method size
     * @return the number of elements in the list.
     **/
    public int size() {
	return(attributeMeanings.size());
    }

}
