Exemplo n.º 1
0
 /**
  * @see viper.api.extensions.AttrValueParser#getXMLFormat(org.w3c.dom.Document, java.lang.Object,
  *     Node)
  */
 public Element getXMLFormat(Document root, Object o, Node container) {
   String qualifier = ViperData.ViPER_DATA_QUALIFIER;
   String uri = ViperData.ViPER_DATA_URI;
   Element el = root.createElementNS(uri, qualifier + "circle");
   Circle c = (Circle) o;
   el.setAttribute(AT_X, String.valueOf(c.getCenter().getX()));
   el.setAttribute(AT_Y, String.valueOf(c.getCenter().getY()));
   el.setAttribute(AT_R, String.valueOf(c.getRadius()));
   return el;
 }
Exemplo n.º 2
0
  /** @see viper.api.extensions.AttrValueParser#setValue(org.w3c.dom.Element, Node) */
  public Object setValue(Element el, Node container) {
    if (el.hasAttribute(AT_X) && el.hasAttribute(AT_Y) && el.hasAttribute(AT_R)) {

      int x = Integer.parseInt(el.getAttribute(AT_X));
      int y = Integer.parseInt(el.getAttribute(AT_Y));
      int r = Integer.parseInt(el.getAttribute(AT_R));

      return new Circle(x, y, r);
    } else {
      throw new BadAttributeDataException("Missing an attribute for dimensions of a circle");
    }
  }