@Test public void testSimpleId() throws Exception { assertArrayEquals(new Node[0], parse("")); assertArrayEquals(new Node[] { new Node("test") }, parse("test")); assertArrayEquals(new Node[] { new Node("form"), new Node("table") }, parse("form:table")); }
public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SeparatorChar.SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); }
IdParser { public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SeparatorChar.SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); } }
IdParser { public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SeparatorChar.SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); } private  IdParser(); }
IdParser { public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SeparatorChar.SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); } private  IdParser(); static Node[] parse(String id); }
IdParser { public static Node[] parse(String id) { if (id.length() == 0) { return EMPTY_NODES_ARRAY; } List<Node> result = Lists.newArrayList(); Iterable<String> split = SeparatorChar.SPLITTER.split(id); for (String s : split) { if (s.charAt(0) == META_COMPONENT_SEPARATOR_CHAR) { int startImageIdx = s.indexOf(FUNCTION_IMAGE_START_TOKEN); if (startImageIdx < 0) { result.add(new Node(s)); } else { if (s.charAt(s.length() - 1) != FUNCTION_IMAGE_END_TOKEN) { throw new IllegalArgumentException(id); } if (startImageIdx + 1 > s.length() - 1) { throw new IllegalArgumentException(id); } String image = s.substring(startImageIdx + 1, s.length() - 1); String functionName = s.substring(1, startImageIdx); result.add(new Node(image, functionName)); } } else { result.add(new Node(s)); } } return result.toArray(new Node[result.size()]); } private  IdParser(); static Node[] parse(String id);  }