FileDocCategorySizeDatePackage
WriteAccessRecord.javaAPI DocApache Poi 3.0.14812Mon Jan 01 12:39:40 GMT 2007org.apache.poi.hssf.record

WriteAccessRecord

public class WriteAccessRecord extends Record
Title: Write Access Record

Description: Stores the username of that who owns the spreadsheet generator (on unix the user's login, on Windoze its the name you typed when you installed the thing)

REFERENCE: PG 424 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

author
Andrew C. Oliver (acoliver at apache dot org)
version
2.0-pre

Fields Summary
public static final short
sid
private String
field_1_username
Constructors Summary
public WriteAccessRecord()


     
    
    
public WriteAccessRecord(RecordInputStream in)
Constructs a WriteAccess record and sets its fields appropriately.

param
id id must be 0x5c or an exception will be throw upon validation
param
size the size of the data area of the record
param
data data of the record (should not contain sid/len)

        super(in);
    
Methods Summary
protected voidfillFields(org.apache.poi.hssf.record.RecordInputStream in)

        byte[] data = in.readRemainder();
        //The string is always 112 characters (padded with spaces), therefore
        //this record can not be continued.

        //What a wierd record, it is not really a unicode string because the
        //header doesnt provide a correct size indication.???
        //But the header is present, so we need to skip over it.
        //Odd, Odd, Odd ;-)
        field_1_username = StringUtil.getFromCompressedUnicode(data, 3, data.length - 3);
    
public intgetRecordSize()

        return 116;
    
public shortgetSid()

        return sid;
    
public java.lang.StringgetUsername()
get the username for the user that created the report. HSSF uses the logged in user. On natively created M$ Excel sheet this would be the name you typed in when you installed it in most cases.

return
username of the user who is logged in (probably "tomcat" or "apache")

        return field_1_username;
    
public intserialize(int offset, byte[] data)

        String       username = getUsername();
        StringBuffer temp     = new StringBuffer(0x70 - (0x3));

        temp.append(username);
        while (temp.length() < 0x70 - 0x3)
        {
            temp.append(
                " ");   // (70 = fixed lenght -3 = the overhead bits of unicode string)
        }
        username = temp.toString();
        UnicodeString str = new UnicodeString(username);
        str.setOptionFlags(( byte ) 0x0);

        LittleEndian.putShort(data, 0 + offset, sid);
        LittleEndian.putShort(data, 2 + offset, (short)112);   // 112 bytes (115 total)
        UnicodeString.UnicodeRecordStats stats = new UnicodeString.UnicodeRecordStats();
        stats.recordSize += 4;
        stats.remainingSize-= 4;
        str.serialize(stats, 4 + offset, data);

        return getRecordSize();
    
public voidsetUsername(java.lang.String username)
set the username for the user that created the report. HSSF uses the logged in user.

param
username of the user who is logged in (probably "tomcat" or "apache")

        field_1_username = username;
    
public java.lang.StringtoString()

        StringBuffer buffer = new StringBuffer();

        buffer.append("[WRITEACCESS]\n");
        buffer.append("    .name            = ")
            .append(field_1_username.toString()).append("\n");
        buffer.append("[/WRITEACCESS]\n");
        return buffer.toString();
    
protected voidvalidateSid(short id)

        if (id != sid)
        {
            throw new RecordFormatException("NOT A WRITEACCESS RECORD");
        }