@Test(expected=Exception.class) public void testNoCommandMatchRaiseError() throws Exception { String simpleText = "set Commandx {foo}"; String contents = XviImporter.getBlockContents(simpleText, "set Command"); }
public static String getBlockContents(String text, String command) throws Exception { outer: for (int i = 0; i < text.length(); i++) { for (int j = 0; j < command.length(); j++) { char text_current = text.charAt(i + j); char command_current = command.charAt(j); if (text_current != command_current) { continue outer; } } i += command.length(); while (Character.isWhitespace(text.charAt(i))) { i++; } if (text.charAt(i) == '{') { i++; } else { continue outer; } int openBraces = 1; int startOfContent = i; for(; i < text.length(); i++) { if (text.charAt(i) == '{') { openBraces++; } else if (text.charAt(i) == '}') { openBraces--; } if (openBraces == 0) { int endOfContent = i; String content = text.substring(startOfContent, endOfContent); return content; } } throw new Exception("Malformed text: could not match braces"); } throw new Exception("Could not match command in text"); }
XviImporter extends Importer { public static String getBlockContents(String text, String command) throws Exception { outer: for (int i = 0; i < text.length(); i++) { for (int j = 0; j < command.length(); j++) { char text_current = text.charAt(i + j); char command_current = command.charAt(j); if (text_current != command_current) { continue outer; } } i += command.length(); while (Character.isWhitespace(text.charAt(i))) { i++; } if (text.charAt(i) == '{') { i++; } else { continue outer; } int openBraces = 1; int startOfContent = i; for(; i < text.length(); i++) { if (text.charAt(i) == '{') { openBraces++; } else if (text.charAt(i) == '}') { openBraces--; } if (openBraces == 0) { int endOfContent = i; String content = text.substring(startOfContent, endOfContent); return content; } } throw new Exception("Malformed text: could not match braces"); } throw new Exception("Could not match command in text"); } }
XviImporter extends Importer { public static String getBlockContents(String text, String command) throws Exception { outer: for (int i = 0; i < text.length(); i++) { for (int j = 0; j < command.length(); j++) { char text_current = text.charAt(i + j); char command_current = command.charAt(j); if (text_current != command_current) { continue outer; } } i += command.length(); while (Character.isWhitespace(text.charAt(i))) { i++; } if (text.charAt(i) == '{') { i++; } else { continue outer; } int openBraces = 1; int startOfContent = i; for(; i < text.length(); i++) { if (text.charAt(i) == '{') { openBraces++; } else if (text.charAt(i) == '}') { openBraces--; } if (openBraces == 0) { int endOfContent = i; String content = text.substring(startOfContent, endOfContent); return content; } } throw new Exception("Malformed text: could not match braces"); } throw new Exception("Could not match command in text"); }  }
XviImporter extends Importer { public static String getBlockContents(String text, String command) throws Exception { outer: for (int i = 0; i < text.length(); i++) { for (int j = 0; j < command.length(); j++) { char text_current = text.charAt(i + j); char command_current = command.charAt(j); if (text_current != command_current) { continue outer; } } i += command.length(); while (Character.isWhitespace(text.charAt(i))) { i++; } if (text.charAt(i) == '{') { i++; } else { continue outer; } int openBraces = 1; int startOfContent = i; for(; i < text.length(); i++) { if (text.charAt(i) == '{') { openBraces++; } else if (text.charAt(i) == '}') { openBraces--; } if (openBraces == 0) { int endOfContent = i; String content = text.substring(startOfContent, endOfContent); return content; } } throw new Exception("Malformed text: could not match braces"); } throw new Exception("Could not match command in text"); }  Survey toSurvey(File file); static Sketch getSketch(File file); boolean canHandleFile(File file); Grid parseGrid(String contents); static Set<PathDetail> parseSketchlineBlock(double scale, String contents); static List<String> parseBlockEntries(String content); static PathDetail parseSketchEntry(double scale, String entry); static String getBlockContents(String text, String command); }
XviImporter extends Importer { public static String getBlockContents(String text, String command) throws Exception { outer: for (int i = 0; i < text.length(); i++) { for (int j = 0; j < command.length(); j++) { char text_current = text.charAt(i + j); char command_current = command.charAt(j); if (text_current != command_current) { continue outer; } } i += command.length(); while (Character.isWhitespace(text.charAt(i))) { i++; } if (text.charAt(i) == '{') { i++; } else { continue outer; } int openBraces = 1; int startOfContent = i; for(; i < text.length(); i++) { if (text.charAt(i) == '{') { openBraces++; } else if (text.charAt(i) == '}') { openBraces--; } if (openBraces == 0) { int endOfContent = i; String content = text.substring(startOfContent, endOfContent); return content; } } throw new Exception("Malformed text: could not match braces"); } throw new Exception("Could not match command in text"); }  Survey toSurvey(File file); static Sketch getSketch(File file); boolean canHandleFile(File file); Grid parseGrid(String contents); static Set<PathDetail> parseSketchlineBlock(double scale, String contents); static List<String> parseBlockEntries(String content); static PathDetail parseSketchEntry(double scale, String entry); static String getBlockContents(String text, String command);  }