{"id":506,"date":"2004-03-12T10:23:13","date_gmt":"2004-03-12T01:23:13","guid":{"rendered":"\/?p=506"},"modified":"2004-03-12T10:23:13","modified_gmt":"2004-03-12T01:23:13","slug":"java2-sdk-15-tiger-metadata","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/506.html","title":{"rendered":"Java2 SDK 1.5 (Tiger) [Metadata]"},"content":{"rendered":"<p>\nRef: <a href=\"http:\/\/java.sun.com\/developer\/technicalArticles\/releases\/j2se15\/\">J2SE 1.5 in a Nutshell<\/a>\n<\/p>\n<p>\n<a href=\"http:\/\/java.sun.com\/j2se\/1.5.0\/ja\/download.html\">J2SE 1.5 (Tiger) download<\/a> \u304b\u3089 J2SE 1.5 \u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3088\u3046\u3002\u4e3b\u8981\u306a\u5909\u66f4\u70b9\u3092\u8a66\u3059\u306e\u306b\u5fd8\u308c\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u306f\u3001javac \u30b3\u30de\u30f3\u30c9\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u304d\u306b -source 1.5 \u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3060\u3051\u3060\u3002\n<\/p>\n<p><div class=\"code\">javac -source 1.5 GenericTest.java<\/div>\n<\/p>\n<p>\nNutshell\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u6b21\u306e\u5185\u5bb9\u306b\u3064\u3044\u3066\u307f\u3066\u307f\u3088\u3046\u3002<br \/>\n\u30fbMetadata<\/p>\n<p>\n<!--more--><\/p>\n<h2>Metadata<\/h2>\n<p><font color=\"red\">\u6ce8\u610f &#8230; \u5b8c\u5168\u306b\u7406\u89e3\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u9593\u9055\u3044\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u52d8\u9055\u3044\u306a\u3069\u3042\u308a\u307e\u3057\u305f\u3089\u3001\u3054\u6307\u6458\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/font><\/p>\n<p>\nMetadata\u306f\u666e\u901a\u306e\u30e6\u30fc\u30b6\u30fc\u306f\u3042\u307e\u308a\u5b9a\u7fa9\u3057\u306a\u3044\u3060\u308d\u3046\u304c\u3001\u958b\u767a\u30c4\u30fc\u30eb\u306a\u3069\u304c\u5229\u7528\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u3060\u308d\u3046\u3002\u305f\u3068\u3048\u3070\u3001XDoclet\u306a\u3069\u306f\u30b3\u30e1\u30f3\u30c8\u306e\u4e2d\u306b\u8a18\u8ff0\u3057\u305f\u7279\u6b8a\u306a\u30bf\u30b0\u3092\u5229\u7528\u3057\u30661\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u5fc5\u8981\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3059\u308b\u3002\u3053\u308c\u3089\u306e\u30b3\u30e1\u30f3\u30c8\u5185\u306e\u7279\u6b8a\u306a\u30bf\u30b0\u306f\u3001\u30af\u30e9\u30b9\u3084\u30e1\u30bd\u30c3\u30c9\u306a\u3069\u3068\u5f37\u304f\u7d50\u3073\u3064\u3044\u305f\u3082\u306e\u306a\u306e\u3060\u304c\u3001\u8a00\u8a9e\u4ed5\u69d8\u3067\u306f\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u305f\u3081\u3001\u4ed5\u65b9\u306a\u304f\u30b3\u30e1\u30f3\u30c8\u306e\u4e2d\u306b\u7d44\u307f\u3053\u3093\u3067\u3044\u305f\u306e\u3060\u3002\u3053\u3046\u3044\u3063\u305f\u7279\u6b8a\u306a\u30bf\u30b0\u3092\u8a00\u8a9e\u4ed5\u69d8\u3067\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306bMetadata\u304c\u5c0e\u5165\u3055\u308c\u305f\u3068\u8003\u3048\u3066\u826f\u3044\u3060\u308d\u3046\u3002\n<\/p>\n<p>\n\u305b\u3063\u304b\u304f\u8a00\u8a9e\u4ed5\u69d8\u3067\u3053\u3046\u3044\u3063\u305f\u3053\u3068\u3092\u5c0e\u5165\u3059\u308b\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u691c\u8a0e\u3055\u308c\u305f\u306e\u3060\u308d\u3046\u3002\u9762\u767d\u3044\u6a5f\u80fd\u304c\u591a\u3044\u3002Annotation\u3068\u3044\u3046\u3060\u3051\u3042\u3063\u3066\u3001\u5358\u306a\u308b\u30b3\u30e1\u30f3\u30c8\u3068\u306f\u9055\u3046\u6a5f\u80fd\u3092\u5b9f\u73fe\u3067\u304d\u308b\u3002java.lang.annotation.RetentionPolicy.SOURCE\u3092\u6307\u5b9a\u3059\u308c\u3070\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e0a\u3067\u306e\u30d2\u30f3\u30c8\u3068\u3057\u3066\u5229\u7528\u3067\u304d\u308b\u304c\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u305d\u306e\u30d2\u30f3\u30c8\u306f\u524a\u9664\u3055\u308c\u308b\u3002\u3057\u304b\u3057\u3001java.lang.annotation.RetentionPolicy.RUNTIME\u3092\u6307\u5b9a\u3059\u308c\u3070\u5b9f\u884c\u6642\u306b\u305d\u306eAnnotation\u3092\u53d6\u308a\u3060\u3057\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3002\u3057\u304b\u3082\u30d2\u30f3\u30c8\u60c5\u5831\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306b\u7279\u5225\u306ainterface\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u308b\u306e\u3060\u3002Nutshell\u3067\u306f\u3001Annotation\u306e\u5ba3\u8a00\u65b9\u6cd5\u3068\u3001\u30e1\u30bd\u30c3\u30c9\u306b\u3064\u3051\u3089\u308c\u3066\u3044\u308b\u30d2\u30f3\u30c8\u60c5\u5831\u3092\u3068\u308a\u3060\u3059\u65b9\u6cd5\u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u3002\u305d\u3061\u3089\u3082\u898b\u306a\u304c\u3089\u6b21\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u53c2\u8003\u306b\u3057\u3066\u3082\u3089\u3044\u305f\u3044\u3002\n<\/p>\n<p>\n\u3053\u3053\u3067\u306f\u3001\u5b9f\u884c\u6642\u306b\u5229\u7528\u53ef\u80fd\u306adebug, info \u3068\u3044\u3046\u30e1\u30bf\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3068\u3001\u958b\u767a\u6642\u306b\u5229\u7528\u53ef\u80fd\u306atodo\u3068\u3044\u3046\u30e1\u30bf\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3092\u7528\u610f\u3057\u3066\u307f\u305f\u3002MetadataTest\u306e\u30e1\u30bd\u30c3\u30c9 testMethod1, testMethod2 \u306b Annotation \u3092\u8a18\u8ff0\u3057\u3066\u3044\u308b\u3002\n<\/p>\n<div class=\"code\">import java.lang.annotation.Annotation;<br \/>\nimport java.lang.annotation.Retention;<br \/>\nimport java.lang.annotation.RetentionPolicy;<br \/>\nimport java.lang.reflect.*;<\/p>\n<p>@Retention(RetentionPolicy.RUNTIME) @interface debug {<br \/>\n    boolean isDebugMode() default false;<br \/>\n    int priority();<br \/>\n}<br \/>\n@Retention(RetentionPolicy.RUNTIME) @interface info {<br \/>\n    String info() default &#8220;&#8221;;<br \/>\n}<br \/>\n@Retention(RetentionPolicy.SOURCE) @interface todo {<br \/>\n    String memo() default &#8220;Todo&#8221;;<br \/>\n}<\/p>\n<p>public class MetadataTest {<br \/>\n    final boolean debugMode=true;<\/p>\n<p>    @debug(isDebugMode=debugMode,priority=2)<br \/>\n    public void testMethod1()  {<br \/>\n    }<\/p>\n<p>    @debug(isDebugMode=debugMode,priority=1)<br \/>\n    @info(info=&#8221;something&#8221;)<br \/>\n    @todo(memo=&#8221;priority 1&#8243;)<br \/>\n    public void testMethod2()  {<br \/>\n    }<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        MetadataTest mt = new MetadataTest();<br \/>\n        try {<br \/>\n            Annotation[] a = mt.getClass().<br \/>\n                             getMethod(&#8220;testMethod1&#8221;).getAnnotations();<br \/>\n            for (Annotation i : a) {<br \/>\n                 System.out.println(&#8220;testMethod1 anotations: &#8220;+i);<br \/>\n            }<br \/>\n            a = mt.getClass().getMethod(&#8220;testMethod2&#8221;).getAnnotations();<br \/>\n            for (Annotation i : a) {<br \/>\n                 System.out.println(&#8220;testMethod2 anotations: &#8220;+i);<br \/>\n            }<br \/>\n         } catch(NoSuchMethodException e) {<br \/>\n             System.out.println(e);<br \/>\n         }<br \/>\n     }<br \/>\n }<\/p><\/div>\n<p>\n\u5b9f\u884c\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308b\u3002\u5b9f\u884c\u6642\u306b\u53d6\u308a\u3060\u3055\u308c\u308b\u3082\u306e\u3068\u3001\u53d6\u308a\u3060\u3055\u308c\u306a\u3044\u3082\u306e\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3060\u308d\u3046\u3002todo\u306e\u3088\u3046\u306a\u3082\u306e\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u7de8\u96c6\u6642\u306b\u5fc5\u8981\u306a\u3060\u3051\u306a\u306e\u3067\u3001\u5b9f\u884c\u6642\u306b\u53d6\u308a\u3060\u305b\u308b\u5fc5\u8981\u306f\u306a\u3044\u3002\u5b9f\u884c\u6642\u306bdebug\u306eprioriy\u306e\u5024\u306b\u3088\u3063\u3066\u51e6\u7406\u306e\u5206\u5c90\u3092\u3055\u305b\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3001\u7d71\u5408\u74b0\u5883\u306e\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\u306e\u304d\u3081\u7d30\u304b\u306a\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u305d\u3046\u3060\u3002info\u306f\u8907\u6570\u306eAnnotation\u3092\u95a2\u9023\u3065\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3053\u3068\u306e\u78ba\u8a8d\u306e\u305f\u3081\u306b\u3064\u3051\u305f\u3060\u3051\u306a\u306e\u3067\u3001\u3053\u3053\u3067\u306f\u305d\u308c\u4ee5\u5916\u306b\u7279\u5225\u306a\u610f\u5473\u306f\u306a\u3044\u3002\n<\/p>\n<div class=\"code\">$ javac -source 1.5 MetadataTest.java<br \/>\n$ java MetadataTest<br \/>\ntestMethod1 anotations: @debug(isDebugMode=true, priority=2)<br \/>\ntestMethod2 anotations: @debug(isDebugMode=true, priority=1)<br \/>\ntestMethod2 anotations: @info(info=something)\n<\/div>\n<p>\u958b\u767a\u30c4\u30fc\u30eb\u3092\u63d0\u4f9b\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30de\u306b\u3068\u3063\u3066\u306f\u9b45\u529b\u7684\u306a\u6a5f\u80fd\u3060\u304c\u3001\u901a\u5e38\u306e\u30d7\u30ed\u30b0\u30e9\u30de\u306b\u3068\u3063\u3066\u306f\u3069\u3093\u306a\u6d3b\u7528\u6cd5\u304c\u3042\u308b\u306e\u304b\u3001\u3068\u3044\u3046\u306e\u306f\u3061\u3087\u3063\u3068\u307f\u3048\u306b\u304f\u3044\u3002\u3057\u304b\u3057\u3001Metadata\u3092\u3046\u307e\u304f\u5229\u7528\u3057\u3066\u3042\u3052\u308b\u3068\u3001\u958b\u767a\u52b9\u7387\u3092\u3042\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u3044\u3046\u306e\u306f\u60f3\u50cf\u3067\u304d\u308b\u3002\u8208\u5473\u6df1\u3044\u6a5f\u80fd\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ref: J2SE 1.5 in a Nutshell J2SE 1.5 (Tiger) download \u304b\u3089 J2SE 1.5 \u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3088\u3046\u3002\u4e3b\u8981\u306a\u5909\u66f4\u70b9\u3092\u8a66\u3059\u306e\u306b\u5fd8\u308c\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u306f\u3001jav &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/506.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=506"}],"version-history":[{"count":0,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/506\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}