Ejemplo n.º 1
0
 public Table addCell(Object value, String attributes) {
   if (!inHeaders) {
     if (currentCells.size() == headers.size()) {
       throw new ElasticSearchIllegalArgumentException(
           "can't add more cells to a row than the header");
     }
   }
   Map<String, String> mAttr;
   if (attributes.length() == 0) {
     if (inHeaders) {
       mAttr = ImmutableMap.of();
     } else {
       // get the attributes of the header cell we are going to add to
       mAttr = headers.get(currentCells.size()).attr;
     }
   } else {
     mAttr = new HashMap<String, String>();
     if (!inHeaders) {
       // get the attributes of the header cell we are going to add
       mAttr.putAll(headers.get(currentCells.size()).attr);
     }
     String[] sAttrs = Strings.splitStringToArray(attributes, ';');
     for (String sAttr : sAttrs) {
       if (sAttr.length() == 0) {
         continue;
       }
       int idx = sAttr.indexOf(':');
       mAttr.put(sAttr.substring(0, idx), sAttr.substring(idx + 1));
     }
   }
   addCell(new Cell(value, mAttr));
   return this;
 }