本文整理汇总了Java中com.thoughtworks.qdox.model.DocletTag类的典型用法代码示例。如果您正苦于以下问题:Java DocletTag类的具体用法?Java DocletTag怎么用?Java DocletTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocletTag类属于com.thoughtworks.qdox.model包,在下文中一共展示了DocletTag类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addJsonSchemaDefinition
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addJsonSchemaDefinition(ObjectNode definitions, DocletTag tag) {
File definitionsDirectory = new File(srcDirectory + "/src/main/resources/definitions");
if (tag != null) {
tag.getParameters().stream().forEach(param -> {
try {
File config = new File(definitionsDirectory.getAbsolutePath() + "/"
+ param + ".json");
definitions.putPOJO(param, jsonParser.parse(new FileReader(config)));
} catch (IOException e) {
getLog().error(String.format("Could not process %s in %[email protected]%s: %s",
tag.getName(), tag.getContext(), tag.getLineNumber(),
e.getMessage()));
throw Throwables.propagate(e);
}
});
}
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OnosSwaggerMojo.java
示例2: addResponses
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addResponses(ObjectNode methodNode, DocletTag tag, boolean responseJson) {
ObjectNode responses = mapper.createObjectNode();
methodNode.set("responses", responses);
ObjectNode success = mapper.createObjectNode();
success.put("description", "successful operation");
responses.set("200", success);
if (tag != null && responseJson) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(
param -> schema.put("$ref", "#/definitions/" + param));
success.set("schema", schema);
}
ObjectNode defaultObj = mapper.createObjectNode();
defaultObj.put("description", "Unexpected error");
responses.set("default", defaultObj);
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OnosSwaggerMojo.java
示例3: getTagListAsMap
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private static Map<String, String> getTagListAsMap( List<DocletTag> tagList, boolean simpleName )
{
Map<String, String> map = new HashMap<String, String>();
for ( DocletTag tag : tagList )
{
String value = tag.getValue();
int firstSpace = value.indexOf( ' ' );
if ( firstSpace > 0 )
{
String subTag = value.substring( 0, firstSpace );
if ( simpleName )
{
subTag = Util.getSimpleName( subTag );
}
String comment = value.substring( firstSpace + 1 );
map.put( subTag, comment );
}
}
return map;
}
开发者ID:mojohaus,项目名称:servicedocgen-maven-plugin,代码行数:21,代码来源:JMethod.java
示例4: addJsonSchemaDefinition
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addJsonSchemaDefinition(ObjectNode definitions, DocletTag tag) {
File definitionsDirectory = new File(srcDirectory + "/src/main/resources/definitions");
if (tag != null) {
tag.getParameters().forEach(param -> {
try {
File config = new File(definitionsDirectory.getAbsolutePath() + "/"
+ param + ".json");
definitions.putPOJO(param, jsonParser.parse(new FileReader(config)));
} catch (IOException e) {
getLog().error(String.format("Could not process %s in %[email protected]%s: %s",
tag.getName(), tag.getContext(), tag.getLineNumber(),
e.getMessage()));
throw Throwables.propagate(e);
}
});
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:OnosSwaggerMojo.java
示例5: addResponses
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addResponses(ObjectNode methodNode, DocletTag tag, boolean responseJson) {
ObjectNode responses = mapper.createObjectNode();
methodNode.set("responses", responses);
ObjectNode success = mapper.createObjectNode();
success.put("description", "successful operation");
responses.set("200", success);
if (tag != null && responseJson) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().forEach(
param -> schema.put("$ref", "#/definitions/" + param));
success.set("schema", schema);
}
ObjectNode defaultObj = mapper.createObjectNode();
defaultObj.put("description", "Unexpected error");
responses.set("default", defaultObj);
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:OnosSwaggerMojo.java
示例6: JavaDocData
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
/**
* Creates a JavaDocData for a particular entry with the supplied JavaDoc comment and List of DocletTags.
*
* @param comment The actual comment in the JavaDoc. Null values are replaced with the value {@code NO_COMMENT},
* to ensure that the {@code getComment() } method does not return null values.
* @param tags The DocletTags of the JavaDoc entry. Can be null or empty.
*/
public JavaDocData(final String comment, final List<DocletTag> tags) {
// Assign internal state
this.comment = comment == null ? NO_COMMENT : comment;
this.tag2ValueMap = new TreeMap<String, String>();
// Parse, and assign internal state
for (DocletTag current : tags) {
final String tagName = current.getName();
String tagValue = current.getValue();
// Handle the case of multi-valued tags, such as
//
// @author SomeAuthor
// @author AnotherAuthor
//
// which becomes [author] --> [SomeAuthor, AnotherAuthor]
String currentValue = tag2ValueMap.get(tagName);
if (currentValue != null) {
tagValue = currentValue + ", " + current.getValue();
}
tag2ValueMap.put(tagName, tagValue);
}
}
开发者ID:mojohaus,项目名称:jaxb2-maven-plugin,代码行数:34,代码来源:JavaDocData.java
示例7: addJsonSchemaDefinition
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addJsonSchemaDefinition(File srcDirectory, ObjectNode definitions, DocletTag tag) {
final File definitionsDirectory;
if (resourceDirectory != null) {
definitionsDirectory = new File(resourceDirectory, "definitions");
} else if (srcDirectory != null) {
definitionsDirectory = new File(srcDirectory + "/src/main/resources/definitions");
} else {
definitionsDirectory = null;
}
if (tag != null) {
tag.getParameters().forEach(param -> {
try {
File config;
if (definitionsDirectory != null) {
config = new File(definitionsDirectory.getAbsolutePath() + "/" + param + ".json");
} else {
config = resources.stream().filter(f -> f.getName().equals(param + ".json")).findFirst().orElse(null);
}
definitions.set(param, mapper.readTree(config));
} catch (IOException e) {
throw new RuntimeException(String.format("Could not process %s in %[email protected]%s: %s",
tag.getName(), tag.getContext(), tag.getLineNumber(),
e.getMessage()), e);
}
});
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:28,代码来源:SwaggerGenerator.java
示例8: addResponses
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void addResponses(JavaMethod javaMethod, ObjectNode methodNode, DocletTag tag, boolean responseJson) {
ObjectNode responses = mapper.createObjectNode();
methodNode.set("responses", responses);
Optional<JavaAnnotation> responsesAnnotation = getResponsesAnnotation(javaMethod);
if (responsesAnnotation.isPresent()) {
Object annotationsObj = responsesAnnotation.get().getNamedParameter("value");
if (annotationsObj != null && annotationsObj instanceof List) {
List<JavaAnnotation> responseAnnotation = (List<JavaAnnotation>) annotationsObj;
responseAnnotation.forEach(
javaAnnotation -> {
ObjectNode response = mapper.createObjectNode();
response.put("description",
String.valueOf(javaAnnotation.getNamedParameter("message"))
.replaceAll("^\"|\"$", ""));
responses.set(String.valueOf(javaAnnotation.getNamedParameter("code")), response);
}
);
}
} else {
ObjectNode success = mapper.createObjectNode();
success.put("description", "successful operation");
responses.set("200", success);
ObjectNode defaultObj = mapper.createObjectNode();
defaultObj.put("description", "Unexpected error");
responses.set("default", defaultObj);
if (tag != null && responseJson) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(
param -> schema.put("$ref", "#/definitions/" + param));
success.set("schema", schema);
}
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:38,代码来源:SwaggerGenerator.java
示例9: processRestMethod
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void processRestMethod(JavaMethod javaMethod, String method,
Map<String, ObjectNode> pathMap,
String resourcePath, ArrayNode tagArray, ObjectNode definitions) {
String fullPath = resourcePath, consumes = "", produces = "",
comment = javaMethod.getComment();
DocletTag tag = javaMethod.getTagByName("onos.rsModel");
for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
String name = annotation.getType().getName();
if (name.equals(PATH)) {
fullPath = resourcePath + "/" + getPath(annotation);
fullPath = fullPath.replaceFirst("^//", "/");
}
if (name.equals(CONSUMES)) {
consumes = getIOType(annotation);
}
if (name.equals(PRODUCES)) {
produces = getIOType(annotation);
}
}
ObjectNode methodNode = mapper.createObjectNode();
methodNode.set("tags", tagArray);
addSummaryDescriptions(methodNode, comment);
addJsonSchemaDefinition(definitions, tag);
processParameters(javaMethod, methodNode, method, tag);
processConsumesProduces(methodNode, "consumes", consumes);
processConsumesProduces(methodNode, "produces", produces);
if (tag == null || ((method.toLowerCase().equals("post") || method.toLowerCase().equals("put"))
&& !(tag.getParameters().size() > 1))) {
addResponses(methodNode, tag, false);
} else {
addResponses(methodNode, tag, true);
}
ObjectNode operations = pathMap.get(fullPath);
if (operations == null) {
operations = mapper.createObjectNode();
operations.set(method, methodNode);
pathMap.put(fullPath, operations);
} else {
operations.set(method, methodNode);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:46,代码来源:OnosSwaggerMojo.java
示例10: processParameters
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
getLog().warn(String.format(
"No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}
开发者ID:shlee89,项目名称:athena,代码行数:64,代码来源:OnosSwaggerMojo.java
示例11: processRestMethod
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void processRestMethod(JavaMethod javaMethod, String method,
Map<String, ObjectNode> pathMap,
String resourcePath, ArrayNode tagArray,
ObjectNode definitions, File srcDirectory) {
String fullPath = resourcePath, consumes = "", produces = "",
comment = javaMethod.getComment();
DocletTag tag = javaMethod.getTagByName("onos.rsModel");
for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
String name = annotation.getType().getName();
if (name.equals(PATH)) {
fullPath = resourcePath + "/" + getPath(annotation);
fullPath = fullPath.replaceFirst("^//", "/");
}
if (name.equals(CONSUMES)) {
consumes = getIOType(annotation);
}
if (name.equals(PRODUCES)) {
produces = getIOType(annotation);
}
}
ObjectNode methodNode = mapper.createObjectNode();
methodNode.set("tags", tagArray);
addSummaryDescriptions(methodNode, comment);
addJsonSchemaDefinition(srcDirectory, definitions, tag);
processParameters(javaMethod, methodNode, method, tag);
processConsumesProduces(methodNode, "consumes", consumes);
processConsumesProduces(methodNode, "produces", produces);
if (tag == null || !(tag.getParameters().size() > 1)) {
addResponses(javaMethod, methodNode, tag, false);
} else {
addResponses(javaMethod, methodNode, tag, true);
}
ObjectNode operations = pathMap.get(fullPath);
if (operations == null) {
operations = mapper.createObjectNode();
operations.set(method, methodNode);
pathMap.put(fullPath, operations);
} else {
operations.set(method, methodNode);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:46,代码来源:SwaggerGenerator.java
示例12: processParameters
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
throw new RuntimeException(String.format("No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:63,代码来源:SwaggerGenerator.java
示例13: processParameters
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
getLog().warn(String.format(
"No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}
开发者ID:opennetworkinglab,项目名称:onos,代码行数:64,代码来源:OnosSwaggerMojo.java
示例14: createMethodModel
import com.thoughtworks.qdox.model.DocletTag; //导入依赖的package包/类
private EventMethodModel createMethodModel(JavaMethod method)
throws EventConventionException, ClassNotFoundException {
JavaClass clazz = method.getParentClass();
//Check EventProducer conventions
if (!method.getReturnType().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) {
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())) {
throw new EventConventionException("The first parameter of the method " + methodSig
+ " must be: 'Object source'!");
}
//build method model
DocletTag tag = method.getTagByName("event.severity");
EventSeverity severity;
if (tag != null) {
severity = EventSeverity.valueOf(tag.getValue());
} else {
severity = EventSeverity.INFO;
}
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];
Class<?> type;
JavaClass pClass = p.getType().getJavaClass();
if (p.getType().isPrimitive()) {
type = PRIMITIVE_MAP.get(pClass.getName());
if (type == null) {
throw new UnsupportedOperationException(
"Primitive datatype not supported: " + pClass.getName());
}
} else {
String className = pClass.getFullyQualifiedName();
type = Class.forName(className);
}
methodMeta.addParameter(type, p.getName());
}
}
Type[] exceptions = method.getExceptions();
if (exceptions != null && exceptions.length > 0) {
//We only use the first declared exception because that is always thrown
JavaClass cl = exceptions[0].getJavaClass();
methodMeta.setExceptionClass(cl.getFullyQualifiedName());
methodMeta.setSeverity(EventSeverity.FATAL); //In case it's not set in the comments
}
return methodMeta;
}
开发者ID:pellcorp,项目名称:fop,代码行数:58,代码来源:EventProducerCollector.java
注:本文中的com.thoughtworks.qdox.model.DocletTag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论