Java Vector from String vectorContainsIgnoreCaseFirstLetter(Vector v, String value)

Here you can find the source of vectorContainsIgnoreCaseFirstLetter(Vector v, String value)

Description

vector Contains Ignore Case First Letter

License

Apache License

Declaration

public static boolean vectorContainsIgnoreCaseFirstLetter(Vector v, String value) 

Method Source Code


//package com.java2s;
/*/*from   ww  w  .jav  a2  s.  c  o  m*/
Copyright 2016 Goldman Sachs.
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.
*/

import java.util.*;

public class Main {
    public static boolean vectorContainsIgnoreCaseFirstLetter(Vector v, String value) {
        for (int i = 0; i < v.size(); i++) {
            String s = (String) v.elementAt(i);
            if (equalsIgnoreCaseFirstLetter(s, value))
                return true;
        }

        return false;
    }

    public static boolean equalsIgnoreCaseFirstLetter(String aName, String bName) {
        if (aName.length() != bName.length())
            return false;
        if (!aName.substring(0, 1).toUpperCase().equals(bName.substring(0, 1).toUpperCase()))
            return false;
        return (aName.substring(1).compareToIgnoreCase(bName.substring(1)) == 0);
    }
}

Related

  1. string2Vector(String s, String delimiter)
  2. stringArrayToVector(String[] array)
  3. stringToVector(String[] arr)
  4. stringVector(String input, String sepChars)
  5. unique(Vector list)
  6. vectorString(String splitStr, String delim)