/** * Prints as a String the complex content (List->Attribute) * * @return a String the complex content */ public String printString(int[] numValues) { String cad = ""; for (int x = 0; x < compl.size(); x++) { Selector s = (Selector) compl.get(x); // cad += "Atr" + s.getAtributo() + " "; double[] values = s.getValues(); String[] nValues = s.getNValues(); // si para un atributo aparecen todos sus valores, la condicion es true // no imprimimos condicion if (values.length < numValues[s.getAttribute()]) { if ((x < (compl.size())) && (x > 0)) { cad += " AND "; } cad += attributeNames[s.getAttribute()] + " "; switch (s.getOperator()) { case 0: if (values.length > 1) cad += "in"; else cad += "="; break; case 1: cad += "<>"; break; case 2: cad += "<="; break; case 3: cad += ">"; break; } if (Attributes.getInputAttribute(s.getAttribute()).getType() == Attribute.NOMINAL) { if (nValues.length > 1) { cad += " [" + nValues[0]; for (int i = 1; i < nValues.length - 1; i++) { cad += " , " + nValues[i]; } cad += " , " + nValues[nValues.length - 1] + "] "; } else { cad += " " + nValues[0] + ""; } } else { if (values.length > 1) { cad += " [" + values[0]; for (int i = 1; i < values.length - 1; i++) { cad += " , " + values[i]; } cad += " , " + values[values.length - 1] + "]"; } else { cad += " " + values[0] + ""; } } } } return cad; }
/** * Prints on the standard output the content of this complex object. (List -> Attribute operator * value) */ public void print(int nominal) { for (int x = 0; x < compl.size(); x++) { Selector s = (Selector) compl.get(x); double[] values = s.getValues(); String[] nValues = s.getNValues(); // System.out.print("(Atr" + s.getAtributo() + " "); System.out.print("(" + attributeNames[s.getAttribute()] + " "); switch (s.getOperator()) { case 0: if (values.length > 1 /*|| valoresN.length>1*/) System.out.print("in"); else System.out.print("="); break; case 1: System.out.print("<>"); break; case 2: System.out.print("<="); break; default: System.out.print(">"); } if (nominal == 0) { // el atributo es nominal if (nValues.length > 1) { System.out.print(" " + nValues[0]); for (int i = 1; i < nValues.length - 1; i++) { System.out.print(" " + nValues[i]); } System.out.print(" " + nValues[nValues.length - 1] + ")"); } else { System.out.print(" " + nValues[0] + ")"); } } else { if (values.length > 1) { System.out.print(" [" + values[0]); for (int i = 1; i < values.length - 1; i++) { System.out.print(" " + values[i]); } System.out.print(" " + values[values.length - 1] + "])"); } else { System.out.print(" " + values[0] + ")"); } } if (x < compl.size() - 1) { System.out.print(" AND "); } // System.out.print(" -- "+heuristica+" -- "); System.out.println(); } }