FileDocCategorySizeDatePackage
MutableProperty.javaAPI DocApache Poi 3.0.13519Mon Jan 01 12:39:34 GMT 2007org.apache.poi.hpsf

MutableProperty

public class MutableProperty extends Property

Adds writing capability to the {@link Property} class.

Please be aware that this class' functionality will be merged into the {@link Property} class at a later time, so the API will change.

author
Rainer Klute <klute@rainer-klute.de>
since
2003-08-03
version
$Id: MutableProperty.java 489730 2006-12-22 19:18:16Z bayard $

Fields Summary
Constructors Summary
public MutableProperty()

Creates an empty property. It must be filled using the set method to be usable.

 
public MutableProperty(Property p)

Creates a MutableProperty as a copy of an existing Property.

param
p The property to copy.

        setID(p.getID());
        setType(p.getType());
        setValue(p.getValue());
    
Methods Summary
public voidsetID(long id)

Sets the property's ID.

param
id the ID

        this.id = id;
    
public voidsetType(long type)

Sets the property's type.

param
type the property's type

        this.type = type;
    
public voidsetValue(java.lang.Object value)

Sets the property's value.

param
value the property's value

        this.value = value;
    
public intwrite(java.io.OutputStream out, int codepage)

Writes the property to an output stream.

param
out The output stream to write to.
param
codepage The codepage to use for writing non-wide strings
return
the number of bytes written to the stream
exception
IOException if an I/O error occurs
exception
WritingNotSupportedException if a variant type is to be written that is not yet supported

        int length = 0;
        long variantType = getType();

        /* Ensure that wide strings are written if the codepage is Unicode. */
        if (codepage == Constants.CP_UNICODE && variantType == Variant.VT_LPSTR)
            variantType = Variant.VT_LPWSTR;

        length += TypeWriter.writeUIntToStream(out, variantType);
        length += VariantSupport.write(out, variantType, getValue(), codepage);
        return length;