Skip to content

Commit

Permalink
Merge pull request SalesforceFoundation#30 from Bobnix/master
Browse files Browse the repository at this point in the history
Response to Issues opened by @Bobnix
  • Loading branch information
David Habib committed Feb 5, 2015
2 parents 3049f64 + b61b4b9 commit 36088ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
17 changes: 13 additions & 4 deletions src/org/salesforce/apexdoc/ClassModel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.salesforce.apexdoc;

import java.util.List;
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.Collections;
import java.util.Comparator;

public class ClassModel extends ApexModel {

Expand Down Expand Up @@ -40,10 +43,16 @@ public ArrayList<MethodModel> getMethods() {
}

public ArrayList<MethodModel> getMethodsSorted() {
TreeMap<String, MethodModel> tm = new TreeMap<String, MethodModel>();
for (MethodModel method : methods)
tm.put(method.getMethodName().toLowerCase(), method);
return new ArrayList<MethodModel>(tm.values());
List<MethodModel> sorted = ( List<MethodModel>)methods.clone();
Collections.sort(sorted, new Comparator(){
@Override
public int compare(Object o1, Object o2) {
String methodName1 = ((MethodModel)o1).getMethodName().toLowerCase();
String methodName2 = ((MethodModel)o2).getMethodName().toLowerCase();
return (methodName1.compareTo(methodName2));
}
});
return new ArrayList<MethodModel>(sorted);
}

public void setMethods(ArrayList<MethodModel> methods) {
Expand Down
9 changes: 7 additions & 2 deletions src/org/salesforce/apexdoc/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FileManager {
FileOutputStream fos;
Expand Down Expand Up @@ -239,10 +241,13 @@ private String htmlForClassModel(ClassModel cModel, String hostedSourceURL) {
for (String param : method.getParams()) {
param = escapeHTML(param);
if (param != null && param.trim().length() > 0) {
int ich = param.indexOf(" ");
Pattern p = Pattern.compile("\\s");
Matcher m = p.matcher(param);

String paramName;
String paramDescription;
if (ich != -1) {
if (m.find()) {
int ich = m.start();
paramName = param.substring(0, ich);
paramDescription = param.substring(ich + 1);
} else {
Expand Down

0 comments on commit 36088ce

Please sign in to comment.