📄 datastnchl.java
字号:
package org.trinet.jdbc.table;
import org.trinet.jdbc.datatypes.*;
import org.trinet.jdbc.*;
import java.util.*;
import org.trinet.jasi.AuthChannelIdIF;
import org.trinet.jasi.ChannelIdIF;
/** Data class stores string data describing station channel data as defined by NCEDC database schema tables.
* Primarily used by the DataTableRow class the descendent database table classes (Amp, Arrival, etc.) containing station data.
* Static data define the table column names and their relative positions in the database tables.
* Each station channel data element is stored as a DataString data object in the fields data vector member.
* The class implements the state interface as do each of the stored DataString objects.
* @see DataString
* @see DataObject
* @see DataTableRow
*/
public class DataStnChl implements AuthChannelIdIF, DataClasses, DataClassIds, Cloneable {
/** Total number of data member fields in a station channel description
*/
public static final int MAX_FIELDS = 8;
/** DataObject type used to stored string elements of station channel description.
* Types are defined by the DataClassIds and DataClasses static data interfaces.
* @see DataClassIds
* @see DataClasses
*/
public static final int [] FIELD_CLASS_IDS = {DATASTRING, DATASTRING, DATASTRING, DATASTRING,
DATASTRING, DATASTRING, DATASTRING, DATASTRING};
/** Names of the table columns used to describe a station channel in their relative index order.
*/
public static final String [] FIELD_NAMES =
{"STA", "NET", "AUTH", "SUBSOURCE", "CHANNEL", "CHANNELSRC", "SEEDCHAN", "LOCATION"};
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int STA = 0;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int NET = 1;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int AUTH = 2;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int SUBSOURCE = 3;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int CHANNEL = 4;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int CHANNELSRC = 5;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int SEEDCHAN = 6;
/** Constant declares relative position index of column field in station channel/table description.
*/
public static final int LOCATION = 7;
/** Delimiters for parsing input string tokens */
public static final String FIELD_DELIMITERS = " _\t,";
/** Character "*" flags a null token field in input strings. */
public static final String STAR_NULL_FIELD = "*";
protected Integer hashCache;
/*
public DataString sta;
public DataString net;
public DataString auth;
public DataString subsource;
public DataString channel;
public DataString channelsrc;
public DataString seedchan;
public DataString location;
*/
/** List object used to store the DataObject data types of the declared station channel description.
*/
Vector fields = new Vector(MAX_FIELDS);
/** Flag indicates whether to consider this object's data value changed.
*/
boolean valueUpdate = false;
/** Flag indicates whether to consider this object NULL.
*/
boolean valueNull = true;
/** Flag indicates whether to consider this object's data members changeable.
*/
boolean valueMutable = true;
/** Default constructor creates new DataString data members that are set to empty string values.
* Default state flag settings are Update:false, Null:true, Mutable:true.
*/
public DataStnChl () {
for (int index = 0; index < MAX_FIELDS; index++) {
fields.add(new DataString(""));
}
}
/** Copy constructor clones the input argument object data.
* Sets the data members to clones of the input object's data; sets state flags to the input object values.
*/
public DataStnChl (DataStnChl x) {
for (int index = 0; index < MAX_FIELDS; index++) {
fields.add(((DataString) x.fields.get(index)).clone());
}
valueNull = x.valueNull;
valueUpdate = x.valueUpdate;
valueMutable = x.valueMutable;
}
/** Constructs new data members from input string arguments.
* Both null and empty strings are set to an empty String value.
* Sets the state flags to Update:true, Null:false, Mutable:true.
* @see DataString#DataString()
*/
public DataStnChl (String sta, String net, String auth, String subsource,
String channel, String channelsrc, String seedchan, String location) {
fields.add(new DataString(sta));
fields.add(new DataString(net));
fields.add(new DataString(auth));
fields.add(new DataString(subsource));
fields.add(new DataString(channel));
fields.add(new DataString(channelsrc));
fields.add(new DataString(seedchan));
fields.add(new DataString(location));
valueUpdate = true;
valueNull = false;
}
/** Constructs new data members from input string arguments.
* Invokes the complete string field constructor with null values for the missing fields.
* Sets the state flags to Update:true, Null:false, Mutable:true.
*/
public DataStnChl (String sta, String net, String auth, String subsource,
String channel) {
this(sta, net, auth, subsource, channel, null, null, null);
valueUpdate = true;
valueNull = false;
}
/** Constructs new data members from clones of the input DataString arguments.
* Null argument values invoke the DataString() (empty string) constructor for the respective data member.
* Sets the state flags to Update:true, Null:false, Mutable:true.
*/
public DataStnChl (DataString sta, DataString net, DataString auth, DataString subsource,
DataString channel, DataString channelsrc, DataString seedchan, DataString location) {
if (sta == null) fields.add(new DataString());
else fields.add(sta.clone());
if (net == null) fields.add(new DataString());
else fields.add(net.clone());
if (auth == null) fields.add(new DataString());
else fields.add(auth.clone());
if (subsource == null) fields.add(new DataString());
else fields.add(subsource.clone());
if (channel == null) fields.add(new DataString());
else fields.add(channel.clone());
if (channelsrc == null) fields.add(new DataString());
else fields.add(channelsrc.clone());
if (seedchan == null) fields.add(new DataString());
else fields.add(seedchan.clone());
if (location == null) fields.add(new DataString());
else fields.add(location.clone());
valueUpdate = true;
valueNull = false;
}
/** Constructs new data members from clones of the input DataString arguments.
* Invokes the complete DataString constructor with null arguments for the missing fields.
* Sets the state flags to Update:true, Null:false, Mutable:true.
*/
public DataStnChl (DataString sta, DataString net, DataString auth, DataString subsource,
DataString channel) {
this(sta, net, auth, subsource, channel, null, null, null);
valueUpdate = true;
valueNull = false;
}
/** Constructs new data members by parsing a input string in which the data fields are delimited by
* a space, underline, tab, or comma.
* Invokes the default constructor.
* Parses the input string tokens replacing each of the defaults fields in order;
* Missing or null fields can be indicated by a delimited "*" character and are stored as empty strings.
* Throws IndexOutOfBounds exception if the number of token fields is greater than MAX_FIELDS.
* Sets the state flags to Update:true, Null:false, Mutable:true.
*/
public DataStnChl (String scString) throws IndexOutOfBoundsException {
this();
StringTokenizer st = new StringTokenizer(scString, FIELD_DELIMITERS);
if (st.countTokens() > MAX_FIELDS)
throw new IndexOutOfBoundsException("DataStnChl stringToDataStnChl(string) string:" + scString);
for (int index = 0; index < MAX_FIELDS; index++) {
if (! st.hasMoreTokens()) break;
try {
String tmpString = st.nextToken();
if (tmpString.equals(STAR_NULL_FIELD)) continue;
else fields.set(index, new DataString(tmpString));
}
catch (NoSuchElementException ex) { break;}
}
valueUpdate = true;
valueNull = false;
}
/** Sets the update flags of all the DataString data members to the specified input argument value.
* Sets the update flag of this object instance to the input value.
* Returns a handle to this object instance.
*/
public DataStnChl setUpdateAllValues(boolean value) {
for (int index = 0; index < MAX_FIELDS; index++) {
((DataString) fields.get(index)).setUpdate(value);
}
valueUpdate = value;
return this;
}
/** Sets the null data flags of all the DataString data members to the specified input argument value.
* Sets the null flag of this object instance to input value.
* Returns a handle to this object instance.
*/
public DataStnChl setNullAllValues(boolean value) {
for (int index = 0; index < MAX_FIELDS; index++) {
((DataString) fields.get(index)).setNull(value);
}
valueNull = value;
return this;
}
/** Sets the mutability flags of all the DataString data members to the specified input argument value.
* Sets the mutability flag of this object instance to input value.
* Returns a handle to this object instance.
*/
public DataStnChl setMutableAllValues(boolean value) {
for (int index = 0; index < MAX_FIELDS; index++) {
((DataString) fields.get(index)).setMutable(value);
}
valueMutable = value;
return this;
}
/** Sets the update flag to the specified argument value. Determines data legitimacy in implemented class extensions.
* An input value of true == "set", false == "not set". Returns the handle (this) of the invoking class instance.
*/
public DataStnChl setUpdate(boolean value) {
this.valueUpdate = value;
return this;
}
/** Returns the boolean value of the data update flag for the invoking instance.
*/
public boolean isUpdate() {
return valueUpdate;
}
/** Sets the null flag to the specified argument value. Determines whether the data value is considered undefined or NULL.
* An input value of true == "NULL", false == "not NULL". Returns the handle (this) of the invoking class instance.
*/
public DataStnChl setNull(boolean value) {
this.valueNull = value;
return this;
}
/** Returns the boolean value of the data null flag for the invoking instance.
*/
public boolean isNull() {
return valueNull;
}
/** Sets the mutability flag to the specified argument value. Determines whether the data value can be modified.
* An input value of true == "mutable", false == "not mutable". Returns the handle (this) of the invoking class instance.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -