2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.netconf.cli.writer;
10 public class OutFormatter {
12 public static final String INDENT_STEP = " ";
13 public static final String COMPOSITE_OPEN_NODE = " {";
14 public static final String COMPOSITE_CLOSE_NODE = "}";
15 public static final String NEW_LINE = "\n";
18 private String currentIndent = "";
20 public OutFormatter indent(final StringBuilder buffer) {
21 buffer.append(currentIndent);
25 public OutFormatter openComposite(final StringBuilder buffer) {
26 buffer.append(COMPOSITE_OPEN_NODE);
30 public OutFormatter closeCompositeWithIndent(final StringBuilder buffer) {
31 buffer.append(currentIndent);
32 buffer.append(COMPOSITE_CLOSE_NODE);
36 public OutFormatter newLine(final StringBuilder buffer) {
37 buffer.append(NEW_LINE);
41 private void prepareIndent() {
42 final StringBuilder output = new StringBuilder();
43 for (int i = 0; i < indentLevel; i++) {
44 output.append(INDENT_STEP);
46 currentIndent = output.toString();
49 public OutFormatter increaseIndent() {
55 public OutFormatter decreaseIndent() {
61 public OutFormatter addStringWithIndent(final StringBuilder buffer, final String value) {