Here you can find the source of getIndexOrConstraintName(String command)
public static String getIndexOrConstraintName(String command)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static String getIndexOrConstraintName(String command) { String[] lines = command.split("\n"); String indexOrConstraintName = ""; if (lines.length < 1) { return indexOrConstraintName; }/* w w w . j a v a 2 s . c o m*/ String line1 = lines[0]; List<Integer> indices = getQuotePositions(line1); if ((line1.contains("CREATE INDEX") || line1.contains("CREATE UNIQUE INDEX")) && indices.size() >= 4) { return line1.substring(indices.get(0), indices.get(3) + 1); } if (line1.contains("ALTER TABLE") && line1.contains("ADD CONSTRAINT") && indices.size() >= 6) { return line1.substring(indices.get(4), indices.get(5) + 1); } return indexOrConstraintName; } protected static List<Integer> getQuotePositions(String line) { List<Integer> indices = new ArrayList<>(); char[] chars = line.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '"') { indices.add(i); } } return indices; } }