static public Integer getAttachmentPosition ( JSONObject targetDoc , String attachmentName ) { JSONObject targetAttachments = targetDoc . optJSONObject ( "_attachments" ) ; if ( null == targetAttachments ) { // No attachment on target doc return null ; } JSONObject targetAttachment = targetAttachments . optJSONObject ( attachmentName ) ; if ( null == targetAttachment ) { // Target document does not have an attachment with this name return null ; } if ( JSONSupport . containsKey ( targetAttachment , "revpos" ) ) { int revPos = targetAttachment . optInt ( "revpos" , - 1 ) ; if ( revPos < 0 ) { return null ; } return revPos ; } return null ; }
Given a JSON document and an attachment name returns the revision position associated with the attachment .