?? solution.java
字號:
method if a different set of defaults is desired. */
public void setDefaultValues() {
// make new instances here rather then setValue() because that would
// set the modified flag true.
type = new DataString("H");
validFlag = new DataLong(DefaultValidFlag);
eventType = new DataString(EventTypeMap.getDefault());
processingState = new DataString(DefaultProcessingState);
// depthFixed = new DataBoolean(false);
// locationFixed = new DataBoolean(false);
// timeFixed = new DataBoolean(false);
}
/** Set value of isStale flag. If true, solution should be relocated. */
public void setStale (boolean tf) {
isStale = tf;
// setStale=true forces need for commit but setStale=false does NOT
// That must be done only after a commit();
if (tf) setNeedsCommit(true); // stale event need commit
}
/** True if changes have been made to the phase list and a relocation is
needed. */
public boolean hasStaleLocation () { return isStale; };
public boolean isStale () { return isStale; };
public void setNeedsCommit(boolean tf) {
needsCommit = tf;
}
/** Returns true if the solution or magnitude needs to be committed to the
* data source. */
public boolean getNeedsCommit() {
return needsCommit || hasChanged() || magnitude.hasChanged();
}
/** Return a string describing the results of the commit() operation.
This is the same message that would be returned by
JasiCommitException.getMessage() if an exception is thrown. */
public String getCommitStatus() {
return commitStatus;
}
/** True if changes have been made to the coda or amp list and a magnitude should be
* recalculated. */
public boolean hasStaleMagnitude () { return magnitude.hasStaleMagnitude(); };
/** Set DataObject null only if its not already. Otherwise the 'Update' flag would get
set even if there was no real change. This should be faster then creating
new instances of the data objects. */
public void resetValue(DataObject dataObject) {
if (!dataObject.isNull()) dataObject.setNull(true);
}
/**
* Set all location dependent fields to default values.
* This should be done before parsing a relocation
* to insure old values from an earlier location are not left by an imperfect parse
* of a subsequent location result.
*/
public void clearLocationAttributes () {
resetValue(datetime);
// if (!datetime.isNull()) datetime.setNull(true);
resetValue(lat);
resetValue(lon);
resetValue(depth);
resetValue(horizDatum) ;
resetValue(vertDatum) ;
// resetValue(type) ;
// resetValue(eventType) ;
resetValue(method) ;
resetValue(crustModel) ;
resetValue(velModel) ;
resetValue(authority) ;
resetValue(source) ;
resetValue(gap) ;
resetValue(distance) ;
resetValue(rms) ;
resetValue(errorTime) ;
resetValue(errorHoriz) ;
resetValue(errorVert) ;
resetValue(errorLat) ;
resetValue(errorLon) ;
resetValue(totalReadings) ;
resetValue(usedReadings) ;
resetValue(sReadings) ;
resetValue(firstMotions) ;
resetValue(externalId) ;
resetValue(quality) ;
// resetValue(processingState) ;
// resetValue(depthFixed) ;
// resetValue(locationFixed) ;
// resetValue(timeFixed) ;
setDefaultValues();
// BEGIN DK CODE CHANGE 020403
/* also notify the phases for this solution, that they
are being unassociated with the CURRENT LOCATION */
this.phaseList.clearLocationAttributes();
// END DK CODE CHANGE 020403
}
/**
* Load any phases that are associated with this Solution in the DataSource to this
* Solution's phaseList. Note that references are used, the phases are
* not copied. Returns a count of the number of phases that were added. Sets
* staleLocation 'true' if phases are added */
public boolean loadPhaseList() {
return addPhases(Phase.create().getBySolution(this));
}
/** @deprecated: use loadPhaseList() */
public boolean getPhases() {
// return addPhases(Phase.create().getBySolution(this));
return loadPhaseList();
}
/**
* Return the PhaseList. */
public PhaseList getPhaseList() {
return phaseList;
}
/**
* Given a Collection of Phases, add any phases that are associated with this
* Solution to its phaseList. Note that references are used, the phases are
* not copied. Returns a count of the number of phases that were added. Sets
* staleLocation 'true' if phases are added */
public boolean addPhases(Collection newList) {
if (phaseList.addAll(newList)) {
setStale(true);
return true;
} else {
return false;
}
}
/**
* Add the phase to the phaseList ONLY if the phase is associated with
* this Solution. Sets staleLocation 'true' and returns 'true' if the phase
* was added. */
public boolean addPhase(Phase ph) {
if (ph.sol == this) { // must be associated with this sol
if (phaseList.add(ph)) {
setStale(true);
return true;
}
}
return false;
}
/**
* Delete the phase from the phaseList ONLY if the phase is associated with
* this Solution. Sets staleLocation 'true' and returns 'true' if the phase
* was deleted. */
public boolean deletePhase(Phase ph) {
if (ph != null && ph.sol == this) { // must be associated with this sol
if (phaseList.delete(ph)) {
setStale(true);
return true;
}
}
return false;
}
/**
* Overrides PhaseList.addOrReplacePhase() to set solution stale.
*/
public Phase addOrReplacePhase(Phase ph) {
setStale(true);
return phaseList.addOrReplacePhase(ph);
}
/**
* Remove this phase from the phaseList. Returns 'true' if the phase was in the
* list to start with. NOTE: this should NOT be confused with Phase.delete()
* which marks a phase for deletion from the data source. Sets staleLocation
* 'true' if phases are removed. */
public boolean removePhase(Phase ph) {
if (phaseList.remove(ph) ) {
setStale(true);
return true;
}
return false;
}
/**
* Given a Collection of Phases, remove any phases that are associated with this
* Solution from its phaseList.Sets staleLocation 'true' if phases are
* removed. Returns the number of phases removed. NOTE: this should NOT be
* confused with Phase.delete() which marks a phase for deletion from the data
* source.
* */
public int removePhases(Collection phaseList) {
if (phaseList == null) return 0;
Phase ph[] = new Phase[phaseList.size()];
phaseList.toArray(ph);
int knt = 0;
for (int i = 0; i<ph.length; i++) {
if (removePhase(ph[i])) knt++ ;
}
return knt;
}
/**
* Delete the amp from the ampList ONLY if it is associated with
* this Solution. Sets magnitude stale and returns 'true' if the amp
* was deleted. */
public boolean deleteAmplitude(Amplitude amp) {
if (amp.sol == this) { // must be associated with this sol
if (ampList.delete(amp)) {
if (magnitude.ampList.contains(amp)) {
magnitude.ampList.delete(amp);
magnitude.setStale(true);
}
return true;
}
}
return false;
}
/**
* Delete the coda from the codaList ONLY if it is associated with
* this Solution. Sets magnitude stale and returns 'true' if the coda
* was deleted. */
public boolean deleteCoda(Coda coda) {
if (coda.sol == this) { // must be associated with this sol
if (codaList.delete(coda)) {
if (magnitude.codaList.contains(coda)) {
magnitude.codaList.delete(coda);
magnitude.setStale(true);
}
return true;
}
}
return false;
}
/**
* Given a Collection of Codas, add any that are associated with this
* Solution to its coda list. Note that references are used, the codas are
* not copied. Returns a count of the number that were added. Sets
* staleMagnitude 'true' if any are added.
*/
public int addCodas(Collection list) {
if (list == null || list.isEmpty()) return 0;
Coda coda[] = new Coda[list.size()];
list.toArray(coda);
int knt = 0;
for (int i = 0; i<coda.length; i++) {
if (addCoda(coda[i])) knt++ ; // only adds if its for this Sol
}
return knt;
}
/**
* Return the CodaList. */
public CodaList getCodaList() {
return codaList;
}
/**
* Add any codas that are associated in the DataSource to this
* Solution's coda list. Note that references are used, the codas are
* not copied. Returns a count of the number that were added. Sets
* staleMagnitude 'true' if any are added.
*/
public int loadCodaList() {
return addCodas(Coda.create().getBySolution(this));
}
/** @deprecated: use loadCodaList() */
public int getCodas() {
return addCodas(Coda.create().getBySolution(this));
}
/**
* Add one coda to the solution's list ONLY if it is associated with
* this Solution. Sets staleMagnitude 'true' and returns 'true' if the coda
* was added.
*/
public boolean addCoda(Coda coda)
{
if (coda.sol == this) {
if (codaList.add(coda)) {
magnitude.setStale(true);
return true;
}
}
return false;
}
/**
* Remove this coda from the coda list. Returns 'true' if the coda was in the
* list to start with. NOTE: this should NOT be confused with Coda.delete()
* which marks a Coda for deletion from the data source. Sets staleMagnitude
* 'true' if codas are removed.
*/
public boolean removeCoda(Coda coda)
{
if (codaList.remove(coda) ) {
magnitude.setStale(true);
return true;
}
return false;
}
/**
* Add any amps that are associated in the DataSource to this
* Solution's ampList. Note that references are used, the amps are
* not copied. Returns a count of the number that were added. Sets
* staleMagnitude 'true' if any are added <p>
* Amps may be associated with the solution that are not associated with
* its magnitude. */
public int loadAmpList() {
return addAmps(Amplitude.create().getBySolution(this));
}
/**
* Add any amps that are associated in the DataSource to this
* Solution's magnitude. Note that references are used, the amps are
* not copied. Returns a count of the number that were added. Sets
* staleMagnitude 'true' if any are added <p>
* Amps may be associated with the solution that are not associated with
* its magnitude. */
public void loadMagAmpList() {
// add amps to the sol's mag's list...
if (magnitude != null)
addAmps (Amplitude.create().getByMagnitude(magnitude) );
}
/** Return this Solution's AmpList. */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -