Obfuscate Java Logging CS3 Class SO

  1. import java.io.File;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.util.TreeMap;
  6.  
  7. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  8. import org.apache.poi.ss.usermodel.Row;
  9. import org.apache.poi.ss.usermodel.Sheet;
  10. import org.apache.poi.ss.usermodel.Workbook;
  11. import org.apache.poi.ss.usermodel.WorkbookFactory;
  12.  
  13. public class SO
  14. {
  15. static private SO m_placeholder;
  16. private TreeMap<String, String> m_mappings;
  17.  
  18. protected SO()
  19. {
  20. m_placeholder = null;
  21. m_mappings = new TreeMap<String, String>();
  22. }
  23.  
  24. static public synchronized SO g()
  25. {
  26. if (m_placeholder == null)
  27. {
  28. m_placeholder = new SO();
  29. }
  30. return m_placeholder;
  31. }
  32. public String u(String theObfuscatedString)
  33. {
  34. String u = m_mappings.get(theObfuscatedString);
  35. if (u != null)
  36. {
  37. return u;
  38. }
  39. else
  40. {
  41. return theObfuscatedString;
  42. }
  43. }
  44. public void setSOMappingsFile(File theMappingsFile)
  45. throws InvalidFormatException, IOException
  46. {
  47. InputStream inp = new FileInputStream(theMappingsFile);
  48.  
  49. Workbook wb = WorkbookFactory.create(inp);
  50. Sheet sheet = wb.getSheetAt(0);
  51. Row row = null;
  52. // System.out.println("Setting Mappings start read.");
  53. for (int r = 1; r < sheet.getLastRowNum(); r++)
  54. {
  55. // System.out.println("Setting Mappings start read. - in for loop");
  56. row = sheet.getRow(r);
  57. // System.out.println("Setting Mappings start read. - got row");
  58. if ((row != null) && (row.getCell(0) != null) && (row.getCell(0).getStringCellValue() != null))
  59. {
  60. if (row.getCell(0).getStringCellValue().compareTo("") != 0)
  61. {
  62. // System.out.println("Col1 = " + row.getCell(0).getStringCellValue() + " Col2 = " + row.getCell(1).getStringCellValue());
  63. m_mappings.put
  64. (
  65. row.getCell(0).getStringCellValue(),
  66. row.getCell(1).getStringCellValue()
  67. );
  68. }
  69. }
  70. }
  71. // System.out.println("Setting Mappings all read.");
  72. }
  73. }