⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datastnchl.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
*/
    public DataStnChl setMutable(boolean value) {
  this.valueMutable = value;
  return this;
    }

/** Returns the boolean value of the data mutability flag for the invoking instance.
*/
    public boolean isMutable() {
  return valueMutable;
    }

/** Return the relative postion of named data member field in the station channel description.
* Returns -1 if no names matches the input argument value.
*/
    public int findFieldIndex(String name) {
  for (int index = 0; index < MAX_FIELDS; index++) {
      if (FIELD_NAMES[index].equals(name.trim().toUpperCase())) return index;
  }
  return -1;
    }

/** Returns the null status of the data field at the specified input position index.
*/
    public boolean isNullValue(int index) throws IndexOutOfBoundsException {
  if (index < 0 || index > MAX_FIELDS)
                throw new IndexOutOfBoundsException("DataStnChl isNullValue(int) index out of bounds:" + index);
  return ((DataState) fields.get(index)).isNull();
    }

/** Returns the null status of the data field with the name specified in the input argument.
*/
    public boolean isNullValue(String name) throws NoSuchFieldException {
  int index = findFieldIndex(name);
  if (index < 0) throw new NoSuchFieldException("DataStnChl isNullValue(name) unknown field name:" + name);
  return isNullValue(index);
    }

/** Returns the update status of the data field at the specified input position index.
*/
    public boolean isUpdateValue(int index) throws IndexOutOfBoundsException {
  if (index < 0 || index > MAX_FIELDS)
    throw new IndexOutOfBoundsException("DataStnChl isUpdateValue(int) field index out of bounds:" + index);
  return ((DataState) fields.get(index)).isUpdate();
    }

/** Returns the update status of the data field with the name specified in the input argument.
*/
    public boolean isUpdateValue(String name) throws NoSuchFieldException {
  int index = findFieldIndex(name);
  if (index < 0) throw new NoSuchFieldException("DataStnChl isUpdateValue(name) unknown field name:" + name);
  return isUpdateValue(index);
    }

/** Returns the mutability status of the data field at the specified input position index.
*/
    public boolean isMutableValue(int index) throws IndexOutOfBoundsException {
  if (index < 0 || index > MAX_FIELDS)
    throw new IndexOutOfBoundsException("DataStnChl isMutableValue(int) field index out of bounds:" + index);
  return ((DataState) fields.get(index)).isMutable();
    }

/** Returns the mutability status of the data field with the name specified in the input argument.
*/
    public boolean isMutableValue(String name) throws NoSuchFieldException {
  int index = findFieldIndex(name);
  if (index < 0) throw new NoSuchFieldException("DataStnChl isMutableValue(name) unknown field name:" + name);
  return isMutableValue(index);
    }

/** Returns the handle of the DataString object for the data field with the name specified in the input argument.
*/
    public DataObject getDataObject(String name) throws NoSuchFieldException {
        int index = findFieldIndex(name);
        if (index < 0) throw new NoSuchFieldException("DataStnChl getDataObject(String name) unknown field name:" + name);
        return getDataObject(index);
    }

/** Returns the handle of the DataString object for the data field at the specified input position index.
*/
    public DataObject getDataObject(int index) throws IndexOutOfBoundsException {
        if (index < 0 || index > fields.size())
                throw new IndexOutOfBoundsException("DataStnChl getDataObject(index) field index out of bounds:" + index);
        return (DataObject) fields.get(index);
    }

/** Returns the string value of the data field with the name specified in the input argument.
*/
    public String getStringValue(String name) throws NoSuchFieldException {
        int index = findFieldIndex(name);
        if (index < 0) throw new NoSuchFieldException("DataStnChl getStringValue(String name) unknown field name:" + name);
        return getStringValue(index);
    }

/** Returns the string value of the data field at the specified input position index.
*/
    public String getStringValue(int index) throws IndexOutOfBoundsException, NullPointerException, ClassCastException  {
        if (index < 0 || index > fields.size())
                throw new IndexOutOfBoundsException("DataStnChl getStringValue(index) field index out of bounds:" + index);
        if (fields.get(index) == null)
                throw new NullPointerException("DataStnChl getStringValue: field object null at index: " + index);
        String retVal = "";
        if (fields.get(index) instanceof DataObject) {
            retVal = ((DataObject) fields.get(index)).toString();
        }
        else throw new ClassCastException("DataStnChl getStringValue(index) fields[index] must be a DataObject class type: "
                                         + fields.get(index).getClass().getName());
        return retVal;
    }

/** Sets the string value of the data field with the name specified in the input argument to the input value argument.
* Does a no-op if isMutable() == false.
* Returns a handle to this object instance.
*/
    public DataStnChl setValue(String name, String value) throws NoSuchFieldException {
  if(! isMutable()) return this;
  int index = findFieldIndex(name);
  if (index < 0)
    throw new NoSuchFieldException("DataStnChl setValue(String name, String value) unknown field name:" + name);
  return setValue(index, value);
    }

/** Sets the string value of the data field at the specified input position index to the input value argument.
* Does a no-op if isMutable() == false.
* Returns a handle to this object instance.
*/
    public DataStnChl setValue(int index, String value) throws IndexOutOfBoundsException {
  if(! isMutable()) return this;
  if (index < 0 || index > fields.size())
      throw new IndexOutOfBoundsException("DataStnChl setValue(int index, String value) field index out of bounds:"
    + index);
  if (fields.get(index) == null) {
      try {
    fields.set(index, DATA_CLASSES[FIELD_CLASS_IDS[index]].newInstance());
      }
      catch (IllegalAccessException ex) {
    System.out.println("DataStnChl setValue(int,String): class or initializer not accessible." +
      DATA_CLASSES[FIELD_CLASS_IDS[index]]);
      }
      catch (InstantiationException ex) {
    System.out.println("DataStnChl setValue(int,String): cannot instantiate class check type." +
      DATA_CLASSES[FIELD_CLASS_IDS[index]]);
      }
  }
  ((DataObject) fields.get(index)).setValue(value);
        hashCache = null;
  return this;
    }

/** Sets the string value of the data field with the name specified in the input argument.
* Set value to the string value of the input Object argument (for example class of input object == DataString).
* Does a no-op if isMutable() == false.
* Returns a handle to this object instance.
*/
    public DataStnChl setValue(String name, Object value) throws NoSuchFieldException {
  if(! isMutable()) return this;
  int index = findFieldIndex(name);
  if (index < 0)
    throw new NoSuchFieldException("DataStnChl setValue(String name, Object value) unknown field name:" + name);
  return setValue(index, value);
    }

/** Sets the string value of the data field at the specified input position index.
* Set value to the string value of the input Object argument (for example class of input object == DataString).
* Does a no-op if isMutable() == false.
* Returns a handle to this object instance.
*/
    public DataStnChl setValue(int index, Object value) throws NullPointerException, IndexOutOfBoundsException {
  if(! isMutable()) return this;
  if (value == null) throw new NullPointerException("DataStnChl setValue(Object) argument null");
  if (index < 0 || index > fields.size())
      throw new IndexOutOfBoundsException("DataStnChl setValue(int index, Object value) field index out of bounds:"
    + index);
  if (fields.get(index) == null) {
      try {
    fields.set(index, DATA_CLASSES[FIELD_CLASS_IDS[index]].newInstance());
      }
      catch (IllegalAccessException ex) {
    System.out.println("DataStnChl setValue(int,String): class or initializer not accessible." +
      DATA_CLASSES[FIELD_CLASS_IDS[index]]);
      }
      catch (InstantiationException ex) {
    System.out.println("DataStnChl setValue(int,String): cannot instantiate class check type." +
      DATA_CLASSES[FIELD_CLASS_IDS[index]]);
      }
  }
  ((DataObject) fields.get(index)).setValue(value);
        hashCache = null;
  return this;
    }

/** Overrides the Object.clone() method.
* Invokes Object.clone(), does a deep copy of its data member objects.
* Returns a handle to the new object instance of this type.
*/
    public Object clone() {
  DataStnChl obj = null;
  try {
      obj = (DataStnChl) super.clone();
  }
  catch (CloneNotSupportedException ex) {
      System.out.println("Cloneable not implemented for class: " + this.getClass().getName());
      ex.printStackTrace();
  }

  for (int index = 0; index < MAX_FIELDS; index++) {
      obj.fields.set(index, ((DataObject) fields.get(index)).clone());
  }
  return obj;
    }

/** Returns true if all data values and state flags of this instance equal those of the input argument object.
* Returns false if input object is null or not an instanceof DataStnChl.
* The data field string comparison is case sensitive.
*/
    public boolean equals(Object x) {
  if (x == null || ! ( x instanceof DataStnChl) ) return false;
  //throw new ClassCastException("equals(object) argument must be a DataStnChl class type: " + x.getClass().getName());

//	if (x == null || ! (x instanceof DataStnChl)) return false;
  for (int index = 0; index < MAX_FIELDS; index++) {
      if (! ((DataObject) fields.get(index)).equals((DataObject) ((DataStnChl) x).fields.get(index)) ) return false;
  }
  if (this.valueNull == ((DataStnChl) x).valueNull && this.valueUpdate == ((DataStnChl) x).valueUpdate &&
    this.valueMutable == ((DataStnChl) x).valueMutable) return true;
  return false;

    }

/** Returns true if STA, NET, and SEEDCHAN string values of this instance equal those of the input object.
* Returns false if input object is null or not an instanceof DataStnChl.
* No state flags are checked. The data field string comparison is case insensitive.
*/
    public boolean sameAs(Object x) {
        if (x == null || ! ( x instanceof DataStnChl) ) return false;
        //throw new ClassCastException("sameAs(object) argument must be a DataStnChl class type: " + x.getClass().getName());

        String seedchan = this.getStringValue(SEEDCHAN).toUpperCase().trim();
        String channel = this.getStringValue(CHANNEL).toUpperCase().trim();
        String testSeedchan = ((DataStnChl) x).getStringValue(SEEDCHAN).toUpperCase().trim();
        String testChannel = ((DataStnChl) x).getStringValue(CHANNEL).toUpperCase().trim();

        return  ( this.getStringValue(STA).trim().equalsIgnoreCase( ((DataStnChl) x).getStringValue(STA).trim()) &&
                  this.getStringValue(NET).trim().equalsIgnoreCase( ((DataStnChl) x).getStringValue(NET).trim()) &&
                  ( seedchan.equals(testSeedchan) || seedchan.equals(testChannel)  ||
                    channel.equals(testSeedchan)  || channel.equals(testChannel) ) );
    }

/** Returns true if all string values of all data field for this instance are equal to those of the input object.
* Returns false if input object is null or not an instanceof DataStnChl.
* No state flags are checked. The data field string comparison is case insensitive.
*/
    public boolean equalsIgnoreCase(Object x) {
  if (x == null || ! ( x instanceof DataStnChl) ) return false;
  //throw new ClassCastException("equalsIgnoreCase(object) argument must be a DataStnChl class type: " + x.getClass().getName());

  for (int index = 0 ; index < MAX_FIELDS; index++) {
      if (! this.getStringValue(index).equalsIgnoreCase( ((DataStnChl) x).getStringValue(index)) ) return false;
  }
  return true;
    }

/** Returns the value of this.toString().hashCode()
*/
    public int hashCode() {
        if (hashCache == null) hashCache = new Integer(toString().hashCode());
        return hashCache.intValue();
    }

/** Returns the result of comparing the strings generated by invoking toString() for this instance and the input object.
* Throws ClassCastException if input object is not an instanceof DataStnChl.
* A return of 0 == value equals, <0 == value less than, >0 == value greater than, the string value of the input argument.
*/
    public int compareTo(Object x) {
  if (x == null || ! ( x instanceof DataStnChl) )
     throw new ClassCastException("compareTo(object) argument must be a DataStnChl class type: "
                                + x.getClass().getName());

  return this.toString().compareTo(((DataStnChl) x).toString());
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -