Пример #1
0
 public CharBuffer encodeResetCmd(int[] ids) {
   charBuffer.clear();
   jsonWriter
       .startObject()
       .writeString(FIELD.type.name(), TYPE.resetCmd.name())
       .next()
       .writeFieldName(FIELD.data.name())
       .startArray();
   int i = 0;
   for (int id : ids) {
     if (i > 0) jsonWriter.next();
     jsonWriter.writeDecimal(id, 0);
   }
   jsonWriter.endArray().endObject();
   charBuffer.flip();
   return charBuffer;
 }
Пример #2
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;
 }
Пример #3
0
 public CharBuffer encodeDescCmd(String template) {
   charBuffer.clear();
   jsonWriter
       .startObject()
       .writeString(FIELD.type.name(), TYPE.descCmd.name())
       .next()
       .writeString(FIELD.data.name(), template)
       .endObject();
   charBuffer.flip();
   return charBuffer;
 }
Пример #4
0
 public CharBuffer encodeListCmd(Mode mode) {
   charBuffer.clear();
   jsonWriter
       .startObject()
       .writeString(FIELD.type.name(), TYPE.listCmd.name())
       .next()
       .writeString(FIELD.data.name(), mode.name())
       .endObject();
   charBuffer.flip();
   return charBuffer;
 }
Пример #5
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;
 }
Пример #6
0
 public CharBuffer encodeStatCmd() {
   charBuffer.clear();
   jsonWriter.startObject().writeString(FIELD.type.name(), TYPE.statCmd.name()).endObject();
   charBuffer.flip();
   return charBuffer;
 }