读书人

[Java] Annotation(内注)范例一则

发布时间: 2012-09-22 21:54:54 作者: rapoo

[Java] Annotation(内注)实例一则

为下篇“[Android] 数据实体的自动存取--SQLite篇”准备
* 参考地址:http://www.blogjava.net/ericwang/archive/2005/12/13/23743.html
* http://www.blogjava.net/weidagang2046/articles/27958.html
* http://www.blogjava.net/mlh123caoer/archive/2007/09/06/143260.html
* 官方文档:
* http://docs.oracle.com/javase/tutorial/java/javaOO/annotations.html

以上链接很全面,不过多说明了。直接上代码,仅做备份

package lab.sodino.annotation;@author(name="sodino",webSite="sodino.com")//以"key=value"的形式进行赋值。public class GoodsBean {@uniquepublic long id;public String name;public long time;public int price;public boolean isPaid;/** 测试用。 */public byte testByte;/** 测试用。 */public short testShort;public float cicle;public double testDouble;public String toString() {StringBuffer strBuffer = new StringBuffer();strBuffer.append("id[" + id + "]\n");strBuffer.append("name[" + name + "]\n");strBuffer.append("time[" + time + "]\n");strBuffer.append("price[" + price + "]\n");strBuffer.append("isPaid[" + isPaid + "]\n");strBuffer.append("cicle[" + cicle + "]\n");strBuffer.append("testByte[" + testByte + "]\n");strBuffer.append("testShort[" + testShort + "]\n");strBuffer.append("testDouble[" + testDouble + "]\n");return strBuffer.toString();}public static GoodsBean newInstance() {GoodsBean bean = new GoodsBean();bean.id = 123456789l;bean.name = "AutoSave";bean.time = 12345234252342l;bean.price = 1024;bean.isPaid = true;bean.cicle = 2.356f;bean.testByte = 8;bean.testShort = 128;bean.testDouble = 9856.2145d;return bean;}}


读书人网 >编程

热点推荐