001package io.ebeaninternal.dbmigration.ddlgeneration.platform.util; 002 003/** 004 * Utility to remove vowels (from constraint names primarily for Oracle and DB2). 005 */ 006public class VowelRemover { 007 008 /** 009 * Trim a word by removing vowels skipping some initial characters. 010 */ 011 public static String trim(String word, int skipChars) { 012 013 if (word.length() < skipChars) { 014 return word; 015 } 016 017 StringBuilder res = new StringBuilder(); 018 res.append(word.substring(0, skipChars)); 019 020 for (int i = skipChars; i < word.length(); i++) { 021 char ch = word.charAt(i); 022 if (!isVowel(ch)) { 023 res.append(ch); 024 } 025 } 026 return res.toString(); 027 } 028 029 private static boolean isVowel(char ch) { 030 ch = Character.toLowerCase(ch); 031 return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'; 032 } 033}