示例#1
0
 public CharBuffer encodeHistCmd(Boolean activate, String[] names) {
   charBuffer.clear();
   jsonWriter.startObject();
   if (activate != null) {
     jsonWriter
         .writeString(FIELD.type.name(), TYPE.histCmd.name())
         .next()
         .writeFieldName(FIELD.data.name())
         .startObject()
         .writeBoolean(FIELD.activate.name(), activate)
         .next()
         .writeFieldName(FIELD.names.name())
         .startArray();
     if (names != null) {
       int i = 0;
       for (String name : names) {
         if (i > 0) jsonWriter.next();
         jsonWriter.writeString(name);
         i++;
       }
     }
     jsonWriter.endArray().endObject();
   } else {
     jsonWriter
         .writeString(FIELD.type.name(), TYPE.statCmd.name())
         .next()
         .writeFieldName(FIELD.data.name())
         .startObject()
         .writeBoolean(FIELD.hist.name(), true)
         .endObject();
   }
   jsonWriter.endObject();
   charBuffer.flip();
   return charBuffer;
 }
示例#2
0
 public CharBuffer encodeUnregCmd(Mode mode, String[] names) {
   charBuffer.clear();
   jsonWriter
       .startObject()
       .writeString(FIELD.type.name(), TYPE.unregCmd.name())
       .next()
       .writeFieldName(FIELD.data.name())
       .startObject()
       .writeString(FIELD.mode.name(), mode.name())
       .next()
       .writeFieldName(FIELD.names.name())
       .startArray();
   int i = 0;
   for (String name : names) {
     if (i > 0) jsonWriter.next();
     jsonWriter.writeString(name);
     i++;
   }
   jsonWriter.endArray().endObject().endObject();
   charBuffer.flip();
   return charBuffer;
 }