Java Hash String hasHint(String hint, String parameter)

Here you can find the source of hasHint(String hint, String parameter)

Description

has Hint

License

Apache License

Declaration

public static boolean hasHint(String hint, String parameter) 

Method Source Code

//package com.java2s;
/*//from   www .  ja  va 2s  . c o m
 * Copyright 2007 The Fornax Project Team, including 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.
 */

public class Main {
    public static boolean hasHint(String hint, String parameter) {
        return getHint(hint, parameter) != null;
    }

    public static String getHint(String hint, String parameter) {
        if (hint == null) {
            return null;
        }
        if (hint.indexOf(parameter) == -1) {
            return null;
        }
        String[] split = hint.split("[,;]");
        split = trim(split);
        for (int i = 0; i < split.length; i++) {
            int indexOfEq = split[i].indexOf("=");
            if (indexOfEq == -1) {
                if (split[i].equals(parameter)) {
                    return "";
                }
            } else {
                if (split[i].substring(0, indexOfEq).trim().equals(parameter)) {
                    return split[i].substring(indexOfEq + 1).trim();
                }
            }
        }

        // not found
        return null;
    }

    private static String[] trim(String[] array) {
        String[] result = new String[array.length];
        for (int i = 0; i < array.length; i++) {
            result[i] = array[i].trim();
        }
        return result;
    }
}

Related

  1. hashCodeToString(long code)
  2. hasHeirarchy(String xpath)
  3. hasHexOrDecLongUrnSuffix(String value)
  4. hasHexPrefix(final String hexSymbols)
  5. hasHighChars(String s)
  6. hashIt(String s)
  7. hasHost(String path)
  8. hashOTP(String otp)
  9. hashPassword(String password)