/** * get an unsigned short value from the beginning of a byte array * * @param data * the byte array * @return the unsigned short (16-bit) value in an int */ public static int getUShort( byte[] data ) { return getUShort( data, 0 ); }
public EscherColorRef(byte[] source, int start, int len) { assert(len == 4 || len == 6); int offset = start; if (len == 6) { opid = LittleEndian.getUShort(source, offset); offset += 2; } colorRef = LittleEndian.getInt(source, offset); }
public int getNumberOfElementsInMemory() { return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 2); }
/** * Gets the locator for the corresponding {@link org.apache.poi.hssf.record.SharedFormulaRecord}, * {@link org.apache.poi.hssf.record.ArrayRecord} or {@link org.apache.poi.hssf.record.TableRecord} * if this formula belongs to such a grouping. The {@link CellReference} * returned by this method will match the top left corner of the range of that grouping. * The return value is usually not the same as the location of the cell containing this formula. * * @return the firstRow & firstColumn of an array formula or shared formula that this formula * belongs to. <code>null</code> if this formula is not part of an array or shared formula. */ public CellReference getExpReference() { byte[] data = _byteEncoding; if (data.length != 5) { // tExp and tTbl are always 5 bytes long, and the only ptg in the formula return null; } switch (data[0]) { case ExpPtg.sid: break; case TblPtg.sid: break; default: return null; } int firstRow = LittleEndian.getUShort(data, 1); int firstColumn = LittleEndian.getUShort(data, 3); return new CellReference(firstRow, firstColumn); } public boolean isSame(Formula other) {
public int getNumberOfElementsInArray() { return (emptyComplexPart) ? 0 : LittleEndian.getUShort(getComplexData(), 0); }
@Override public int readUShort() { byte buf[] = new byte[LittleEndianConsts.SHORT_SIZE]; try { checkEOF(read(buf), LittleEndianConsts.SHORT_SIZE); } catch (IOException e) { throw new RuntimeException(e); } return LittleEndian.getUShort(buf); }
/** * Reads an unsigned short value without decrypting */ @Override public int readRecordSID() { readPlain(buffer, 0, LittleEndianConsts.SHORT_SIZE); int sid = LittleEndian.getUShort(buffer, 0); shouldSkipEncryptionOnCurrentRecord = isNeverEncryptedRecord(sid); return sid; }
/** * Reads an unsigned short value without decrypting */ @Override public int readDataSize() { readPlain(buffer, 0, LittleEndianConsts.SHORT_SIZE); int dataSize = LittleEndian.getUShort(buffer, 0); ccis.setNextRecordSize(dataSize); return dataSize; }
@Override public int readUShort() { checkAvaliable(SHORT_SIZE); byte[] data = new byte[SHORT_SIZE]; readFully(data, 0, SHORT_SIZE); return LittleEndian.getUShort(data); }
for (int i = 0; i < compressed.length; i++) { if (compressed[i] == 0x01 && i < compressed.length-1) { int w = LittleEndian.getUShort(compressed, i+1); if (w <= 0 || (w & 0x7000) != 0x3000) { continue;
return Byte.toString(b[0]); case 2: return Integer.toString( LittleEndian.getUShort(b) ); case 4: return Long.toString( LittleEndian.getUInt(b) );
@Override public boolean verifyPassword(String password) { XOREncryptionVerifier ver = (XOREncryptionVerifier)getEncryptionInfo().getVerifier(); int keyVer = LittleEndian.getUShort(ver.getEncryptedKey()); int verifierVer = LittleEndian.getUShort(ver.getEncryptedVerifier()); int keyComp = CryptoFunctions.createXorKey1(password); int verifierComp = CryptoFunctions.createXorVerifier1(password); if (keyVer == keyComp && verifierVer == verifierComp) { byte xorArray[] = CryptoFunctions.createXorArray1(password); setSecretKey(new SecretKeySpec(xorArray, "XOR")); return true; } else { return false; } }
firstRow = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; lastRow = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; firstCol = LittleEndian.getUByte(data, offset); lastCol = LittleEndian.getUByte(data, offset); offset += LittleEndian.BYTE_SIZE; charCount = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; if (charCount < 2)
public ImageHeaderWMF(byte[] data, final int off) { int offset = off; int key = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; //header key if (key != APMHEADER_KEY) { LOG.log(POILogger.WARN, "WMF file doesn't contain a placeable header - ignore parsing"); handle = 0; left = 0; top = 0; right = 200; bottom = 200; inch = Units.POINT_DPI; //default resolution is 72 dpi reserved = 0; return; } handle = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; left = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; top = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; right = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; bottom = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; inch = LittleEndian.getUShort(data, offset); offset += LittleEndian.SHORT_SIZE; reserved = LittleEndian.getInt(data, offset); offset += LittleEndian.INT_SIZE; checksum = LittleEndian.getShort(data, offset); offset += LittleEndian.SHORT_SIZE; if (checksum != getChecksum()){ LOG.log(POILogger.WARN, "WMF checksum does not match the header data"); } }
if (LittleEndian.getUShort(subRecordData, 0) != CommonObjectDataSubRecord.sid) {
/** * Create a new holder for a boring record with children, but with * position dependent characteristics */ protected DummyPositionSensitiveRecordWithChildren(byte[] source, int start, int len) { // Just grab the header, not the whole contents _header = new byte[8]; System.arraycopy(source,start,_header,0,8); _type = LittleEndian.getUShort(_header,2); // Find our children _children = Record.findChildRecords(source,start+8,len-8); }
int machine = LittleEndian.getUShort(pe, 4); int numSectors = LittleEndian.getUShort(pe, 6); long createdAt = LittleEndian.getInt(pe, 8); long symbolTableOffset = LittleEndian.getInt(pe, 12); long numSymbols = LittleEndian.getInt(pe, 16); int sizeOptHdrs = LittleEndian.getUShort(pe, 20); int characteristcs = LittleEndian.getUShort(pe, 22);
public static Record findRecordAtPos(int pos) { long type = LittleEndian.getUShort(fileContents, pos+2); long rlen = LittleEndian.getUInt(fileContents, pos+4); return Record.createRecordForType(type,fileContents,pos,(int)rlen+8); } }