示例#1
0
 public UserIdNameArrayItem addData(long userId, String userName, int career, int level) {
   UserIdNameArrayItem item = new UserIdNameArrayItem();
   item.setUserId(userId);
   item.setUserName(userName);
   item.setCareer(career);
   item.setLevel(level);
   list.add(item);
   return item;
 }
示例#2
0
 @Override
 public boolean validate() {
   for (UserIdNameArrayItem item : list) {
     if (!item.validate()) {
       return false;
     }
   }
   return true;
 }
示例#3
0
 /** 编码 */
 @Override
 public void encode(Data data) {
   data.writeInt(list.size());
   for (UserIdNameArrayItem item : list) {
     data.writeLong(item.getUserId());
     data.writeString(item.getUserName());
     data.writeInt(item.getCareer());
     data.writeInt(item.getLevel());
   }
 }
示例#4
0
 public String toString() {
   StringBuilder bb = new StringBuilder();
   bb.append("[");
   int i = 0;
   for (UserIdNameArrayItem item : list) {
     bb.append("{").append(item.toString()).append("}");
     i++;
     if (i != list.size()) {
       bb.append(", ");
     }
   }
   bb.append("]");
   return bb.toString();
 }
示例#5
0
 /** 解码 */
 @Override
 public void decode(Data data) {
   int size = data.getInt();
   for (int i = 0; i < size; i++) {
     UserIdNameArrayItem item = UserIdNameArrayItem.create();
     item.setUserId(data.getLong());
     item.setUserName(data.getString());
     item.setCareer(data.getInt());
     item.setLevel(data.getInt());
     list.add(item);
   }
 }