com.wiiyaya.framework.common.utils.StringUtils.java Source code

Java tutorial

Introduction

Here is the source code for com.wiiyaya.framework.common.utils.StringUtils.java

Source

/*
 * Copyright 2016-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.wiiyaya.framework.common.utils;

/**
 * <p>{@link org.apache.commons.lang3.StringUtils}</p>
 *
 * <p>??</p>
 *
 * <p></p>
 *
 * @author wiiyaya
 *
 */
public class StringUtils {

    public static final String EMPTY = org.apache.commons.lang3.StringUtils.EMPTY;
    public static final String SPACE = org.apache.commons.lang3.StringUtils.SPACE;
    public static final String LF = org.apache.commons.lang3.StringUtils.LF;
    public static final String CR = org.apache.commons.lang3.StringUtils.CR;
    public static final String PERCENT = "%";
    public static final String SLASH = "/";//back slash\
    public static final String SPACE_SLASH = " / ";
    public static final String DOT = ".";
    public static final String HYPHEN = "-";//dash
    public static final String SPACE_HYPHEN = " - ";
    public static final String UNDER_SCORE = "_";//under line
    public static final String COMMA = ",";
    public static final String COLON = ":";
    public static final String L_PT = "(";//parenthesis
    public static final String R_PT = ")";

    public static final String REGEX_LAST_COMMA = ",$";

    /**
     * ??
     * @param num 
     * @return 
     */
    public static String defaultString(final Number num) {
        return num == null ? EMPTY : num.toString();
    }

    /**
     * ?
     * @return 
     */
    public static String defaultString(final String str) {
        return str == null ? EMPTY : str;
    }

    /**
     * ?
     * @param num 
     * @param defaultStr 
     * @return 
     */
    public static String defaultString(final Number num, final String defaultStr) {
        return num == null ? defaultStr : num.toString();
    }

    /**
     * ?
     * @param num 
     * @param size ?
     * @param padChar 
     * @return ?
     */
    public static String leftPad(final Number num, final int size, final char padChar) {
        return leftPad(defaultString(num), size, padChar);
    }

    /**
     * ?
     * @param str 
     * @param size ?
     * @param padChar 
     * @return ?
     */
    public static String leftPad(final String str, final int size, final char padChar) {
        return org.apache.commons.lang3.StringUtils.leftPad(str, size, padChar);
    }

    /**
     * ???
     * @param cs ?
     * @param searchChars 
     * @return true ? false??
     */
    public static boolean containsAny(final CharSequence cs, final char... searchChars) {
        return org.apache.commons.lang3.StringUtils.containsAny(cs, searchChars);
    }

    /**
     * ?
     * @param text ?
     * @param searchList ?
     * @param replacementList ?
     * @return ??
     */
    public static String replaceEach(final String text, final String[] searchList, final String[] replacementList) {
        return org.apache.commons.lang3.StringUtils.replaceEach(text, searchList, replacementList);
    }

    /**
     * ?
     * @param cs 
     * @return true ?false 
     */
    public static boolean isNotEmpty(final CharSequence cs) {
        return org.apache.commons.lang3.StringUtils.isNotEmpty(cs);
    }

    /**
     * ?
     * @param cs 
     * @return true false ?
     */
    public static boolean isEmpty(final CharSequence cs) {
        return org.apache.commons.lang3.StringUtils.isEmpty(cs);
    }

    /**
     * ?
     * @param iterable 
     * @param separator 
     * @return ?
     */
    public static String join(final Iterable<?> iterable, final String separator) {
        return org.apache.commons.lang3.StringUtils.join(iterable, separator);
    }

    /**
     * ?
     * @param array 
     * @param separator 
     * @return ?
     */
    public static String join(final Object[] array, final String separator) {
        return org.apache.commons.lang3.StringUtils.join(array, separator);
    }

    public static String[] split(final String str, final String separatorChars) {
        return org.apache.commons.lang3.StringUtils.split(str, separatorChars);
    }
}