📄 solution.java
字号:
}
/** Returns true if there are alternate magnitudes for this solution. In some
* databases an "event" can have multiple magnitudes.
* For example, Ml, Mb, Ms, Me, etc. or magnitudes from different
* institutions might be stored and associated with this solution.
*/
public boolean hasAlternateMagnitudes() {
if (altMagList.size() > 0) return true;
return false;
}
/** Return number of alternate magnitudes */
public int alternateMagnitudeCount() {
return altMagList.size();
}
/** Returns Collection of Magnitude objects each containing an alternate magnitude.
* The primary or "prefered" magnitude is NOT included in this set */
public Collection getAlternateMagnitudes() {
return altMagList;
}
/** Returns Collection of Magnitude objects each containing an alternate magnitude.
* The primary or "prefered" magnitude is NOT included in this set */
public Collection fetchAlternateMagnitudes() {
altMagList = (ArrayList) Magnitude.create().getAltBySolutionId(this.getId().longValue());
return altMagList;
}
/** Returns array of Magnitude objects each containing an alternate magnitude.
* The primary or "prefered" magnitude is NOT included in this set */
public Magnitude[] getAlternateMagnitudeArray() {
return (Magnitude[]) altMagList.toArray(
new Magnitude[alternateMagnitudeCount()]);
}
/** Add a magnitude to the list of alternate magnitudes. */
public void addAlternateMagnitude(Magnitude mag) {
altMagList.add(mag);
}
/**
* Set the processing state of the solution. The argument is one of the following:<p>
* Solution.STATE_NONE <br>
* Solution.STATE_AUTOMATIC <br>
* Solution.STATE_HUMAN <br>
* Solution.STATE_FINAL <br>
*/
public void setProcessingState(int state) {
if (state == STATE_NONE) {
this.processingState.setNull(true);
} else if (state == STATE_AUTOMATIC) {
this.processingState.setValue("A");
} else if (state == STATE_HUMAN) {
this.processingState.setValue("H");
} else if (state == STATE_FINAL) {
this.processingState.setValue("F");
}
}
/**
* Return the processing state of the solution. The return is one of the following:<p>
* Solution.STATE_NONE <br>
* Solution.STATE_AUTOMATIC <br>
* Solution.STATE_HUMAN <br>
* Solution.STATE_FINAL <br>
*/
public int getProcessingState() {
// if (this.processingState.isNull()) return STATE_NONE;
if (this.processingState.equals("A")) return STATE_AUTOMATIC;
if (this.processingState.equals("H")) return STATE_HUMAN;
if (this.processingState.equals("F")) return STATE_FINAL;
return STATE_NONE;
}
/** Set the comment string. Override this method is the concrete
data source must limit the lenght or format of the string. */
public void setComment(String str) {
comment.setValue(str);
}
/** Get the comment string. Returns null if there is no comment. */
public String getComment () {
return comment.toString();
}
/** Returns 'true' if there is a comment. */
public boolean hasComment() {
return !comment.isNull();
}
/**
* Return a brief string of the form:
*/
public String toString()
{
// accomodate null magnitude
Format df4 = new Format("%4.2f");
String magType = "**";
String magVal = df4.form(0.0);
if (magnitude != null) {
magType = magnitude.getTypeString();
magVal = df4.form(magnitude.value.doubleValue());
}
return id.intValue() +" "+
datetime.toString() + " "+
lat.toString() + " "+
lon.toString() +" "+
depth.toString() +" "+
magType +" "+
magVal +" "+
rms.toString() +" "+
totalReadings.toString() +" "+
distance.toString() +" "+
gap.toString() +" "+
authority.toString() +" "+
source.toString() +" "+
getEventTypeString() +" "+
processingState.toString()
;
}
/**
* Make a summary text string. <p>
* Example: <p>
9619508 October 21, 1999 22:18:12.87 34.1417 -116.5068 5.00 1.90 Ml local
*/
public String toSummaryString () {
Format df0 = new Format("%10d"); // CORE Java Format class
Format df1 = new Format("%8.4f"); // CORE Java Format class
Format df2 = new Format("%9.4f"); // CORE Java Format class
Format df3 = new Format("%4.1f");
Format df4 = new Format("%4.2f");
//final String fmtString = "MMMM dd, yyyy HH:mm:ss.SS";
// "ss.SS" produces bad values
final String fmtString = "MMMM dd, yyyy HH:mm:ss.SSS";
String dtStr = DateTime.toString(datetime.doubleValue(), fmtString);
String str = df0.form(id.longValue()) + " " +
dtStr + " " +
df1.form(lat.floatValue()) + " " +
df2.form(lon.floatValue()) + " " +
df3.form(depth.floatValue());
// only append mag if not null
if (magnitude != null) {
str += " " + df4.form(magnitude.value.doubleValue()) +
" " + magnitude.getTypeString() ;
} else {
str += " (no mag)";
}
str += " "+ getEventTypeString();
return str;
}
public String toNeatString() {
return toSummaryString();
}
/*
Return a fixed format header to match output from toNeatString(). Has the form:
<tt>
" Event ID Date Time Lat Lon Z Mag type"
</tt>
@see: toNeatString()
*/
public static String getNeatStringHeader() {
// 9619508 October 21, 1999 22:18:12.8700 34.1417 -116.5068 5.00 1.90 Ml local
return " Event ID Date Time Lat Lon Z Mag type";
}
/**
* Make a summary text string of the error information. <p>
*/
public String toErrorString () {
Format df1 = new Format("%5.2f");
Format df2 = new Format("%4d");
Format df3 = new Format("%-6s");
int Scount = sReadings.intValue();
if (Scount < 0) Scount = 0; // no nulls
int Pcount = usedReadings.intValue() -Scount;
if (Pcount < 0) Pcount = 0;
String str =
df2.form(Pcount) + "/" + df2.form(Scount) +
" " + df1.form(rms.doubleValue()) +
" " + df1.form(errorHoriz.doubleValue()) +
" " + df1.form(errorVert.doubleValue()) +
" " + df2.form(distance.intValue()) +
" " + df2.form(gap.intValue()) +
" " + df1.form(quality.doubleValue()) +
" " + df3.form(authority.toString()) +
" " + df3.form(source.toString()) +
" " + df3.form(method.toString()) ;
return str;
}
public String getErrorStringHeader() {
// dddd/dddd xx.xx xx.xx xx.xx dddd dddd xx.xx ssssss ssssss ssssss
return "# P/S RMS errH errZ dmin gap qual auth src meth";
}
/*
Finger 1
00/01/12 20:19:01 35.05N 117.65W 8.4 1.5MGN C* 4 mi. N of Boron, CA
Finger 2
9133867 CI 00/01/12 20:19:01 35.05N 117.65W 8.4 1.5MGN C* 4 mi. N of Boron, CA"
Finger 3
ffff.ff ffff.ff fff.f f.f
9133867 CI 2000/01/12 20:19:01 35.05N 117.65W 8.4 1.5MGN C* 4 mi. N of Boron, CA
9619508 le October 21, 1999 22:18:12.870 34.1417 -116.5068 5.00 1.90 Ml
*/
public String toFingerFormat ()
{
Format df0 = new Format("%10d"); // CORE Java Format class
Format df1 = new Format("%5.2f");
Format df2 = new Format("%6.2f");
Format df3 = new Format("%5.1f");
Format df4 = new Format("%3.1f");
//
String DateTimeFormat = "yyyy/MM/dd HH:mm:ss";
String dtStr = EpochTime.epochToString( datetime.doubleValue(), DateTimeFormat );
String ns = "N";
String ew = "E";
float latf = lat.floatValue();
float lonf = lon.floatValue();
// handle hemipsphere issues
if (latf < 0) {
latf = Math.abs(latf);
ns = "S";
}
if (lonf < 0) {
lonf = Math.abs(lonf);
ew = "W";
}
// guard against null or short authority
String auth = authority.toString();
if (auth == null) auth = " ";
if (auth.length() < 2) {
auth = auth+" ";
} else {
auth = auth.substring(0, 2); // truncate to 2 chars
}
return ( df0.form(id.longValue()) + " " +
auth +" "+ // 1st 2 chars
dtStr + " " +
df1.form(latf) + ns + " "+
df2.form(lonf) + ew +" " +
df3.form(depth.floatValue()) + " "+
df4.form(magnitude.value.doubleValue()) + " " +
magnitude.getTypeString()
);
}
public String fullDump () {
String str= toSummaryString() + "\n";
str += phaseList.dumpToArcString();
if (waveformList.size() > 0) {
Waveform wf[] = new Waveform[waveformList.size()];
waveformList.toArray(wf);
for (int i = 0; i < wf.length; i++) {
str += wf[i].toString() + "\n";
}
} else {
str += " * No waveforms for this solution. \n";
}
return str;
}
// Lockable interface
/** Lock this solution, returns true on success, false on failure.
* If locked, information on the current lock holder is in the data members. */
public boolean lock () {
if (solLock == null) return false; // locking not supported
solLock.setSolution(this);
return solLock.lock();
}
/** Release the lock on this solution. Returns true even if the lock was not held
* in the first place. */
public boolean unlock () {
if (solLock == null) return false; // locking not supported
solLock.setSolution(this);
return solLock.unlock();
}
/** Returns true if this solution is locked by anyone, the caller included. */
public boolean isLocked () {
if (solLock == null) return false; // locking not supported
solLock.setSolution(this);
return solLock.isLocked();
}
/** Returns true if this solution is locked by the caller. */
public boolean lockIsMine () {
if (solLock == null) return false; // locking not supported
solLock.setSolution(this);
return solLock.lockIsMine();
}
/* this function is meant to be static.
* it should be used to retrieve the next valid solution ID from
* the JASI data source. In EW this is done by selecting the next
* value from the EventSeq.
* Because this is an abstract function, it cannot be static;
* however, it is logically static because it is not related to the current
* solution object, it only uses that object to access the appropriate
* JASI concrete class.
*/
public abstract long getNextID();
} // JasiObject
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -