protected void writeDirective(DirectiveInstance directive, DirectiveInOutState state) {

    state.setCurrentDirective(directive);
    Directive directiveInfo = directive.getDirective();

    directiveInfo.getOutFunc().process(state);
  }
  /**
   * Exports the directives in the supplied DirectiveFile.
   *
   * @param file the DirectiveFile to export.
   * @param state tracks the current directive and export location.
   */
  public void writeDirectivesFile(DirectiveFile file, DirectiveInOutState state) {
    try {
      List<DirectiveInstance> directives = file.getDirectives();

      for (int i = 0; i < directives.size(); i++) {
        writeDirective(directives.get(i), state);
        if (i != directives.size() - 1) {
          state.getPrinter().writeBlankLines(1, 0);
        }
      }
      state.getPrinter().printBufferLine();
      file.setLastModifiedTime(System.currentTimeMillis());

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (state.getPrinter() != null) {
        state.getPrinter().close();
      }
    }
  }