package ai.d.ai18; import drjava.util.Lizt; import drjava.util.StringUtil; import net.luaos.tb.tb15.CentralDatabase; import net.luaos.tb.tb20.DatabaseAPI; import net.luaos.tb.tb20.ListEntry; import java.util.List; import java.util.Map; import java.util.TreeMap; public class GetDiskStats { public static void main(String[] args) { DatabaseAPI db = CentralDatabase.copyToMemory("df", "GetDiskStats"); String dfOutputID = "#t1-kokjwjhpwuas-qbtsjoyahagl"; doIt(db, dfOutputID); } public static void doIt(DatabaseAPI db, String dfOutputID) { ListEntry dfOutput = db.get(dfOutputID); String text = dfOutput.desc; System.out.println(text); List<String> lines = StringUtil.toLines(text); System.out.println(StringUtil.n(lines.size(), "line")); ListEntry rowMarking = db.oneOfType_flex("RowMarking"); // TODO: check link to DFOutput System.out.println("RowMarking: " + rowMarking); List<ListEntry> colMarkings = db.allOfType("ColMarking"); // TODO: check link to DFOutput System.out.println("ColMarkings: " + colMarkings); Map<String, String> map = new TreeMap<String, String>(); // Yes - we like it sorted for (ListEntry colMarking : colMarkings) { int textRow = rowMarking.getInt("textRow"); String line = lines.get(textRow-1); String textCol = colMarking.getString("textCol"); String[] fromTo = textCol.split("\\-"); int col1 = Integer.parseInt(fromTo[0]), col2; if (fromTo[1].equals("end")) col2 = line.length(); else if (fromTo[1].endsWith(" (inc)")) col2 = Integer.parseInt(fromTo[1].substring(0, fromTo[1].length()-" (inc)".length())); else throw new RuntimeException("Ambiguous column range: " + textCol); String value = line.substring(col1-1, col2); System.out.println("Value: |" + value + "|"); map.put(colMarking.desc, value); } System.out.println("Values: " + map); } }
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
556 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { package ai.d.ai18; import drjava.util.Lizt; import drjava.util.StringUtil; import net.luaos.tb.tb15.CentralDatabase; import net.luaos.tb.tb20.DatabaseAPI; import net.luaos.tb.tb20.ListEntry; import java.util.List; import java.util.Map; import java.util.TreeMap; public class GetDiskStats { public static void main(String[] args) { DatabaseAPI db = CentralDatabase.copyToMemory("df", "GetDiskStats"); String dfOutputID = "#t1-kokjwjhpwuas-qbtsjoyahagl"; doIt(db, dfOutputID); } public static void doIt(DatabaseAPI db, String dfOutputID) { ListEntry dfOutput = db.get(dfOutputID); String text = dfOutput.desc; System.out.println(text); List<String> lines = StringUtil.toLines(text); System.out.println(StringUtil.n(lines.size(), "line")); ListEntry rowMarking = db.oneOfType_flex("RowMarking"); // TODO: check link to DFOutput System.out.println("RowMarking: " + rowMarking); List<ListEntry> colMarkings = db.allOfType("ColMarking"); // TODO: check link to DFOutput System.out.println("ColMarkings: " + colMarkings); Map<String, String> map = new TreeMap<String, String>(); // Yes - we like it sorted for (ListEntry colMarking : colMarkings) { int textRow = rowMarking.getInt("textRow"); String line = lines.get(textRow-1); String textCol = colMarking.getString("textCol"); String[] fromTo = textCol.split("\\-"); int col1 = Integer.parseInt(fromTo[0]), col2; if (fromTo[1].equals("end")) col2 = line.length(); else if (fromTo[1].endsWith(" (inc)")) col2 = Integer.parseInt(fromTo[1].substring(0, fromTo[1].length()-" (inc)".length())); else throw new RuntimeException("Ambiguous column range: " + textCol); String value = line.substring(col1-1, col2); System.out.println("Value: |" + value + "|"); map.put(colMarking.desc, value); } System.out.println("Values: " + map); } } }} | 2015-08-18 20:05:35 | delete |
554 | #1000604 (pitcher) | 2015-08-18 00:07:22 |
Recognizer | Recognition Result | Visualize | Recalc |
---|---|---|---|
#308 | 1999 | [visualize] |
Snippet ID: | #283 |
Snippet name: | GetDiskStats.java |
Eternal ID of this version: | #283/1 |
Text MD5: | 917644d594c2117e0d5d2ba65462cc54 |
Author: | stefan |
Category: | |
Type: | Java source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2014-11-08 22:25:05 |
Source code size: | 1999 bytes / 54 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1262 / 173 |
Referenced in: | [show references] |