@Test public void read() throws Exception { Map<String, Attributes> entities = LDIFUtils.read(getClass().getResourceAsStream("/example.ldif")); assertThat(entities.size(), is(4)); }
public static Map<String, Attributes> read(InputStream in) throws IOException { Map<String, Attributes> result = new LinkedHashMap<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; Attributes currentEntity = null; String currentLine = null; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { continue; } if (line.isEmpty()) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentEntity = null; currentLine = null; continue; } if (currentEntity == null) { currentEntity = new BasicAttributes(); } if (!line.startsWith(" ")) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentLine = line; } else { currentLine = currentLine + line; } } if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } } return result; }
LDIFUtils { public static Map<String, Attributes> read(InputStream in) throws IOException { Map<String, Attributes> result = new LinkedHashMap<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; Attributes currentEntity = null; String currentLine = null; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { continue; } if (line.isEmpty()) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentEntity = null; currentLine = null; continue; } if (currentEntity == null) { currentEntity = new BasicAttributes(); } if (!line.startsWith(" ")) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentLine = line; } else { currentLine = currentLine + line; } } if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } } return result; } }
LDIFUtils { public static Map<String, Attributes> read(InputStream in) throws IOException { Map<String, Attributes> result = new LinkedHashMap<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; Attributes currentEntity = null; String currentLine = null; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { continue; } if (line.isEmpty()) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentEntity = null; currentLine = null; continue; } if (currentEntity == null) { currentEntity = new BasicAttributes(); } if (!line.startsWith(" ")) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentLine = line; } else { currentLine = currentLine + line; } } if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } } return result; }  }
LDIFUtils { public static Map<String, Attributes> read(InputStream in) throws IOException { Map<String, Attributes> result = new LinkedHashMap<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; Attributes currentEntity = null; String currentLine = null; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { continue; } if (line.isEmpty()) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentEntity = null; currentLine = null; continue; } if (currentEntity == null) { currentEntity = new BasicAttributes(); } if (!line.startsWith(" ")) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentLine = line; } else { currentLine = currentLine + line; } } if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } } return result; }  static Map<String, Attributes> read(InputStream in); }
LDIFUtils { public static Map<String, Attributes> read(InputStream in) throws IOException { Map<String, Attributes> result = new LinkedHashMap<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line; Attributes currentEntity = null; String currentLine = null; while ((line = reader.readLine()) != null) { if (line.startsWith("#")) { continue; } if (line.isEmpty()) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentEntity = null; currentLine = null; continue; } if (currentEntity == null) { currentEntity = new BasicAttributes(); } if (!line.startsWith(" ")) { if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } currentLine = line; } else { currentLine = currentLine + line; } } if (currentLine != null) { storeAttribute(result, currentEntity, currentLine); } } return result; }  static Map<String, Attributes> read(InputStream in);  }