Пример #1
0
 private void flushBuffer() throws IOException {
   for (Text t : buffer) {
     if (t instanceof Comment) {
       listener.onComment(t.getText());
     } else if (t instanceof Whitespace) {
       listener.onWhitespace(t.getText());
     }
   }
   buffer.clear();
 }
Пример #2
0
 @Override
 public void onSection(String section, String text) throws IOException {
   if (currentSection != null) {
     listener.onSectionEnd(currentSection);
   }
   flushBuffer();
   currentSection = section;
   listener.onSection(section, text);
   skipToNewline = true;
 }
Пример #3
0
 @Override
 public void cleanup() throws IOException {
   if (currentSection != null) {
     listener.onSectionEnd(currentSection);
   }
   flushBuffer();
 }
Пример #4
0
 @Override
 public void onWhitespace(String text) throws IOException {
   if (skipToNewline) {
     listener.onWhitespace(text);
     skipToNewline = !text.contains("\n");
   } else {
     buffer.add(new Whitespace(text));
   }
 }
Пример #5
0
 @Override
 public void onOption(String name, String value, String text) throws IOException {
   flushBuffer();
   listener.onOption(name, value, text);
   skipToNewline = true;
 }