Show PDouble.java syntax highlighted
/*
* PDouble.java
*
* Created on March 29, 2007, 1:49 PM
*
* Description: PDouble is a persistent floating-point number in the Texai logical representation language.
*
* Copyright (C) 2007 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.kb.entity;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.Relationship;
import com.sleepycat.persist.model.SecondaryKey;
import org.texai.kb.Constants;
import org.texai.kb.ejb.session.shared.KBPartitionFacadeLocal;
/**
*
* @author reed
*/
@Entity
public class PDouble extends AbstractTerm {
/** the double precision value */
@SecondaryKey(relate=Relationship.ONE_TO_ONE)
private Double doubleValue; // NOPMD
/** Creates a new instance of PDouble. */
public PDouble() {
super();
}
/** Creates a new instance of PDouble
*
* @param termId the database term ID
* @param doubleValue the double precision value
*/
public PDouble(final int termId, final Double doubleValue) {
super(termId);
//Preconditions
assert doubleValue != null : "doubleValue must not be null";
this.doubleValue = doubleValue;
}
/** Gets the term type.
*
* @return the term type
*/
public byte getTermType() {
return Constants.DOUBLE;
}
/** Gets the double precision value
*
* @return the double precision value
*/
public Double getDoubleValue() {
return doubleValue;
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return getTermId();
}
/** Determines whether another object is equal to this PDoubleInfo object.
*
* @param object the reference object with which to compare
* @return <code>true</code> if this object is the same as the argument;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(final Object object) {
if (!(object instanceof PDouble)) {
return false;
}
final PDouble that = (PDouble) object;
return this.getTermId() == that.getTermId();
}
/** Returns a string representation of this object.
*
* @param kbPartitionFacade the KB partition facade
* @return a string representation of this object
*/
public String toString(final KBPartitionFacadeLocal kbPartitionFacade) {
return doubleValue.toString();
}
/** Returns a CycL representation of this object.
*
* @param kbPartitionFacade the KB partition facade
* @return a CycL representation of this object
*/
public String toCycLString(final KBPartitionFacadeLocal kbPartitionFacade) {
return toString(kbPartitionFacade);
}
}
See more files for this project here