下面列出了org.apache.commons.lang3.ArrayUtils#INDEX_NOT_FOUND 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Nonnull
private static Body[] addBodyToCell(@Nullable Body[] cellBodies, @Nonnull Body body) {
if (cellBodies == null) {
return new Body[] {body};
}
int bodyIndex = ArrayUtils.indexOf(cellBodies, body);
if (bodyIndex != ArrayUtils.INDEX_NOT_FOUND) {
throw new IllegalStateException("Can't add Body {id=" + body.getId() + "} to index.");
}
int bodyCount = cellBodies.length;
Body[] newCellBodies = new Body[bodyCount + 1];
System.arraycopy(cellBodies, 0, newCellBodies, 0, bodyCount);
newCellBodies[bodyCount] = body;
return newCellBodies;
}
@Nullable
private static Body[] removeBodyFromCell(@Nonnull Body[] cellBodies, @Nonnull Body body) {
int bodyIndex = ArrayUtils.indexOf(cellBodies, body);
if (bodyIndex == ArrayUtils.INDEX_NOT_FOUND) {
throw new IllegalStateException("Can't remove Body {id=" + body.getId() + "} from index.");
}
int bodyCount = cellBodies.length;
if (bodyCount == 1) {
return null;
}
Body[] newCellBodies = new Body[bodyCount - 1];
System.arraycopy(cellBodies, 0, newCellBodies, 0, bodyIndex);
System.arraycopy(cellBodies, bodyIndex + 1, newCellBodies, bodyIndex, bodyCount - bodyIndex - 1);
return newCellBodies;
}
@Override
public String[] read() throws IOException, NoSuchElementException {
if (!hasNext()) {
throw new NoSuchElementException();
}
String[] values = reader.getValues();
readRecord();
lineNumber++;
// drop all values after last non-empty cell
// otherwise a lot of empty (but styled) cells will be returned
int lastNonEmptyCellIdx = ArrayUtils.INDEX_NOT_FOUND;
for (int i = values.length - 1; i >= 0; i--) {
if (StringUtils.isNotBlank(values[i])) {
lastNonEmptyCellIdx = i;
break;
}
}
if(lastNonEmptyCellIdx == ArrayUtils.INDEX_NOT_FOUND) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
if(values.length != lastNonEmptyCellIdx + 1) {
values = Arrays.copyOf(values, lastNonEmptyCellIdx + 1);
}
for (int i=0; i<values.length; i++) {
values[i] = values[i].trim();
}
return values;
}
private boolean inDefinedHoliday(Calendar c) {
if (ArrayUtils.isNotEmpty(this.definedHolidays)) {
if (ArrayUtils.indexOf(this.definedHolidays,
DateFormatUtils.format(c, DATEPARTFORMATPATTERN[0])) > ArrayUtils.INDEX_NOT_FOUND) {
return true;
}
}
return false;
}
private boolean inDefinedWorkday(Calendar c) {
if (ArrayUtils.isNotEmpty(this.definedWorkdays)) {
if (ArrayUtils.indexOf(this.definedWorkdays,
DateFormatUtils.format(c, DATEPARTFORMATPATTERN[0])) > ArrayUtils.INDEX_NOT_FOUND) {
return true;
}
}
return false;
}
private boolean inDefinedWeekends(Calendar c) {
if (ArrayUtils.indexOf(this.definedWeekends, c.get(Calendar.DAY_OF_WEEK)) > ArrayUtils.INDEX_NOT_FOUND) {
return true;
}
return false;
}
public static float direction8ToRadians(int direction) {
int i = ArrayUtils.indexOf(DIRS_8M, direction);
if (i == ArrayUtils.INDEX_NOT_FOUND) return 0;
return RADIANS_8[i];
}