Ejemplo n.º 1
0
 /**
  * Formats results in COMPACT format
  *
  * @param context Search context
  * @throws RetsServerException if an error occurs
  */
 public void formatResults(SearchFormatterContext context) throws RetsServerException {
   try {
     PrintWriter out = context.getWriter();
     out.println("<DELIMITER value=\"09\"/>");
     TagBuilder columnsTag = new TagBuilder(out, "COLUMNS").beginContent();
     columnsTag.print("\t");
     Collection fields = columnsToFields(context.getColumns(), context.getMetadata());
     columnsTag.print(StringUtils.join(fields.iterator(), "\t"));
     columnsTag.print("\t");
     columnsTag.close();
     int numColumns = context.getColumns().size();
     while (context.hasNext()) {
       formatRow(context, numColumns);
     }
   } catch (SQLException e) {
     throw new RetsServerException(e);
   }
 }
 private void formatRow(SearchFormatterContext context) throws SQLException {
   PrintWriter out = context.getWriter();
   DmqlParserMetadata metadata = context.getMetadata();
   TagBuilder residentialProperty =
       new TagBuilder(out, "ResidentialProperty").beginContentOnNewLine();
   TagBuilder listing = new TagBuilder(out, "Listing").beginContentOnNewLine();
   new TagBuilder(out, "StreetAddress")
       .beginContentOnNewLine()
       .emptyTag("StreetNumber")
       .simpleTag("StreetName", context.getResultString("StreetName"))
       .simpleTag("PostalCode", context.getResultString("PostalCode"))
       .close();
   listing.close();
   TagBuilder livingArea = new TagBuilder(out, "LivingArea").beginContentOnNewLine();
   TagBuilder area = new TagBuilder(out, "Area");
   Table livingAreaTable = metadata.getTable("LivingArea");
   String units = getUnits(livingAreaTable);
   if (units != null) {
     area.appendAttribute("Units", units);
   }
   area.beginContent().print(context.getResultString("LivingArea")).close();
   livingArea.close();
   residentialProperty.close();
 }