Package ca.carleton.gcrc.couch.onUpload.conversion

Source Code of ca.carleton.gcrc.couch.onUpload.conversion.UserDataDescriptor

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);
  }
}
TOP

Related Classes of ca.carleton.gcrc.couch.onUpload.conversion.UserDataDescriptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.