FileDocCategorySizeDatePackage
PieceDescriptor.javaAPI DocApache Poi 3.0.12785Mon Jan 01 18:55:34 GMT 2007org.apache.poi.hwpf.model

PieceDescriptor

public class PieceDescriptor extends Object

Fields Summary
short
descriptor
private static BitField
fNoParaLast
private static BitField
fPaphNil
private static BitField
fCopied
int
fc
short
prm
boolean
unicode
Constructors Summary
public PieceDescriptor(byte[] buf, int offset)



      
  
    descriptor = LittleEndian.getShort(buf, offset);
    offset += LittleEndian.SHORT_SIZE;
    fc = LittleEndian.getInt(buf, offset);
    offset += LittleEndian.INT_SIZE;
    prm = LittleEndian.getShort(buf, offset);

    // see if this piece uses unicode.
    if ((fc & 0x40000000) == 0)
    {
        unicode = true;
    }
    else
    {
        unicode = false;
        fc &= ~(0x40000000);//gives me FC in doc stream
        fc /= 2;
    }

  
Methods Summary
public booleanequals(java.lang.Object o)

    PieceDescriptor pd = (PieceDescriptor)o;

    return descriptor == pd.descriptor && prm == pd.prm && unicode == pd.unicode;
  
public intgetFilePosition()

    return fc;
  
public static intgetSizeInBytes()

    return 8;
  
public booleanisUnicode()

    return unicode;
  
public voidsetFilePosition(int pos)

    fc = pos;
  
protected byte[]toByteArray()

    // set up the fc
    int tempFc = fc;
    if (!unicode)
    {
      tempFc *= 2;
      tempFc |= (0x40000000);
    }

    int offset = 0;
    byte[] buf = new byte[8];
    LittleEndian.putShort(buf, offset, descriptor);
    offset += LittleEndian.SHORT_SIZE;
    LittleEndian.putInt(buf, offset, tempFc);
    offset += LittleEndian.INT_SIZE;
    LittleEndian.putShort(buf, offset, prm);

    return buf;