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


Java LittleEndian.getUShort方法代码示例

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


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

示例1: Type0

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private Type0(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 2 byte values
	for(int i=0; i<numberOfPLCs; i++) {
		plcValA[i] = LittleEndian.getUShort(data, 16+(4*i));
		plcValB[i] = LittleEndian.getUShort(data, 16+(4*i)+2);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:17,代码来源:QCPLCBit.java

示例2: fillFields

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public void fillFields( byte[] data, int offset )
{
    int lcb = LittleEndian.getInt( data, offset );
    int cbHeader = LittleEndian.getUShort( data, offset
            + LittleEndian.INT_SIZE );

    if ( cbHeader != 0x44 )
    {
        log.log( POILogger.WARN, "NilPICFAndBinData at offset ", offset,
                " cbHeader 0x" + Integer.toHexString( cbHeader )
                        + " != 0x44" );
    }

    // skip the 62 ignored bytes
    int binaryLength = lcb - cbHeader;
    this._binData = ArrayUtil.copyOfRange( data, offset + cbHeader,
            offset + cbHeader + binaryLength );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:19,代码来源:NilPICFAndBinData.java

示例3: read

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public void read(byte[] data, int offset){
    int pos = offset;
    int key = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE; //header key
    if (key != APMHEADER_KEY) throw new HSLFException("Not a valid WMF file");

    handle = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    left = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    top = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    right = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    bottom = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;

    inch = LittleEndian.getUShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    reserved = LittleEndian.getInt(data, pos); pos += LittleEndian.INT_SIZE;

    checksum = LittleEndian.getShort(data, pos); pos += LittleEndian.SHORT_SIZE;
    if (checksum != getChecksum()){
        logger.log(POILogger.WARN, "WMF checksum does not match the header data");
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:20,代码来源:WMF.java

示例4: OldPAPBinTable

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public OldPAPBinTable(byte[] documentStream, int offset,
                   int size, int fcMin, TextPieceTable tpt)
{
  PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);

  int length = binTable.length();
  for (int x = 0; x < length; x++)
  {
    GenericPropertyNode node = binTable.getProperty(x);

    int pageNum = LittleEndian.getUShort(node.getBytes());
    int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;

    PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(documentStream,
      documentStream, pageOffset, tpt);

          for ( PAPX papx : pfkp.getPAPXs() )
          {
              if ( papx != null )
                  _paragraphs.add( papx );
          }
  }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:24,代码来源:OldPAPBinTable.java

示例5: Xst

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
public Xst( byte[] data, int startOffset )
{
    int offset = startOffset;

    _cch = LittleEndian.getUShort( data, offset );
    offset += LittleEndian.SHORT_SIZE;

    _rgtchar = new char[_cch];
    for ( int x = 0; x < _cch; x++ )
    {
        _rgtchar[x] = (char) LittleEndian.getShort( data, offset );
        offset += LittleEndian.SHORT_SIZE;
    }

}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:16,代码来源:Xst.java

示例6: BinaryTagDataBlob

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * Create a new holder for a boring record with children, but with
 *  position dependent characteristics
 */
protected BinaryTagDataBlob(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);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:14,代码来源:BinaryTagDataBlob.java

示例7: 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

示例8: getPictureType

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
private String getPictureType(byte[] header){
    String type;
    int meta = LittleEndian.getUShort(header, 0);

    switch(meta){
        case 0x46A0: type = "jpeg"; break;
        case 0x2160: type = "wmf"; break;
        case 0x6E00: type = "png"; break;
        default: type = "unknown"; break;
    }
    return type;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:13,代码来源:PPTXMLDump.java

示例9: 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

示例10: DummyRecordWithChildren

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * Create a new holder for a boring record with children
 */
protected DummyRecordWithChildren(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);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:13,代码来源:DummyRecordWithChildren.java

示例11: 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

示例12: PPDrawing

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * Sets everything up, groks the escher etc
 */
protected PPDrawing(byte[] source, int start, int len) {
	// Get the header
	_header = new byte[8];
	System.arraycopy(source,start,_header,0,8);

	// Get the type
	_type = LittleEndian.getUShort(_header,2);

	// Get the contents for now
	final byte[] contents = new byte[len];
	System.arraycopy(source,start,contents,0,len);

	// Build up a tree of Escher records contained within
	final DefaultEscherRecordFactory erf = new DefaultEscherRecordFactory();
	final Vector<EscherRecord> escherChildren = new Vector<EscherRecord>();
	findEscherChildren(erf, contents, 8, len-8, escherChildren);
	this.childRecords = (EscherRecord[]) escherChildren.toArray(new EscherRecord[escherChildren.size()]);

	if (1 == this.childRecords.length && (short)0xf002 == this.childRecords[0].getRecordId() && this.childRecords[0] instanceof EscherContainerRecord) {
		this.textboxWrappers = findInDgContainer((EscherContainerRecord) this.childRecords[0]);
	} else {
		// Find and EscherTextboxRecord's, and wrap them up
		final Vector<EscherTextboxWrapper> textboxes = new Vector<EscherTextboxWrapper>();
		findEscherTextboxRecord(childRecords, textboxes);
		this.textboxWrappers = (EscherTextboxWrapper[]) textboxes.toArray(new EscherTextboxWrapper[textboxes.size()]);
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:31,代码来源:PPDrawing.java

示例13: NotesAtom

import org.apache.poi.util.LittleEndian; //导入方法依赖的package包/类
/**
 * For the Notes Atom
 */
protected NotesAtom(byte[] source, int start, int len) {
	// Sanity Checking
	if(len < 8) { len = 8; }

	// Get the header
	_header = new byte[8];
	System.arraycopy(source,start,_header,0,8);

	// Get the slide ID
	slideID = LittleEndian.getInt(source,start+8);

	// Grok the flags, stored as bits
	int flags = LittleEndian.getUShort(source,start+12);
	if((flags&4) == 4) {
		followMasterBackground = true;
	} else {
		followMasterBackground = false;
	}
	if((flags&2) == 2) {
		followMasterScheme = true;
	} else {
		followMasterScheme = false;
	}
	if((flags&1) == 1) {
		followMasterObjects = true;
	} else {
		followMasterObjects = false;
	}

	// There might be 2 more bytes, which are a reserved field
	reserved = new byte[len-14];
	System.arraycopy(source,start+14,reserved,0,reserved.length);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:37,代码来源:NotesAtom.java

示例14: 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

示例15: QuillContents

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

	// Now parse the first 512 bytes, and produce
	//  all our bits

	// Check first 8 bytes
	String f8 = new String(data, 0, 8);
	if(! f8.equals("CHNKINK ")) {
		throw new IllegalArgumentException("Expecting 'CHNKINK ' but was '"+f8+"'");
	}
	// Ignore the next 24, for now at least

	// Now, parse all our QC Bits
	bits = new QCBit[20];
	for(int i=0; i<20; i++) {
		int offset = 0x20 + i*24;
		if(data[offset] == 0x18 && data[offset+1] == 0x00) {
			// Has some data
			String thingType = new String(data, offset+2, 4);
			int optA = LittleEndian.getUShort(data, offset+6);
			int optB = LittleEndian.getUShort(data, offset+8);
			int optC = LittleEndian.getUShort(data, offset+10);
			String bitType = new String(data, offset+12, 4);
			int from = (int)LittleEndian.getUInt(data, offset+16);
			int len = (int)LittleEndian.getUInt(data, offset+20);

			byte[] bitData = new byte[len];
			System.arraycopy(data, from, bitData, 0, len);

			// Create
			if(bitType.equals("TEXT")) {
				bits[i] = new QCTextBit(thingType, bitType, bitData);
			} else if(bitType.equals("PLC ")) {
				bits[i] = QCPLCBit.createQCPLCBit(thingType, bitType, bitData);
			} else {
				bits[i] = new UnknownQCBit(thingType, bitType, bitData);
			}
			bits[i].setOptA(optA);
			bits[i].setOptB(optB);
			bits[i].setOptC(optC);
			bits[i].setDataOffset(from);
		} else {
			// Doesn't have data
		}
	}
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:48,代码来源:QuillContents.java


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