Example usage for org.apache.commons.lang3 StringUtils rightPad

List of usage examples for org.apache.commons.lang3 StringUtils rightPad

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils rightPad.

Prototype

public static String rightPad(final String str, final int size) 

Source Link

Document

Right pad a String with spaces (' ').

The String is padded to the size of size .

 StringUtils.rightPad(null, *)   = null StringUtils.rightPad("", 3)     = "   " StringUtils.rightPad("bat", 3)  = "bat" StringUtils.rightPad("bat", 5)  = "bat  " StringUtils.rightPad("bat", 1)  = "bat" StringUtils.rightPad("bat", -1) = "bat" 

Usage

From source file:edu.usc.qufd.Main.java

/**
 * The main method./*from   w  w w . j  a v  a  2s.co m*/
 *
 * @param args the arguments
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void main(String[] args) throws IOException {
    if (parseInputs(args) == false) {
        System.exit(-1); //The input files do not exist
    }

    /*
     * Parsing inputs: fabric & qasm file
     */
    PrintWriter outputFile;
    RandomAccessFile raf = null;
    String latencyPlaceHolder;
    if (RuntimeConfig.OUTPUT_TO_FILE) {
        latencyPlaceHolder = "Total Latency: " + Long.MAX_VALUE + " us" + System.lineSeparator();
        raf = new RandomAccessFile(outputFileAddr, "rws");
        //removing the old values in the file
        raf.setLength(0);
        //writing a place holder for the total latency
        raf.writeBytes(latencyPlaceHolder);
        raf.close();

        outputFile = new PrintWriter(new BufferedWriter(new FileWriter(outputFileAddr, true)), true);
    } else { //writing to stdout
        outputFile = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
    }
    /* parsing the input*/
    layout = LayoutParser.parse(pmdFileAddr);
    qasm = QASMParser.QASMParser(qasmFileAddr, layout);

    long totalLatency = qufd(outputFile);

    if (RuntimeConfig.OUTPUT_TO_FILE) {
        outputFile.close();
        //Over writing the place holder with the actual latency
        String latencyActual = "Total Latency: " + totalLatency + " " + layout.getTimeUnit();
        latencyActual = StringUtils.rightPad(latencyActual,
                latencyPlaceHolder.length() - System.lineSeparator().length());
        raf = new RandomAccessFile(outputFileAddr, "rws");
        //Writing to the top of a file
        raf.seek(0);
        //writing the actual total latency in the at the top of the output file
        raf.writeBytes(latencyActual + System.lineSeparator());
        raf.close();
    } else {
        outputFile.flush();
        System.out.println("Total Latency: " + totalLatency + " " + layout.getTimeUnit());
    }

    if (RuntimeConfig.VERBOSE) {
        System.out.println("Done.");
    }
    outputFile.close();
}

From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.ValidadorFormato.java

public static String completarEspaciosDerecha(String cadena, int tamanio) {
    return StringUtils.rightPad(cadena, tamanio);
}

From source file:com.espe.distribuidas.protocolocajero.seguridad.AutenticacionRQ.java

public void setUsuario(String usuario) {
    this.usuario = StringUtils.rightPad(usuario, 10);
}

From source file:com.espe.distribuidas.protocolocajero.seguridad.AutenticacionRQ.java

public void setClave(String clave) {
    this.clave = StringUtils.rightPad(clave, 10);
}

From source file:kenh.expl.functions.RightPad.java

public String process(String str, int size) {
    return StringUtils.rightPad(str, size);
}

From source file:minij.flowanalysis.FlowAnalyser.java

public static SimpleGraph<CoalesceableTemp> analyseFlow(Configuration config, List<Assem> body,
        String methodName) throws FlowAnalyserException {

    try {/*from   ww  w. j  a va2  s .  co m*/

        SimpleGraph<Assem> controlFlowGraph = ControlFlowGraphBuilder.build(body, methodName);
        Map<Assem, LivenessSetsBuilder.InOut> inOut = LivenessSetsBuilder.build(controlFlowGraph, body);
        SimpleGraph<CoalesceableTemp> interferenceGraph = InterferenceGraphBuilder.build(controlFlowGraph,
                inOut);

        if (config.printInterferenceGraphs) {
            Logger.log(interferenceGraph.getDot());
        }

        int maxInterference = 0;
        I386PrintAssemblyVisitor visitor = new I386PrintAssemblyVisitor();
        Iterator<Assem> iter = body.iterator();
        StringBuilder inOutStringBuilder = new StringBuilder();

        if (config.printFlowAnalysisDetails) {
            while (iter.hasNext()) {

                Assem next = iter.next();
                String nextString = StringUtils.rightPad(next.accept(visitor), 30);
                String padding = StringUtils.rightPad("", 30);
                String separator = StringUtils.rightPad("", 100, '-');

                LivenessSetsBuilder.InOut inOutN = inOut.get(next);
                if (inOutN.in.size() > maxInterference) {
                    maxInterference = inOutN.in.size();
                }
                if (inOutN.out.size() > maxInterference) {
                    maxInterference = inOutN.out.size();
                }

                inOutStringBuilder.append(nextString).append("   in: ").append(inOutN.in)
                        .append(System.lineSeparator()).append(padding).append("   out:").append(inOutN.out)
                        .append(System.lineSeparator()).append(separator).append(System.lineSeparator());
            }
            inOutStringBuilder.append("Max interference: ").append(maxInterference);

            Logger.log(inOutStringBuilder.toString());
        }

        return interferenceGraph;
    } catch (Exception e) {
        throw new FlowAnalyserException("Failed to analyse control flow", e);
    }
}

From source file:com.daraf.projectdarafprotocol.appdb.ingresos.IngresoFacturaRQ.java

public void setIdentificacionCliente(String identificacionCliente) {
    this.identificacionCliente = StringUtils.rightPad(identificacionCliente, 20);
}

From source file:com.zack6849.alphabot.commands.Help.java

@Override
public boolean execute(MessageEvent event) {
    String[] args = event.getMessage().split(" ");
    if (args.length == 1) {
        String header = String.format("| %s| %s| %s|", StringUtils.rightPad("Command Name", 15),
                StringUtils.rightPad("Description", 50), StringUtils.rightPad("Help", 50));
        String seperator = "+" + StringUtils.repeat('-', 16) + "+" + StringUtils.repeat('-', 51) + "+"
                + StringUtils.repeat('-', 51) + "+";
        event.getUser().send().notice(seperator);
        event.getUser().send().notice(header);
        event.getUser().send().notice(seperator);
        for (String s : CommandRegistry.commands.keySet()) {
            Command command = CommandRegistry.getCommand(s);
            event.getUser().send()/*from  www  .j ava2 s  . c om*/
                    .notice(String.format("| %s| %s| %s|", StringUtils.rightPad(command.getName(), 15),
                            StringUtils.rightPad(command.getDescription(), 50),
                            StringUtils.rightPad(command.getHelp(), 50)));
        }
        event.getUser().send().notice(seperator);
        return true;
    }
    if (args.length == 2) {
        Command command = CommandRegistry.getCommand(StringUtils.capitalize(args[1].toLowerCase()));
        if (command != null) {
            event.getUser().send().notice(String.format("Help for command: %s - %s - %s", command.getName(),
                    command.getDescription(), command.getHelp()));
        } else {
            event.getUser().send()
                    .notice("Could not find the command " + args[1] + ", are you sure you spelled it right?");
        }
        return true;
    }
    return false;
}

From source file:io.stallion.services.LogFormatter.java

@Override
public String format(LogRecord record) {
    StringBuilder sb = new StringBuilder();
    SimpleDateFormat df = new SimpleDateFormat("MMM dd HH:mm:ss");

    String dateString = df.format(new Date(record.getMillis()));
    String classAndMethod = record.getSourceClassName() + "." + record.getSourceMethodName() + " ";
    classAndMethod = StringUtils.rightPad(classAndMethod, 50);
    sb.append(dateString).append(" ").append(record.getLevel().getLocalizedName()).append(" ")
            .append(classAndMethod).append(formatMessage(record)).append(LINE_SEPARATOR);

    if (record.getThrown() != null) {
        try {/*from   w  w w  .  ja  v a2  s.c  om*/
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            record.getThrown().printStackTrace(pw);
            pw.close();
            sb.append(sw.toString());
        } catch (Exception ex) {
            // ignore
        }
    }

    return sb.toString();
}

From source file:com.daraf.projectdarafprotocol.clienteapp.ingresos.IngresoFacturaRQ.java

public void setIdentificacion(String identificacion) {
    this.identificacion = StringUtils.rightPad(identificacion, 20);
}