Projects
Mega:24.03
fop
_service:tar_scm:Port-to-QDox-2.0.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:Port-to-QDox-2.0.patch of Package fop
From: Michael Simacek <msimacek@redhat.com> Date: Tue, 17 Mar 2015 10:59:41 +0100 Subject: [PATCH] Port to QDox 2.0 diff --git a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java index 2351fc870..64cd7edf0 100644 --- a/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java +++ b/fop-events/src/main/java/org/apache/fop/tools/EventProducerCollector.java @@ -21,6 +21,7 @@ package org.apache.fop.tools; import java.io.File; import java.io.IOException; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -31,14 +32,11 @@ import org.apache.fop.events.model.EventModel; import org.apache.fop.events.model.EventProducerModel; import org.apache.fop.events.model.EventSeverity; -import com.thoughtworks.qdox.JavaDocBuilder; -import com.thoughtworks.qdox.model.DefaultDocletTagFactory; +import com.thoughtworks.qdox.JavaProjectBuilder; import com.thoughtworks.qdox.model.DocletTag; -import com.thoughtworks.qdox.model.DocletTagFactory; import com.thoughtworks.qdox.model.JavaClass; import com.thoughtworks.qdox.model.JavaMethod; import com.thoughtworks.qdox.model.JavaParameter; -import com.thoughtworks.qdox.model.Type; /** * Finds EventProducer interfaces and builds the event model for them. @@ -61,22 +59,12 @@ class EventProducerCollector { PRIMITIVE_MAP = Collections.unmodifiableMap(m); } - private DocletTagFactory tagFactory; private List<EventModel> models = new java.util.ArrayList<EventModel>(); /** * Creates a new EventProducerCollector. */ EventProducerCollector() { - this.tagFactory = createDocletTagFactory(); - } - - /** - * Creates the {@link DocletTagFactory} to be used by the collector. - * @return the doclet tag factory - */ - protected DocletTagFactory createDocletTagFactory() { - return new DefaultDocletTagFactory(); } /** @@ -89,9 +77,9 @@ class EventProducerCollector { */ public boolean scanFile(File src) throws IOException, EventConventionException, ClassNotFoundException { - JavaDocBuilder builder = new JavaDocBuilder(this.tagFactory); + JavaProjectBuilder builder = new JavaProjectBuilder(); builder.addSource(src); - JavaClass[] classes = builder.getClasses(); + Collection<JavaClass> classes = builder.getClasses(); boolean eventProducerFound = false; for (JavaClass clazz : classes) { if (clazz.isInterface() && implementsInterface(clazz, CLASSNAME_EVENT_PRODUCER)) { @@ -103,7 +91,7 @@ class EventProducerCollector { } private boolean implementsInterface(JavaClass clazz, String intf) { - JavaClass[] classes = clazz.getImplementedInterfaces(); + List<JavaClass> classes = clazz.getInterfaces(); for (JavaClass cl : classes) { if (cl.getFullyQualifiedName().equals(intf)) { return true; @@ -121,7 +109,7 @@ class EventProducerCollector { protected void processEventProducerInterface(JavaClass clazz) throws EventConventionException, ClassNotFoundException { EventProducerModel prodMeta = new EventProducerModel(clazz.getFullyQualifiedName()); - JavaMethod[] methods = clazz.getMethods(true); + List<JavaMethod> methods = clazz.getMethods(true); for (JavaMethod method : methods) { EventMethodModel methodMeta = createMethodModel(method); prodMeta.addMethod(methodMeta); @@ -133,20 +121,20 @@ class EventProducerCollector { private EventMethodModel createMethodModel(JavaMethod method) throws EventConventionException, ClassNotFoundException { - JavaClass clazz = method.getParentClass(); + JavaClass clazz = method.getDeclaringClass(); //Check EventProducer conventions - if (!method.getReturnType().isVoid()) { + if (!method.getReturns().isVoid()) { throw new EventConventionException("All methods of interface " + clazz.getFullyQualifiedName() + " must have return type 'void'!"); } String methodSig = clazz.getFullyQualifiedName() + "." + method.getCallSignature(); - JavaParameter[] params = method.getParameters(); - if (params.length < 1) { + List<JavaParameter> params = method.getParameters(); + if (params.size() < 1) { throw new EventConventionException("The method " + methodSig + " must have at least one parameter: 'Object source'!"); } - Type firstType = params[0].getType(); - if (firstType.isPrimitive() || !"source".equals(params[0].getName())) { + JavaClass firstType = params.get(0).getJavaClass(); + if (firstType.isPrimitive() || !"source".equals(params.get(0).getName())) { throw new EventConventionException("The first parameter of the method " + methodSig + " must be: 'Object source'!"); } @@ -161,12 +149,12 @@ class EventProducerCollector { } EventMethodModel methodMeta = new EventMethodModel( method.getName(), severity); - if (params.length > 1) { - for (int j = 1, cj = params.length; j < cj; j++) { - JavaParameter p = params[j]; + if (params.size() > 1) { + for (int j = 1, cj = params.size(); j < cj; j++) { + JavaParameter p = params.get(j); Class<?> type; - JavaClass pClass = p.getType().getJavaClass(); - if (p.getType().isPrimitive()) { + JavaClass pClass = p.getJavaClass(); + if (pClass.isPrimitive()) { type = PRIMITIVE_MAP.get(pClass.getName()); if (type == null) { throw new UnsupportedOperationException( @@ -179,10 +167,10 @@ class EventProducerCollector { methodMeta.addParameter(type, p.getName()); } } - Type[] exceptions = method.getExceptions(); - if (exceptions != null && exceptions.length > 0) { + List<JavaClass> exceptions = method.getExceptions(); + if (exceptions != null && exceptions.size() > 0) { //We only use the first declared exception because that is always thrown - JavaClass cl = exceptions[0].getJavaClass(); + JavaClass cl = exceptions.get(0); methodMeta.setExceptionClass(cl.getFullyQualifiedName()); methodMeta.setSeverity(EventSeverity.FATAL); //In case it's not set in the comments }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2