⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtffield.java

📁 iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        writeFieldInstEnd(result);
        return result.toByteArray();
    }
    /**
     * Writes the end of the field instruction area.
     */
    private void writeFieldInstEnd(OutputStream result) throws IOException 
    {
        if(fieldAlt) {
            result.write(DELIMITER);
            result.write(FIELD_ALT);
        }
        result.write(CLOSE_GROUP);
    }
    
    /**
     * Writes the beginning of the field result area
     * 
     * @return A byte array containing the beginning of the field result area
     * @deprecated replaced by {@link #writeFieldResultBegin(OutputStream)} 
     * @throws IOException
     */
    private byte[] writeFieldResultBegin() throws IOException 
    {
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        writeFieldResultBegin(result);
        return result.toByteArray();
    }
    /**
     * Writes the beginning of the field result area
     */
    private void writeFieldResultBegin(final OutputStream result) throws IOException 
    {
        result.write(OPEN_GROUP);
        result.write(FIELD_RESULT);
        result.write(DELIMITER);
    }
    
    /**
     * Writes the content of the pre-calculated field result. Override this
     * method in your subclasses.
     * 
     * @return A byte array containing the field result
     * @deprecated replaced by {@link #writeFieldResultContent(OutputStream)}
     * @throws IOException If an error occurs
     */
    protected abstract byte[] writeFieldResultContent() throws IOException;    
    /**
     * Writes the content of the pre-calculated field result. Override this
     * method in your subclasses.
     */ 
    protected void writeFieldResultContent(OutputStream out) throws IOException
    {
    	byte[] b = writeFieldResultContent();
    	if(b != null) out.write(b);
    }
    
    /**
     * Writes the end of the field result area
     * 
     * @return A byte array containing the end of the field result area
     * @deprecated replaced by {@link #writeFieldResultEnd(OutputStream)}
     * @throws IOException
     */
    private byte[] writeFieldResultEnd() throws IOException 
    {
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        writeFieldResultEnd(result);
        return result.toByteArray();
    }
    /**
     * Writes the end of the field result area
     */ 
    private void writeFieldResultEnd(final OutputStream result) throws IOException 
    {
        result.write(DELIMITER);
        result.write(CLOSE_GROUP);
    }
    
    /**
     * Writes the end of the field
     * 
     * @return A byte array containing the end of the field
     * @deprecated replaced by {@link #writeFieldEnd(OutputStream)}
     * @throws IOException
     */
    private byte[] writeFieldEnd() throws IOException
    {
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        writeFieldEnd(result);        
        return result.toByteArray();
    }
    /**
     * Writes the end of the field
     */
    private void writeFieldEnd(OutputStream result) throws IOException
    {
        result.write(CLOSE_GROUP);
    }
    
    
    /**
     * Write the content of this RtfField.
     * 
     * @return A byte array containing the content of this RtfField
     * @deprecated replaced by {@link #writeContent(OutputStream)}
     */
    public byte[] write()
    {
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        try {
        	writeContent(result);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
        return result.toByteArray();
    }
    /**
     * Writes the element content to the given output stream.
     */    
    public void writeContent(final OutputStream result) throws IOException
    {
        result.write(this.font.writeBegin());
        
//        result.write(writeFieldBegin());
//        result.write(writeFieldInstBegin());
//        result.write(writeFieldInstContent());
//        result.write(writeFieldInstEnd());
//        result.write(writeFieldResultBegin());
//        result.write(writeFieldResultContent());
//        result.write(writeFieldResultEnd());
//        result.write(writeFieldEnd());        
        writeFieldBegin(result);
        writeFieldInstBegin(result);
        writeFieldInstContent(result);
        writeFieldInstEnd(result);
        writeFieldResultBegin(result);
        writeFieldResultContent(result);
        writeFieldResultEnd(result);
        writeFieldEnd(result);
        
        result.write(this.font.writeEnd());
    }        
        
    /**
     * Get whether this field is an alt field
     * 
     * @return Returns whether this field is an alt field
     */
    public boolean isFieldAlt() {
        return fieldAlt;
    }
    
    /**
     * Set whether this field is an alt field
     * 
     * @param fieldAlt The value to use
     */
    public void setFieldAlt(boolean fieldAlt) {
        this.fieldAlt = fieldAlt;
    }
    
    /**
     * Get whether this field is dirty
     * 
     * @return Returns whether this field is dirty
     */
    public boolean isFieldDirty() {
        return fieldDirty;
    }
    
    /**
     * Set whether this field is dirty
     * 
     * @param fieldDirty The value to use
     */
    public void setFieldDirty(boolean fieldDirty) {
        this.fieldDirty = fieldDirty;
    }
    
    /**
     * Get whether this field is edited
     * 
     * @return Returns whether this field is edited
     */
    public boolean isFieldEdit() {
        return fieldEdit;
    }
    
    /**
     * Set whether this field is edited.
     * 
     * @param fieldEdit The value to use
     */
    public void setFieldEdit(boolean fieldEdit) {
        this.fieldEdit = fieldEdit;
    }
    
    /**
     * Get whether this field is locked
     * 
     * @return Returns the fieldLocked.
     */
    public boolean isFieldLocked() {
        return fieldLocked;
    }
    
    /**
     * Set whether this field is locked
     * @param fieldLocked The value to use
     */
    public void setFieldLocked(boolean fieldLocked) {
        this.fieldLocked = fieldLocked;
    }
    
    /**
     * Get whether this field is private
     * 
     * @return Returns the fieldPrivate.
     */
    public boolean isFieldPrivate() {
        return fieldPrivate;
    }
    
    /**
     * Set whether this field is private
     * 
     * @param fieldPrivate The value to use
     */
    public void setFieldPrivate(boolean fieldPrivate) {
        this.fieldPrivate = fieldPrivate;
    }

    /**
     * Sets whether this RtfField is in a table
     * 
     * @param inTable <code>True</code> if this RtfField is in a table, <code>false</code> otherwise
     */
    public void setInTable(boolean inTable) {
        this.inTable = inTable;
    }
    
    /**
     * Sets whether this RtfField is in a header
     * 
     * @param inHeader <code>True</code> if this RtfField is in a header, <code>false</code> otherwise
     */
    public void setInHeader(boolean inHeader) {
        this.inHeader = inHeader;
    }
    
    /**
     * An RtfField is never empty.
     */
    public boolean isEmpty() {
        return false;
    }
    
    /**
     * Override setFont to perform the correct font handling.
     */
    public void setFont(Font font) {
        super.setFont(font);
        this.font = new RtfFont(this.document, font);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -