用于多行文本的 Java 注释实用程序 [英] Java annotation utility for multiline text

查看:35
本文介绍了用于多行文本的 Java 注释实用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WRT 多行 Java 字符串的任何未来计划.>

编写一个执行以下操作的实用程序有多难?

@AllYouCanEatText(return="query")私有字符串 getQuery(String empid, String[] 列) {字符串查询;/*选择 ${列}来自员工哪里 empid = ${empid};*/返回查询;};

当然,在我跳到枪管前面之前,我应该问 - 这样的实用程序是否已经可用?如果有,在哪里?

手头的问题实际上是 - 我如何在编译时在反射中阅读评论部分.作为我对反射和注释处理的(令人沮丧的)熟悉程度的一个指示——我最后一次使用反射是在运行时读取方法.编译时反射是否可行?

有没有人有兴趣与我分享一个谷歌代码项目来做到这一点?可能已经有一个 apache 项目在进行中?

解决方案

我不久前遇到了这个,我自己从未使用过,但我认为它是您正在寻找的 http://www.adrianwalker.org/2011/12/java-multiline-string.html

WRT Any Future Plans for Multiline Java String.

How difficult is it to write a utility that does the following?

@AllYouCanEatText(return="query")
private String getQuery(String empid, String[] columns) {
  String query;
  /*
  SELECT ${columns}
  FROM Employees
  WHERE empid = ${empid}
  ;
  */
  return query;
};

Of course, before I jump in front of the barrel, I should have asked - Is such a utility already available? If so, where?

The issue at hand is actually - how do I read the comments section in reflection during compile time. As an indication of my (dismal) level of familiarity with Reflection and annotation processing - the last time I used reflection was run-time to read methods. Is compile-time reflection possible?

Is anyone interested in sharing a google code project with me to do this? May be there is already an apache project afoot?

解决方案

I came across this a while ago, never used it myself, but I think its what you are looking for http://www.adrianwalker.org/2011/12/java-multiline-string.html

这篇关于用于多行文本的 Java 注释实用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆