Ejemplo n.º 1
0
 public Map<String, Object> write(Element element) {
   Map<String, Object> entity = new HashMap<String, Object>();
   entity.put(Dictionary.FIELD_RESEND, 0);
   entity.put(Dictionary.FIELD_ACTIVATE, true);
   entity.put(Dictionary.FIELD_PID, element.getId());
   entity.put(Dictionary.FIELD_TYPE, element.getType());
   entity.put(Dictionary.FIELD_TIMESTAMP, System.currentTimeMillis());
   entity.put(Dictionary.FIELD_DELAY, this.format.format(new Date()));
   entity.put(Dictionary.FIELD_CLASS, element.getClass().getSimpleName());
   JID to = this.jidBuilder.build(element.getTo());
   JID from = this.jidBuilder.build(element.getFrom());
   entity.put(Dictionary.FIELD_TO, this.bare ? to.asStringWithBare() : to.asString());
   entity.put(Dictionary.FIELD_FROM, this.bare ? from.asStringWithBare() : from.asString());
   return entity;
 }
Ejemplo n.º 2
0
 /**
  * ID,FROM,TO,TYPE
  *
  * @param storage
  * @param element
  * @return
  */
 protected Element read(Map<String, Object> storage, Element element) {
   return element
       .setId(this.toString(storage, Dictionary.FIELD_PID))
       .setFrom(this.toString(storage, Dictionary.FIELD_FROM))
       .setTo(this.toString(storage, Dictionary.FIELD_TO))
       .setType(this.toString(storage, Dictionary.FIELD_TYPE));
 }
Ejemplo n.º 3
0
 /*
  * Class比较
  *
  * @see com.sissi.persistent.PersistentElement#isSupport(com.sissi.protocol.Element)
  */
 public boolean isSupport(Element element) {
   return this.support == element.getClass();
 }
Ejemplo n.º 4
0
 /*
  * {"id":Xxx}
  *
  * @see com.sissi.persistent.PersistentElement#query(com.sissi.protocol.Element)
  */
 public Map<String, Object> query(Element element) {
   return MongoUtils.asMap(
       BasicDBObjectBuilder.start(Dictionary.FIELD_PID, element.getId()).get());
 }