Ejemplo n.º 1
0
 public void remove(DominoDocument doc, String fieldName, int idx) throws Exception {
   String json = doc.getItemValueString(fieldName);
   if (!StringUtil.isSpace(json)) {
     List<Object> array = (List<Object>) JsonParser.fromJson(JsonJavaFactory.instance, json);
     if (idx < array.size()) {
       array.remove(idx);
       doc.replaceItemValue(fieldName, JsonGenerator.toJson(JsonJavaFactory.instance, array));
     }
   }
 }
Ejemplo n.º 2
0
 public boolean isEmpty(DominoDocument doc, String fieldName) throws Exception {
   if (doc != null) {
     Item item = doc.getDocument().getFirstItem(fieldName);
     if (item != null) {
       String content;
       MIMEEntity e = item.getMIMEEntity();
       if (e != null) {
         content = e.getContentAsText();
       } else {
         content = item.getText();
       }
       if (!StringUtil.isSpace(content)) {
         // Should handle empty json objects/arrays as well
         content = content.trim();
         return content.equals("[]") || content.equals("{}");
       }
     }
   }
   return true;
 }