id
stringlengths
36
36
text
stringlengths
1
1.25M
43fb4984-c61e-4bbe-a493-3e8b245c422d
@Test public void testMultipleTags() { ArrayList<String> comments = new ArrayList<String>(); comments.add("first"); comments.add("one"); comments.add("@author me"); comments.add("@description second"); comments.add("one"); comments.add("@author you"); Model m = new Model("", comments);...
6d9eaf31-81b9-4e5d-b3a2-2067034602e5
@Test public void testEmptyPreTag() { ArrayList<String> comments = new ArrayList<String>(); comments.add("before"); comments.add("<pre>"); comments.add("</pre>"); comments.add("after"); Model m = new Model("", comments); assertEquals("description", "before <pre>\n</pre> after", m.getDescri...
60ac1ca1-0072-4202-af88-c5b20d4139e4
@Test public void testNonEmptyPreTag() { ArrayList<String> comments = new ArrayList<String>(); comments.add("<pre>"); comments.add("* // a sample class"); comments.add(" void foo() { "); comments.add(" return;"); comments.add(" }"); comments.add("</pre>"); Model m = new Model("", co...
a3d16c5b-4dd9-41ac-971d-d7ad46a2bd29
private void assertBlankComment(Model m) { assertEquals("blank description", "", m.getDescription()); assertEquals("blank author", "", m.getAuthor()); assertEquals("blank date", "", m.getDate()); assertEquals("blank returns", "", m.getReturns()); assertEquals("blank see", "", m.getSee()); assert...
4879304d-e798-45d5-a916-a4e04f84b9db
public void testNullPath() { new FileManager(null); }
933e6768-a029-4da9-824e-54675bf0edfa
@Test public void testValidPath() { assertEquals("current folder", ".", new FileManager("").path); assertEquals("current folder", ".", new FileManager(" \t").path); assertEquals("current folder", ".", new FileManager(".").path); assertEquals("current folder", "..", new FileManager(" .. ").path); ...
93f8c54e-8957-4e81-b1a2-0b6a29b081b9
@Test (expected = NullPointerException.class) public void testCreateDocsWithNullModels() { new FileManager("").createDocs(null, "", ""); }
d9e0a0b4-70d0-48db-90f7-b1b5940533f1
@Test (expected = NullPointerException.class) public void testCreateDocsWithNullDetail() { new FileManager("").createDocs(new ArrayList<ClassModel>(), null, ""); }
5c78e28c-c647-4d88-8ea5-d75c997a6b60
@Test (expected = NullPointerException.class) public void testCreateDocsWithNullContents() { new FileManager("").createDocs(new ArrayList<ClassModel>(), "", null); }
88152b38-8f0a-4614-9ee3-6b5748c9823a
@Test public void testGetName() { ArrayList<String> comments = new ArrayList<String>(); PropertyModel m = new PropertyModel("", comments); assertEquals("", m.getName()); m = new PropertyModel(" ", comments); assertEquals("", m.getName()); m = new PropertyModel("\t", comments); ...
75eb02cb-a462-49ce-9d90-16dc7282cdd3
@Test public void testGetName() { ArrayList<String> comments = new ArrayList<String>(); assertEquals("", new MethodModel("", comments).getName()); assertEquals("", new MethodModel(" ", comments).getName()); assertEquals("", new MethodModel("\t", comments).getName()); assertEquals("a", new MethodMo...
6802d2b3-890d-45d2-846e-af1006d800a4
public int compare(Model o1, Model o2) { return o1.getName().compareToIgnoreCase(o2.getName()); }
56dce878-49c8-4626-80a8-463fcc013d93
protected Model(String nameLine, ArrayList<String> comments) { SfApexDoc.assertPrecondition(null != comments); setNameLine(nameLine); parseComments(comments); }
bfc8d203-64d1-438a-a934-9d1fc2edbf41
public String getName() { SfApexDoc.assertPrecondition(false); return null; }
ad702c00-d26d-418d-86a5-cee380d11612
public String getNameLine() { return nameLine; }
77d06fa7-88d6-4052-bd51-f16c41b346b6
public void setNameLine(String nameLine) { SfApexDoc.assertPrecondition(null != nameLine); SfApexDoc.assertPrecondition(nameLine.isEmpty() || (!Character.isWhitespace(nameLine.charAt(0)) && !Character.isWhitespace(nameLine.charAt(nameLine.length()-1)))); this.nameLine = nameLine; }
c1ddca57-e92b-477d-a952-af4bc929286e
public String getDescription() { return description; }
305e5871-4c4f-4f00-887b-06735780daa6
public String getAuthor() { return author; }
09222211-7ef4-4cb1-95f9-a43679af0541
public String getDate() { return date; }
ec7be499-311c-4e82-8c37-9dec42b2998c
public String getReturns() { return returns; }
073e9fa5-f79c-47d4-93ea-4a5338dba96a
public String getSee() { return see; }
1d8a8e49-68ad-4578-bffc-49120072b540
public String getSince() { return since; }
6b72cc17-6c64-4919-84eb-da919c11e115
public String getVersion() { return version; }
bfad1d68-a8ee-48d3-9d06-445d31b50d69
public String getHistory() { return history; }
bea314fe-9b0c-4e2d-866e-bfd7bc88e7e8
public ArrayList<String> getParams() { return params; }
26cb5aea-c3d0-4fc9-ade3-1571fcbe2e7b
public ArrayList<String> getThrows() { return except; }
7424bc62-aed1-4f23-8f96-fa44b4b5901f
public String getThrowsAsString() { String result = ""; for (String x : except) { result += "<br/>throws " + x; } return result; }
290c87d7-19b5-4b78-91b8-2da770e51150
public void addLinks() { SfApexDoc.assertPrecondition(!linksAdded); setNameLine(addLinks(nameLine)); see = addLinks(see); for (Integer i = 0; i < except.size(); ++i) { except.set(i, addLinks(except.get(i))); } linksAdded = true; }
d641ec24-4c99-464f-8efd-2b3707628ff4
protected void addType(String name, String link) { typeLinks.put(name.toLowerCase(), link.toLowerCase()); }
86d95432-23de-49f0-9e75-222df89d5b9c
private String addLinks(String text) { String result = text; if (!result.isEmpty()) { // HTML-encode the string result = result.replace("<", "&lt;").replace(">", "&gt;"); // replace words with their links, if we know them. // splitting into words breaks on '.', so replace them tem...
96510341-4e65-43bd-b47c-37f18f84802a
private void parseComments(ArrayList<String> comments) { String curBlock=null, block=null; boolean inPre=false; for (String comment : comments) { boolean newBlock = false; String lowerComment = comment.toLowerCase(); int i; // if we find a tag, start a new block if (((i = lower...
9814d5e1-1464-42c4-9e00-503cbabae4f2
public SfApexDoc() { instance = this; }
155422da-2061-4c13-aa64-0cbefb50f509
public static void main(String[] args) { SfApexDoc.args = new ArrayList<String>(Arrays.asList(args)); new SfApexDoc().doIt(); }
ed7304b3-d9c5-454e-907c-92867f963001
public void doIt() { log("SfApexDoc version " + VERSION + "\n"); SfApexDoc.assertPrecondition(null != args); // create a log file try { logFile = new PrintStream(new FileOutputStream(new File(LOG_FILE_NAME))); } catch (Exception e) { System.err.println("Failed to create log fil...
06a8568a-0418-4595-8cc6-92a506cefab7
public static void log(Exception e) { e.printStackTrace(); log(e.getMessage()); }
1e904234-47d4-412a-a721-7b971ef5155f
public static void log(String message) { if (null != message) { System.out.println(" " + message); if (null != logFile) { logFile.println(message); } } }
42fb2f87-cf22-4009-9b1d-3f8d0eb0de26
public static void assertPrecondition(boolean condition) { if (!condition) { throw new NullPointerException(); } }
d6600685-1fb8-4b69-8cee-7a545f05a393
public void initProgress(int units) {}
85fa1439-eff3-4857-9c1e-7d381b2549a3
public void showProgress() {}
eb1549bb-4b3c-4c0a-bd60-3ebace9921de
private static String getFileContents(String filePath) { String result = "", line = ""; try { BufferedReader reader = new BufferedReader(new FileReader(filePath)); while (null != (line = reader.readLine())) { result += line + '\n'; } reader.close(); } catch (Exception e) { ...
c6079224-b7bb-4d71-ae05-cdef8cefa189
public static ClassModel parse(String text, ArrayList<String> scope) { if (scope.contains(SCOPE_GLOBAL)) { scope.add(SCOPE_WEBSERVICE); } ClassModel parentClass = null, model = null; String line = "", prevLine = null; int lineIndex = 0, nestedCurlyBraceDepth = 0; try { boolean c...
2db636cf-fdd4-41a9-b6e8-3285cec66d63
private static void processCompleteModel(ClassModel model) { if ((null != model) && model.inScope) { Collections.sort(model.properties, new ModelComparer()); Collections.sort(model.methods, new ModelComparer()); debug(model); } }
4aebda6a-8dcb-46b6-8719-4b22df1053b3
private static boolean lineContainsScope(String line, ArrayList<String> scope) { SfApexDoc.assertPrecondition(null != line); SfApexDoc.assertPrecondition(null != scope); String l = line.toLowerCase(); for (int i = 0; i < scope.size(); i++) { if (l.matches("(^|.*\\s)" + scope.get(i) + "\\s+(?!...
2f638244-fd7d-44c8-997b-82cee17da458
private static void debug(ClassModel model) { if ((null != model) && debugOutput) { log("Class: " + model.getName()); if (!model.properties.isEmpty()) { String properties = ""; for (PropertyModel property : model.properties) { properties += property.getName() + " "; ...
f3c7c390-1a5e-4c9f-a9de-13ec50e4c7fc
private static void syntaxError(String message) { log(message); // display usage log(""); log("SfApexDoc is a tool for generating documentation from Salesforce Apex code class files.\n"); log("The syntax is:"); log(" SfApexDoc [-v] -s <source_folder> [-t <target_folder>] [-h <homefile>] [-...
da22320d-a32c-4530-a365-a7a5d43f2c82
private static void bail(String message) { log(message); log(""); System.exit(-1); }
bd63a8ca-c78a-4cc4-a513-9176d7f3267e
private static int countChars(String haystack, char needle) { int count = 0; for (int i = 0; i < haystack.length(); ++i) { if (haystack.charAt(i) == needle) { ++count; } } return count; }
334f2b60-9353-4a87-b44e-2edc2bdab353
public MethodModel(String nameLine, ArrayList<String> comments) { super("", comments); // truncate to just the signature int i = nameLine.indexOf('{'); setNameLine(((i >= 0) ? nameLine.substring(0, i) : nameLine).trim()); }
3dd8bdbb-2728-4ff7-8735-8940880d31f0
public String getName() { // the word just before the '(' is the method name final String line = getNameLine(); int end = line.indexOf('('); String[] words = ((end < 0) ? line : line.substring(0, end)).split("\\s+"); return (words.length > 0) ? words[words.length - 1] : words[0]; }
fa6ba520-7f91-4b56-8d37-5075b413a6b8
public FileManager() { this(""); }
27344c59-0b8e-4e8f-a8e5-477d5446894c
public FileManager(String path) { SfApexDoc.assertPrecondition(null != path); this.path = path.trim(); if (this.path.isEmpty()) this.path = "."; }
1348361a-e17e-4204-9b16-cc48ee04cc23
public void createDocs(ArrayList<ClassModel> models, String detailFile, String homeFile) { SfApexDoc.assertPrecondition(null != models); SfApexDoc.assertPrecondition(null != detailFile); SfApexDoc.assertPrecondition(null != homeFile); String projectDetail = parseProjectDetail(detailFile.trim()); ...
67641539-7ce0-441c-872c-e3599cf9ba81
private String formatHistory(String history) { String[] lines = history.split("\\r?\\n"); String[] fields; String result = "<table class=\"history\"><thead>"; for (Integer i=0; i<lines.length; i++) { String line = lines[i].trim(); if (line.matches("(\\-+[\\s\\t]*\\|?[\\s\\t]*)+")) { ...
2c3163e7-67c3-4b06-86ae-e35236db0c99
private String createClassDoc(ClassModel model, String fileName) { model.addLinks(); String contents = "<td class='classCell'>"; contents += "<h2 class='section-title'>" + fileName + TOGGLE_ALL + "</h2>" + "<div class='toggle_container_subtitle'>" + model.getNameLine() + "</div>" + "<table...
4a934ef7-f078-436e-971a-1649ab112042
private String parseProjectDetail(String filePath) { String contents = ""; try { BufferedReader reader = new BufferedReader(new FileReader(filePath)); String line; while ((line = reader.readLine()) != null) { line = line.trim(); int equalsPos = line.indexOf("="); String...
ca60a127-ffc5-4e57-8e27-64e6ba6021e3
private String parseHtmlFile(String filePath) { String contents = ""; try { BufferedReader reader = new BufferedReader(new FileReader(filePath)); String line; while ((line = reader.readLine()) != null) { contents += line.trim(); } reader.close(); } catch (Exception e) {...
393d49cc-4007-4db8-a9db-9c9b84cdd911
private void copyFile(String source, String target) throws Exception { target += "/" + source; if (!(new File(target).exists())) { InputStream is = getClass().getResourceAsStream(source); FileOutputStream to = new FileOutputStream(target); byte[] buffer = new byte[4096]; int bytesRead; ...
dd0512c4-350c-4676-918b-99b662202d9f
private void createDocFiles(Hashtable<String, String> classHashTable) { try { // create required folders for documentation files if (!path.endsWith("/") && !path.endsWith("\\")) { path += '/'; } path += ROOT_DIRECTORY; (new File(path)).mkdirs(); for (String fileNam...
d676cc36-424d-4248-886c-28fae5da8be8
private String getPageLinks(ArrayList<ClassModel> models){ String links = "<td class='leftmenus' rowspan='100'><div onclick=\"gotomenu('index.html');\">Home</div>"; for (ClassModel model : models) { String name; if (!(name = model.getName()).isEmpty()) { links += "<div onclick=\"gotomenu('" ...
0b6d5aab-3c06-491c-9aaf-2141a82ac49a
private void copyResources(String toPath) throws IOException, Exception { copyFile("logo.png", toPath); copyFile("SfApexDoc.css", toPath); copyFile("h2_trigger_a.gif", toPath); copyFile("jquery-latest.js", toPath); copyFile("toggle_block_btm.gif", toPath); copyFile("toggle_block_stretch.gif", to...
f0ef1e6f-c08f-4610-a326-b9567ba83034
public ClassModel(ClassModel parent, String nameLine, ArrayList<String> comments) { super(nameLine.trim(), comments); isInterface = getNameLine().matches("(^|.*\\s)interface\\s+.*"); this.parent = parent; final String name = getName(); // add this as a 'type' we can link to addType(nam...
de68ccfb-acf0-4e1f-bbe7-b348efce48a1
public ClassModel(String nameLine, ArrayList<String> comments) { this(null, nameLine, comments); }
64f3efa5-c27e-4665-ac9d-dae937470f30
public String getName() { // the name is the word after "class" or "interface" final String typesToSearch = '|' + types + '|'; String[] words = getNameLine().split("\\s+"); for (int i = 0; i < words.length; ++i) { if (((i + 1) < words.length) && (typesToSearch.contains('|' + words[i].toLowerCase()...
cb02d9bb-5b70-42ac-8fba-75c98dc4cf74
public PropertyModel(String nameLine, ArrayList<String> comments) { super(nameLine.trim(), comments); }
aada3f8e-5b97-4f6b-a532-6a5cd506b35c
public String getName() { final String line = getNameLine(); int i = line.lastIndexOf(' '); return (i >= 0) ? line.substring(i + 1) : line; }
f7a5b20c-4fa0-4183-8e2b-0a4f30a8f9a7
public static int[] Sort(int[] data){ int[] sorted=data; for(int i=1;i<data.length;i++){ int temp = sorted[i]; int position = i; while(position>0 && temp<sorted[position-1]){ sorted[position]=sorted[position-1]; position--; ...
e8a9950c-ab8d-4b75-9c82-01ad8ed969c4
public static int[] RandomArray(int min, int max){ return RandomArray(max-min+1, min, max); }
c142711e-b5a4-43d3-8ea3-6407822bccf7
public static int[] RandomArray(int size, int min, int max){ Random rand = new Random(); int[] array = new int [size]; for(int i=0;i<size;i++){ array[i] = min+Math.abs(rand.nextInt()%(max-min+1)); } return array; }
7f4f231c-24b5-4d6a-8e89-d52ad17fe1cb
public static int Max(int[] data){ int max=data[0]; for(int d : data){ if(max<d){ max = d; } } return max; }
c9f73500-cfda-4c75-b22a-6f8d1100df96
public static int Min(int[] data){ int min=data[0]; for(int d : data){ if(min>d){ min = d; } } return min; }
188055ae-8113-47d5-b80b-acec3f2b9766
public static int[] Sort(int[] data){ int min = Utils.Min(data); //also used for offset int max = Utils.Max(data); //step 1: initialize the buckets ArrayList[] buckets = new ArrayList[max-min+1]; for(int i=0;i<buckets.length;i++) { buckets[i] = new ArrayList(); } //st...
aeb7f1d3-c6db-491b-91b1-79af70a9a98c
public static int[] Sort(int[] data){ int[] sorted = data; for(int i=data.length-1;i>0;i--) { for(int j=0;j<i;j++) { if(sorted[j]>sorted[j+1]){ int temp = sorted[j]; sorted[j]=sorted[j+1]; sorted[j+1]=temp; ...
abbf91ee-cf64-48da-ac36-92483ab04764
public static void main(String[] args) { // TODO code application logic here int[] ar = Utils.RandomArray(100,-50,-20); System.out.println("Unsorted..."); for(int i: ar) System.out.print(i+" "); ar = BucketSort.Sort(ar); System.out.println("\nSorted..."); ...
63392365-e886-4b83-84ce-bc0998c328f6
public static int[] Sort(int[] data){ int[] sorted = new int[data.length]; System.arraycopy( data, 0, sorted, 0, data.length ); boolean isSorted; Random rand = new Random(); while (true){ isSorted = true; for(int i=0;i<sorted.length-1;i++){ ...
aab8fd7d-635f-4702-9a2c-36621268c9d2
public static void main(String[] args){ System.out.println("\nPrepare for StupidSort!"); int size = 11; int min = 0; int max = 100; int[] ar; ar = Utils.RandomArray(size, min, max); //ar = new int[] {1,3,6,4,9,7,12,5,10,11,17}; ar = StupidSort.Sort(ar); ...
65f94dc0-473f-4e82-ae38-5a7fb4d22c1b
public static int[] Sort(int[] data){ int[] sorted=new int[data.length]; Heap heap = new Heap(data.length); for(int d:data){ heap.insert(d); } while(heap.getSize()>0){ sorted[heap.getSize()-1] = heap.remove(); } return sorted; ...
ae72275b-7cc5-4f84-a9e2-26dcb514c3a3
public EnvironmentReader(String location, int lineCount, int lineLength) throws IOException { _location = location; _lineCount = lineCount; _lineLength = lineLength; readEnvironment(); }
aae15bd5-1c2f-40bc-aa7f-284d92b3c0a4
private void readEnvironment() throws IOException { BufferedReader reader = new BufferedReader(new FileReader(_location)); char[][] environment = new char[_lineCount][_lineLength]; for (int currentLine = 0; currentLine < _lineCount; ++currentLine) { String line = reader.readLine();...
9fb5f3c9-9767-4d78-a4d4-68363685b290
public char[][] getEnvironment() { return _environment; }
f9877760-9ecd-4857-833c-ba8a2176d33e
public int[] getStartPos() { return _startPos; }
2f9ad483-6859-4c0a-ae44-5c8e2244019d
public int getStartPosX() { return _startPos[1]; }
766fff3d-02fe-432e-868d-0384abc59a6a
public int getStartPosY() { return _startPos[0]; }
3deaedae-87f7-40e8-9548-9b54487866b9
public int getGoalPosX() { return _goalPos[1]; }
6a899745-4bc2-4d24-8041-4a3a491854c2
public int getGoalPosY() { return _goalPos[0]; }
9a5d7112-8e64-4dfd-b655-4a4600dd97ff
public char getGoalChar() { return GOAL_CHAR; }
5b9960c4-16d0-462d-b146-093803bbc4eb
public Path(Node s) { nodelist.add(s); }
a7fe1074-fc6b-41de-b5a6-2937177976b7
public Path() { }
e696cceb-b08b-4467-a2bb-a0370a50c9a0
public void addNode(Node node) { nodelist.add(node); }
41187622-ae97-4c66-bcf3-a4af3d78f705
public Node getLastNode() { int lastIndex = nodelist.size() - 1; if (lastIndex >= 0) { return nodelist.get(lastIndex); } else { return null; } }
9362f9bc-1694-416d-9657-a034bf41be5e
public List<Character> getCharPath() { List<Character> charList = new ArrayList<Character>(); for (Node node : nodelist) { charList.add(node.getDirection()); } return charList; }
e481bb00-6d31-4434-8d70-a7d9b4f10b37
public Path expandPath(Node newNode) { Path newPath = new Path(); newPath.nodelist.addAll(this.nodelist); newPath.addNode(newNode); return newPath; }
5e2103ba-f632-48e0-82ae-ffee590b5d49
public Node(int x, int y, char Direction) { this.x = x; this.y = y; this.Direction = Direction; }
47eab872-c4e0-4762-8637-f9b38dca5cde
public Node(int x, int y, int Schrittkosten, int heuristik, Node vorgaenger) { this.x = x; this.y = y; this.kosten = Schrittkosten; this.heuristik = heuristik; this.vorgaenger = vorgaenger; this.Direction='1'; }
9d252c70-e482-4a32-85af-d4ab8bd2c2fb
public int getKostenSum() { return this.getKostenBisher() + this.kosten + this.heuristik; }
7c0d6f2f-8154-4af7-990a-c277500b5013
public int getKostenBisher() { if (this.vorgaenger == null) { return 0; } return this.vorgaenger.getKostenBisher() + this.kosten; }
ef430d1a-1e33-4020-b91a-529844e5a9dc
public void setVorgaenger(Node neuer) { this.vorgaenger = neuer; }
c9b35dd6-df6d-49d0-a565-2798daa2a38a
public int getX() { return x; }
93c99b0b-b280-440f-93ca-0b7bff84cc93
public int getY() { return y; }
c9a86071-0972-40e0-8ff0-51070b663558
public char getDirection() { return Direction; }
f9d19dad-9733-45b0-825c-6c81fda6073e
@Override public int hashCode() { int hash = 5; hash = 59 * hash + this.x; hash = 59 * hash + this.y; hash = 59 * hash + this.Direction; return hash; }