Updated buid info and made package list consistant.

This commit is contained in:
Willem Cazander 2013-08-09 19:34:52 +02:00
parent f290b73132
commit d4f80f338a
17 changed files with 122 additions and 26 deletions

View file

@ -42,7 +42,7 @@ import org.xml.sax.SAXException;
public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
private ApiDocNodeBody nodeBody = null;
private Integer nodeBodyOrder = null;
private List<Integer> nodeBodyOrders = null;
private Object bean = null;
private String method = null;
private List<Class<?>> targetClasses = null;
@ -75,10 +75,18 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
if (ammo==null) {
continue;
}
ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
if (ammo.nodeBodyOrder()!=-1) {
methodWriter.setNodeBodyOrder(ammo.nodeBodyOrder());
if (ammo.targetClasses().length==0) {
throw new IllegalArgumentException("Can't configure writer bean with empty 'targetClasses' parameter.");
}
if (ammo.targetClasses().length!=ammo.nodeBodyOrders().length) {
throw new IllegalArgumentException("Can't configure writer bean with non-equal array size of 'nodeBodyOrders'("+ammo.nodeBodyOrders().length+") and 'targetClasses'("+ammo.targetClasses().length+") parameters.");
}
ApiDocNodeWriterBean methodWriter = new ApiDocNodeWriterBean(ammo.nodeBody(), bean, method.getName(), ammo.targetClasses());
List<Integer> nodeBodyOrder = new ArrayList<Integer>();
for (int order:ammo.nodeBodyOrders()) {
nodeBodyOrder.add(order);
}
methodWriter.setNodeBodyOrders(nodeBodyOrder);
if (ammo.contentGroup().length()>0) {
methodWriter.setContentGroup(ammo.contentGroup());
}
@ -154,17 +162,17 @@ public class ApiDocNodeWriterBean implements ApiDocNodeWriter {
}
/**
* @return the nodeBodyOrder
* @return the nodeBodyOrders
*/
public Integer getNodeBodyOrder() {
return nodeBodyOrder;
public List<Integer> getNodeBodyOrders() {
return nodeBodyOrders;
}
/**
* @param nodeBodyOrder the nodeBodyOrder to set
* @param nodeBodyOrders the nodeBodyOrders to set
*/
public void setNodeBodyOrder(Integer nodeBodyOrder) {
this.nodeBodyOrder = nodeBodyOrder;
public void setNodeBodyOrders(List<Integer> nodeBodyOrders) {
this.nodeBodyOrders = nodeBodyOrders;
}
/**

View file

@ -43,7 +43,7 @@ public @interface ApiDocNodeWriterMethod {
ApiDocNodeBody nodeBody();
int nodeBodyOrder() default -1;
int[] nodeBodyOrders() default {-1};
String contentGroup() default "";

View file

@ -34,6 +34,8 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@ -387,7 +389,7 @@ public class ApiDocWriter {
private List<ApiDocNodeWriter> findNodeBodyWriters(ApiDocNode node,ApiDocNodeBody nodeBody) {
List<ApiDocNodeWriter> result = new ArrayList<ApiDocNodeWriter>();
Class<?> objClass = node.getUserData().getClass();
final Class<?> objClass = node.getUserData().getClass();
for (ApiDocNodeWriter writer:doc.getNodeBodyWriters()) {
if (!nodeBody.equals(writer.getNodeBody())) {
continue;
@ -398,6 +400,45 @@ public class ApiDocWriter {
}
}
}
Collections.sort(result, new Comparator<ApiDocNodeWriter>() {
public int compare(ApiDocNodeWriter o1, ApiDocNodeWriter o2) {
int index1 = -1;
int index2 = -1;
for (int i=0;i<o1.getTargetClasses().size();i++) {
Class<?> c = o1.getTargetClasses().get(i);
if (c.isAssignableFrom(objClass)) {
index1 = i;
break;
}
}
for (int i=0;i<o2.getTargetClasses().size();i++) {
Class<?> c = o2.getTargetClasses().get(i);
if (c.isAssignableFrom(objClass)) {
index1 = i;
break;
}
}
// TODO: note check return value if are oke in order..
if (index1==-1 && index2==-1) {
return 0;
}
if (index1==-1) {
return 1;
}
if (index2==-1) {
return -1;
}
int orderValue1 = o1.getNodeBodyOrders().get(index1);
int orderValue2 = o2.getNodeBodyOrders().get(index2);
if (orderValue1==orderValue2) {
return 0;
}
if (orderValue1 > orderValue2) {
return -1;
}
return 1;
}
});
return result;
}

View file

@ -36,6 +36,7 @@ public interface ApiDocNodeWriter {
ApiDocNodeBody getNodeBody();
List<Class<?>> getTargetClasses();
List<Integer> getNodeBodyOrders();
void writeNodeContent(ApiDocWriteEvent<ApiDocNode> e) throws SAXException;
}

View file

@ -22,7 +22,7 @@
*/
/**
* Api Doc Dom classes.
* The Api Doc Dom classes.
*
* @author Willem Cazander
* @since 1.0 May 12,2013

View file

@ -22,7 +22,7 @@
*/
/**
* Api Doc Writer classes.
* The Api Doc Writer classes.
*
* @author Willem Cazander
* @since 1.0 May 12,2013