📄 abstractcolumn.java
字号:
} else {
throw new DataTypeException(int.class);
}
}
/**
* Set the data value at the specified row as an integer
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the integer type
*/
public void setInt(int val, int row) throws DataTypeException {
if ( canSetInt() ) {
set(new Integer(val), row);
} else {
throw new DataTypeException(int.class);
}
}
// -- long ----------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the long type.
* @return true if getLong is supported, false otherwise
*/
public boolean canGetLong() {
return canGet(long.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the long type.
* @return true if setLong is supported, false otherwise
*/
public boolean canSetLong() {
return canSet(long.class);
}
/**
* Get the data value at the specified row as a long
* @param row the row from which to retrieve the value
* @return the data value as a long
* @throws DataTypeException if this column does not
* support the long type
*/
public long getLong(int row) throws DataTypeException {
if ( canGetLong() ) {
return ((Long)get(row)).longValue();
} else {
throw new DataTypeException(long.class);
}
}
/**
* Set the data value at the specified row as a long
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the long type
*/
public void setLong(long val, int row) throws DataTypeException {
if ( canSetLong() ) {
set(new Long(val), row);
} else {
throw new DataTypeException(long.class);
}
}
// -- float ---------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the float type.
* @return true if getFloat is supported, false otherwise
*/
public boolean canGetFloat() {
return canGet(float.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the float type.
* @return true if setFloat is supported, false otherwise
*/
public boolean canSetFloat() {
return canSet(float.class);
}
/**
* Get the data value at the specified row as a float
* @param row the row from which to retrieve the value
* @return the data value as a float
* @throws DataTypeException if this column does not
* support the float type
*/
public float getFloat(int row) throws DataTypeException {
if ( canGetFloat() ) {
return ((Float)get(row)).floatValue();
} else {
throw new DataTypeException(float.class);
}
}
/**
* Set the data value at the specified row as a float
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the float type
*/
public void setFloat(float val, int row) throws DataTypeException {
if ( canSetFloat() ) {
set(new Float(val), row);
} else {
throw new DataTypeException(float.class);
}
}
// -- double --------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the double type.
* @return true if getDouble is supported, false otherwise
*/
public boolean canGetDouble() {
return canGet(double.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the double type.
* @return true if setDouble is supported, false otherwise
*/
public boolean canSetDouble() {
return canSet(double.class);
}
/**
* Get the data value at the specified row as a double
* @param row the row from which to retrieve the value
* @return the data value as a double
* @throws DataTypeException if this column does not
* support the double type
*/
public double getDouble(int row) throws DataTypeException {
if ( canGetDouble() ) {
return ((Double)get(row)).doubleValue();
} else {
throw new DataTypeException(double.class);
}
}
/**
* Set the data value at the specified row as a double
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the double type
*/
public void setDouble(double val, int row) throws DataTypeException {
if ( canSetDouble() ) {
set(new Double(val), row);
} else {
throw new DataTypeException(double.class);
}
}
// -- boolean -------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the boolean type.
* @return true if getBoolean is supported, false otherwise
*/
public boolean canGetBoolean() {
return canGet(boolean.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the boolean type.
* @return true if setBoolean is supported, false otherwise
*/
public boolean canSetBoolean() {
return canSet(boolean.class);
}
/**
* Get the data value at the specified row as a boolean
* @param row the row from which to retrieve the value
* @return the data value as a boolean
* @throws DataTypeException if this column does not
* support the boolean type
*/
public boolean getBoolean(int row) throws DataTypeException {
if ( canGetBoolean() ) {
return ((Boolean)get(row)).booleanValue();
} else {
throw new DataTypeException(boolean.class);
}
}
/**
* Set the data value at the specified row as a boolean
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the boolean type
*/
public void setBoolean(boolean val, int row) throws DataTypeException {
if ( canSetBoolean() ) {
set(new Boolean(val), row);
} else {
throw new DataTypeException(boolean.class);
}
}
// -- String --------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the String type.
* @return true if getString is supported, false otherwise
*/
public boolean canGetString() {
return true;
//return canGet(String.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the String type.
* @return true if setString is supported, false otherwise
*/
public boolean canSetString() {
return m_parser != null && !(m_parser instanceof ObjectParser);
//return canSet(String.class);
}
/**
* Get the data value at the specified row as a String
* @param row the row from which to retrieve the value
* @return the data value as a String
* @throws DataTypeException if this column does not
* support the String type
*/
public String getString(int row) throws DataTypeException {
if ( canGetString() ) {
return m_parser.format(get(row));
} else {
throw new DataTypeException(String.class);
}
}
/**
* Set the data value at the specified row as a String
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the String type
*/
public void setString(String val, int row) throws DataTypeException {
try {
set(m_parser.parse(val), row);
} catch (DataParseException e) {
throw new DataTypeException(e);
}
}
// -- Date ----------------------------------------------------------------
/**
* Indicates if convenience get method can be called without
* an exception being thrown for the Date type.
* @return true if getDate is supported, false otherwise
*/
public boolean canGetDate() {
return canGet(Date.class);
}
/**
* Indicates if convenience set method can be called without
* an exception being thrown for the Date type.
* @return true if setDate is supported, false otherwise
*/
public boolean canSetDate() {
return canSet(Date.class);
}
/**
* Get the data value at the specified row as a Date
* @param row the row from which to retrieve the value
* @return the data value as a Date
* @throws DataTypeException if this column does not
* support the Date type
*/
public Date getDate(int row) throws DataTypeException {
if ( canGetDate() ) {
return (Date)get(row);
} else {
throw new DataTypeException(Date.class);
}
}
/**
* Set the data value at the specified row as a Date
* @param val the value to set
* @param row the row at which to set the value
* @throws DataTypeException if this column does not
* support the Date type
*/
public void setDate(Date val, int row) throws DataTypeException {
set(val, row);
}
} // end of abstract class AbstractColumn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -