?? validationdelegatecomboimpl.java
字號(hào):
package com.onetsoft.fastjsp;
import com.onetsoft.fastjsp.util.StringUtils;
import com.onetsoft.fastjsp.valid.ValidationDelegate;
import com.onetsoft.fastjsp.valid.ValidationException;
import org.apache.commons.lang.ArrayUtils;
/*
* 組合驗(yàn)證代理
* 用以為用戶提供一致的驗(yàn)證代理界面
* 此類的目的在于支持 {@link AbstractComponent#initialize()}中的{@link com.onetsoft.fastjsp.valid.ValidationException}
* 不同于頁(yè)面/組件確保全部執(zhí)行初始化,方法{@link ActionsManager#execute(AbstractPageService)}在遇到驗(yàn)證錯(cuò)誤即拋出
*/
class ValidationDelegateComboImpl implements ValidationDelegate {
private ValidationDelegate[] delegates = new ValidationDelegate[0];
private int count = 0;
public void addDelegate(ValidationDelegate delegate) {
ensureConpacity();
delegates[count++] = delegate;
}
private void ensureConpacity() {
if (count == delegates.length) {
ValidationDelegate[] b = new ValidationDelegate[count + 2];
System.arraycopy(delegates, 0, b, 0, count);
this.delegates = b;
}
}
public boolean containsDelegate() {
return count > 0;
}
public boolean isError() {
for (int i = 0; i < count; i++) {
if (delegates[i].isError()) return true;
}
return false;
}
public boolean isError(String field) {
for (int i = 0; i < count; i++) {
if (delegates[i].isError(field)) return true;
}
return false;
}
public String getMessage(String field) {
for (int i = 0; i < count; i++) {
String err = delegates[i].getMessage(field);
if (err.length() != 0) return err;
}
return StringUtils.EMPTY;
}
public String[] getMessages() {
String[] a = ArrayUtils.EMPTY_STRING_ARRAY;
for (int i = 0; i < count; i++) {
String[] e = delegates[i].getMessages();
if (e.length != 0) {
if (a.length == 0) a = e;
else {
String[] tmp = new String[a.length + e.length];
System.arraycopy(a, 0, tmp, 0, a.length);
System.arraycopy(e, 0, tmp, a.length, e.length);
}
}
}
return a;
}
public void validate() throws ValidationException {
throw new UnsupportedOperationException();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -