コード例 #1
0
ファイル: DataMarshaller.java プロジェクト: xaviersq/collect
 private void writeField(XmlSerializer serializer, Attribute<?, ?> attr, int fieldIdx)
     throws IOException {
   AttributeDefinition definition = attr.getDefinition();
   List<FieldDefinition<?>> fldDefns = definition.getFieldDefinitions();
   Field<?> fld = attr.getField(fieldIdx);
   if (fld.hasData()) {
     FieldDefinition<?> fldDefn = fldDefns.get(fieldIdx);
     String name = fldDefn.getName();
     serializer.startTag(null, name);
     Object val = fld.getValue();
     if (StringUtils.isNotBlank(fld.getRemarks())) {
       serializer.attribute(null, REMARKS_ATTRIBUTE, fld.getRemarks());
     }
     if (fld.getSymbol() != null) {
       serializer.attribute(null, SYMBOL_ATTRIBUTE, fld.getSymbol().toString());
     }
     State state = fld.getState();
     int stateInt = state.intValue();
     if (stateInt > 0) {
       serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(stateInt));
     }
     if (val != null) {
       String valStr = val.toString();
       serializer.text(valStr);
     }
     serializer.endTag(null, name);
   }
 }
コード例 #2
0
ファイル: DataMarshaller.java プロジェクト: xaviersq/collect
 private void writeState(XmlSerializer serializer, Node<?> node) throws IOException {
   Entity parent = node.getParent();
   if (parent != null) {
     State s = parent.getChildState(node.getName());
     int state = s.intValue();
     if (state > 0) {
       serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(state));
     }
   }
 }
コード例 #3
0
ファイル: DataMarshaller.java プロジェクト: xaviersq/collect
 /**
  * Writes empty nodes child of an entity if there is a node state specified.
  *
  * @param serializer
  * @param entity
  * @throws IOException
  */
 private void writeEmptyNodes(XmlSerializer serializer, Entity entity) throws IOException {
   EntityDefinition defn = entity.getDefinition();
   List<NodeDefinition> childDefns = defn.getChildDefinitions();
   for (NodeDefinition childDefn : childDefns) {
     String childName = childDefn.getName();
     if (entity.getCount(childName) == 0) {
       State childState = entity.getChildState(childName);
       int childStateInt = childState.intValue();
       if (childStateInt > 0) {
         serializer.startTag(null, childName);
         serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(childStateInt));
         serializer.endTag(null, childName);
       }
     }
   }
 }