mirror of https://github.com/apache/poi.git
accept java string
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1187637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
679a16f022
commit
9a34081088
|
@ -2,6 +2,7 @@ package org.apache.poi.hpsf;
|
|||
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
||||
@Internal
|
||||
class UnicodeString
|
||||
|
@ -18,9 +19,8 @@ class UnicodeString
|
|||
return;
|
||||
}
|
||||
|
||||
_value = new byte[length * 2];
|
||||
LittleEndian.getByteArray( data, offset + LittleEndian.INT_SIZE,
|
||||
length * 2 );
|
||||
_value = LittleEndian.getByteArray( data, offset
|
||||
+ LittleEndian.INT_SIZE, length * 2 );
|
||||
|
||||
if ( _value[length * 2 - 1] != 0 || _value[length * 2 - 2] != 0 )
|
||||
throw new IllegalPropertySetDataException(
|
||||
|
@ -28,8 +28,22 @@ class UnicodeString
|
|||
+ " is not NULL-terminated" );
|
||||
}
|
||||
|
||||
String toJavaString()
|
||||
{
|
||||
if ( _value.length == 0 )
|
||||
return null;
|
||||
|
||||
return StringUtil.getFromUnicodeLE( _value, 0,
|
||||
( _value.length - 2 ) >> 1 );
|
||||
}
|
||||
|
||||
int getSize()
|
||||
{
|
||||
return LittleEndian.INT_SIZE + _value.length;
|
||||
}
|
||||
|
||||
byte[] getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue