/** * Given a byte array of 16-bit unicode characters in little endian * format (most important byte last), return a Java String representation * of it. * <p> * { 0x16, 0x00 } -0x16 * * @param string the byte array to be converted * @return the converted string, never <code>null</code> */ public static String getFromUnicodeLE(byte[] string) { if (string.length == 0) { return ""; } return getFromUnicodeLE(string, 0, string.length / 2); }
public String toJavaString() { if ( _value.length == 0 ) { return null; } String result = StringUtil.getFromUnicodeLE( _value, 0, _value.length >> 1 ); final int terminator = result.indexOf( '\0' ); if ( terminator == -1 ) { String msg = "String terminator (\\0) for UnicodeString property value not found."+ "Continue without trimming and hope for the best."; LOG.log(POILogger.WARN, msg); return result; } if ( terminator != result.length() - 1 ) { String msg = "String terminator (\\0) for UnicodeString property value occured before the end of string. "+ "Trimming and hope for the best."; LOG.log(POILogger.WARN, msg); } return result.substring( 0, terminator ); }
/** * The filename of the embedded image */ public String getFileName() { EscherComplexProperty propFile = getOptRecord().lookup( EscherProperties.BLIP__BLIPFILENAME); return (null == propFile) ? "" : StringUtil.getFromUnicodeLE(propFile.getComplexData()).trim(); }
/** * @return the name of this shape */ public String getShapeName() { EscherOptRecord eor = getOptRecord(); if (eor == null) { return null; } EscherProperty ep = eor.lookup(EscherProperties.GROUPSHAPE__SHAPENAME); if (ep instanceof EscherComplexProperty) { return StringUtil.getFromUnicodeLE(((EscherComplexProperty)ep).getComplexData()); } return null; } }
/** * Does this HSSFPatriarch contain a chart? * (Technically a reference to a chart, since they * get stored in a different block of records) * FIXME - detect chart in all cases (only seems * to work on some charts so far) */ public boolean containsChart() { // TODO - support charts properly in usermodel // We're looking for a EscherOptRecord EscherOptRecord optRecord = (EscherOptRecord) _boundAggregate.findFirstWithId(EscherOptRecord.RECORD_ID); if (optRecord == null) { // No opt record, can't have chart return false; } for (EscherProperty prop : optRecord.getEscherProperties()) { if (prop.getPropertyNumber() == 896 && prop.isComplex()) { EscherComplexProperty cp = (EscherComplexProperty) prop; String str = StringUtil.getFromUnicodeLE(cp.getComplexData()); if (str.equals("Chart 1\0")) { return true; } } } return false; }
private String read2007and2010String(InputStream stream) throws IOException, TikaException { int stringLen = EndianUtils.readUShortLE(stream); byte[] stringData = new byte[stringLen * 2]; IOUtils.readFully(stream, stringData); String value = StringUtil.getFromUnicodeLE(stringData); // Some strings are null terminated if(value.charAt(value.length()-1) == 0) { value = value.substring(0, value.length()-1); } return value; }
/** * Returns the text. Note that line endings * are \r and not \n */ public String getText() { return StringUtil.getFromUnicodeLE( data, 0, data.length/2 ); }
/** Grabs the text. Never <code>null</code> */ public String getText() { return StringUtil.getFromUnicodeLE(_text); }
/** Grabs the text. */ public String getText() { return StringUtil.getFromUnicodeLE(_text); }
/** Grabs the text. */ public String getText() { return StringUtil.getFromUnicodeLE(_text); }
/** Grabs the text. Never <code>null</code> */ public String getText() { return StringUtil.getFromUnicodeLE(_text); }
/** * Given a byte array of 16-bit unicode characters in little endian * format (most important byte last), return a Java String representation * of it. * * { 0x16, 0x00 } -0x16 * * @param string the byte array to be converted * @return the converted string, never <code>null</code> */ public static String getFromUnicodeLE(byte[] string) { if(string.length == 0) { return ""; } return getFromUnicodeLE(string, 0, string.length / 2); }
/** * Given a byte array of 16-bit unicode characters in little endian * format (most important byte last), return a Java String representation * of it. * * { 0x16, 0x00 } -0x16 * * @param string the byte array to be converted * @return the converted string, never <code>null</code> */ public static String getFromUnicodeLE(byte[] string) { if(string.length == 0) { return ""; } return getFromUnicodeLE(string, 0, string.length / 2); }
/** * Returns the text. Note that line endings * are \r and not \n */ public String getText() { return StringUtil.getFromUnicodeLE(getData()); }
private String read2007and2010String(InputStream stream) throws IOException, TikaException { int stringLen = EndianUtils.readUShortLE(stream); byte[] stringData = new byte[stringLen * 2]; IOUtils.readFully(stream, stringData); String value = StringUtil.getFromUnicodeLE(stringData); // Some strings are null terminated if(value.charAt(value.length()-1) == 0) { value = value.substring(0, value.length()-1); } return value; }
private String read2007and2010String(InputStream stream) throws IOException, TikaException { int stringLen = EndianUtils.readUShortLE(stream); byte[] stringData = new byte[stringLen * 2]; IOUtils.readFully(stream, stringData); String value = StringUtil.getFromUnicodeLE(stringData); // Some strings are null terminated if(value.charAt(value.length()-1) == 0) { value = value.substring(0, value.length()-1); } return value; }
/** * The filename of the embedded image */ public String getFileName() { EscherComplexProperty propFile = getOptRecord().lookup( EscherProperties.BLIP__BLIPFILENAME); return (null == propFile) ? "" : StringUtil.getFromUnicodeLE(propFile.getComplexData()).trim(); }
/** * Name of this picture. * * @return name of this picture */ public String getPictureName(){ AbstractEscherOptRecord opt = getEscherOptRecord(); EscherComplexProperty prop = getEscherProperty(opt, EscherProperties.BLIP__BLIPFILENAME); if (prop == null) return null; String name = StringUtil.getFromUnicodeLE(prop.getComplexData()); return name.trim(); }
private void parseString() { String tmpValue; if (getType() == Types.ASCII_STRING) { tmpValue = parseAs7BitData(rawValue, encoding7Bit); } else if (getType() == Types.UNICODE_STRING) { tmpValue = StringUtil.getFromUnicodeLE(rawValue); } else { throw new IllegalArgumentException("Invalid type " + getType() + " for String Chunk"); } // Clean up this.value = tmpValue.replace("\0", ""); }
/** * @return the name of this shape */ public String getShapeName() { EscherOptRecord eor = getOptRecord(); if (eor == null) { return null; } EscherProperty ep = eor.lookup(EscherProperties.GROUPSHAPE__SHAPENAME); if (ep instanceof EscherComplexProperty) { return StringUtil.getFromUnicodeLE(((EscherComplexProperty)ep).getComplexData()); } return null; } }