package ca.carleton.gcrc.couch.onUpload.conversion;
import net.sf.json.JSONObject;
import ca.carleton.gcrc.couch.onUpload.UploadConstants;
public class UserDataDescriptor extends AbstractDescriptor {
private AttachmentDescriptor attDescription;
public UserDataDescriptor(AttachmentDescriptor attDescription){
this.attDescription = attDescription;
}
public String getStringAttribute(String key) {
String value = null;
JSONObject descriptionObj = getJson();
if( descriptionObj.containsKey(key) ) {
value = descriptionObj.getString(key);
}
return value;
}
public void setStringAttribute(String key, String value) {
JSONObject descriptionObj = getJson();
descriptionObj.put(key,value);
attDescription.setSavingRequired(true);
}
@Override
protected JSONObject getJson(){
JSONObject attachmentDescription = attDescription.getJson();
return attachmentDescription.getJSONObject(UploadConstants.DATA_KEY);
}
@Override
protected void setSavingRequired(boolean flag) {
attDescription.setSavingRequired(flag);
}
}