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; } } } }
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(); 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; } } } 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. throw new NoSuchFieldException( "Attribute \"" + attributePath.attribute + "\" is not a valid DVA"); } }