GVKun编程网logo

将编程注释添加到Java类(将编程注释添加到java类中)

31

本文将带您了解关于将编程注释添加到Java类的新内容,同时我们还将为您解释将编程注释添加到java类中的相关知识,另外,我们还将为您提供关于GWT-将外部Java类添加到客户端项目、IDEA添加Jav

本文将带您了解关于将编程注释添加到Java类的新内容,同时我们还将为您解释将编程注释添加到java类中的相关知识,另外,我们还将为您提供关于GWT-将外部Java类添加到客户端项目、IDEA添加Java类注释模版的方法、ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?、Java 6-将java.sql.Types映射到Java类型的实用信息。

本文目录一览:

将编程注释添加到Java类(将编程注释添加到java类中)

将编程注释添加到Java类(将编程注释添加到java类中)

用法示例:
我想在类字段上添加一个自定义注释@MyContainer,然后在所有这些字段上自动添加相关的Hibernate注释(取决于字段类型和属性).
另外,我需要将JAXB XmlType注释添加到类中,并将类型名称基于类名.
我还想要根据其类型等向字段添加注释.
所有添加的注释都应该在运行时可用(因此hibernate / JAXB可以找到它们).
我知道以下选项:

>预处理类源(错误选项)
>使用javax.annotation.processing API进行编译期间的处理
>使用Java Assist等工具进行编译后操作
>使用java.lang.instrument API加载类时的操作
>使用AspectJ(功能不够强大)

我的主要目标是:

>在类和源之间保持同步以进行调试
>支持Maven和IDE(Eclipse / Intellij)的工作

如果已经完成此类工作的人能够为这样的任务推荐最佳方法(也许还有潜在的陷阱),我将不胜感激.

解决方法

我认为预处理类源应该是您的首选方式.这使您可以使源与已编译的类同步,这对于您提到的调试很有用.但它也适用于版本控制,因为您可以检入那些生成的注释.如果在编译期间运行它,那么跟踪工具中的问题也要困难得多.在generate-sources阶段运行代码生成时,IDE支持也应该没有问题.

编辑:
快速搜索产生了一些关于程序化java源代码修改的信息
using the eclipse jdt或some thing in netbeans.但这可能值得更多的研究或自己的问题.

GWT-将外部Java类添加到客户端项目

GWT-将外部Java类添加到客户端项目

我有一个GWT项目。客户端代码位于“客户端”目录中。我想附加外部目录中的外部Java类(主要是普通的POJO DTO类)。如何配置gwt.xml文件?

我收到此类错误:

[错误]“文件:/
C:/development/projects/CodeSpaces/LocateMe/LocateMeWeb/src/com/dominolog/locateme/client/LocateMeWeb.java”中的错误[错误]第56行:com类型的源代码不可用.dominolog.locateme.model.dto.LocationInfo;
您忘了继承必需的模块吗?

IDEA添加Java类注释模版的方法

IDEA添加Java类注释模版的方法

本篇文章主要介绍了IDEA添加java类注释模版的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

本文介绍了IDEA添加java类注释模版的方法,分享给大家,具体如下:

IDEA版本:IntelliJ IDEA 2017.2.5 x64

eclipse能在类上方输入/**,回车添加类注释模版,但idea没有默认添加这个功能,需要做一些设置。下面介绍三种方法实现:

创建类默认添加类注释

手动添加类注释

批量添加JavaDoc注释

一、设置新建类默认添加注释

依次点击Setting|Editor|File and code templates,添加如图配置

例子:

/** *describe: * *@author xxx *@date ${YEAR}/${MONTH}/${DAY} */

支持的变量在描述内,找到需要配置即可!

二、利用Live Template手动添加注释模版

依次点击Setting|Editor|Live templates

1、点击+添加templates group,如My Live Templates

2、点击+添加live templates,修改abbreviation,再添加模版内容,模版变量以$var$格式定义,如

/** *describe: * *@author xxx *@date $date$ */

 

3. 点击define定义模版作用范围,选择Java

 

4. 点击Edit variables定义变量,表达式解释见附件

 

5. 保存后,在类任意位置输入cc即可添加模版

三、批量添加注释

安装JavaDoc插件,alt+insert即可批量添加注释,包括所有类和方法,但是不能定制化,注释都是固定的。

附件

Item Description annotated("annotation qname") Creates a symbol of type with an annotation that resides at the specified location. For an example, see Live Templates in the iterations group. arrayVariable() Suggests all array variables applicable in the current scope. For an example, see Live Templates in the iterations group. anonymoussuper() Suggests a supertype for a Kotlin object expression. camelCase(String) Returns the string passed as a parameter, converted to camel case. For example, my-text-file/my text file/my_text_file will be converted to myTextFile. capitalize(String) Capitalizes the first letter of the name passed as a parameter. capitalizeAndUnderscore(sCamelCaseName) Capitalizes the all letters of a CamelCase name passed as a parameter, and inserts an underscore between the parts. For example, if the string passed as a parameter is FooBar, then the function returns FOO_BAR. castToLeftSideType() Casts the right-side expression to the left-side expression type. It is used in the iterations group to have a single template for generating both raw-type and Generics Collections. className(sClassName) Returns the name of the current class (the class where the template is expanded). classNameComplete() This expression substitutes for the class name completion at the variable position. clipboard() Returns the contents of the system clipboard. snakeCase(String) Returns CamelCase string out of snake_case string. For example, if the string passed as a parameter is foo_bar, then the function returns fooBar. complete() This expression substitutes for the code completion invocation at the variable position. completeSmart() This expression substitutes for the smart type completion invocation at the variable position. componentTypeOf () Returns component type of an array. For example, see the Live Templates in the iterations group in the other group. currentPackage() Returns the current package name. date(sDate) Returns the current system date in the specified format. By default, the current date is returned in the default system format. However, if you specify date format in double quotes, the date will be presented in this format: decapitalize(sName) Replaces the first letter of the name passed as a parameter with the corresponding lowercase letter. descendantClassEnum() Shows the children of the class entered as a string parameter. enum(sCompletionString1,sCompletionString2,...) List of comma-delimited strings suggested for completion at the template invocation. escapestring(sEscapestring) Escapes the specified string. expectedType() Returns the type which is expected as a result of the whole template. Makes sense if the template is expanded in the right part of an assignment, after return, etc. fileName(sFileName) Returns file name with extension. fileNameWithoutExtension() Returns file name without extension. firstWord(sFirstWord) Returns the first word of the string passed as a parameter. groovyScript("groovy code") Returns Groovy script with the specified code. You can use groovyScript macro with multiple arguments. The first argument is a script text that is executed or a path to the file that contains a script. The next arguments are bound to _1, _2, _3, ..._nvariables that are available inside your script. Also, _editor variable is available inside the script. This variable is bound to the current editor. guessElementType () Makes a guess on the type of elements stored in a java.util.Collection. To make a guess, IntelliJ IDEA tries to find the places where the elements were added to or extracted from the container. iterableComponentType() Returns the type of an iterable component, such as an array or a collection. iterableVariable() Returns the name of a variable that can be iterated. lineNumber() Returns the current line number. lowercaseAndDash(String) Returns lower case separated by dashes, of the string passed as a parameter. For example, the string MyExampleName is converted to my-example-name. methodName() Returns the name of the embracing method (where the template is expanded). methodParameters() Returns the list of parameters of the embracing method (where the template is expanded). methodReturnType() Returns the type of the value returned by the current method (the method within which the template is expanded). qualifiedClassName() Returns the fully qualified name of the current class (the class where the template is expanded). Clear the Shorten FQ names check Box. rightSideType() Declares the left-side variable with a type of the right-side expression. It is used in theiterations group to have a single template for generating both raw-type and Generics Collections. snakeCase(sCamelCaseText) Returns snake_case string out of CamelCase string passed as a parameter. spaceSeparated(String) Returns string separated with spaces out of CamelCase string passed as a parameter. For example, if the string passed as a parameter is fooBar, then the function returns foo bar. subtypes(sType) Returns the subtypes of the type passed as a parameter. suggestIndexName() Suggests the name of an index variable. Returns i if there is no such variable in scope, otherwise returns j if there is no such variable in scope, etc. suggestvariableName() Suggests the name for a variable based on the variable type and its initializer expression, according to your code style settings that refer to the variable naming rules. For example, if it is a variable that holds an element within iteration, IntelliJ IDEA makes a guess on the most reasonable names, also taking into account the name of the container being iterated. suggestFirstvariableName(sFirstvariableName) Doesn't suggest true, false, this, super. time(sSystemTime) Returns the current system time. typeOfVariable(VAR) Returns the type of the variable passed as a parameter. underscoresToCamelCase(sCamelCaseText) Returns the string passed as a parameter with CamelHump letters substituting for underscores. For example, if the string passed as a parameter is foo_bar, then the function returns fooBar. underscoresToSpaces(sParameterWithSpaces) Returns the string passed as a parameter with spaces substituting for underscores. user() Returns the name of the current user. variableOfType() Suggests all variables that may be assigned to the type passed as a parameter, for example variableOfType("java.util.Vector"). If you pass an empty string ("") as a parameter, suggests all variables regardless of their types. JsArrayVariable Returns JavaScript array name. jsClassName() Returns the name of the current JavaScript class. jsComponentType Returns the JavaScript component type. jsMethodName() Returns the name of the current JavaScript method. jsQualifiedClassName Returns the complete name of the current JavaScript class. jsSuggestIndexName Returns a suggested name for an index. jsSuggestvariableName Returns a suggested name for a variable.

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持小编。

ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?

ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?

我使用viewDidLoad中的以下代码创建了一个UIView(其中’secondview’显然是UIView的名称):

secondview = [[UIView alloc] initWithFrame:self.view.frame];
    [secondview setBackgroundColor: [UIColor yellowColor]];
    secondview.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:secondview];

然后在viewDidAppear中,我添加了这个视图的约束:

NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:secondview attribute:NSLayoutAttributeRight
    relatedBy:NSLayoutRelationEqual
    toItem:self.view
    attribute:NSLayoutAttributeRight
    multiplier:1.0f constant:-20.0f];
[self.view addConstraint:constraint];

但是,约束不适用于视图(至少不是我可以看到的)。相反,该视图似乎从屏幕上消失。然而,如果约束代码被注释掉,则视图再次加载适当的框架(显然没有使用约束)。当对Button或ImageView应用相同的约束时,约束将被完美地应用。这导致我认为问题是因为创建视图时的’initWithFrame’,因为按钮和ImageView实际上都不需要指定它的大小。

你怎么看?我该怎么做不同

解决方法

对于遇到这个的任何人,我需要添加多个约束。这样做了。

Java 6-将java.sql.Types映射到Java类型

Java 6-将java.sql.Types映射到Java类型

我正在寻找一个表的链接,该表包含SQL类型(java.sql.Types)与Java类型之间的映射。

你知道我在哪里可以找到吗?

答案1

小编典典

JDBC 4.x的规范 ,通过提供JSR
221,提供在标题为附录B中该信息 数据类型转换表

请参阅包含从Java对象类型到JDBC类型的映射的表。当调用JDBC
API的不同方法时,将有不同的表用于映射。例如,在方法期间使用的映射存在一个单独的映射CallableStatement.getObjectResultSet.getObject而另一个存在ResultSet.getXXX

单击该JSR
221页面以下载规范文档的PDF,当前为JDBC
4.3。

关于将编程注释添加到Java类将编程注释添加到java类中的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于GWT-将外部Java类添加到客户端项目、IDEA添加Java类注释模版的方法、ios – 如何以编程方式将编程方式添加到以编程方式创建的UIView?、Java 6-将java.sql.Types映射到Java类型等相关知识的信息别忘了在本站进行查找喔。

本文标签: