Back to project page DEVIEW2014_AndroidApp_Demo.
The source code is released under:
Apache License
If you think the Android project DEVIEW2014_AndroidApp_Demo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nhn.android.deview.core.transfer; // w w w.j a v a 2 s. c o m import java.lang.reflect.Field; import android.net.Uri; public class UriObject { public UriObject(Uri uri) { Field[] fields = getClass().getFields(); for (Field field : fields) { String value = uri.getQueryParameter(field.getName()); if (value != null) { setStrToFieldValue(field,this, value); } } } boolean setStrToFieldValue(Field field,Object object,String value) { try { String tn = field.getType().getSimpleName(); if (field.getType().isPrimitive() == true) { if (tn.equals("int")) { field.setInt(object, Integer.parseInt(value)); } else if (tn.equals("float")) { field.setFloat(object, Float.parseFloat(value)); } else { return false; } } else { if (tn.equals("String") == true || tn.equals("Integer") || tn.equals("Float")) { field.set(object, value); } return true; } } catch (Exception e) { } return false; } }