Here you can find the source of startsWithOneOf(String source, boolean ignoreCase, String... values)
Parameter | Description |
---|---|
source | the string to match with the values. |
ignoreCase | specifies whether case should be ignore in the string matching. |
values | the values to match the source with. |
public static boolean startsWithOneOf(String source, boolean ignoreCase, String... values)
//package com.java2s; /*//from www. ja va 2 s . co m * JPPF. * Copyright (C) 2005-2010 JPPF Team. * http://www.jppf.org * * 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 { /** * Determine whether the specified source string starts with one of the specified values. * @param source the string to match with the values. * @param ignoreCase specifies whether case should be ignore in the string matching. * @param values the values to match the source with. * @return true if the source matches one of the values, false otherwise. */ public static boolean startsWithOneOf(String source, boolean ignoreCase, String... values) { if ((source == null) || (values == null)) return false; String s = ignoreCase ? source.toLowerCase() : source; for (String val : values) { if (val == null) continue; String s2 = ignoreCase ? val.toLowerCase() : val; if (s.startsWith(s2)) return true; } return false; } }