コード例 #1
0
  /**
   * Parses xml data into an ArrayList of Team objects
   *
   * @param teamRoot xml root (XML_ROOT_NAME_TEAM_MANAGER)
   * @return array list of team objects
   */
  public ArrayList<Team> parseTeam(Element teamRoot) {

    ArrayList<Team> parsedList = new ArrayList<Team>();

    Iterator teamIterator = teamRoot.getDescendants();
    // iterate through the teams elements
    while (teamIterator.hasNext()) {

      Object element = teamIterator.next();

      if (!(element instanceof Element)) {
        continue;
      }

      Element teamElement = (Element) element;

      Team parsedTeam = parseTeamElement(teamElement);
      if (parsedTeam != null) {
        // parse each team object and add them to the list
        parsedList.add(parsedTeam);
      }
    }

    return parsedList;
  }
コード例 #2
0
  private Element extractElementWithFilter(
      Element rootElement, String elementName, Namespace namespace) {
    Filter filter = new ElementFilter(elementName, namespace);
    Iterator it = rootElement.getDescendants(filter);

    return it.hasNext() ? (Element) it.next() : null;
  }
コード例 #3
0
 /* (non-Javadoc)
  * @see net.bpelunit.framework.coverage.annotation.metrics.IMetric#setOriginalBPELProcess(org.jdom.Element)
  */
 public void setOriginalBPELProcess(Element process) {
   Iterator<Element> compensHandlers =
       process.getDescendants(new ElementFilter(COMPENSATION_HANDLER, getProcessNamespace()));
   elementsOfBPEL = new ArrayList<Element>();
   while (compensHandlers.hasNext()) {
     elementsOfBPEL.add(compensHandlers.next());
   }
 }
コード例 #4
0
ファイル: ActivityMetric.java プロジェクト: rbecher/bpelunit
 /**
  * Gets the unmodified bpel process as xml element. <br>
  * All elements needed for instrumentating will be saved
  *
  * @param unmodified bpel process
  */
 public void setOriginalBPELProcess(Element process) {
   ElementFilter filter = new ElementFilter(process.getNamespace());
   elementsOfBPEL = new ArrayList<Element>();
   for (Iterator<Element> iter = process.getDescendants(filter); iter.hasNext(); ) {
     Element basicActivity = iter.next();
     if (activities_to_respekt.contains(basicActivity.getName()))
       elementsOfBPEL.add(basicActivity);
   }
 }
コード例 #5
0
  public XMLModelFile(Element root) {
    xmlModel = root; // doc.getRootElement();

    identifiedElements = new HashMap<String, XMLModelIdentifiable>();
    /* Parse out all the elements with id's and idref's
     Create a mapping of parameter names to the corresponding xml elements
     and a mapping of other identified elements to the corresponding xml elements
    */

    Iterator identifiedIter = xmlModel.getDescendants(new IdentifiedFilter());

    while (identifiedIter.hasNext()) {
      Element child = (Element) identifiedIter.next();
      Attribute idAttr = child.getAttribute("id");
      if (idAttr != null) {
        identifiedElements.put(
            idAttr.getValue(), new XMLModelIdentifiable(idAttr.getValue(), child));
      } else {
        idAttr = child.getAttribute("idref");
        identifiedElements.get(idAttr.getValue()).addReference(child);
      }
    }

    Iterator mcmcIter = xmlModel.getDescendants(new MCMCFilter());
    Element mcmc = (Element) mcmcIter.next();
    if (mcmc == null) {
      System.err.println("Error: cannot find mcmc element");
    } else {
      for (Object child : mcmc.getChildren("posterior")) {
        if ((child instanceof Element)) {
          Element posteriorElement = (Element) child;
        }
      }
      mcmc.detach();
    }
  }
コード例 #6
0
  @Override
  public void loadState(Element componentTag) {

    if (componentTag.getName().equals(XML_TEAM_MANAGER_COMPONENT)) {

      Iterator rootIterator = componentTag.getDescendants();

      // loop through all the root elements and parse them accordingly
      while (rootIterator.hasNext()) {

        Object element = rootIterator.next();

        if (!(element instanceof Element)) {
          continue;
        }

        Element rootElement = (Element) element;

        if (rootElement.getName().equals(XML_ROOT_NAME_TEAM_MANAGER)) {
          // parse the team list
          teamList = parseTeam(rootElement);

        } else if (rootElement.getName().equals(XML_ROOT_NAME_API_KEY)) {
          // parse the api key
          apiKey = parseApiKey(rootElement);

        } else if (rootElement.getName().equals(XML_ROOT_NAME_APK_FILE_PATH)) {
          // parse the apk file path
          apkFilePath = parseApkFilePath(rootElement);

        } else if (rootElement.getName().equals(XML_ROOT_NAME_SELECTED_MODULE_NAME)) {
          // parse the user selected module name
          selectedModuleName = parseUserSelectedModuleName(rootElement);

        } else if (rootElement.getName().equals(XML_ROOT_NAME_SELECTED_PROJECT_NAME)) {
          // parse the user selected project name
          selectedProjectName = parseUserSelectedProjectName(rootElement);
        }
      }
    }
  }
コード例 #7
0
  /**
   * Parses a team xml element into a team object
   *
   * @param teamElement team element
   * @return parsed team object
   */
  public Team parseTeamElement(Element teamElement) {

    Team team = new Team();

    Iterator teamComponents = teamElement.getDescendants();
    // iterate through the Team components (token/name)
    while (teamComponents.hasNext()) {

      Object elementComponents = teamComponents.next();

      if (!(elementComponents instanceof Element)) {
        continue;
      }

      Element component = (Element) elementComponents;

      if (component.getName().equals(XML_TEAM_MANAGER_NAME)) {
        // if the name is found, set the name of the team
        team.setName(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_TOKEN)) {
        // if the token is found, set the token of the team
        team.setToken(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_DISTRIBUTION_LIST)) {
        // if the token is found, set the token of the team
        team.setDistributionList(component.getText());
      }
    }

    if (team.getName() != null) {
      // add the parsed team to the list
      return team;
    }

    return null;
  }