Page MenuHomeHEPForge

Value.java
No OneTemporary

Value.java

package cedar.hepdata.model;
import cedar.hepdata.db.*;
import cedar.hepdata.migration.model.*;
import cedar.hepdata.util.HDException;
import java.util.Iterator;
import java.util.Map;
//import cedar.hepdata.file.*;
import java.util.TreeMap;
/**
* A datapoint with its associated errors
*
* @author S Butterworth
* @version $Date: 2006-02-02 16:35:56 +0000 (Thu, 02 Feb 2006) $ $Revision: 500 $
*
*/
public class Value implements HDPersistable {
/** String signifying percentage */
public static final String PCT = "PCT";
/** limit type greater than*/
public static String LIMIT_GT = ">";
/** limit type less than*/
public static String LIMIT_LT = "<";
/** limit type greater than or equals*/
public static String LIMIT_GE = ">=";
/** limit type less than or equals*/
public static String LIMIT_LE = "<=";
/** limit type equals*/
public static String NO_LIMIT = "=";
/** default confidence level */
public static Double DEFAULT_CL = null;
private int pointId;
private Double value;
private String description;
private Double confidenceLevel = DEFAULT_CL;
private Double lower;
private Double upper;
private Double binWidth;
private ErrorValue binValue;
private String limit = NO_LIMIT;
private String comment;
private Map<Integer,ErrorValue> errors = new TreeMap<Integer,ErrorValue>();
private Matchable match;
/** constructs an empty value */
public Value() {
this.comment = comment;
}
/**
* constructs a value with all defining information.
*/
public Value(int pointId, String description, Double value, String lim, Double cl,
String comment) {
this.pointId = pointId;
this.description = description;
this.value = value;
if (lim != null) {
this.limit = lim;
}
this.confidenceLevel = cl;
this.comment = comment;
}
public int getId() {
return getPointId();
}
public void setId(int id) {
setPointId(id);
}
/**
* Return the value ID
*
* @return pointId
*/
public int getPointId() {
return pointId;
}
public void setPointId(int id) {
this.pointId = id;
}
public Double getValue() {
return value;
}
// public void setValue(double dbl){this.value = dbl;}
public String getDescription() {
return description;
}
public void setDescription(String s) {
this.description = s;
}
public Double getConfidenceLevel() {
return confidenceLevel;
}
public String getLimit() {
return limit;
}
public String getComment() {
return comment;
}
public void addError(Integer id, ErrorValue err) {
//System.out.println("OK!");
errors.put(id, err);
}
public Map<Integer,ErrorValue> getErrors() {
return errors;
}
public Iterator getErrorsIt() {
return errors.values().iterator();
}
public ErrorValue getError(Integer i) {
return errors.get(i);
}
/** for yaxis: bin info specified as error */
public void setBinValue(ErrorValue bv) {
binValue = new ErrorValue(bv.getErrPlus(), bv.getErrMinus(), null);
// System.out.println(binValue.toString());
}
/** for xaxis: bin info preserved in original form */
public void setBinWidth(Double bw) {
binWidth = bw;
// System.out.println(binWidth.toString());
}
/** for xaxis: bin info preserved in original form*/
public void setBinUpper(Double dbl) {
upper = dbl;
// System.out.println(binWidth.toString());
}
/** for xaxis: bin info preserved in original form */
public void setBinLower(Double dbl) {
lower = dbl;
// System.out.println(binWidth.toString());
}
/** for yaxis: bin info specified as error */
public ErrorValue getBinValue() {
return binValue;
}
/** for xaxis: bin info preserved in original form */
public Double getBinWidth() {
return binWidth;
}
/** for xaxis: bin info preserved in original form */
public Double getBinUpper() {
return upper;
}
/** for xaxis: bin info preserved in original form */
public Double getBinLower() {
return lower;
}
/** match information stored on a Value object */
public void createMatch(int paperId, int datasetId, int yaxisId, int xaxisId, String xvalues) {
match = Match.createMatch(paperId, datasetId, yaxisId, xaxisId, xvalues);
}
/** match information stored on a Value object */
public Matchable getMatch() {
return match;
}
public String toString() {
StringBuffer s = new StringBuffer("Point ID:" + pointId);
s.append("\n");
if (value != null) {
if (limit != null) {
s.append("Value: ");
if (limit.equals(LIMIT_GT)) {
s.append(">");
} else if (limit.equals(LIMIT_LT)) {
s.append("<");
} else if (limit.equals(LIMIT_GE)) {
s.append(">=");
} else if (limit.equals(LIMIT_LE)) {
s.append("<=");
}
s.append(value.toString());
} else {
s.append("Value: " + value.toString());
}
} else {
s.append("Value is null");
}
s.append("\n");
if (description != null) {
s.append("Description:" + description);
} else {
s.append("Description is null");
}
s.append("\n");
if (confidenceLevel != null) {
s.append("CL=" + confidenceLevel.toString());
s.append("\n");
}
s.append(errors.size() + " Errors");
if (!errors.isEmpty()) {
Iterator errs = errors.values().iterator();
while (errs.hasNext()) {
ErrorValue err = (ErrorValue) errs.next();
s.append("\n");
s.append(err.toString());
}
}
s.append("\n");
return s.toString();
}
public String toStringShort() {
StringBuffer s = new StringBuffer("Point ID:" + pointId);
//s.append("\n");
//if (value!=null){
// s.append(" Value:"+value.toString());
// } else {
// s.append(" Value is null ");
//}
//s.append("\n");
if (description != null) {
s.append(" " + description);
} else {
s.append(" Description is null ");
}
//s.append("\n");
s.append(": " + errors.size() + " Errors");
// if(!errors.isEmpty()){
// Iterator errs=errors.values().iterator();
// while(errs.hasNext()){
// ErrorValue err=(ErrorValue)errs.next();
// s.append("\n");
// s.append(err.toString());
// }
// }
//s.append("\n");
return s.toString();
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 24, 6:44 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4494615
Default Alt Text
Value.java (7 KB)

Event Timeline