Example usage for org.apache.commons.lang.text StrBuilder appendFixedWidthPadLeft

List of usage examples for org.apache.commons.lang.text StrBuilder appendFixedWidthPadLeft

Introduction

In this page you can find the example usage for org.apache.commons.lang.text StrBuilder appendFixedWidthPadLeft.

Prototype

public StrBuilder appendFixedWidthPadLeft(int value, int width, char padChar) 

Source Link

Document

Appends an object to the builder padding on the left to a fixed width.

Usage

From source file:org.eclipse.gyrex.jobs.internal.commands.LsCmd.java

private void printJob(final JobImpl job) throws Exception {
    final StrBuilder info = new StrBuilder();
    info.appendln(job.getId());//from  w ww . jav  a 2s.  c o m
    info.appendFixedWidthPadLeft("type: ", 26, ' ').appendln(job.getTypeId());
    info.appendFixedWidthPadLeft("state: ", 26, ' ').appendln(job.getState());
    info.appendFixedWidthPadLeft("last start time: ", 26, ' ')
            .appendln(job.getLastStart() > -1
                    ? DateFormatUtils.formatUTC(job.getLastStart(), "yyyy-MM-dd 'at' HH:mm:ss z")
                    : "never");
    info.appendFixedWidthPadLeft("last successfull finish: ", 26, ' ')
            .appendln(job.getLastSuccessfulFinish() > -1
                    ? DateFormatUtils.formatUTC(job.getLastSuccessfulFinish(), "yyyy-MM-dd 'at' HH:mm:ss z")
                    : "never");
    info.appendFixedWidthPadLeft("last result: ", 26, ' ')
            .appendln(job.getLastResult() != null ? job.getLastResult().getMessage() : "(not available)");

    final String activeNodeId = getActiveNodeId(job.getStorageKey());
    info.appendFixedWidthPadLeft("active on: ", 26, ' ')
            .appendln(null != activeNodeId ? activeNodeId : "(not active)");

    final IEclipsePreferences historyNode = CloudPreferncesJobHistoryStorage.getJobsHistoryNode();
    if (historyNode.nodeExists(job.getStorageKey())) {
        final IEclipsePreferences jobHistory = CloudPreferncesJobHistoryStorage
                .getHistoryNode(job.getStorageKey());
        final String[] childrenNames = jobHistory.childrenNames();
        final SortedSet<IJobHistoryEntry> entries = new TreeSet<IJobHistoryEntry>();
        for (final String entryId : childrenNames) {
            entries.add(new StorableBackedJobHistoryEntry(
                    CloudPreferncesJobHistoryStorage.readItem(jobHistory.node(entryId))));
        }

        info.appendNewLine();
        for (final IJobHistoryEntry entry : entries) {
            info.appendln(entry.toString());
        }
    }

    printf("%s", info.toString());
}