public static Element stripAttributes(Element e) {
   e.setAttributes(null);
   for (Element child : e.getChildren()) {
     stripAttributes(child); // recurse
   }
   return e;
 }
Beispiel #2
0
  private static final Element marshalSpot(final Spot spot, final FeatureModel fm) {
    final Collection<Attribute> attributes = new ArrayList<Attribute>();
    final Attribute IDattribute = new Attribute(SPOT_ID_ATTRIBUTE_NAME, "" + spot.ID());
    attributes.add(IDattribute);
    final Attribute nameAttribute = new Attribute(SPOT_NAME_ATTRIBUTE_NAME, spot.getName());
    attributes.add(nameAttribute);
    Double val;
    Attribute featureAttribute;

    for (final String feature : spot.getFeatures().keySet()) {
      val = spot.getFeature(feature);
      if (null == val) {
        // Skip missing features.
        continue;
      }

      final String str;
      if (fm.getSpotFeatureIsInt().get(feature).booleanValue()) {
        str = "" + val.intValue();
      } else {
        str = val.toString();
      }
      featureAttribute = new Attribute(feature, str);
      attributes.add(featureAttribute);
    }

    final Element spotElement = new Element(SPOT_ELEMENT_KEY);
    spotElement.setAttributes(attributes);
    return spotElement;
  }