public void PrintAttribute(PrintNode row, AttributePath attributePath, ParserAdapter scda)
      throws Exception {
    ClassDef myClass = this.getClassDef(scda);
    if (attributePath.levelsOfIndirection() <= 0) {
      if (attributePath.attribute.equals("*")) {
        for (int j = 0; j < myClass.attributes.size(); j++) {
          Attribute currentAttribute = (Attribute) myClass.getAttribute(j);
          if (currentAttribute.getClass() == DVA.class) {
            Object dvaValue = dvaValues.get(currentAttribute.name);
            PrintCell cell = new PrintCell();
            cell.setOutput(String.format("%s", dvaValue));
            row.addCell(cell);
          }
        }
        if (myClass.getClass() == SubclassDef.class) {
          for (int i = 0; i < ((SubclassDef) myClass).numberOfSuperClasses(); i++) {
            String parentClass = (String) ((SubclassDef) myClass).getSuperClass(i);
            Integer parentUid = (Integer) this.parents.get(parentClass);
            WDBObject parent = scda.getObject(parentClass, parentUid);
            parent.PrintAttribute(row, attributePath, scda);
          }
        }
      } else {
        Attribute currentAttribute = (Attribute) myClass.getAttribute(attributePath.attribute);
        Object dvaValue = getDvaValue(attributePath.attribute, scda);
        PrintCell cell = new PrintCell();
        cell.setOutput(String.format("%s", dvaValue));
        row.addCell(cell);
      }
    } else {
      String evaName = attributePath.getIndirection(attributePath.levelsOfIndirection() - 1);
      WDBObject[] objects = this.getEvaObjects(evaName, scda);
      ArrayList<PrintNode> branch = row.getBranch(evaName);

      if (objects != null && objects.length > 0) {
        if (branch == null) {
          branch = row.newBranch(evaName, objects.length);
        }
        attributePath.removeIndirection(attributePath.levelsOfIndirection() - 1);
        for (int i = 0; i < objects.length; i++) {
          objects[i].PrintAttribute(branch.get(i), attributePath, scda);
        }
        attributePath.addIndirection(evaName);
      } else {
        if (branch == null) {
          branch = row.newBranch(evaName, 1);
          myClass.padAttribute(branch.get(0), attributePath, scda);
        }
      }

      row.updateBranchCols(evaName);
    }
  }
Exemple #2
0
  public void printAttributeName(PrintNode row, AttributePath attributePath, Adapter scda)
      throws Exception {
    for (int j = 0; j < attributes.size(); j++) {
      Attribute currentAttribute = (Attribute) attributes.get(j);
      int attributeLength = currentAttribute.name.length() + 2;

      if (currentAttribute.getClass() == DVA.class && attributePath.levelsOfIndirection() <= 0) {
        // If the attribute we want is found or we just want everything, output
        if (attributePath.attribute.equals("*")) {
          PrintCell cell = new PrintCell();
          cell.setOutput(String.format("%s", currentAttribute.name));
          row.addCell(cell);
        } else if (attributePath.attribute.equals(currentAttribute.name)) {
          PrintCell cell = new PrintCell();
          cell.setOutput(String.format("%s", currentAttribute.name));
          row.addCell(cell);
          return;
        }
      }
      if (currentAttribute.getClass() == EVA.class && attributePath.levelsOfIndirection() > 0) {
        String evaName = attributePath.getIndirection(attributePath.levelsOfIndirection() - 1);
        if (evaName.equals(currentAttribute.name)) {
          ClassDef targetClass = scda.getClass(((EVA) currentAttribute).baseClassName);
          attributePath.removeIndirection(attributePath.levelsOfIndirection() - 1);
          targetClass.printAttributeName(row, attributePath, scda);
          attributePath.addIndirection(evaName);
          return;
        }
      }
    }

    // Got here if we didn't get what we need in this class
    int i = 0;
    while (i < superClasses.size()) {
      try {
        ClassDef superClass = scda.getClass(((String) superClasses.get(i)));
        superClass.printAttributeName(row, attributePath, scda);
        i++;
      } catch (NoSuchFieldException nsfe) {
        if (i < superClasses.size()) {
          i++;
        } else {
          throw nsfe;
        }
      }
    }
  }
Exemple #3
0
  public void padAttribute(PrintNode row, AttributePath attributePath, Adapter scda)
      throws Exception {
    for (int j = 0; j < attributes.size(); j++) {
      Attribute currentAttribute = (Attribute) attributes.get(j);
      int attributeLength = currentAttribute.name.length();

      if (currentAttribute.getClass() == DVA.class && attributePath.levelsOfIndirection() <= 0) {
        // If the attribute we want is found or we just want everything, output
        if (attributePath.attribute.equals("*")) {
          PrintCell cell = new PrintCell();
          cell.setOutput(String.format(""));
          row.addCell(cell);
        } else if (attributePath.attribute.equals(currentAttribute.name)) {
          PrintCell cell = new PrintCell();
          cell.setOutput(String.format(""));
          row.addCell(cell);
          return;
        }
      }
      if (currentAttribute.getClass() == EVA.class && attributePath.levelsOfIndirection() > 0) {
        String evaName = attributePath.getIndirection(attributePath.levelsOfIndirection() - 1);
        if (evaName.equals(currentAttribute.name)) {
          ClassDef targetClass = scda.getClass(((EVA) currentAttribute).baseClassName);
          attributePath.removeIndirection(attributePath.levelsOfIndirection() - 1);
          targetClass.padAttribute(row, attributePath, scda);
          attributePath.addIndirection(evaName);
          return;
        }
      }
    }

    if (!(attributePath.attribute.equals("*") && attributePath.levelsOfIndirection() <= 0)) {
      // If we got here and we weren't trying to output all the attributes, we didn't find the
      // requested attribute.

      if (this.getClass() == SubclassDef.class) {
        for (int i = 0; i < ((SubclassDef) this).numberOfSuperClasses(); i++) {
          ClassDef parentClass = scda.getClass(((SubclassDef) this).getSuperClass(i));
          parentClass.padAttribute(row, attributePath, scda);
        }
      } else {
        throw new NoSuchFieldException(
            "Attribute \"" + attributePath.attribute + "\" is not a valid DVA");
      }
    }
  }