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

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

Introduction

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

Prototype

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

Source Link

Document

Right pad a String with a specified String.

Usage

From source file:br.com.nordestefomento.jrimum.utilix.Filler.java

/**
 * <p>//from w w  w . j  ava 2s .com
 * Preenche a String a direita com valor do atributo <tt>"fillWith".</tt>
 * </p>
 * 
 * @param toFill
 *            Valor a ser preenchido
 * @param length
 *            tamanho mximo que o valor deve ter depois de preenchido
 * @return Nova String preenchida de acordo com o preenchedor do objeto at
 *         o tamanho especificado
 * @since 0.2
 */
private String fillRight(String toFill, int length) {

    return StringUtils.rightPad(toFill, length, fillWith.toString());
}

From source file:com.sds.acube.ndisc.xadmin.XNDiscAdminMedia.java

/**
 *      Console? // w ww  .j a  va 2  s.co  m
 * 
 * @param id  ?
 * @param name  
 * @param type  
 * @param path  
 * @param desc  
 * @param maxSize   ?
 * @param volumeId   ?
 */
public void changeMedia(int id, String name, int type, String path, String desc, int maxSize, int volumeId) {
    try {
        Media media = new Media();
        media.setId(id);
        media.setName(name);
        media.setType(type);
        media.setPath(path);
        media.setDesc(desc);
        media.setMaxSize(maxSize);
        media.setVolumeId(volumeId);
        dao.updateMedia(media);
        StringBuilder medias = new StringBuilder(LINE_SEPERATOR);
        medias.append("").append(StringUtils.rightPad("", 100, "-")).append("?").append(LINE_SEPERATOR);
        medias.append("").append(StringUtils.center("changeMedia Successfully", 100, " ")).append("")
                .append(LINE_SEPERATOR);
        medias.append("").append(StringUtils.rightPad("", 100, "-")).append("").append(LINE_SEPERATOR);
        if (printlog) {
            log.info(medias.toString());
        } else {
            out.print(medias.toString());
        }
    } catch (Exception ex) {
        logger.log(LoggerIF.LOG_ERROR, ex.getMessage());
    }
}

From source file:com.sds.acube.ndisc.xadmin.XNDiscAdminMedia.java

/**
 *     /*from   ww  w  .j ava2 s . c om*/
 * 
 * @param id  ?
 */
public void removeMedia(int id) {
    try {
        dao.deleteMedia(id);
        StringBuilder medias = new StringBuilder(LINE_SEPERATOR);
        medias.append("").append(StringUtils.rightPad("", 100, "-")).append("?").append(LINE_SEPERATOR);
        medias.append("").append(StringUtils.center("removeMedia Successfully", 100, " ")).append("")
                .append(LINE_SEPERATOR);
        medias.append("").append(StringUtils.rightPad("", 100, "-")).append("").append(LINE_SEPERATOR);
        if (printlog) {
            log.info(medias.toString());
        } else {
            out.print(medias.toString());
        }
    } catch (Exception ex) {
        logger.log(LoggerIF.LOG_ERROR, ex.getMessage());
    }
}

From source file:com.sds.acube.ndisc.xadmin.XNDiscAdminFile.java

/**
 * ? ? ? ?    Console? //from   ww w  .  j  av a  2 s.  c o  m
 * 
 * @param fileId ? ?
 */
public void getFilePathByFileId(String fileId) {
    NFile[] nFile = null;
    try {
        nFile = new NFile[1];
        nFile[0] = new NFile();
        nFile[0].setId(fileId);
        nFile = storage.aquireStorageInfo(nFile, NDCommon.STORAGE_PATH_ACCESS);
        String ret = nFile[0].getStoragePath();
        if (!StringUtils.isEmpty(ret)) {
            StringBuilder files = new StringBuilder(LINE_SEPERATOR);
            files.append("").append(StringUtils.rightPad("", PRINT_COLUMN_SIZE, "-")).append("?")
                    .append(LINE_SEPERATOR);
            files.append("").append(StringUtils.center("getFilePath : " + ret, PRINT_COLUMN_SIZE, " "))
                    .append("").append(LINE_SEPERATOR);
            files.append("").append(StringUtils.rightPad("", PRINT_COLUMN_SIZE, "-")).append("")
                    .append(LINE_SEPERATOR);
            if (printlog) {
                log.info(files.toString());
            } else {
                out.print(files.toString());
            }
        }
    } catch (Exception e) {
        logger.log(LoggerIF.LOG_ERROR, e.getMessage());
    }
}

From source file:com.sds.acube.ndisc.mts.xserver.XNDiscServer.java

/**
 * FixedThreadPool ?  Console?   Notice 
 *//* w  w  w.java 2  s  .c  o m*/
private void getXNDiscNotice() {
    if (WORKER_POOL_TYPE.equals("F")
            && XNDiscConfig.getBoolean(XNDiscConfig.MULTIPLICATION_THREAD_AVAILABLE_PROCESSORS)) {
        int worker_thread_pool = XNDiscConfig.getInt(XNDiscConfig.WORKER_POOL_THREAD_COUNT, 15);
        StringBuilder msg = new StringBuilder(LINE_SEPERATOR);
        msg.append("").append(StringUtils.center(" XNDisc Server Notice !!! ", 90, "-")).append("?")
                .append(LINE_SEPERATOR);
        msg.append("").append(StringUtils.center("", 90, " ")).append("").append(LINE_SEPERATOR);
        msg.append("")
                .append(StringUtils.rightPad("Readjust the number of the Worker Thread Pool,", 90, " "))
                .append("").append(LINE_SEPERATOR);
        msg.append("").append(StringUtils.center("", 90, " ")).append("").append(LINE_SEPERATOR);
        msg.append("")
                .append(StringUtils.rightPad("Original Thread Pool Size : " + worker_thread_pool
                        + " => Changed Thread Pool Size : " + WORKER_THREAD_POOL, 90, " "))
                .append("").append(LINE_SEPERATOR);
        msg.append("").append(StringUtils.center("", 90, " ")).append("").append(LINE_SEPERATOR);
        msg.append("").append(StringUtils.rightPad("", 90, "-")).append("").append(LINE_SEPERATOR);
        logger.log(LoggerIF.LOG_INFO, msg.toString());
    }
}

From source file:com.googlecode.fascinator.storage.fedora.Fedora3DigitalObject.java

/**
 * Turn an InputStream into a temporary File for uploading.
 * //  w  ww .ja  v  a  2s.c  om
 * @param pid the local Fascinator Payload ID used in creating a temp file
 * @param in an InputStream containing the data to upload
 * @return File the new temporary File, NULL if there is an error
 */
private File createTempFile(String pid, InputStream in) {
    File tempFile = null;
    FileOutputStream out = null;

    // Work out a robust temp file name
    // TODO: 20th Oct 2011: Do we still need this? Leaving it in for now.
    String prefix = FilenameUtils.getBaseName(pid);
    String suffix = FilenameUtils.getExtension(pid);
    prefix = StringUtils.rightPad(prefix, 3, "_");
    suffix = "".equals(suffix) ? null : "." + suffix;
    try {
        // Create and access our empty file in temp space
        tempFile = File.createTempFile(prefix, suffix);
        out = new FileOutputStream(tempFile);
        // Stream the data into storage
        IOUtils.copy(in, out);
    } catch (IOException ex) {
        log.error("Error creating temp file: ", ex);
        return null;
    } finally {
        Fedora3.close(in);
        Fedora3.close(out);
    }

    return tempFile;
}

From source file:com.jaspersoft.studio.property.color.chooser.AdvancedColorWidget.java

/**
 * Return the hexadecimal representation of a color
 * //w  w  w  .  j a  v a2s. co  m
 * @param color The color
 * @return The color hexadecimal representation
 */
private String getHexFromRGB(RGB color) {
    int r = color.red;
    int g = color.green;
    int b = color.blue;
    String s = Integer.toHexString(r) + Integer.toHexString(g) + Integer.toHexString(b);
    return "#" + StringUtils.rightPad(s, 6, "0").toUpperCase(); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:com.conversantmedia.mapreduce.tool.ToolContext.java

protected void toRowString(StringBuffer sb, String left, String right, int lc, int rc) {
    sb.append(StringUtils.rightPad(left + ":", lc, '.'));
    sb.append(StringUtils.leftPad("[" + right + "]", rc, '.'));
    sb.append("\n");
}

From source file:adalid.util.velocity.MavenArchetypeBuilder.java

private void printSummary() {
    for (String name : classes) {
        logger.info(name);/*ww w.  j a v a 2  s  .  com*/
    }
    for (String name : sources) {
        logger.info(name);
    }
    for (String name : resources) {
        logger.info(name);
    }
    Map<String, Integer> map;
    for (String extension : extensionCharsetMap.keySet()) {
        map = extensionCharsetMap.get(extension);
        logger.trace(extension);
        for (String charset : map.keySet()) {
            logger.trace("\t" + StringUtils.rightPad(charset + " ", 20, '.') + " " + map.get(charset));
        }
    }
    logger.info(binaryFilesCopied + " binary files copied ");
    logger.info(textFilesCopied + " text files copied ");
    logger.info(binaryFilesCopied + textFilesCopied + " files copied ");
    logger.info(readingWarnings + " reading warnings ");
    logger.info(readingErrors + " reading errors ");
    logger.info(writingErrors + " writing errors ");
}

From source file:com.sds.acube.ndisc.xadmin.XNDiscAdminFile.java

/**
 * ?   ? Console? //  www  . j  a v a  2  s  .  c  om
 * 
 * @param host HOST 
 * @param port PORT 
 * @param fileId ? ?
 */
public void removeFile(String host, int port, String fileId) {
    NFile[] nFile = null;
    int numOfFiles = 1;
    try {
        if (fileId.indexOf(",") >= 0) {
            String fileIds[] = StringUtils.split(fileId, ",");
            if (fileIds != null && fileIds.length > 0) {
                nFile = new NFile[fileIds.length];
                for (int i = 0; i < fileIds.length; i++) {
                    nFile[i] = new NFile();
                    nFile[i].setId(fileIds[i]);
                }
            }
        } else {
            nFile = new NFile[numOfFiles];
            nFile[0] = new NFile();
            nFile[0].setId(fileId);
        }
        xnapi.XNDisc_Connect(host, port);
        boolean ret = xnapi.XNDISC_FileDel(nFile);
        if (ret) {
            StringBuilder files = new StringBuilder(LINE_SEPERATOR);
            files.append("").append(StringUtils.rightPad("", PRINT_COLUMN_SIZE, "-")).append("?")
                    .append(LINE_SEPERATOR);
            if (fileId.indexOf(",") >= 0) {
                String fileIds[] = StringUtils.split(fileId, ",");
                if (fileIds != null && fileIds.length > 0) {
                    for (int i = 0; i < fileIds.length; i++) {
                        files.append("").append(StringUtils.center("removeFile[" + i + "] : " + fileIds[i],
                                PRINT_COLUMN_SIZE, " ")).append("").append(LINE_SEPERATOR);
                    }
                }
            } else {
                files.append("").append(StringUtils.center("removeFile : " + fileId, PRINT_COLUMN_SIZE, " "))
                        .append("").append(LINE_SEPERATOR);
            }
            files.append("").append(StringUtils.rightPad("", PRINT_COLUMN_SIZE, "-")).append("")
                    .append(LINE_SEPERATOR);
            if (printlog) {
                log.info(files.toString());
            } else {
                out.print(files.toString());
            }
        } else {
            logger.log(LoggerIF.LOG_ERROR, "Remove File ID : " + fileId + " failed !!!!");
        }
    } catch (FileException e) {
        logger.log(LoggerIF.LOG_ERROR, e.getMessage());
    } catch (NetworkException e) {
        logger.log(LoggerIF.LOG_ERROR, e.getMessage());
    } catch (NDiscException e) {
        logger.log(LoggerIF.LOG_ERROR, e.getMessage());
    } finally {
        try {
            xnapi.XNDisc_Disconnect();
        } catch (NetworkException ne) {
            logger.log(LoggerIF.LOG_ERROR, ne.getMessage());
        } catch (IOException e) {
            logger.log(LoggerIF.LOG_ERROR, e.getMessage());
        }
    }
}