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:
Sergey Vladimirov 2011-10-22 02:01:04 +00:00
parent 86d46b4713
commit 8d5369235d
1 changed files with 17 additions and 3 deletions

View File

@ -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;
}
}