Writes the section definition data
@param result
343936
public void writeSectionDefinition(final OutputStream result) 
    {
        try {
            RtfHeaderFooterGroup header = convertHeaderFooter(this.header, RtfHeaderFooter.TYPE_HEADER);
            RtfHeaderFooterGroup footer = convertHeaderFooter(this.footer, RtfHeaderFooter.TYPE_FOOTER);
            if(header.hasTitlePage() || footer.hasTitlePage()) {
                result.write(TITLE_PAGE);
                header.setHasTitlePage();
                footer.setHasTitlePage();
            }
            if(header.hasFacingPages() || footer.hasFacingPages()) {
                result.write(FACING_PAGES);
                header.setHasFacingPages();
                footer.setHasFacingPages();
            }
            footer.writeContent(result);
            header.writeContent(result);
            pageSetting.writeSectionDefinition(result);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }    	
    }
462770
public void writeDefinition(final OutputStream result) throws IOException
    {
        result.write(OPEN_GROUP);
        result.write(LIST_TABLE);
        this.document.outputDebugLinebreak(result);
        
        for(int i = 0; i < picturelists.size(); i++) {
        	RtfPictureList l = (RtfPictureList)picturelists.get(i);
//        	l.setID(document.getRandomInt());
        	l.writeDefinition(result);
        	this.document.outputDebugLinebreak(result);
        }

        for(int i = 0; i < lists.size(); i++) {
        	RtfList l = (RtfList)lists.get(i);
        	l.setID(document.getRandomInt());
        	l.writeDefinition(result);
        	this.document.outputDebugLinebreak(result);
        }
        result.write(CLOSE_GROUP);
        this.document.outputDebugLinebreak(result);
        
        result.write(OPEN_GROUP);
        result.write(LIST_OVERRIDE_TABLE);
        this.document.outputDebugLinebreak(result);
        
        // list override index values are 1-based, not 0.
        // valid list override index values \ls are 1 to 2000.
        // if there are more then 2000 lists, the result is undefined.
        for(int i = 0; i < lists.size(); i++) {
            result.write(OPEN_GROUP);
            result.write(LIST_OVERRIDE);
            result.write(RtfList.LIST_ID);
            result.write(intToByteArray( ((RtfList) lists.get(i)).getID() ));
            result.write(LIST_OVERRIDE_COUNT);
            result.write(intToByteArray(0));	// is this correct? Spec says valid values are 1 or 9.
            result.write(RtfList.LIST_NUMBER);
            result.write(intToByteArray( ((RtfList) lists.get(i)).getListNumber()) );
            result.write(CLOSE_GROUP);
            this.document.outputDebugLinebreak(result);
        }
        result.write(CLOSE_GROUP);
        this.document.outputDebugLinebreak(result);
    }
968338
@Override
	public void write(T result, HttpServerRequest request, HttpServerResponse response) {

		if (result != null) {
			response.end(JsonUtils.toJson(result, io.vertx.core.json.Json.mapper));
		}
		else {
			response.end();
		}
	}
1342968
private void writeRowDefinition(final OutputStream result) throws IOException {
        result.write(ROW_BEGIN);
        this.document.outputDebugLinebreak(result);
        result.write(ROW_WIDTH_STYLE);
        result.write(ROW_WIDTH);
        result.write(intToByteArray(this.width));
        if(this.parentTable.getCellsFitToPage()) {
            result.write(ROW_KEEP_TOGETHER);
        }
        if(this.rowNumber <= this.parentTable.getHeaderRows()) {
            result.write(ROW_HEADER_ROW);
        }
        switch (this.parentTable.getAlignment()) {
            case Element.ALIGN_LEFT:
            	result.write(ROW_ALIGN_LEFT);
                break;
            case Element.ALIGN_RIGHT:
                result.write(ROW_ALIGN_RIGHT);
                break;
            case Element.ALIGN_CENTER:
                result.write(ROW_ALIGN_CENTER);
                break;
            case Element.ALIGN_JUSTIFIED:
            case Element.ALIGN_JUSTIFIED_ALL:
                result.write(ROW_ALIGN_JUSTIFIED);
                break;
        }
        result.write(ROW_GRAPH);
        RtfBorderGroup borders =this.parentTable.getBorders();
        if(borders != null) {
        	borders.writeContent(result);
        }
        
        if(this.parentTable.getCellSpacing() > 0) {
            result.write(ROW_CELL_SPACING_LEFT);
            result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
            result.write(ROW_CELL_SPACING_LEFT_STYLE);
            result.write(ROW_CELL_SPACING_TOP);
            result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
            result.write(ROW_CELL_SPACING_TOP_STYLE);
            result.write(ROW_CELL_SPACING_RIGHT);
            result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
            result.write(ROW_CELL_SPACING_RIGHT_STYLE);
            result.write(ROW_CELL_SPACING_BOTTOM);
            result.write(intToByteArray((int) (this.parentTable.getCellSpacing() / 2)));
            result.write(ROW_CELL_SPACING_BOTTOM_STYLE);
        }
        
        result.write(ROW_CELL_PADDING_LEFT);
        result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2)));
        result.write(ROW_CELL_PADDING_RIGHT);
        result.write(intToByteArray((int) (this.parentTable.getCellPadding() / 2)));
        result.write(ROW_CELL_PADDING_LEFT_STYLE);
        result.write(ROW_CELL_PADDING_RIGHT_STYLE);
        
        this.document.outputDebugLinebreak(result);
        
        for(int i = 0; i < this.cells.size(); i++) {
            RtfCell rtfCell = (RtfCell) this.cells.get(i);
            rtfCell.writeDefinition(result);
        }    	
    }
307174
public void writeContent(final OutputStream result) throws IOException
    {
        result.write(OPEN_GROUP);
        if(this.type == TYPE_HEADER) {
            if(this.displayAt == DISPLAY_ALL_PAGES) {
                result.write(HEADER_ALL);
            } else if(this.displayAt == DISPLAY_FIRST_PAGE) {
                result.write(HEADER_FIRST);
            } else if(this.displayAt == DISPLAY_LEFT_PAGES) {
                result.write(HEADER_LEFT);
            } else if(this.displayAt == DISPLAY_RIGHT_PAGES) {
                result.write(HEADER_RIGHT);
            }
        } else {
            if(this.displayAt == DISPLAY_ALL_PAGES) {
                result.write(FOOTER_ALL);
            } else if(this.displayAt == DISPLAY_FIRST_PAGE) {
                result.write(FOOTER_FIRST);
            } else if(this.displayAt == DISPLAY_LEFT_PAGES) {
                result.write(FOOTER_LEFT);
            } else if(this.displayAt == DISPLAY_RIGHT_PAGES) {
                result.write(FOOTER_RIGHT);
            }
        }
        result.write(DELIMITER);
        for(int i = 0; i < this.content.length; i++) {
            if(this.content[i] instanceof RtfBasicElement) {
            	RtfBasicElement rbe = (RtfBasicElement)this.content[i];
            	rbe.writeContent(result);
            }
        }
        result.write(CLOSE_GROUP);
    }
130962
private void writeFieldResultEnd(final OutputStream result) throws IOException 
    {
        result.write(DELIMITER);
        result.write(CLOSE_GROUP);
    }
803938
def write_result(self, data):
        
        data['custom_timers'] = ujson.dumps(data['custom_timers'])
        self.results.append(data)

        if len(self.results) >= 150:  # 150 rows for SQLite default limit
            with db.execution_context():
                with db.atomic():
                    Result.insert_many(self.results).execute()
                del self.results[:]
741951
private void write(ProcessResult processResult) throws IOException {
        if (processResult.getName() != null) {
            openCurlyBracket();
            writeName(processResult.getName());
        }
        if (processResult.isEmpty()) {
            writeNull();
        } else if (processResult.size() == 1) {
            ContentResult contentResult = processResult.get(0);
            write(contentResult);
        } else {
            openSquareBracket();
            Iterator<ContentResult> it = processResult.iterator();
            while (it.hasNext()) {
                ContentResult contentResult = it.next();
                write(contentResult);
                if (it.hasNext()) {
                    writeComma();
                }
            }
            closeSquareBracket();
        }
        if (processResult.getName() != null) {
            closeCurlyBracket();
        }
    }
479548
public static void writeResults(final String name, final Object output) {
		Writer writer = null;

		try {
			writer = new BufferedWriter(
					new OutputStreamWriter(
					new FileOutputStream(name + ".json"), "utf-8"));

			writer.write(output.toString());
		} catch (IOException ignored) {
		} finally {
			try {writer.close();}
            catch (Exception ignored) {}
		}
	}
357518
public void writeBegin(final OutputStream result) throws IOException {
        result.write(DocWriter.getISOBytes("\\s"));
        result.write(intToByteArray(this.styleNumber));
        writeParagraphSettings(result);
    }
182728
@Override
    public void writeFile(String arg0, Map result) {

        // Initial variables
        HashMap wthFile;                  // Data holder for whole weather data
        ArrayList wthRecords;                   // Daily data array
        HashMap wthRecord;                // Data holder for daily data
        BufferedWriter bwW;                     // output object
        StringBuilder sbData = new StringBuilder();     // construct the data info in the output
        LinkedHashMap dailyVarHeaderMap = new LinkedHashMap();   // Define the mapping of daily data fields and header
        dailyVarHeaderMap.put("tdew", "DEWP");
        dailyVarHeaderMap.put("wind", "WIND");
        dailyVarHeaderMap.put("pard", "PAR");
        dailyVarHeaderMap.put("vprsd", "VPRS");
        dailyVarHeaderMap.put("rhumd", "RHUM");
        String dailyKey = "dailyWeather";  // P.S. the key name might change
        HeaderArrayList<String> dailyHeaders = new HeaderArrayList();
        StringBuilder[] dailyData;

        try {

            // Set default value for missing data
            setDefVal();

            // Get weather files
            wthFile = (HashMap) getObjectOr(result, "weather", new HashMap());
            if (wthFile.isEmpty()) {
                return;
            }
//            decompressData(wthFiles);

            // Output all weather files
            wthRecords = (ArrayList) getObjectOr(wthFile, dailyKey, new ArrayList());

            // Initial BufferedWriter
            // Get File name
            String fileName = getValueOr(result, "wst_id", "");
            if (fileName.equals("")) {
                fileName = getWthFileName(result);
            }
            fileName += ".WTH";
            arg0 = revisePath(arg0);
            outputFile = new File(arg0 + fileName);
            bwW = new BufferedWriter(new FileWriter(outputFile));

            // Output Weather File
            // Titel Section
            if (getObjectOr(wthFile, "wst_notes", ".AgMIP File").equals(".AgMIP File")) {
                sbData.append(String.format("*WEATHER DATA : %1$s\r\n!Climate ID: %2$s\r\n", getObjectOr(wthFile, "wst_source", defValBlank), getValueOr(wthFile, "clim_id", "N/A")));
            } else {
                sbData.append(String.format("*WEATHER DATA : %1$s\r\n!Climate ID: %2$s\r\n", getObjectOr(wthFile, "wst_notes", defValBlank), getValueOr(wthFile, "clim_id", "N/A")));
            }

            // Weather Station Section
            String wid = getObjectOr(wthFile, "wst_id", defValC);
            if (wid.length() > 4) {
                wid = wid.substring(0, 4);
            }
            sbData.append("@ INSI      LAT     LONG  ELEV   TAV   AMP REFHT WNDHT  CCO2\r\n");
            sbData.append(String.format("  %1$-4s %2$8s %3$8s %4$5s %5$5s %6$5s %7$5s %8$5s %9$5s\r\n",
                    formatStr(4, wthFile, "dssat_insi", wid),
                    formatNumStr(8, wthFile, "wst_lat", defValR),
                    formatNumStr(8, wthFile, "wst_long", defValR),
                    formatNumStr(5, wthFile, "wst_elev", defValR),
                    formatNumStr(5, wthFile, "tav", defValR),
                    formatNumStr(5, wthFile, "tamp", defValR),
                    formatNumStr(5, wthFile, "refht", defValR),
                    formatNumStr(5, wthFile, "wndht", defValR),
                    formatNumStr(5, wthFile, "co2y", defValR)));

            // Daily weather data section
            // Title line
            sbData.append("@DATE  SRAD  TMAX  TMIN  RAIN  DEWP  WIND   PAR");
            // Register fixed headers
            dailyHeaders.add("w_date");
            dailyHeaders.add("srad");
            dailyHeaders.add("tmax");
            dailyHeaders.add("tmin");
            dailyHeaders.add("rain");
            dailyHeaders.add("tdew");
            dailyHeaders.add("wind");
            dailyHeaders.add("pard");

            // Output daily data
            dailyData = new StringBuilder[wthRecords.size()];
            for (int i = 0; i < wthRecords.size(); i++) {

                wthRecord = (HashMap) wthRecords.get(i);
                dailyData[i] = new StringBuilder();
                dailyHeaders.seCurItems(wthRecord.keySet());

                // if date is missing, jump the record
                if (!getObjectOr(wthRecord, "w_date", "").equals("")) {
                    //  Format handling for daily date
                    dailyData[i].append(String.format("%1$5s", formatDateStr(getObjectOr(wthRecord, dailyHeaders.get(0), defValD))));

                    // Output the registered variables
                    for (int j = 1; j < dailyHeaders.size(); j++) {
                        dailyData[i].append(String.format(" %1$5s", formatNumStr(5, wthRecord, dailyHeaders.get(j), defValR)));
                    }

                    // Check if there is new variable not been regitered in the output list
                    while (dailyHeaders.hasMoreItem()) {
                        // Register the variable
                        String key = dailyHeaders.applyNext();

                        if (key != null) {
                            // Add title to the header line
                            sbData.append(String.format("%1$6s", getObjectOr(dailyVarHeaderMap, key, key.toUpperCase())));
                            // Add blank for previous lines (this might be optional)
                            for (int j = 0; j < i; j++) {
                                dailyData[j].append("   -99");
                            }
                            // Output new variable
                            dailyData[i].append(String.format(" %1$5s", formatNumStr(5, wthRecord, key, defValR)));
                        }
                    }
                } else {
                    sbError.append("! Warning: A daily record has the missing date in it.\r\n");
                }
            }

            // Combine the daily data
            sbData.append("\r\n");
            for (int i = 0; i < dailyData.length; i++) {
                dailyData[i].append("\r\n");
                sbData.append(dailyData[i]);
                dailyData[i] = null;
            }

            // Output finish
            bwW.write(sbError.toString());
            bwW.write(sbData.toString());
            bwW.close();
            sbError = new StringBuilder();

        } catch (IOException e) {
            LOG.error(DssatCommonOutput.getStackTrace(e));
        }
    }
1371815
private void writeFieldResultBegin(final OutputStream result) throws IOException 
    {
        result.write(OPEN_GROUP);
        result.write(FIELD_RESULT);
        result.write(DELIMITER);
    }
619758
public void writeContent(final OutputStream result) throws IOException
    {
        if(this.content.size() == 0) {
            result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
            if(this.parentRow.getParentTable().getTableFitToPage()) {
                result.write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT);
            }
            result.write(RtfParagraph.IN_TABLE);
        } else {
            for(int i = 0; i < this.content.size(); i++) {
                RtfBasicElement rtfElement = (RtfBasicElement) this.content.get(i);
                if(rtfElement instanceof RtfParagraph) {
                    ((RtfParagraph) rtfElement).setKeepTogetherWithNext(this.parentRow.getParentTable().getTableFitToPage());
                }
                rtfElement.writeContent(result);
                if(rtfElement instanceof RtfParagraph && i < (this.content.size() - 1)) {
                    result.write(RtfParagraph.PARAGRAPH);
                }
            }
        }
        result.write(DocWriter.getISOBytes("\\cell"));
    }
774556
public void addResult(CmsResourceTypeStatResult result) {

        if (!m_results.contains(result)) {
            m_results.add(result);
            m_updated = false;
        } else {
            m_results.remove(result);
            m_results.add(result);
            m_updated = true;
        }
    }
161470
void writeResult(final RpcResult<?, ?> result, final HttpServletResponse resp)
			throws IOException {
		if (result.isSuccess()) {
			resp.setStatus(HttpServletResponse.SC_OK);
			resp.setContentType(JSON_CONTENT_TYPE);
		} else {
			resp.setStatus(APPLICATION_EXC_STATUS);
			resp.setContentType(JSON_CONTENT_TYPE);
		}

		PrintWriter writer = resp.getWriter();
		result.toJson(writer, true);
		writer.flush();
	}
504794
@Override
  public void onSave(Result<Void> result)
  {
    StubContainerAmp container = _container;
    
    if (container != null) {
      container.onSave(result);
    }
    else {
      onSaveChild(result);
    }
  }
627087
public void setResults(java.util.Collection<String> results) {
        if (results == null) {
            this.results = null;
            return;
        }

        this.results = new com.amazonaws.internal.SdkInternalList<String>(results);
    }