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

uk.ac.starlink.table.URLValueInfo Maven / Gradle / Ivy

There is a newer version: 4.3
Show newest version
package uk.ac.starlink.table;

import java.util.ArrayList;
import java.util.List;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.table.TableCellRenderer;

/**
 * ValueInfo for URL values.
 *
 * @author   Mark Taylor (Starlink)
 * @since    16 Sep 2004
 */
public class URLValueInfo implements ValueInfo {

    private String ucd_;
    private String utype_;
    private String name_;
    private String description_;
    private List auxData_;

    /**
     * Constructs a new URLValueInfo.
     * 
     * @param  name  info name
     * @param  description  info description
     */
    public URLValueInfo( String name, String description ) {
        name_ = name;
        description_ = description;
        auxData_ = new ArrayList();
    }

    public String getName() {
        return name_;
    }

    public String getDescription() {
        return description_;
    }

    public String getUnitString() {
        return null;
    }

    public String getUCD() {
        return ucd_;
    }

    public String getUtype() {
        return utype_;
    }

    public String getXtype() {
        return null;
    }

    public Class getContentClass() {
        return URL.class;
    }

    public boolean isArray() {
        return false;
    }

    public int[] getShape() {
        return null;
    }

    public int getElementSize() {
        return -1;
    }

    public boolean isNullable() {
        return true;
    }

    public DomainMapper[] getDomainMappers() {
        return new DomainMapper[ 0 ];
    }

    public List getAuxData() {
        return auxData_;
    }

    public String formatValue( Object value, int maxLength ) {
        if ( value == null ) {
            return "";
        }
        else {
            String txt = value.toString();
            int leng = txt.length();
            return leng <= maxLength ? txt : txt.substring( 0, maxLength );
        }
    }

    public Object unformatString( String rep ) {
        try {
            return new URL( rep );
        }
        catch ( MalformedURLException e ) {
            return null;
        }
    }

    public TableCellRenderer getCellRenderer() {
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy