Ejemplo n.º 1
0
 public void endElement(String uri, String name, String qName) {
   taskHandler.endElement(uri, name, qName);
   if (SaxUtils.equalsOrSuffix(qName, "Task")) {
     this.tasks.add(taskHandler.getResult());
   } else if (SaxUtils.equalsOrSuffix(qName, "Description")) {
     description = currentOrNull();
   } else if (SaxUtils.equalsOrSuffix(qName, "IsPublished")) {
     published = Boolean.parseBoolean(currentOrNull());
   }
   currentText = new StringBuilder();
 }
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attrs)
     throws SAXException {
   Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
   if (qName.equals("property")) {
     this.kind = Kind.fromValue(attributes.get("kind"));
     this.name = attributes.get("name");
     this.unit = attributes.get("unit");
     if (attributes.containsKey("value")) {
       this.value = stringOrNumber(attributes.get("value"));
     }
   } else if (qName.equals("param")) {
     this.param =
         new HardwareParameter(
             URI.create(attributes.get("href")),
             attributes.get("method"),
             attributes.get("name"),
             attributes.get("operation"));
   } else if (qName.equals("range")) {
     this.first = parseNumberOrNull(attributes.get("first"));
     this.last = parseNumberOrNull(attributes.get("last"));
   } else if (qName.equals("entry")) {
     this.availableValues.add(stringOrNumber(attributes.get("value")));
   }
 }
Ejemplo n.º 3
0
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attrs)
     throws SAXException {
   Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
   if (SaxUtils.equalsOrSuffix(qName, "Catalog")) {
     catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML);
   } else if (SaxUtils.equalsOrSuffix(qName, "CatalogItem")) {
     putReferenceType(contents, attributes);
   } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
     org = newReferenceType(attributes);
   } else if (SaxUtils.equalsOrSuffix(qName, "Link") && "add".equals(attributes.get("rel"))) {
     readOnly = false;
   } else {
     taskHandler.startElement(uri, localName, qName, attrs);
   }
 }
Ejemplo n.º 4
0
 @Override
 public void startElement(String uri, String localName, String qName, Attributes attrs)
     throws SAXException {
   Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
   if (equalsOrSuffix(qName, "Children")) {
     inChildren = true;
   } else if (equalsOrSuffix(qName, "Tasks")) {
     inTasks = true;
   } else if (equalsOrSuffix(qName, "NetworkSection")) {
     inNetworkSection = true;
   }
   if (inChildren) {
     vmHandler.startElement(uri, localName, qName, attrs);
   } else if (inTasks) {
     taskHandler.startElement(uri, localName, qName, attrs);
   } else if (inNetworkSection) {
     networkSectionHandler.startElement(uri, localName, qName, attrs);
   } else if (equalsOrSuffix(qName, "VAppTemplate")) {
     template = newReferenceType(attributes);
     if (attributes.containsKey("status"))
       this.status = Status.fromValue(Integer.parseInt(attributes.get("status")));
   } else if (equalsOrSuffix(qName, "Link") && "up".equals(attributes.get("rel"))) {
     vdc = newReferenceType(attributes);
   }
 }
Ejemplo n.º 5
0
  public void startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
    depth++;
    if (depth == 2) {
      if (equalsOrSuffix(qName, "DiskSection")) {
        inDisk = true;
      } else if (equalsOrSuffix(qName, "NetworkSection")) {
        inNetwork = true;
      } else if (equalsOrSuffix(qName, "VirtualSystem")) {
        inVirtualSystem = true;
      } else if (extensionHandlers.containsKey(qName)
          || attributes.containsKey("type")
              && extensionHandlers.containsKey(attributes.get("type"))) {
        inExtensionSection = true;
        extensionHandler = extensionHandlers.get(qName).get();
      } else if (qName.endsWith("Section")) {
        inSection = true;
      }
    }

    if (inDisk) {
      diskHandler.startElement(uri, localName, qName, attrs);
    } else if (inNetwork) {
      networkHandler.startElement(uri, localName, qName, attrs);
    } else if (inVirtualSystem) {
      virtualSystemHandler.startElement(uri, localName, qName, attrs);
    } else if (inExtensionSection) {
      extensionHandler.startElement(uri, localName, qName, attrs);
    } else if (inSection) {
      defaultSectionHandler.startElement(uri, localName, qName, attrs);
    }
  }
Ejemplo n.º 6
0
  /** {@inheritDoc} */
  @Override
  public void endElement(String uri, String name, String qName) throws SAXException {
    if (inDimensions) {
      if (qName.equals("Dimensions")) {
        inDimensions = false;
      } else if (qName.equals("member")) {
        dimensions.add(dimensionHandler.getResult());
      } else {
        dimensionHandler.endElement(uri, name, qName);
      }
    } else if (qName.equals("MetricName")) {
      metricName = SaxUtils.currentOrNull(currentText);
    } else if (qName.equals("Namespace")) {
      namespace = SaxUtils.currentOrNull(currentText);
    }

    currentText = new StringBuilder();
  }
Ejemplo n.º 7
0
 /** {@inheritDoc} */
 @Override
 public void startElement(String url, String name, String qName, Attributes attributes)
     throws SAXException {
   if (!inDimensions && SaxUtils.equalsOrSuffix(qName, "member")) {
     inDimensions = true;
   }
   if (inDimensions) {
     dimensionHandler.startElement(url, name, qName, attributes);
   }
 }
 @Override
 public void startElement(String url, String name, String qName, Attributes attributes)
     throws SAXException {
   if (SaxUtils.equalsOrSuffix(qName, "MetricAlarms")) {
     inMetricAlarms = true;
   }
   if (inMetricAlarms) {
     metricAlarmHandler.startElement(url, name, qName, attributes);
   }
 }
 public void startElement(String uri, String localName, String qName, Attributes attrs) {
   Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
   if (equalsOrSuffix(qName, "Network")) {
     networkBuilder.name(attributes.get("name"));
   }
 }