indexrecord.java

来自「shape file read and write」· Java 代码 · 共 40 行

JAVA
40
字号
package org.geotools.data.shapefile.indexed.attribute;

/**
 * Record stored in attribute index file
 * 
 * @author Manuele Ventoruzzo
 */
public class IndexRecord implements Comparable {

    private Comparable attribute;
    private long featureID;

    public IndexRecord(Comparable attribute, long featureID) {
        this.attribute = attribute;
        this.featureID = featureID;
    }

    public Object getAttribute() {
        return attribute;
    }

    public long getFeatureID() {
        return featureID;
    }

    public int compareTo(Object o) {
        if (o instanceof IndexRecord) {
            return attribute.compareTo(((IndexRecord) o).getAttribute());
        }
        if (attribute.getClass().isInstance(o)) {
            // compare just attribute with o
            return attribute.compareTo(o);
        }
        throw new ClassCastException("Object " + o.toString() + " is not of Record type");
    }

    public String toString() {
        return "(" + attribute.toString() + "," + featureID + ")";
    }
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?