Java tutorial
/* * Project Name: xnode * File Name: StringUtils.java * Class Name: StringUtils * * Copyright 2014 xuce * * 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.xc.xnode.utils; /** * Utils - StringEscapeUtils * * @author yupengshen * @version 2.0_beta */ public final class StringUtils { // private static final Logger logger = LoggerFactory.getLogger(StringEscapeUtils.class); private static String DB_ESCAPSE = "[%_]"; private static String DB_ESCAPSE_CODE = "\\\\$0"; private static String DB_STRICT_CHAR_REG = "[\\w\\d]+"; /** * ?? */ private StringUtils() { } /** * <p> * ?("")null. * </p> * * * @param value * @return */ public static boolean isBlank(String value) { return org.apache.commons.lang3.StringUtils.isBlank(value); } /** * <p> * ?("")null. * </p> * * @param value * @return */ public static boolean isNotBlank(String value) { return !StringUtils.isBlank(value); } /** * <p> * ?("")null. * </p> * * @param value * @return */ public static boolean isEmpty(String value) { return org.apache.commons.lang3.StringUtils.isEmpty(value); } /** * <p> * ?("")null. * </p> * * @param value * @return */ public static boolean isNotEmpty(String value) { return !StringUtils.isEmpty(value); } /** * <p> * (char<=32) * </p> * * @param value * @return */ public static String trim(String value) { return org.apache.commons.lang3.StringUtils.trim(value); } /** * <p> * LIKE?SQL * </p> * * @param value * @return */ public static String escapseSql(String value) { return StringUtils.isEmpty(value) ? value : value.replaceAll(DB_ESCAPSE, DB_ESCAPSE_CODE); } /** * <p> * HTML?HTML * </p> * * @param value * @return */ public static String escapseHtml(String value) { return org.apache.commons.lang3.StringEscapeUtils.escapeHtml4(value); } public static boolean isDBStrictChar(String value) { return isBlank(value) ? false : value.matches(DB_STRICT_CHAR_REG); } }