/**
  * Formats a single data row.
  *
  * @param context search context
  * @param numColumns number of columns
  * @throws SQLException if an error occurs
  */
 private void formatRow(SearchFormatterContext context, int numColumns) throws SQLException {
   DataRowBuilder row = new DataRowBuilder(context.getWriter());
   ResultSet results = context.getResultSet();
   row.begin();
   for (int i = 1; i <= numColumns; i++) {
     row.append(results.getString(i));
   }
   row.end();
 }
 public void formatResults(SearchFormatterContext context) throws RetsServerException {
   try {
     PrintWriter out = context.getWriter();
     TagBuilder reData = new TagBuilder(out, "REData").beginContentOnNewLine();
     TagBuilder reProperties = new TagBuilder(out, "REProperties").beginContentOnNewLine();
     while (context.hasNext()) {
       formatRow(context);
     }
     reProperties.close();
     reData.close();
   } catch (SQLException e) {
     throw new RetsServerException(e);
   }
 }
 /**
  * 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();
 }