please rewrite following oracle package to java code :
CREATE OR REPLACE package body TWIST\_LFDNRPACKAGE is
 i BINARY\_INTEGER := 0;
 j BINARY\_INTEGER := 0;
 res NUMBER;
 -- is used to define temporary ab\_lfdnr that will be recalculated in AIUF\_TKS.
 -- these temporary ab\_lfdnr(s) are always negative.
 n\_temp\_ad\_lfdnr NUMBER := 0;

 procedure putRecord(pID TWIST\_KORREKTUR\_STAMM.ID%TYPE,
 pMST\_EDV TWIST\_KORREKTUR\_STAMM.MST\_EDV%TYPE,
 pLABOR\_NR TWIST\_KORREKTUR\_STAMM.LABOR\_NR%TYPE,
 pAUFTRAGSDATUM TWIST\_KORREKTUR\_STAMM.AUFTRAGSDATUM%TYPE) is
 begin
 i := i+1;
 lfdRecords(i).ID := pID;
 lfdRecords(i).MST\_EDV := pMST\_EDV;
 lfdRecords(i).LABOR\_NR := pLABOR\_NR;
 lfdRecords(i).AUFTRAGSDATUM := pAUFTRAGSDATUM;
 end;

 procedure doLFD is
 begin
 for j in 1..i loop
 lfdRecord := lfdRecords(j);
 select max(AD\_LFDNR) into res from TWIST\_KORREKTUR\_STAMM
 where MST\_EDV = lfdRecord.MST\_EDV and LABOR\_NR = lfdRecord.LABOR\_NR
 and to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY');
 if res is NULL then
 res := 1;
 else
 res := res + 1;
 end if;
 update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID;
 end loop;
 lfdRecords.delete;
 i := 0;
 end;

 procedure putRecordBeforeInsertUpdate(pAD\_LFDNR\_ORIGINAL OUT TWIST\_KORREKTUR\_STAMM.AD\_LFDNR%TYPE) is
 begin
 i := i + 1;
 n\_temp\_ad\_lfdnr := n\_temp\_ad\_lfdnr - 1; -- define temporary AD\_LFDNR

 lfdRecords(i).AD\_LFDNR\_ORIGINAL := pAD\_LFDNR\_ORIGINAL;
 lfdRecords(i).AD\_LFDNR\_TEMPORARY := n\_temp\_ad\_lfdnr; -- set temporary AD\_LFDNR
 pAD\_LFDNR\_ORIGINAL := n\_temp\_ad\_lfdnr;
 end;

 procedure putRecordAfterInsertUpdate(pID TWIST\_KORREKTUR\_STAMM.ID%TYPE,
 pMST\_EDV TWIST\_KORREKTUR\_STAMM.MST\_EDV%TYPE,
 pLABOR\_NR TWIST\_KORREKTUR\_STAMM.LABOR\_NR%TYPE,
 pAUFTRAGSDATUM TWIST\_KORREKTUR\_STAMM.AUFTRAGSDATUM%TYPE,
 pAD\_LFDNR\_TEMPORARY TWIST\_KORREKTUR\_STAMM.AD\_LFDNR%TYPE) is
 begin
 for j in 1..i loop
 lfdRecord := lfdRecords(j);

 if lfdRecord.AD\_LFDNR\_TEMPORARY = pAD\_LFDNR\_TEMPORARY then
 lfdRecords(j).ID := pID;
 lfdRecords(j).MST\_EDV := pMST\_EDV;
 lfdRecords(j).LABOR\_NR := pLABOR\_NR;
 lfdRecords(j).AUFTRAGSDATUM := pAUFTRAGSDATUM;
 exit;
 end if;
 end loop;
 end;

 procedure calculateLFD is
 begin
 for j in 1..i loop
 lfdRecord := lfdRecords(j);

 if lfdRecord.AD\_LFDNR\_ORIGINAL is not null then
 -- update record
 select AD\_LFDNR into res from TWIST\_KORREKTUR\_STAMM
 where MST\_EDV = lfdRecord.MST\_EDV and LABOR\_NR = lfdRecord.LABOR\_NR and
 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY') and
 ID <> lfdRecord.ID and AD\_LFDNR = lfdRecord.AD\_LFDNR\_ORIGINAL;

 if res is NULL then
 -- lfdRecord.AD\_LFDNR\_ORIGINAL does not exist in the table and can be used
 res := lfdRecord.AD\_LFDNR\_ORIGINAL;
 else
 -- lfdRecord.AD\_LFDNR\_ORIGINAL exists in the table
 -- calculate new AD\_LFDNR
 select max(AD\_LFDNR) into res from TWIST\_KORREKTUR\_STAMM
 where MST\_EDV = lfdRecord.MST\_EDV and LABOR\_NR = lfdRecord.LABOR\_NR and
 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY');

 if res is NULL then
 -- there are not any AB with this AD\_LFDNR
 res := 1;
 else
 -- there is at least one AB with this AD\_LFDNR
 res := res + 1;
 end if;
 end if;
 -- save defined/calculated AD\_LFDNR
 update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID;
 else
 -- insert record
 select max(AD\_LFDNR) into res from TWIST\_KORREKTUR\_STAMM
 where MST\_EDV = lfdRecord.MST\_EDV and LABOR\_NR = lfdRecord.LABOR\_NR and
 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY') and
 ID <> lfdRecord.ID;

 if res is NULL then
 -- there are not any AB with this AD\_LFDNR
 res := 1;
 else
 -- there is at least one AB with this AD\_LFDNR
 res := res + 1;
 end if;
 --raise\_application\_error(-20003, 'res = ' || res || ', ID = ' || lfdRecord.ID);
 update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID;
 end if;
 end loop;
 -- clear global variables
 lfdRecords.delete;
 i := 0;
 n\_temp\_ad\_lfdnr := 0;
 end;

end;
임대 다음 오라클 패키지를 자바 코드로 다시 작성합니다:패키지 본문을 생성하거나 교체하십시오. TWIST\_LFDNRPACKAGE는 다음과 같습니다. i BINARY\_INTEGER := 0; j BINARY\_INTEGER := 0; res NUMBER; -- 는 AIUF\_TKS에서 재계산될 임시 ab\_lfdnr을 정의하는 데 사용됩니다. -- 이러한 임시 ab\_lfdnr은 항상 음수입니다. n\_temp\_ad\_lfdnr NUMBER := 0; procedure putRecord(pID TWIST\_KORREKTUR\_STAMM.ID%TYPE, pMST\_EDV TWIST\_KORREKTUR\_STAMM.MST\_EDV%TYPE, pLABOR\_NR TWIST\_KORREKTUR\_STAMM.LABOR\_NR%TYPE, pAUFTRAGSDATUM TWIST\_KORREKTUR\_STAMM.AUFTRAGSDATUM%TYPE)은 다음과 같습니다. begin i := i+1; lfdRecords(i).ID := pID; lfdRecords(i).MST\_EDV := pMST\_EDV; lfdRecords(i).LABOR\_NR := pLABOR\_NR; lfdRecords(i).AUFTRAGSDATUM := pAUFTRAGSDATUM; end; 프로시저 doLFD는 begin FOR J IN 1..I LOOP lfdRecord := lfdRecords(j); select max(AD\_LFDNR) into res from TWIST\_KORREKTUR\_STAMM 여기서 MST\_EDV = lfdRecord.MST\_EDV 및 LABOR\_NR = lfdRecord.LABOR\_NR 및 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY'); res가 NULL이면 res := 1; else res := res + 1; end if; update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID; 루프 종료; lfdRecords.delete; i := 0; end; putRecordBeforeInsertUpdate(pAD\_LFDNR\_ORIGINAL OUT TWIST\_KORREKTUR\_STAMM.AD\_LFDNR%TYPE) procedure is begin i := i + 1; n\_temp\_ad\_lfdnr := n\_temp\_ad\_lfdnr - 1; -- 임시 AD\_LFDNR 정의 lfdRecords(i).AD\_LFDNR\_ORIGINAL := pAD\_LFDNR\_ORIGINAL; lfdRecords(i).AD\_LFDNR\_TEMPORARY := n\_temp\_ad\_lfdnr; -- 임시 AD\_LFDNR 설정 pAD\_LFDNR\_ORIGINAL := n\_temp\_ad\_lfdnr; end; procedure putRecordAfterInsertUpdate(pID TWIST\_KORREKTUR\_STAMM.ID%TYPE, pMST\_EDV TWIST\_KORREKTUR\_STAMM.MST\_EDV%TYPE, pLABOR\_NR TWIST\_KORREKTUR\_STAMM.LABOR\_NR%TYPE, pAUFTRAGSDATUM TWIST\_KORREKTUR\_STAMM.AUFTRAGSDATUM%TYPE, pAD\_LFDNR\_TEMPORARY TWIST\_KORREKTUR\_STAMM.AD\_LFDNR%TYPE)는 다음과 같습니다. begin FOR J IN 1..I LOOP lfdRecord := lfdRecords(j); if lfdRecord.AD\_LFDNR\_TEMPORARY = pAD\_LFDNR\_TEMPORARY then lfdRecords(j).ID := pID; lfdRecords(j).MST\_EDV := pMST\_EDV; lfdRecords(j).LABOR\_NR := pLABOR\_NR; lfdRecords(j).AUFTRAGSDATUM := pAUFTRAGSDATUM; exit; end if; 루프 종료; end; 프로시저 계산LFD는 begin FOR J IN 1..I LOOP lfdRecord := lfdRecords(j); lfdRecord.AD\_LFDNR\_ORIGINAL이 null이 아닌 경우 -- 레코드 업데이트 TWIST\_KORREKTUR\_STAMM에서 AD\_LFDNR을 res로 선택합니다. 여기서 MST\_EDV = lfdRecord.MST\_EDV 및 LABOR\_NR = lfdRecord.LABOR\_NR 및 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY') 및 ID <> lfdRecord.ID 및 AD\_LFDNR = lfdRecord.AD\_LFDNR\_ORIGINAL; res가 NULL이면 -- 테이블에 lfdRecord.AD\_LFDNR\_ORIGINAL이 존재하지 않으므로 사용할 수 있습니다. res := lfdRecord.AD\_LFDNR\_ORIGINAL; else -- 테이블에 lfdRecord.AD\_LFDNR\_ORIGINAL이 존재합니다. -- 새 AD\_LFDNR 계산 TWIST\_KORREKTUR\_STAMM에서 max(AD\_LFDNR)를 res로 선택합니다. 여기서 MST\_EDV = lfdRecord.MST\_EDV 및 LABOR\_NR = lfdRecord.LABOR\_NR 및 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY'); res가 NULL이면 -- 이 AD\_LFDNR을 가진 AB가 없습니다. res := 1; else -- 이 AD\_LFDNR을 가진 AB가 하나 이상 있습니다. res := res + 1; end if; end if; -- 정의/계산된 AD\_LFDNR 저장 update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID; else -- 레코드 삽입 TWIST\_KORREKTUR\_STAMM에서 max(AD\_LFDNR)를 res로 선택합니다. 여기서 MST\_EDV = lfdRecord.MST\_EDV 및 LABOR\_NR = lfdRecord.LABOR\_NR 및 to\_char(AUFTRAGSDATUM, 'DD.MM.YYYY') = to\_char(lfdRecord.AUFTRAGSDATUM, 'DD.MM.YYYY') 및 ID <> lfdRecord.ID; res가 NULL이면 -- 이 AD\_LFDNR을 가진 AB가 없습니다. res := 1; else -- 이 AD\_LFDNR을 가진 AB가 하나 이상 있습니다. res := res + 1; end if; --raise\_application\_error(-20003, 'res = ' || res || ', ID = ' || lfdRecord.ID); update TWIST\_KORREKTUR\_STAMM set AD\_LFDNR = res where ID = lfdRecord.ID; end if; end loop; -- 전역 변수 지우기 lfdRecords.delete; i := 0; n\_temp\_ad\_lfdnr := 0; end;end;