Writes the font beginning

@param result The <code>OutputStream</code> to write to.
@throws IOException On i/o errors.
978841
public void writeBegin(final OutputStream result) throws IOException {
        if(this.fontNumber != Font.UNDEFINED) {
            result.write(RtfFontList.FONT_NUMBER);
            result.write(intToByteArray(fontNumber));
        }
        if(this.fontSize != Font.UNDEFINED) {
            result.write(FONT_SIZE);
            result.write(intToByteArray(fontSize * 2));
        }
        if(this.fontStyle != UNDEFINED) {
            if((fontStyle & STYLE_BOLD) == STYLE_BOLD) {
                result.write(FONT_BOLD);
            }
            if((fontStyle & STYLE_ITALIC) == STYLE_ITALIC) {
                result.write(FONT_ITALIC);
            }
            if((fontStyle & STYLE_UNDERLINE) == STYLE_UNDERLINE) {
                result.write(FONT_UNDERLINE);
            }
            if((fontStyle & STYLE_STRIKETHROUGH) == STYLE_STRIKETHROUGH) {
                result.write(FONT_STRIKETHROUGH);
            }
            if((fontStyle & STYLE_HIDDEN) == STYLE_HIDDEN) {
                result.write(FONT_HIDDEN);
            }
            if((fontStyle & STYLE_DOUBLE_STRIKETHROUGH) == STYLE_DOUBLE_STRIKETHROUGH) {
                result.write(FONT_DOUBLE_STRIKETHROUGH);
                result.write(intToByteArray(1));
            }
            if((fontStyle & STYLE_SHADOW) == STYLE_SHADOW) {
                result.write(FONT_SHADOW);
            }
            if((fontStyle & STYLE_OUTLINE) == STYLE_OUTLINE) {
                result.write(FONT_OUTLINE);
            }
            if((fontStyle & STYLE_EMBOSSED) == STYLE_EMBOSSED) {
                result.write(FONT_EMBOSSED);
            }
            if((fontStyle & STYLE_ENGRAVED) == STYLE_ENGRAVED) {
                result.write(FONT_ENGRAVED);
            }
        }
        if(color != null) {
            color.writeBegin(result);
        }
    }
595364
private void writeSimpleString(OutputStream out, CharSequence value) throws IOException {
        out.write('"');
        for (int i = 0; i < value.length(); i++) {
            out.write(value.charAt(i));
        }
        out.write('"');
    }
1087685
public void writeDefinition(final OutputStream result) throws IOException
    {
        result.write(ANSI);
        result.write(ANSI_CODEPAGE);
        result.write(intToByteArray(1252));
        this.document.outputDebugLinebreak(result);    	
    }
489719
protected void writeListNumbers(final OutputStream result) throws IOException {
        result.write(RtfList.LIST_NUMBER);
        result.write(intToByteArray(listNumber));
    }
867883
public void writeTo(final OutputStream output) throws IOException {
    final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output);
    writeTo(codedOutput);
    codedOutput.flush();
  }
224530
public void writeContent(final OutputStream result) throws IOException
    {
        if(this.document.getLastElementWritten() != null && !(this.document.getLastElementWritten() instanceof RtfChapter)) {
            result.write(DocWriter.getISOBytes("\\page"));
        }
        result.write(DocWriter.getISOBytes("\\sectd"));
        document.getDocumentHeader().writeSectionDefinition(result);
        if(this.title != null) {
            this.title.writeContent(result);
        }
        for(int i = 0; i < items.size(); i++) {
        	RtfBasicElement rbe = (RtfBasicElement)items.get(i);
        	rbe.writeContent(result);
        }
        result.write(DocWriter.getISOBytes("\\sect"));
    }
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();
	}
786028
public void writeContent(final OutputStream result) throws IOException
    {
        result.write(NEW_PAGE);
        result.write(RtfParagraph.PARAGRAPH_DEFAULTS);    	
    }
784034
public void fsync(Result<Boolean> result)
      throws IOException
  {
    SegmentStream nodeStream = _nodeStream;
      
    // FlushCompletion cont = new FlushCompletion(result, nodeStream, blobStream);
    
    if (nodeStream != null) {
      nodeStream.fsync(result);
    }
    else {
      result.ok(true);
    }
  }
489969
@Override
	public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
		this.startOutput();
		for (String formattedResult : messageFormatter.formatResults(results, server)) {
				log.debug("Sending result: {}", formattedResult);
				this.sendOutput(formattedResult);
		}
		this.finishOutput();
	}
828316
public void writeTo(OutputStream out)
        throws IOException
    {
        out.write(_buf,_start,_pos-_start);
    }
971713
private void writeParagraphSettings(final OutputStream result) throws IOException {
        if(this.keepTogether) {
            result.write(RtfParagraphStyle.KEEP_TOGETHER);
        }
        if(this.keepTogetherWithNext) {
            result.write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT);
        }
        switch (alignment) {
            case Element.ALIGN_LEFT:
                result.write(RtfParagraphStyle.ALIGN_LEFT);
                break;
            case Element.ALIGN_RIGHT:
                result.write(RtfParagraphStyle.ALIGN_RIGHT);
                break;
            case Element.ALIGN_CENTER:
                result.write(RtfParagraphStyle.ALIGN_CENTER);
                break;
            case Element.ALIGN_JUSTIFIED:
            case Element.ALIGN_JUSTIFIED_ALL:
                result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
                break;
        }
        result.write(FIRST_LINE_INDENT);
        result.write(intToByteArray(this.firstLineIndent));
        result.write(RtfParagraphStyle.INDENT_LEFT);
        result.write(intToByteArray(indentLeft));
        result.write(RtfParagraphStyle.INDENT_RIGHT);
        result.write(intToByteArray(indentRight));
        if(this.spacingBefore > 0) {
            result.write(RtfParagraphStyle.SPACING_BEFORE);
            result.write(intToByteArray(this.spacingBefore));
        }
        if(this.spacingAfter > 0) {
            result.write(RtfParagraphStyle.SPACING_AFTER);
            result.write(intToByteArray(this.spacingAfter));
        }
        if(this.lineLeading > 0) {
            result.write(RtfParagraph.LINE_SPACING);
            result.write(intToByteArray(this.lineLeading));
        }            
    }
357518
public void writeBegin(final OutputStream result) throws IOException {
        result.write(DocWriter.getISOBytes("\\s"));
        result.write(intToByteArray(this.styleNumber));
        writeParagraphSettings(result);
    }
485303
public void writeContent(final OutputStream result) throws IOException
    {
        try {
            // This is so that all color, font and similar information is processed once, before
            // the header section is written.
            writeSectionDefinition(new RtfNilOutputStream());
            
            this.codePage.writeDefinition(result);
            this.fontList.writeDefinition(result);
            this.colorList.writeDefinition(result);
            this.stylesheetList.writeDefinition(result);
            this.listTable.writeDefinition(result);
            this.generator.writeContent(result);
            this.infoGroup.writeContent(result);
            this.protectionSetting.writeDefinition(result);
            this.pageSetting.writeDefinition(result);
            
            writeSectionDefinition(result);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
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"));
    }
397567
@Override
	final public void writeSuffixTo(Appendable out) throws IOException {
		writeSuffix(buffer, out);
		buffer.setLength(0);
	}
1327337
public void writeDefinition(final OutputStream result) throws IOException 
    {
        result.write(DEFAULT_FONT);
        result.write(intToByteArray(0));
        result.write(OPEN_GROUP);
        result.write(FONT_TABLE);
        for(int i = 0; i < fontList.size(); i++) {
            result.write(OPEN_GROUP);
            result.write(FONT_NUMBER);
            result.write(intToByteArray(i));
            RtfFont rf = (RtfFont) fontList.get(i);
            rf.writeDefinition(result);
            result.write(COMMA_DELIMITER);
            result.write(CLOSE_GROUP);
        }
        result.write(CLOSE_GROUP);
        this.document.outputDebugLinebreak(result);    	
    }