표준전문 조건 처리 기능 OR 처리 추가

This commit is contained in:
yunjy-hp
2026-01-14 13:34:16 +09:00
parent 6d1e76ad50
commit 0052e85495
@@ -124,31 +124,28 @@ public class FlatReader implements StandardReader {
if(refItemValue != null) refItemValue = refItemValue.trim();
/*
* 값의 경우의수 NR,ER,""(blank)
* ER이 아닐경우 표현하고 싶어서 ! 를 추가했음
* 원칙으로는 NR을 넣었을경우에는 NR 이 있을경우에만 해당됨
* !ER일경우에는 blank와 NR일 경우에 해당됨
* 값의 경우의수 NM,EM,""(blank)
* ! : NOT 조건 (예: !EM → EM이 아닌 경우)
* | : OR 조건 (예: NM|EM → NM 또는 EM인 경우)
* !와 | 조합 가능 (예: !NM|EM → NM도 아니고 EM도 아닌 경우)
*/
String refValue = currentItem.getRefValue();
if (refValue.startsWith("!")) { // 느낌표가 들어가면 다음에 나오는게 아닌경우
boolean isNot = refValue.startsWith("!");
if (isNot) {
refValue = refValue.substring(1);
if (refValue.equals(refItemValue)) {
logger.warn("@GROUP name={} SKIPPED.", currentItem.getName());
currentItem.setHidden(true);
break;
} else {
currentItem.setHidden(false);
}
}
boolean matched = matchRefValue(refValue, refItemValue);
if (isNot) {
matched = !matched;
}
if (!matched) {
logger.warn("@GROUP name={} SKIPPED.", currentItem.getName());
currentItem.setHidden(true);
break;
} else {
if (!currentItem.getRefValue().equals(refItemValue)) {
logger.warn("@GROUP name={} SKIPPED.", currentItem.getName());
currentItem.setHidden(true);
break;
} else {
currentItem.setHidden(false);
}
currentItem.setHidden(false);
}
}
childList = currentItem.getChildsList();
@@ -310,6 +307,21 @@ public class FlatReader implements StandardReader {
}
return refItemValue;
}
// public static void main(String[] args) {
// }
/**
* refValue와 refItemValue를 비교하여 일치 여부를 반환
* | 구분자로 OR 조건 지원 (예: "NM|EM" → "NM" 또는 "EM"과 일치하면 true)
*/
private boolean matchRefValue(String refValue, String refItemValue) {
if (refValue.contains("|")) {
String[] values = refValue.split("\\|");
for (String val : values) {
if (val.equals(refItemValue)) {
return true;
}
}
return false;
}
return refValue.equals(refItemValue);
}
}