コード例 #1
0
 private static String mergeStudent(
     final String lineEmployee, final String lineStudent, final Category destinationCategory) {
   final StringBuilder newLine = new StringBuilder();
   newLine.append(lineStudent.substring(0, 11));
   newLine.append(destinationCategory.getCode());
   // newLine.append(lineStudent.substring(13, 34));
   newLine.append(lineEmployee.substring(13, 34));
   newLine.append(lineStudent.substring(11, 21));
   newLine.append(lineStudent.substring(83, 95));
   newLine.append("           ");
   newLine.append(lineStudent.substring(67, 75));
   newLine.append(lineEmployee.substring(67, 75));
   newLine.append(lineStudent.substring(83, 95));
   newLine.append("             ");
   newLine.append(lineEmployee.substring(44, 67));
   newLine.append(lineEmployee.substring(131));
   return newLine.toString();
 }
コード例 #2
0
 public static String merge(
     final String line1, final Category category1, final String line2, final Category category2) {
   if (category1 == Category.CODE_71 && category2 == Category.CODE_94) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_71 && category1 == Category.CODE_94) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_71 && category2 == Category.CODE_95) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_71 && category1 == Category.CODE_95) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_71 && category2 == Category.CODE_92) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_71 && category1 == Category.CODE_92) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_71 && category2 == Category.CODE_99) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_71 && category1 == Category.CODE_99) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_72 && category2 == Category.CODE_92) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_72 && category1 == Category.CODE_92) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_72 && category2 == Category.CODE_94) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_72 && category1 == Category.CODE_94) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_72 && category2 == Category.CODE_95) {
     return mergeStudent(line1, line2, Category.CODE_73);
   } else if (category2 == Category.CODE_72 && category1 == Category.CODE_95) {
     return mergeStudent(line2, line1, Category.CODE_73);
   }
   if (category1 == Category.CODE_81 && category2 == Category.CODE_94) {
     return mergeStudent(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_81 && category1 == Category.CODE_94) {
     return mergeStudent(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_81 && category2 == Category.CODE_95) {
     return mergeStudent(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_81 && category1 == Category.CODE_95) {
     return mergeStudent(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_81 && category2 == Category.CODE_96) {
     return line1;
   } else if (category2 == Category.CODE_81 && category1 == Category.CODE_96) {
     return line2;
   }
   if (category1 == Category.CODE_81 && category2 == Category.CODE_99) {
     return mergeStudent(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_81 && category1 == Category.CODE_99) {
     return mergeStudent(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_82 && category2 == Category.CODE_92) {
     return mergeInMergedFormat(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_82 && category1 == Category.CODE_92) {
     return mergeInMergedFormat(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_82 && category2 == Category.CODE_94) {
     return mergeInMergedFormat(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_82 && category1 == Category.CODE_94) {
     return mergeInMergedFormat(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_82 && category2 == Category.CODE_95) {
     return mergeInMergedFormat(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_82 && category1 == Category.CODE_95) {
     return mergeInMergedFormat(line2, line1, Category.CODE_82);
   }
   if (category1 == Category.CODE_92 && category2 == Category.CODE_92) {
     throw new Error("??? 92 + 92");
   } else if (category2 == Category.CODE_92 && category1 == Category.CODE_92) {
     throw new Error("??? 92 + 92");
   }
   if (category1 == Category.CODE_92 && category2 == Category.CODE_96) {
     return mergeInMergedFormat(line2, line1, Category.CODE_96);
   } else if (category2 == Category.CODE_92 && category1 == Category.CODE_96) {
     return mergeInMergedFormat(line1, line2, Category.CODE_96);
   }
   if (category1 == Category.CODE_94 && category2 == Category.CODE_94) {
     throw new Error("??? 94 + 94");
   } else if (category2 == Category.CODE_94 && category1 == Category.CODE_94) {
     throw new Error("??? 94 + 94");
   }
   if (category1 == Category.CODE_94 && category2 == Category.CODE_95) {
     return line2;
   } else if (category2 == Category.CODE_94 && category1 == Category.CODE_95) {
     return line1;
   }
   if (category1 == Category.CODE_94 && category2 == Category.CODE_96) {
     return mergeInMergedFormat(line2, line1, Category.CODE_96);
   } else if (category2 == Category.CODE_94 && category1 == Category.CODE_96) {
     return mergeInMergedFormat(line1, line2, Category.CODE_96);
   }
   if (category1 == Category.CODE_95 && category2 == Category.CODE_95) {
     throw new Error("??? 95 + 95");
   } else if (category2 == Category.CODE_95 && category1 == Category.CODE_95) {
     throw new Error("??? 95 + 95");
   }
   if (category1 == Category.CODE_95 && category2 == Category.CODE_96) {
     return mergeInMergedFormat(line2, line1, Category.CODE_96);
   } else if (category2 == Category.CODE_95 && category1 == Category.CODE_96) {
     return mergeInMergedFormat(line1, line2, Category.CODE_96);
   }
   if (category1 == Category.CODE_95 && category2 == Category.CODE_97) {
     return mergeInMergedFormat(line1, line2, Category.CODE_96);
   } else if (category2 == Category.CODE_95 && category1 == Category.CODE_97) {
     return mergeInMergedFormat(line2, line1, Category.CODE_96);
   }
   if (category1 == Category.CODE_83 && category2 == Category.CODE_95) {
     return mergeStudent(line1, line2, Category.CODE_82);
   } else if (category2 == Category.CODE_83 && category1 == Category.CODE_95) {
     return mergeStudent(line2, line1, Category.CODE_82);
   } else {
     throw new Error("Unhandled case: " + category1.getCode() + " & " + category2.getCode());
   }
 }