这个工具已经更新了http://blog.csdn.net/b275518834/article/details/44515675
因为经常做开发的时候很多工作是重复的,繁琐的,所以做了一个小工具把经常用的接口转化为实体工具
将本来几个小时的工作量缩短到数分钟
为了更方便自己做了一个桌面工具来快速拖动自己获得转换实体类的效果目前时间有限只做了自己经常用到3个实体类工具
以后再开发遇上xml或者数据库之类需要生成实体,也会集成到桌面工具里。
目前做了3个 json实体类工具
1:GSON解析json实体类 参考Main1.java
2:url get请求解析实体类 参数Main2.java
3:android findbyID 快速映射 参考Main3.java
源码和工具下载:http://pan.baidu.com/s/1ntmNN4H
桌面工具如图
代码参考Main1.java----------------------------------------------------------------------------
{ "alipay_user_account_search_response":{ "total_results":1000, "total_pages":50, "account_records":{ "account_record":[{ "type":"JF", "business_type":"", "alipay_order_no":"20130422115526888888", "merchant_order_no":"20130422115526005800", "create_time":"2013-4-22 11:55:27" }] } } }
import java.lang.reflect.Field; import java.io.Serializable; import java.util.List; public class JSON1 implements Serializable { public Alipay_user_account_search_response alipay_user_account_search_response; public class Alipay_user_account_search_response implements Serializable { public int total_pages; public int total_results; public Account_records account_records; public class Account_records implements Serializable { public List<Account_record> account_record; public class Account_record implements Serializable { public String alipay_order_no; public String merchant_order_no; public String create_time; public String self_user_id; public String business_type; public String type; } } } }
代码参考Main2.java----------------------------------------------------------------------------
www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=json
public static void main(String[] args) throws Exception { //生成实体类 new UrlParamsEntityTools().read(json).commit(); TestHttp http=new TestHttp(); http.wd="java"; System.out.println(http.getFullUrlToString()); String result=HttpRequest.sendGet(http.getFullUrlToString()); Thread.sleep(3000); System.out.println(result); } public static class TestHttp extends AbsHttpUrl implements IHttpUrl { //**utf-8*/ public String ie; //**8*/ public String f; //**1*/ public String rsv_bp; //**baidu*/ public String tn; //**json*/ public String wd; @Override public String getUrl() { // TODO Auto-generated method stub return "http://www.baidu.com/s"; } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:module="http://schemas.android.com/apk/res-auto" > <TextView android:id="@id/text1" /> <ImageView android:id="@id/img1C" /> <View android:id="@id/view3" /> </RelativeLayout>
@TAInjectView(id = R.id.text1) public TextView text1; @TAInjectView(id = R.id.img1C) public ImageView img1C; @TAInjectView(id = R.id.view3) public View view3;