All Downloads are FREE. Search and download functionalities are using the official Maven repository.

prefuse.data.parser.StringParser Maven / Gradle / Ivy

Go to download

Prefuse is a set of software tools for creating rich interactive data visualizations in the Java programming language.

The newest version!
package prefuse.data.parser;

/**
 * DataParser instance that "parses" a String value from a text string, this
 * is the default fallback parser, which simply returns the string value
 * to be parsed.
 *  
 * @author jeffrey heer
 */
public class StringParser implements DataParser {
    
    /**
     * Returns String.class.
     * @see prefuse.data.parser.DataParser#getType()
     */
    public Class getType() {
        return String.class;
    }
    
    /**
     * @see prefuse.data.parser.DataParser#format(java.lang.Object)
     */
    public String format(Object value) {
        if ( value == null ) return null;
        if ( !(value instanceof String) )
            throw new IllegalArgumentException(
              "This class can only format Objects of type String.");
        return (String)value;
    }
    
    /**
     * @see prefuse.data.parser.DataParser#canParse(java.lang.String)
     */
    public boolean canParse(String text) {
        return true;
    }
    
    /**
     * @see prefuse.data.parser.DataParser#parse(java.lang.String)
     */
    public Object parse(String text) throws DataParseException {
        return text;
    }
    
    /**
     * Simply returns the input string.
     * @param text the text string to "parse"
     * @return the input text string
     * @throws DataParseException never actually throws an exception
     */
    public String parseString(String text) throws DataParseException {
        return text;
    }
    
} // end of class StringParser




© 2015 - 2025 Weber Informatics LLC | Privacy Policy