e")) {
latitude = jObj.getDouble("latitude");
}
if (jObj.has("longitude")) {
longitude = jObj.getDouble("longitude");
}
return this;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public boolean isBusinessLicence() {
return businessLicence;
}
public void setBusinessLicence(boolean businessLicence) {
this.businessLicence = businessLicence;
}
public boolean isHygieneLicence() {
return hygieneLicence;
}
public void setHygieneLicence(boolean hygieneLicence) {
this.hygieneLicence = hygieneLicence;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getEnterprise() {
return enterprise;
}
public void setEnterprise(String enterprise) {
this.enterprise = enterprise;
}
public String getPrincipal() {
return principal;
}
public void setPrincipal(String principal) {
this.principal = principal;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
boolean isMe(String category) {
this.category.equals(category);
}
public String getContent() {
return note;
}
public Drawable getIcon() {
return null;
}
String getVillage() {
return null;
}
public String getCell() {
return null;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
// 反射代码,
final private Map methodMap = new HashMap();// 以set开始的方法的map
// 可以直接获取需要的set方法.
protected void init() {
Class< > userClass = this.getClass();// Class.forName(this.getClass()); 加载类
Method[] methods = userClass.getDeclaredMethods();// 获得类的方法集合
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().startsWith("set")) {
methodMap.put(methods[i].getName().toLowerCase(), methods[i]);
}
}
}
protected void setProperty(String property, Object v) {
Method method = methodMap.get(property.toLowerCase());
try {
method.invoke(this, v);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
对通上述的代码,可以明显发现,使用Java 反射带来的好处
推荐阅读: