当前位置: 首页>>代码示例>>Java>>正文


Java LittleEndian.getUInt方法代码示例

本文整理汇总了Java中org.apache.poi.util.LittleEndian.getUInt方法的典型用法代码示例。如果您正苦于以下问题:Java LittleEndian.getUInt方法的具体用法?Java LittleEndian.getUInt怎么用?Java LittleEndian.getUInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.util.LittleEndian的用法示例。


在下文中一共展示了LittleEndian.getUInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createQCPLCBit

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public static QCPLCBit createQCPLCBit(String thingType, String bitType, byte[] data) {
	// Grab the type
	int type = (int)LittleEndian.getUInt(data, 4);
	switch(type) {
		case 0:
			return new Type0(thingType, bitType, data);
		case 4:
			return new Type4(thingType, bitType, data);
		case 8:
			return new Type8(thingType, bitType, data);
		case 12: // 0xc
			return new Type12(thingType, bitType, data);
		default:
			throw new IllegalArgumentException("Sorry, I don't know how to deal with PLCs of type " + type);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:17,代码来源:QCPLCBit.java

示例2: Type4

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private Type4(String thingType, String bitType, byte[] data) {
	super(thingType, bitType, data);

	// Grab our 4x pre-data
	preData = new int[4];
	preData[0] = LittleEndian.getUShort(data, 8+0);
	preData[1] = LittleEndian.getUShort(data, 8+2);
	preData[2] = LittleEndian.getUShort(data, 8+4);
	preData[3] = LittleEndian.getUShort(data, 8+6);

	// And grab the 4 byte values
	for(int i=0; i<numberOfPLCs; i++) {
		plcValA[i] = LittleEndian.getUInt(data, 16+(8*i));
		plcValB[i] = LittleEndian.getUInt(data, 16+(8*i)+4);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:17,代码来源:QCPLCBit.java

示例3: Type8

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private Type8(String thingType, String bitType, byte[] data) {
	super(thingType, bitType, data);

	// Grab our 7x pre-data
	preData = new int[7];
	preData[0] = LittleEndian.getUShort(data, 8+0);
	preData[1] = LittleEndian.getUShort(data, 8+2);
	preData[2] = LittleEndian.getUShort(data, 8+4);
	preData[3] = LittleEndian.getUShort(data, 8+6);
	preData[4] = LittleEndian.getUShort(data, 8+8);
	preData[5] = LittleEndian.getUShort(data, 8+10);
	preData[6] = LittleEndian.getUShort(data, 8+12);

	// And grab the 4 byte values
	for(int i=0; i<numberOfPLCs; i++) {
		plcValA[i] = LittleEndian.getUInt(data, 22+(8*i));
		plcValB[i] = LittleEndian.getUInt(data, 22+(8*i)+4);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:20,代码来源:QCPLCBit.java

示例4: createPointer

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public Pointer createPointer(byte[] data, int offset) {
	Pointer p;
	if(version >= 6) {
		p = new PointerV6();
		p.type = LittleEndian.getInt(data, offset+0);
		p.address = (int)LittleEndian.getUInt(data, offset+4);
		p.offset = (int)LittleEndian.getUInt(data, offset+8);
		p.length = (int)LittleEndian.getUInt(data, offset+12);
		p.format = LittleEndian.getShort(data, offset+16);

		return p;
	} else if(version == 5) {
		throw new RuntimeException("TODO");
	} else {
		throw new IllegalArgumentException("Visio files with versions below 5 are not supported, yours was " + version);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:18,代码来源:PointerFactory.java

示例5: readFromOldIndexBlock

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public static DocumentLocation readFromOldIndexBlock(byte[] block, int index) {
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index-8, index), 0, 0));
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index, index+8), 0, 0));
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index+8, index+16), 0, 0));
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index+16, index+20), 0, 0));
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index+20, index+28), 0, 0));
//        System.out.println(HexDump.dump(Arrays.copyOfRange(block, index+28, index+32), 0, 0));

        DocumentLocation header = new DocumentLocation();
        
        header.segmentId = LittleEndian.getLong(block, index);
        
        int offset = 8;
        header.arcCreationDate = LittleEndian.getLong(block, index+offset);
        offset += 8;
        
        header.arcFilePartition = LittleEndian.getUInt(block, index+offset);
        offset += 4;
        
        header.arcFileOffset = LittleEndian.getLong(block, index+offset);
        offset += 8;
        
        header.arcFileSize = LittleEndian.getUInt(block, index+offset);
        
        //System.out.println(segmentId + "/" + arcCreationDate + "/" + arcFilePartition + "/" + arcFileOffset + "/" + arcFileSize);
        
        return header;
    }
 
开发者ID:centic9,项目名称:CommonCrawlDocumentDownload,代码行数:29,代码来源:DocumentLocation.java

示例6: readStartPos

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public static Pair<Long, Long> readStartPos(CloseableHttpClient client) throws IOException {
    log.info("Reading header from " + INDEX_URL);
    HttpGet httpGet = new HttpGet(INDEX_URL);
    try (CloseableHttpResponse response = client.execute(httpGet)) {
        HttpEntity entity = Utils.checkAndFetch(response, INDEX_URL);

        try (InputStream stream = entity.getContent()) {
            try {
                // try with the first few bytes initially
                byte[] header = new byte[HEADER_BLOCK_SIZE];
                IOUtils.read(stream, header);

                HexDump.dump(header, 0, System.out, 0);

                long blockSize = LittleEndian.getUInt(header, 0);
                long indexBlockCount = LittleEndian.getUInt(header, 4);
                log.info("Header: blockSize " + blockSize + ", indexBlockCount: " + indexBlockCount);

                return ImmutablePair.of(blockSize, HEADER_BLOCK_SIZE + (blockSize * indexBlockCount));
            } finally {
                // always abort reading here inside the finally block of the InputStream as
                // otherwise HttpClient tries to read the stream fully, which is at least 270GB...
                httpGet.abort();
            }
        }
    }
}
 
开发者ID:centic9,项目名称:CommonCrawlDocumentDownload,代码行数:28,代码来源:Utils.java

示例7: QCPLCBit

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private QCPLCBit(String thingType, String bitType, byte[] data) {
	super(thingType, bitType, data);

	// First four bytes are the number
	numberOfPLCs = (int)LittleEndian.getUInt(data, 0);

	// Next four bytes are the type
	typeOfPLCS = (int)LittleEndian.getUInt(data, 4);

	// Init the arrays that we can
	plcValA = new long[numberOfPLCs];
	plcValB = new long[numberOfPLCs];
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:14,代码来源:QCPLCBit.java

示例8: HDGFDiagram

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public HDGFDiagram(DirectoryNode dir) throws IOException {
	super(dir);

	DocumentEntry docProps =
		(DocumentEntry)dir.getEntry("VisioDocument");

	// Grab the document stream
	_docstream = new byte[docProps.getSize()];
	dir.createDocumentInputStream("VisioDocument").read(_docstream);

	// Check it's really visio
	String typeString = new String(_docstream, 0, 20);
	if(! typeString.equals(VISIO_HEADER)) {
		throw new IllegalArgumentException("Wasn't a valid visio document, started with " + typeString);
	}

	// Grab the version number, 0x1a -> 0x1b
	version = LittleEndian.getShort(_docstream, 0x1a);
	// Grab the document size, 0x1c -> 0x1f
	docSize = LittleEndian.getUInt(_docstream, 0x1c);
	// ??? 0x20 -> 0x23

	// Create the Chunk+Pointer Factories for the document version
	ptrFactory = new PointerFactory(version);
	chunkFactory = new ChunkFactory(version);

	// Grab the pointer to the trailer
	trailerPointer = ptrFactory.createPointer(_docstream, 0x24);

	// Now grab the trailer
	trailer = (TrailerStream)
		Stream.createStream(trailerPointer, _docstream, chunkFactory, ptrFactory);

	// Finally, find all our streams
	trailer.findChildren(_docstream);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:37,代码来源:HDGFDiagram.java

示例9: PointerContainingStream

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
protected PointerContainingStream(Pointer pointer, StreamStore store, ChunkFactory chunkFactory, PointerFactory pointerFactory) {
	super(pointer, store);
	this.chunkFactory = chunkFactory;
	this.pointerFactory = pointerFactory;

	// Find the offset to the number of child pointers we have
	// This ought to be the first thing stored in us
	numPointersLocalOffset = (int)LittleEndian.getUInt(
			store.getContents(), 0
	);

	// Generate the objects for the pointers we contain
	int numPointers = (int)LittleEndian.getUInt(
			store.getContents(), numPointersLocalOffset
	);
	childPointers = new Pointer[numPointers];

	// After the number of pointers is another (unknown)
	//  4 byte value
	int pos = numPointersLocalOffset + 4 + 4;

	// Now create the pointer objects
	for(int i=0; i<numPointers; i++) {
		childPointers[i] = pointerFactory.createPointer(
				store.getContents(), pos
		);
		pos += childPointers[i].getSizeInBytes();
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:30,代码来源:PointerContainingStream.java

示例10: dump

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
  * Dump a part of the document stream into XML
  * @param data PPT binary data
  * @param offset offset from the beginning of the document
  * @param length of the document
  * @param padding used for formatting results
  * @throws java.io.IOException
  */
 public void dump(byte[] data, int offset, int length, int padding) throws IOException {
     int pos = offset;
     while (pos <= (offset + length - HEADER_SIZE)){
         if (pos < 0) break;

         //read record header
         int info = LittleEndian.getUShort(data, pos);
         pos += LittleEndian.SHORT_SIZE;
         int type = LittleEndian.getUShort(data, pos);
         pos += LittleEndian.SHORT_SIZE;
         int size = (int)LittleEndian.getUInt(data, pos);
         pos += LittleEndian.INT_SIZE;

         //get name of the record by type
         String recname = RecordTypes.recordName(type);
         write(out, "<"+recname + " info=\""+info+"\" type=\""+type+"\" size=\""+size+"\" offset=\""+(pos-8)+"\"", padding);
         if (hexHeader){
             out.write(" header=\"");
             dump(out, data, pos-8, 8, 0, false);
             out.write("\"");
         }
         out.write(">" + CR);
padding++;
         //this check works both for Escher and PowerPoint records
         boolean isContainer = (info & 0x000F) == 0x000F;
         if (isContainer) {
             //continue to dump child records
             dump(data, pos, size, padding);
         } else {
             //dump first 100 bytes of the atom data
             dump(out, data, pos, Math.min(size, data.length-pos), padding, true);
         }
padding--;
         write(out, "</"+recname + ">" + CR, padding);

         pos += size;
     }
 }
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:47,代码来源:PPTXMLDump.java

示例11: findRecordAtPos

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public static Record findRecordAtPos(int pos) {
	long type = LittleEndian.getUShort(fileContents, pos+2);
	long rlen = LittleEndian.getUInt(fileContents, pos+4);

	Record r = Record.createRecordForType(type,fileContents,pos,(int)rlen+8);

	return r;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:9,代码来源:UserEditAndPersistListing.java

示例12: buildRecordAtOffset

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * Build and return the Record at the given offset.
 * Note - does less error checking and handling than findChildRecords
 * @param b The byte array to build from
 * @param offset The offset to build at
 */
public static Record buildRecordAtOffset(byte[] b, int offset) {
	long type = LittleEndian.getUShort(b,offset+2);
	long rlen = LittleEndian.getUInt(b,offset+4);

	// Sanity check the length
	int rleni = (int)rlen;
	if(rleni < 0) { rleni = 0; }

	return createRecordForType(type,b,offset,8+rleni);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:17,代码来源:Record.java

示例13: findChildRecords

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * Default method for finding child records of a container record
 */
public static Record[] findChildRecords(byte[] b, int start, int len) {
	List<Record> children = new ArrayList<Record>(5);

	// Jump our little way along, creating records as we go
	int pos = start;
	while(pos <= (start+len-8)) {
		long type = LittleEndian.getUShort(b,pos+2);
		long rlen = LittleEndian.getUInt(b,pos+4);

		// Sanity check the length
		int rleni = (int)rlen;
		if(rleni < 0) { rleni = 0; }

		// Abort if first record is of type 0000 and length FFFF,
		//  as that's a sign of a screwed up record
		if(pos == 0 && type == 0l && rleni == 0xffff) {
			throw new CorruptPowerPointFileException("Corrupt document - starts with record of type 0000 and length 0xFFFF");
		}

		Record r = createRecordForType(type,b,pos,8+rleni);
		if(r != null) {
			children.add(r);
		} else {
			// Record was horribly corrupt
		}
		pos += 8;
		pos += rleni;
	}

	// Turn the vector into an array, and return
	Record[] cRecords = children.toArray( new Record[children.size()] );
	return cRecords;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:37,代码来源:Record.java

示例14: fillFields

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
protected void fillFields( byte[] data, int offset )
{
    field_1_version                = LittleEndian.getUInt( data, 0x0 + offset );
    field_2_bits                   = LittleEndian.getShort( data, 0x4 + offset );
    field_3_cch                    = LittleEndian.getShort( data, 0x6 + offset );
    field_4_hps                    = LittleEndian.getShort( data, 0x8 + offset );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:8,代码来源:FFDataBaseAbstractType.java

示例15: Type12

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private Type12(String thingType, String bitType, byte[] data) {
	super(thingType, bitType, data);

	// How many hyperlinks do we really have?
	// (zero hyperlinks gets numberOfPLCs=1)
	if(data.length == 0x34) {
		hyperlinks = new String[0];
	} else {
		hyperlinks = new String[numberOfPLCs];
	}

	// We have 4 bytes, then the start point of each
	//  hyperlink, then the end point of the text.
	preData = new int[1+numberOfPLCs+1];
	for(int i=0; i<preData.length; i++) {
		preData[i] = (int)LittleEndian.getUInt(data, 8+(i*4));
	}

	// Then we have a whole bunch of stuff, which grows
	//  with the number of hyperlinks
	// For now, we think these are shorts
	int at = 8+4+(numberOfPLCs*4)+4;
	int until = 0x34;
	if(numberOfPLCs == 1 && hyperlinks.length == 1) {
		until = oneStartsAt;
	} else if(numberOfPLCs >= 2) {
		until = twoStartsAt + (numberOfPLCs-2)*threePlusIncrement;
	}

	plcValA = new long[(until-at)/2];
	plcValB = new long[0];
	for(int i=0; i<plcValA.length; i++) {
		plcValA[i] = LittleEndian.getUShort(data, at+(i*2));
	}

	// Finally, we have a series of lengths + hyperlinks
	at = until;
	for(int i=0; i<hyperlinks.length; i++) {
		int len = LittleEndian.getUShort(data, at);
		int first = LittleEndian.getUShort(data, at+2);
		if(first == 0) {
			// Crazy special case
			// Length is in bytes, from the start
			// Hyperlink appears to be empty
			hyperlinks[i] = "";
			at += len;
		} else {
			// Normal case. Length is in characters
			hyperlinks[i] = StringUtil.getFromUnicodeLE(data, at+2, len);
			at += 2 + (2*len);
		}
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:54,代码来源:QCPLCBit.java


注:本文中的org.apache.poi.util.LittleEndian.getUInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。