@Test public void test1() { PathElement pe = PathElement.fromString("aa[1][2][3]"); assertEquals("aa", pe.name); assertArrayEquals(new int[] {1, 2, 3}, pe.index); }
public static PathElement fromString(String s) { List<Integer> idx = new ArrayList<Integer>(); int k = s.indexOf('[', 0); if (k == -1) { return new PathElement(s, null); } String name = k > 0 ? s.substring(0, k) : null; while (true) { k = s.indexOf('[', k); if (k == -1) { break; } int k2 = s.indexOf(']', k); if (k2 == -1) { throw new IllegalArgumentException("Invalid aggregate member path '" + s + "'"); } int n = Integer.parseInt(s.substring(k + 1, k2)); if (n < 0) { throw new IllegalArgumentException("Negative array index: " + n); } idx.add(n); k = k2; } int[] idx1 = null; if (!idx.isEmpty()) { idx1 = new int[idx.size()]; for (int u = 0; u < idx.size(); u++) { idx1[u] = idx.get(u); } } return new PathElement(name, idx1); }
PathElement implements Serializable { public static PathElement fromString(String s) { List<Integer> idx = new ArrayList<Integer>(); int k = s.indexOf('[', 0); if (k == -1) { return new PathElement(s, null); } String name = k > 0 ? s.substring(0, k) : null; while (true) { k = s.indexOf('[', k); if (k == -1) { break; } int k2 = s.indexOf(']', k); if (k2 == -1) { throw new IllegalArgumentException("Invalid aggregate member path '" + s + "'"); } int n = Integer.parseInt(s.substring(k + 1, k2)); if (n < 0) { throw new IllegalArgumentException("Negative array index: " + n); } idx.add(n); k = k2; } int[] idx1 = null; if (!idx.isEmpty()) { idx1 = new int[idx.size()]; for (int u = 0; u < idx.size(); u++) { idx1[u] = idx.get(u); } } return new PathElement(name, idx1); } }
PathElement implements Serializable { public static PathElement fromString(String s) { List<Integer> idx = new ArrayList<Integer>(); int k = s.indexOf('[', 0); if (k == -1) { return new PathElement(s, null); } String name = k > 0 ? s.substring(0, k) : null; while (true) { k = s.indexOf('[', k); if (k == -1) { break; } int k2 = s.indexOf(']', k); if (k2 == -1) { throw new IllegalArgumentException("Invalid aggregate member path '" + s + "'"); } int n = Integer.parseInt(s.substring(k + 1, k2)); if (n < 0) { throw new IllegalArgumentException("Negative array index: " + n); } idx.add(n); k = k2; } int[] idx1 = null; if (!idx.isEmpty()) { idx1 = new int[idx.size()]; for (int u = 0; u < idx.size(); u++) { idx1[u] = idx.get(u); } } return new PathElement(name, idx1); } PathElement(String name, int[] index); }
PathElement implements Serializable { public static PathElement fromString(String s) { List<Integer> idx = new ArrayList<Integer>(); int k = s.indexOf('[', 0); if (k == -1) { return new PathElement(s, null); } String name = k > 0 ? s.substring(0, k) : null; while (true) { k = s.indexOf('[', k); if (k == -1) { break; } int k2 = s.indexOf(']', k); if (k2 == -1) { throw new IllegalArgumentException("Invalid aggregate member path '" + s + "'"); } int n = Integer.parseInt(s.substring(k + 1, k2)); if (n < 0) { throw new IllegalArgumentException("Negative array index: " + n); } idx.add(n); k = k2; } int[] idx1 = null; if (!idx.isEmpty()) { idx1 = new int[idx.size()]; for (int u = 0; u < idx.size(); u++) { idx1[u] = idx.get(u); } } return new PathElement(name, idx1); } PathElement(String name, int[] index); String toString(); static PathElement fromString(String s); String getName(); int[] getIndex(); static String pathToString(PathElement[] path); }
PathElement implements Serializable { public static PathElement fromString(String s) { List<Integer> idx = new ArrayList<Integer>(); int k = s.indexOf('[', 0); if (k == -1) { return new PathElement(s, null); } String name = k > 0 ? s.substring(0, k) : null; while (true) { k = s.indexOf('[', k); if (k == -1) { break; } int k2 = s.indexOf(']', k); if (k2 == -1) { throw new IllegalArgumentException("Invalid aggregate member path '" + s + "'"); } int n = Integer.parseInt(s.substring(k + 1, k2)); if (n < 0) { throw new IllegalArgumentException("Negative array index: " + n); } idx.add(n); k = k2; } int[] idx1 = null; if (!idx.isEmpty()) { idx1 = new int[idx.size()]; for (int u = 0; u < idx.size(); u++) { idx1[u] = idx.get(u); } } return new PathElement(name, idx1); } PathElement(String name, int[] index); String toString(); static PathElement fromString(String s); String getName(); int[] getIndex(); static String pathToString(PathElement[] path);  }