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

com.bigdata.rdf.internal.impl.AbstractNonInlineExtensionIVWithDelegateIV Maven / Gradle / Ivy

package com.bigdata.rdf.internal.impl;

import com.bigdata.rdf.internal.DTE;
import com.bigdata.rdf.internal.IV;
import com.bigdata.rdf.internal.VTE;
import com.bigdata.rdf.internal.impl.literal.AbstractLiteralIV;
import com.bigdata.rdf.model.BigdataLiteral;
import com.bigdata.rdf.model.BigdataValue;

/**
 * Class always has the extension bit set but is NOT
 * 100% "inline". An instance of this class bundles together an value of some
 * primitive data type declared by {@link DTE} with the "extension" {@link IV}.
 * 
 * @author Bryan Thompson
 * @version $Id$
 * 
 * @param 
 * @param 
 */
abstract public class AbstractNonInlineExtensionIVWithDelegateIV
        extends AbstractNonInlineExtensionIV {

	/**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
	 * The inline literal delegate.
	 */
    private final AbstractLiteralIV delegate;

    /**
     * The non-inline extension IV.
     */
    private final IV extensionIV;
    
    protected AbstractNonInlineExtensionIVWithDelegateIV(final VTE vte,
            final AbstractLiteralIV delegate, 
            final IV extensionIv) {

        super(vte, delegate.getDTE());
        
        if (extensionIv == null)
            throw new IllegalArgumentException();
        
        this.delegate = delegate;
        
        this.extensionIV = extensionIv;
        
    }
    
    public AbstractLiteralIV getDelegate() {

        return delegate;
        
    }
    
    @Override
    public IV getExtensionIV() {

        return extensionIV;
        
    }
    
    final public int hashCode() {
        return delegate.hashCode();
    }

    final public boolean equals(final Object o) {
        if (this == o)
            return true;
        if (o instanceof AbstractNonInlineExtensionIVWithDelegateIV) {
            return this.delegate
                    .equals(((AbstractNonInlineExtensionIVWithDelegateIV) o).delegate)
                    && this.extensionIV
                            .equals(((AbstractNonInlineExtensionIVWithDelegateIV) o).extensionIV);
        }
        return false;
    }

    final public int _compareTo(final IV o) {

//        int ret = extensionIv._compareTo(((AbstractExtensionIV) o).extensionIv);

        final int ret = extensionIV
                .compareTo(((AbstractNonInlineExtensionIVWithDelegateIV) o).extensionIV);

        if (ret != 0)
            return ret;

        return delegate
                ._compareTo(((AbstractNonInlineExtensionIVWithDelegateIV) o).delegate);

    }

	/**
	 * Return one (for the flags) plus the length of the extension IV plus the
	 * length of the delegate IV.
	 */
    final public int byteLength() {

        return 1/* flags */+ 1/* extensionByte */+ extensionIV.byteLength()
                + delegate.byteLength();

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy