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

timeBench.data.io.schema.DateInstantEncoding Maven / Gradle / Ivy

Go to download

TimeBench, a flexible, easy-to-use, and reusable software library written in Java that provides foundational data structures and algorithms for time- oriented data in Visual Analytics.

The newest version!
package timeBench.data.io.schema;

import java.util.Date;

import javax.xml.bind.annotation.XmlElement;

import prefuse.data.Tuple;
import timeBench.data.TemporalDataException;

public class DateInstantEncoding extends InstantEncoding {

    @XmlElement(name = "temporal-column", required = true)
    private String temporalColumn;

    DateInstantEncoding() {
    }

    public DateInstantEncoding(String key, String temporalColumn) {
        super.setKey(key);
        this.temporalColumn = temporalColumn;
    }

    @Override
    protected Date buildDate(Tuple tuple) throws TemporalDataException {
        if (logger.isDebugEnabled())
            logger.debug("prepare temp.e. " + tuple.getString(temporalColumn));

        if (tuple.canGetDate(temporalColumn)) {
            return tuple.getDate(temporalColumn);
        } else {
            // the column is not a DateColumn
            throw new TemporalDataException(
                    "import temporal element failed column " + temporalColumn
                            + " is not of type date.");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy