StringPtgpublic class StringPtg extends Ptg Number
Stores a String value in a formula value stored in the format <length 2 bytes>char[] |
Fields Summary |
---|
public static final int | SIZE | public static final byte | sid | int | field_1_length | byte | field_2_options | BitField | fHighByte | private String | field_3_string |
Constructors Summary |
---|
private StringPtg()
//Required for clone methods
| public StringPtg(RecordInputStream in)Create a StringPtg from a byte array read from disk
field_1_length = in.readByte() & 0xFF;
field_2_options = in.readByte();
if (fHighByte.isSet(field_2_options)) {
field_3_string= in.readUnicodeLEString(field_1_length);
}else {
field_3_string=in.readCompressedUnicode(field_1_length);
}
//setValue(new String(data, offset+3, data[offset+1] + 256*data[offset+2]));
| public StringPtg(String value)Create a StringPtg from a string representation of the number
Number format is not checked, it is expected to be validated in the parser
that calls this method.
if (value.length() >255) {
throw new IllegalArgumentException("String literals in formulas cant be bigger than 255 characters ASCII");
}
this.field_2_options=0;
field_2_options = (byte)this.fHighByte.setBoolean(field_2_options, StringUtil.hasMultibyte(value));
this.field_3_string=value;
this.field_1_length=value.length(); //for the moment, we support only ASCII strings in formulas we create
|
Methods Summary |
---|
public java.lang.Object | clone()
StringPtg ptg = new StringPtg();
ptg.field_1_length = field_1_length;
ptg.field_2_options=field_2_options;
ptg.field_3_string=field_3_string;
return ptg;
| public byte | getDefaultOperandClass()
return Ptg.CLASS_VALUE;
| public int | getSize()
if (fHighByte.isSet(field_2_options)) {
return 2*field_1_length+3;
} else {
return field_1_length+3;
}
| public java.lang.String | getValue()
return field_3_string;
| public java.lang.String | toFormulaString(org.apache.poi.hssf.model.Workbook book)
return "\""+getValue()+"\"";
| public void | writeBytes(byte[] array, int offset)
array[ offset + 0 ] = sid;
array[ offset + 1 ] = (byte)field_1_length;
array[ offset + 2 ] = field_2_options;
if (fHighByte.isSet(field_2_options)) {
StringUtil.putUnicodeLE(getValue(),array,offset+3);
}else {
StringUtil.putCompressedUnicode(getValue(),array,offset+3);
}
|
|