All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qiniu.api.fop.ExifRet Maven / Gradle / Ivy

There is a newer version: 6.1.9
Show newest version
package com.qiniu.api.fop;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import com.qiniu.api.net.CallRet;

public class ExifRet extends CallRet {

	public Map result = new HashMap();

	public ExifRet(CallRet ret) {
		super(ret);
		if (ret.ok() && ret.getResponse() != null) {
			try {
				unmarshal(ret.getResponse());
			} catch (Exception e) {
				e.printStackTrace();
				this.exception = e;
			}
		}
	}

	private void unmarshal(String response) throws Exception {
		JSONObject json = new JSONObject(response);
		JSONArray names = json.names();

		for (int i = 0; i < names.length(); i++) {
			String key = (String) names.get(i);
			JSONObject val = (JSONObject) json.get(key);
			ExifValueType vp = new ExifValueType();

			if (val.has("val")) {
				String value = val.getString("val");
				vp.value = value;
			}
			if (val.has("type")) {
				int type = val.getInt("type");
				vp.type = type;
			}

			result.put(key, vp);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy