@Test public void testIndexOfKeyColumns() throws Exception { List<String> key = new ArrayList<String>(); key.add("test1"); key.add("test2"); List<String> columns = new ArrayList<String>(); columns.add("test1"); columns.add("test2"); List<Integer> test = ArrayUtils.getColumnsPosition(key.toArray(new String[] {}), columns.toArray(new String[] {})); Assert.assertEquals(0, test.get(0).intValue()); Assert.assertEquals(1, test.get(1).intValue()); }
public static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (String key : keyColumns) { for (int j = 0; j < columns.length; j++) { if (key.equalsIgnoreCase(columns[j].trim())) { positions.add(j); break; } } } return positions; }
ArrayUtils { public static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (String key : keyColumns) { for (int j = 0; j < columns.length; j++) { if (key.equalsIgnoreCase(columns[j].trim())) { positions.add(j); break; } } } return positions; } }
ArrayUtils { public static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (String key : keyColumns) { for (int j = 0; j < columns.length; j++) { if (key.equalsIgnoreCase(columns[j].trim())) { positions.add(j); break; } } } return positions; }  }
ArrayUtils { public static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (String key : keyColumns) { for (int j = 0; j < columns.length; j++) { if (key.equalsIgnoreCase(columns[j].trim())) { positions.add(j); break; } } } return positions; }  static T[] mergeArrays(T[] one, T[] two); static boolean keysPresentInColumns(String[] keys, String[] columns); static String[] convertStringKeyToArray(String keys, String delimiter); static String[] convertStringKeyToArray(String keys); static int[] getCompareColumnsPosition(String[] columns, String[] keyColumns); static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns); static boolean isIndexOfLastArrayElement(String[] array, int elementIndex); }
ArrayUtils { public static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (String key : keyColumns) { for (int j = 0; j < columns.length; j++) { if (key.equalsIgnoreCase(columns[j].trim())) { positions.add(j); break; } } } return positions; }  static T[] mergeArrays(T[] one, T[] two); static boolean keysPresentInColumns(String[] keys, String[] columns); static String[] convertStringKeyToArray(String keys, String delimiter); static String[] convertStringKeyToArray(String keys); static int[] getCompareColumnsPosition(String[] columns, String[] keyColumns); static List<Integer> getColumnsPosition(String[] columns, String[] keyColumns); static boolean isIndexOfLastArrayElement(String[] array, int elementIndex);  }