Java Wildcard wildCard(final String _name)

Here you can find the source of wildCard(final String _name)

Description

This method appends wild cards before and after a string./

License

BSD License

Parameter

Parameter Description
_name a parameter

Declaration

public static String wildCard(final String _name) 

Method Source Code

//package com.java2s;
/*L//from ww  w .j  ava 2s . c o  m
 *  Copyright Ekagra Software Technologies
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/common-logging-module/LICENSE.txt for details.
 */

public class Main {
    /**
     * This method appends wild cards before and after a string./
     * 
     * @param _name
     * @return
     */
    public static String wildCard(final String _name) {
        String trimmedName = _name.toString().trim();

        if (trimmedName == null || trimmedName.equals("") || trimmedName.length() == 0) {
            return "";
        }

        if (trimmedName.length() > 0 && !trimmedName.endsWith("%")) {
            trimmedName = trimmedName + "%";
        }

        if (trimmedName.length() > 0 && !trimmedName.startsWith("%")) {
            trimmedName = "%" + trimmedName;
        }

        return trimmedName;
    }
}

Related

  1. wildCard(String _name)
  2. wildCardBoth(String s)
  3. wildcardCompare(String s, String z)
  4. wildcardCriterionSQL(final String query)