コード例 #1
0
ファイル: XNode.java プロジェクト: fengshao0907/jdbc_shard
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append("<");
   builder.append(name);
   for (Map.Entry<Object, Object> entry : attributes.entrySet()) {
     builder.append(" ");
     builder.append(entry.getKey());
     builder.append("=\"");
     builder.append(entry.getValue());
     builder.append("\"");
   }
   List<XNode> children = getChildren();
   if (children.size() > 0) {
     builder.append(">\n");
     for (XNode node : children) {
       builder.append(node.toString());
     }
     builder.append("</");
     builder.append(name);
     builder.append(">");
   } else if (body != null) {
     builder.append(">");
     builder.append(body);
     builder.append("</");
     builder.append(name);
     builder.append(">");
   } else {
     builder.append("/>");
   }
   builder.append("\n");
   return builder.toString();
 }
コード例 #2
0
ファイル: XNode.java プロジェクト: fengshao0907/jdbc_shard
 public Properties getChildrenAsProperties() {
   Properties properties = new Properties();
   for (XNode child : getChildren()) {
     String name = child.getStringAttribute("name");
     String value = child.getStringAttribute("value");
     if (name != null && value != null) {
       properties.setProperty(name, value);
     }
   }
   return properties;
 }
コード例 #3
0
ファイル: XNode.java プロジェクト: TuWei1992/zswxsqxt
 public String getValueBasedIdentifier() {
   StringBuilder builder = new StringBuilder();
   XNode current = this;
   while (current != null) {
     if (current != this) {
       builder.insert(0, "_");
     }
     String value =
         current.getStringAttribute(
             "id",
             current.getStringAttribute("value", current.getStringAttribute("property", null)));
     if (value != null) {
       builder.insert(0, "]");
       builder.insert(0, value);
       builder.insert(0, "[");
     }
     builder.insert(0, current.getName());
     current = current.getParent();
   }
   return builder.toString();
 }