public Date getDate(int pos) throws ThreemaException {
String cell = this.getString(pos); if (cell != null && !cell.isEmpty()) { returnnew Date(Long.parseLong(cell));
}
returnnull;
}
public CSVRow write(String fieldName, Object v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, Object v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public CSVRow write(String fieldName, String v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, String v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public CSVRow write(String fieldName, boolean v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, int v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public CSVRow write(String fieldName, int v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, boolean v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public CSVRow write(String fieldName, Date v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, Date v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public CSVRow write(String fieldName, Object[] v) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position");
}
returnthis.write(pos, v);
}
public CSVRow write(int pos, Object[] v) throws ThreemaException { if (this.data.length < pos) { thrownew ThreemaException("invalid position to write [" + pos + "]");
}
this.data[pos] = this.escape(v); returnthis;
}
public String[] getStrings(int pos) throws ThreemaException {
String r = this.getString(pos); return TestUtil.isEmptyOrNull(r) ? new String[]{} : r.split(";");
}
public String getString(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getString(pos);
}
public @NonNull Integer getInteger(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getInteger(pos);
}
public @NonNull Long getLong(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getLong(pos);
}
publicboolean getBoolean(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getBoolean(pos);
}
public Date getDate(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getDate(pos);
}
public String[] getStrings(String fieldName) throws ThreemaException { int pos = this.getValuePosition(fieldName); if (pos < 0) { thrownew ThreemaException("invalid csv header position [" + fieldName + "]");
} returnthis.getStrings(pos);
}
/** * Return the CSV column index for the specified column name. * * @return the index, or -1 if the column was not found.
*/ publicint getValuePosition(String fieldName) { if (this.header != null && fieldName != null) { for (int n = 0; n < this.header.length; n++) { if (fieldName.equals(this.header[n])) { return n;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.