📄 datatablerow.java
字号:
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getIntValue(index) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getIntValue: field object null at index: " + index);
return dataObj.intValue();
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column name.
*/
public long getLongValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getLongValue(String name) unknown field name:" + name);
return getLongValue(index);
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column index.
*/
public long getLongValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getLongValue(index) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + "DataTableRow getLongValue: field object null at index: " + index);
return dataObj.longValue();
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column name.
*/
public float getFloatValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getFloatValue(String name) unknown field name:" + name);
return getFloatValue(index);
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column index.
*/
public float getFloatValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getFloatValue(index) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getFloatValue: field object null at index: " + index);
return dataObj.floatValue();
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column name.
*/
public double getDoubleValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getDoubleValue(String name) unknown field name:" + name);
return getDoubleValue(index);
}
/** Returns a primitive equivalent to the value of the DataObject for the specified table column index.
*/
public double getDoubleValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getDoubleValue(index) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getDoubleValue: field object null at index: " + index);
return dataObj.doubleValue();
}
/** Returns a date object from the DataObject for the specified table column name.
* The table column field DataObject must implement the DataTime interface.
*/
public java.sql.Date getDateValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getDateValue(String name) unknown field name:" + name);
return getDateValue(index);
}
/** Returns a date object from the DataObject for the specified table column index.
* The table column field DataObject must implement the DataTime interface.
*/
public java.sql.Date getDateValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getDateValue(index) field index out of bounds:" + index);
DataTime dataObj = (DataTime) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getDateValue: field object null at index: " + index);
return new java.sql.Date(dataObj.dateValue().getTime());
}
/** Returns a timestamp object from the DataObject for the specified table column name.
* The table column field DataObject must implement the DataTime interface.
*/
public java.sql.Timestamp getTimestampValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getTimestampValue(String name) unknown field name:" + name);
return getTimestampValue(index);
}
/** Returns a timestamp object from the DataObject for the specified table column index.
* The table column field DataObject must implement the DataTime interface.
*/
public java.sql.Timestamp getTimestampValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getTimestampValue(index) field index out of bounds:" + index);
DataTime dataObj = (DataTime) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getTimestampValue: field object null at index: " + index);
return dataObj.timestampValue();
}
/** Returns SQL syntax string value of getStringValue() for the specified table column name
* (non-numeric strings are surrounded by single quotes).
*/
public String getStringValueSQL(String name) throws NoSuchFieldException {
return StringSQL.valueOf(getStringValue(name));
}
/** Returns SQL syntax string value of getStringValue() for the specified table column index
* (non-numeric strings are surrounded by single quotes).
*/
public String getStringValueSQL(int index) throws IndexOutOfBoundsException, NullPointerException {
return StringSQL.valueOf(getStringValue(index));
}
/** Returns a string value derived from the DataObject for the specified table column name.
*/
public String getStringValue(String name) throws NoSuchFieldException {
int index = findFieldIndex(name);
if (index < 0) throw new NoSuchFieldException(tableName +
" DataTableRow getStringValue(String name) unknown field name:" + name);
return getStringValue(index);
}
/** Returns a string value derived from the DataObject for the specified table column index.
*/
public String getStringValue(int index) throws IndexOutOfBoundsException, NullPointerException {
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow getStringValue(index) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null)
throw new NullPointerException(tableName + " DataTableRow getStringValue: field object null at index: " +
index + " name:" + fieldNames[index]);
// if (dataObj == null) return "NULL";
return dataObj.toString();
}
/** Creates for the specified table column index a newInstance of a DataObject of the same type as the column class.
* Invoked by data field value modification methods (setValue(xxx, xxx)) whenever the DataObject in the data collection is null.
* Returns the handle of the newly created DataObject.
*/
private DataObject initializeDataField(int index) {
DataObject dataObj = null;
try {
dataObj = (DataObject) DATA_CLASSES[fieldClassIds[index]].newInstance();
}
catch (IllegalAccessException ex) {
System.err.println(tableName +
" DataTableRow initializeField(int index): class/initializer not accessible: " +
DATA_CLASSES[fieldClassIds[index]]);
// throw ex.fillInStackTrace();
}
catch (InstantiationException ex) {
System.err.println(tableName +
" DataTableRow initializeField(int index): cannot instantiate class of type:" +
DATA_CLASSES[fieldClassIds[index]]);
// throw ex.fillInStackTrace();
}
return dataObj;
}
/** Sets the DataObject value for the specified table column name.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(String name, int value) throws NoSuchFieldException {
if (! isMutable()) return this;
int index = findFieldIndex(name);
if (index < 0)
throw new NoSuchFieldException(tableName +
" DataTableRow setValue(String name, int value) unknown field name:" + name);
return setValue(index, value);
}
/** Sets the DataObject value for the specified table column index.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(int index, int value) throws IndexOutOfBoundsException {
if (! isMutable()) return this;
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow setValue(int index, int value) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null) {
dataObj = initializeDataField(index);
dataObj.setValue(value);
fields.set(index, dataObj);
}
else dataObj.setValue(value);
return setUpdate(true).setNull(false);
}
/** Sets the DataObject value for the specified table column name.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(String name, long value) throws NoSuchFieldException {
if (! isMutable()) return this;
int index = findFieldIndex(name);
if (index < 0)
throw new NoSuchFieldException(tableName +
" DataTableRow setValue(String name, long value) unknown field name:" + name);
return setValue(index, value);
}
/** Sets the DataObject value for the specified table column index.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(int index, long value) throws IndexOutOfBoundsException {
if (! isMutable()) return this;
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow setValue(int index, long value) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null) {
dataObj = initializeDataField(index);
dataObj.setValue(value);
fields.set(index, dataObj);
}
else dataObj.setValue(value);
return setUpdate(true).setNull(false);
}
/** Sets the DataObject value for the specified table column name.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(String name, float value) throws NoSuchFieldException {
if (! isMutable()) return this;
int index = findFieldIndex(name);
if (index < 0)
throw new NoSuchFieldException(tableName +
" DataTableRow setValue(String name, float value) unknown field name:" + name);
return setValue(index, value);
}
/** Sets the DataObject value for the specified table column index.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
* Sets the column field null status flag, isNull() == false.
* Sets the row null status flag, isNull() == false.
* Returns a handle to this object instance.
*/
public DataTableRow setValue(int index, float value) throws IndexOutOfBoundsException {
if (! isMutable()) return this;
if (index < 0 || index > fields.size())
throw new IndexOutOfBoundsException(tableName +
" DataTableRow setValue(int index, float value) field index out of bounds:" + index);
DataObject dataObj = (DataObject) fields.get(index);
if (dataObj == null) {
dataObj = initializeDataField(index);
dataObj.setValue(value);
fields.set(index, dataObj);
}
else dataObj.setValue(value);
return setUpdate(true).setNull(false);
}
/** Sets the DataObject value for the specified table column name.
* Does a no-op if isMutable() == false or if a field is null and the required initializeDataField() fails.
* Sets the column field update status flag, isUpdate() == true.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -