public String[] split(String source, String div) {
// 計算分割後的片段數量
// 依序找出分隔符位置,建立結果陣列
// 處理空字串、無分隔符等邊界情況
}
自訂 split 方法,支援多字元分隔符,回傳字串陣列。邏輯包含:先掃描計算片段數、配置陣列、再逐段擷取子字串。
public class stc_RSYB_Name {
public int pos = -1;
public String NAME = "";
public String host = "";
public String home1 = "", home2 = "", home3 = "";
}
public class stc_SYB_INF {
String reg_name = "";
String G_SYB = "";
String R_SYB = "";
}
兩個簡單的資料容器類別,用於攜帶名稱、主機與 SYB 相關資訊。
void showBlank(int num, JSPWriter out) {
try {
for (int i = 0; i <= num; i++) out.print(" ");
} catch (Exception e) {}
}
String g_syb_mk() {
// 從資料庫查詢 DOMEIN 與 GROUP_SYB
// 依位元邏輯組合成 32 碼字串
// 使用 Char_OR 進行位元 OR 運算
}
核心邏輯:查詢符合特定模式的記錄,提取網域與群組代碼,逐位元檢查並組合成最終字串。
reCount:執行 SELECT COUNT(*) 回傳筆數dCount:條件計數,指定欄位不為 nulldLookup:單值查詢,回傳指定欄位字串String rTrim(String str) {
// 移除字串尾部空白
// 逐字元從尾端檢查,遇非空白即停止
}
void sybinf_set(stc_RSYB_Name in, stc_SYB_INF out) {
// 查詢主機、home1~3 對應的 DOMEIN 代碼
// 透過 Char_OR 合併三組代碼
// 結果存入 out.R_SYB
}
String Char_OR(String a, String b) {
// 逐字元比較,任一為 '1' 則結果為 '1'
// 長度不等時,較長者多出部分直接保留
}
void writeFile(String content, String target) {
try (PrintWriter pw = new PrintWriter(new FileOutputStream(target))) {
pw.println(content);
} catch (IOException e) { System.out.println(e.getMessage()); }
}