本文整理汇总了Java中org.apache.poi.poifs.filesystem.DocumentEntry类的典型用法代码示例。如果您正苦于以下问题:Java DocumentEntry类的具体用法?Java DocumentEntry怎么用?Java DocumentEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentEntry类属于org.apache.poi.poifs.filesystem包,在下文中一共展示了DocumentEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkRecipientDirectoryEntry
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Parses a recipient directory entry which holds informations about one of possibly multiple recipients.
* The parsed information is put into the {@link OutlookMessage} object.
*
* @param dir The current node in the .msg file.
* @param msg The resulting {@link OutlookMessage} object.
* @throws IOException Thrown if the .msg file could not be parsed.
*/
private void checkRecipientDirectoryEntry(final DirectoryEntry dir, final OutlookMessage msg)
throws IOException {
final OutlookRecipient recipient = new OutlookRecipient();
// we iterate through all entries in the current directory
for (final Iterator<?> iter = dir.getEntries(); iter.hasNext(); ) {
final Entry entry = (Entry) iter.next();
// check whether the entry is either a directory entry
// or a document entry, while we are just interested in document entries on this level
if (!entry.isDirectoryEntry() && entry.isDocumentEntry()) {
// a document entry contains information about the mail (e.g, from, to, subject, ...)
checkRecipientDocumentEntry((DocumentEntry) entry, recipient);
}
}
//after all properties are set -> add recipient to msg object
msg.addRecipient(recipient);
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:28,代码来源:OutlookMessageParser.java
示例2: test
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
@Override
public boolean test(Entry entry) {
String entryName = entry.getName();
if (!SummaryInformation.DEFAULT_STREAM_NAME.equals(entryName)) {
return true;
}
if (!(entry instanceof DocumentEntry)) {
return true;
}
DocumentEntry dsiEntry = (DocumentEntry) entry;
sanitizeSummaryInformation(session, dsiEntry);
return true;
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:18,代码来源:SummaryInformationSanitiser.java
示例3: test1
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
@Test
void test1() {
// Test an invalid stream, should be ignored
Entry entry = mock(Entry.class);
doReturn("\005RandomString").when(entry).getName();
assertTrue(instance.test(entry));
verify(instance, never()).sanitizeSummaryInformation(eq(session), (DocumentEntry) any());
// Test a valid stream name, but wrong type (should be ignored)
reset(entry);
doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(entry).getName();
assertTrue(instance.test(entry));
verify(instance, never()).sanitizeSummaryInformation(eq(session), (DocumentEntry) any());
reset(instance, entry);
// Test a valid SummaryInformation name
DocumentEntry docEntry = mock(DocumentEntry.class);
doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(docEntry).getName();
doNothing().when(instance).sanitizeSummaryInformation(session, docEntry);
assertTrue(instance.test(docEntry));
verify(instance, atLeastOnce()).sanitizeSummaryInformation(session, docEntry);
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:25,代码来源:SummaryInformationSanitiserTest.java
示例4: readContent
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
@Override
protected String readContent(final VFSLeaf leaf) throws IOException, DocumentException {
BufferedInputStream bis = null;
final StringBuilder sb = new StringBuilder();
try {
bis = new BufferedInputStream(leaf.getInputStream());
final POIFSFileSystem filesystem = new POIFSFileSystem(bis);
final Iterator<?> entries = filesystem.getRoot().getEntries();
while (entries.hasNext()) {
final Entry entry = (Entry) entries.next();
final String name = entry.getName();
if (!(entry instanceof DocumentEntry)) {
// Skip directory entries
} else if ("WordDocument".equals(name)) {
collectWordDocument(filesystem, sb);
}
}
return sb.toString();
} catch (final Exception e) {
throw new DocumentException(e.getMessage());
} finally {
if (bis != null) {
bis.close();
}
}
}
开发者ID:huihoo,项目名称:olat,代码行数:27,代码来源:WordDocument.java
示例5: initTableStream
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Initializes the table stream
*
* @throws IOException
*/
private void initTableStream() throws IOException
{
String tablename = null;
if(_fib.isFWhichTblStm())
{
tablename="1Table";
}
else
{
tablename="0Table";
}
DocumentEntry tableEntry = (DocumentEntry)_filesystem.getRoot().getEntry(tablename);
//load the table stream into a buffer
int size = tableEntry.getSize();
_tableBuffer = new byte[size];
_filesystem.createDocumentInputStream(tablename).read(_tableBuffer);
}
开发者ID:rmage,项目名称:gnvc-ims,代码行数:25,代码来源:HDFObjectFactory.java
示例6: checkDirectoryDocumentEntry
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Parses a directory document entry which can either be a simple entry or
* a stream that has to be split up into multiple document entries again.
* The parsed information is put into the {@link OutlookMessage} object.
*
* @param de The current node in the .msg file.
* @param msg The resulting {@link OutlookMessage} object.
* @throws IOException Thrown if the .msg file could not be parsed.
*/
private void checkDirectoryDocumentEntry(final DocumentEntry de, final OutlookMessage msg)
throws IOException {
if (de.getName().startsWith(PROPS_KEY)) {
//TODO: parse properties stream
final List<DocumentEntry> deList = getDocumentEntriesFromPropertiesStream(de);
for (final DocumentEntry deFromProps : deList) {
final OutlookMessageProperty msgProp = getMessagePropertyFromDocumentEntry(deFromProps);
msg.setProperty(msgProp);
}
} else {
msg.setProperty(getMessagePropertyFromDocumentEntry(de));
}
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:23,代码来源:OutlookMessageParser.java
示例7: checkRecipientDocumentEntry
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Parses a recipient document entry which can either be a simple entry or
* a stream that has to be split up into multiple document entries again.
* The parsed information is put into the {@link OutlookRecipient} object.
*
* @param de The current node in the .msg file.
* @param recipient The resulting {@link OutlookRecipient} object.
* @throws IOException Thrown if the .msg file could not be parsed.
*/
private void checkRecipientDocumentEntry(final DocumentEntry de, final OutlookRecipient recipient)
throws IOException {
if (de.getName().startsWith(PROPS_KEY)) {
//TODO: parse properties stream
final List<DocumentEntry> deList = getDocumentEntriesFromPropertiesStream(de);
for (final DocumentEntry deFromProps : deList) {
final OutlookMessageProperty msgProp = getMessagePropertyFromDocumentEntry(deFromProps);
recipient.setProperty(msgProp);
}
} else {
recipient.setProperty(getMessagePropertyFromDocumentEntry(de));
}
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:23,代码来源:OutlookMessageParser.java
示例8: getMessagePropertyFromDocumentEntry
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Reads a property from a document entry and puts it's type and data to a {@link OutlookMessageProperty} object.
*
* @param de The {@link DocumentEntry} to be read.
* @return An object holding the type and data of the read property.
* @throws IOException In case the property could not be parsed.
*/
private OutlookMessageProperty getMessagePropertyFromDocumentEntry(final DocumentEntry de)
throws IOException {
// analyze the document entry
// (i.e., get class and data type)
final OutlookFieldInformation info = analyzeDocumentEntry(de);
// create a Java object from the data provided
// by the input stream. depending on the field
// information, either a String or a byte[] will
// be returned. other datatypes are not yet supported
final Object data = getData(de, info);
LOGGER.trace(" Document data: {}", data);
return new OutlookMessageProperty(info.getClazz(), data, de.getSize());
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:21,代码来源:OutlookMessageParser.java
示例9: analyzeDocumentEntry
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Analyzes the {@link DocumentEntry} and returns
* a {@link OutlookFieldInformation} object containing the
* class (the field name, so to say) and type of
* the entry.
*
* @param de The {@link DocumentEntry} that should be examined.
* @return A {@link OutlookFieldInformation} object containing class and type of the document entry or, if the entry is not an interesting field, an empty
* {@link OutlookFieldInformation} object containing {@link OutlookFieldInformation#UNKNOWN} class and type.
*/
private OutlookFieldInformation analyzeDocumentEntry(final DocumentEntry de) {
final String name = de.getName();
// we are only interested in document entries
// with names starting with __substg1.
LOGGER.trace("Document entry: {}", name);
if (name.startsWith(PROPERTY_STREAM_PREFIX)) {
final String clazz;
final String type;
final int mapiType;
try {
final String val = name.substring(PROPERTY_STREAM_PREFIX.length()).toLowerCase();
// the first 4 digits of the remainder
// defines the field class (or field name)
// and the last 4 digits indicate the
// data type.
clazz = val.substring(0, 4);
type = val.substring(4);
LOGGER.trace(" Found document entry: class={}, type={}", clazz, type);
mapiType = Integer.parseInt(type, 16);
} catch (final RuntimeException re) {
LOGGER.error("Could not parse directory entry {}", name, re);
return new OutlookFieldInformation();
}
return new OutlookFieldInformation(clazz, mapiType);
} else {
LOGGER.trace("Ignoring entry with name {}", name);
}
// we are not interested in the field
// and return an empty OutlookFieldInformation object
return new OutlookFieldInformation();
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:42,代码来源:OutlookMessageParser.java
示例10: parseAttachment
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Creates an {@link OutlookAttachment} object based on
* the given directory entry. The entry may either
* point to an attached file or to an
* attached .msg file, which will be added
* as a {@link OutlookMsgAttachment} object instead.
*
* @param dir The directory entry containing the attachment document entry and some other document entries describing the attachment (name, extension, mime
* type, ...)
* @param msg The {@link OutlookMessage} object that this attachment should be added to.
* @throws IOException Thrown if the attachment could not be parsed/read.
*/
private void parseAttachment(final DirectoryEntry dir, final OutlookMessage msg)
throws IOException {
final OutlookFileAttachment attachment = new OutlookFileAttachment();
// iterate through all document entries
for (final Iterator<?> iter = dir.getEntries(); iter.hasNext(); ) {
final Entry entry = (Entry) iter.next();
if (entry.isDocumentEntry()) {
// the document entry may contain information about the attachment
final DocumentEntry de = (DocumentEntry) entry;
final OutlookMessageProperty msgProp = getMessagePropertyFromDocumentEntry(de);
// we provide the class and data of the document entry to the attachment.
// The attachment implementation has to know the semantics of the field names
attachment.setProperty(msgProp);
} else {
// a directory within the attachment directory entry means that a .msg file is attached at this point.
// we recursively parse this .msg file and add it as a OutlookMsgAttachment object to the current OutlookMessage object.
final OutlookMessage attachmentMsg = new OutlookMessage();
final OutlookMsgAttachment msgAttachment = new OutlookMsgAttachment(attachmentMsg);
msg.addAttachment(msgAttachment);
checkDirectoryEntry((DirectoryEntry) entry, attachmentMsg);
}
}
// only if there was really an attachment, we add this object to the OutlookMessage object
if (attachment.getSize() > -1) {
msg.addAttachment(attachment);
}
}
开发者ID:TheConfusedCat,项目名称:msgparser,代码行数:45,代码来源:OutlookMessageParser.java
示例11: test
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
@Override
public boolean test(Entry entry) {
String entryName = entry.getName();
if (!isObject(entryName)) {
return true;
}
LOGGER.info("Found Compound Objects, removing them.");
StringBuilder infos = new StringBuilder();
if (entry instanceof DirectoryEntry) {
Set<String> entryNames = ((DirectoryEntry) entry).getEntryNames();
LOGGER.trace("Compound Objects' entries: {}", entryNames);
infos.append("Entries: ").append(entryNames);
} else if (entry instanceof DocumentEntry) {
int size = ((DocumentEntry) entry).getSize();
infos.append("Size: ").append(size);
}
Threat threat = threat()
.type(ThreatType.EXTERNAL_CONTENT)
.severity(ThreatSeverity.HIGH)
.action(ThreatAction.REMOVE)
.location(entryName)
.details(infos.toString())
.build();
session.recordThreat(threat);
return false;
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:32,代码来源:ObjectRemover.java
示例12: sanitizeSummaryInformation
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
protected void sanitizeSummaryInformation(BleachSession session, DocumentEntry dsiEntry) {
try (DocumentInputStream dis = new DocumentInputStream(dsiEntry)) {
PropertySet ps = new PropertySet(dis);
// Useful for debugging purposes
// LOGGER.debug("PropertySet sections: {}", ps.getSections());
SummaryInformation dsi = new SummaryInformation(ps);
sanitizeSummaryInformation(session, dsi);
} catch (NoPropertySetStreamException | UnexpectedPropertySetTypeException | MarkUnsupportedException | IOException e) {
LOGGER.error("An error occured while trying to sanitize the document entry", e);
}
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:13,代码来源:SummaryInformationSanitiser.java
示例13: test
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
@Override
public boolean test(Entry entry) {
String entryName = entry.getName();
// Matches _VBA_PROJECT_CUR, VBA, ... :)
if (!isMacro(entryName)) {
return true;
}
LOGGER.info("Found Macros, removing them.");
StringBuilder infos = new StringBuilder();
if (entry instanceof DirectoryEntry) {
Set<String> entryNames = ((DirectoryEntry) entry).getEntryNames();
LOGGER.trace("Macros' entries: {}", entryNames);
infos.append("Entries: ").append(entryNames);
} else if (entry instanceof DocumentEntry) {
int size = ((DocumentEntry) entry).getSize();
infos.append("Size: ").append(size);
}
Threat threat = threat()
.type(ThreatType.ACTIVE_CONTENT)
.severity(ThreatSeverity.EXTREME)
.action(ThreatAction.REMOVE)
.location(entryName)
.details(infos.toString())
.build();
session.recordThreat(threat);
return false;
}
开发者ID:docbleach,项目名称:DocBleach,代码行数:33,代码来源:MacroRemover.java
示例14: createWorkbookInputStream
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* returns a {@link BlockStoreInputStream} that exposes all workbook sectors in their correct order
*
* @param is XLS InputStream
* @return {@link BlockStoreInputStream} that wraps the workbook's stream
*
* @throws IOException if the data doesn't contain a proper MS-CFB header
* @throws OldExcelFormatException if the file is too old to be supported
*/
static InputStream createWorkbookInputStream(final XlsInputStream is) throws IOException {
final XlsReader xlsReader = new XlsReader(is);
DocumentEntry workBookEntry = xlsReader.getWorkbookEntry();
DocumentNode workbookNode = (DocumentNode) workBookEntry;
// use proper blockStore
final boolean useMiniStore = workbookNode.getSize() < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE;
final BlockStore blockStore = useMiniStore ? xlsReader.miniStore : xlsReader.difats;
return new BlockStoreInputStream(is, blockStore, workbookNode.getProperty().getStartBlock());
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:XlsReader.java
示例15: writeWordFile
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
public static boolean writeWordFile(String content,String filename,String path,String examPaperName) throws IOException{
String head = "<html><div style=\"text-align: center\"><span style=\"font-size: 28px\"><span style=\"font-family: 黑体\">" + examPaperName +
"<br /> <br /> </span></span></div>";
String tail = "</html>";
content = head + content + tail;
content = exampaper_formater(content);
ByteArrayInputStream bais = null;
FileOutputStream ostream = null;
try{
if (!"".equals(path)){
File fileDir = new File(path);
if(!fileDir.exists())
fileDir.mkdirs();
if (fileDir.exists()) {
String fileName = filename;
byte b[] = content.getBytes("GBK");
bais = new ByteArrayInputStream(b);
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", bais);
ostream = new FileOutputStream(path+ fileName);
poifs.writeFilesystem(ostream);
bais.close();
ostream.close();
}
}
}catch(IOException e){
bais.close();
ostream.close();
e.printStackTrace();
throw e;
}
return true;
}
开发者ID:imalexyang,项目名称:ExamStack,代码行数:37,代码来源:Html2Doc.java
示例16: getChildStreamReader
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* 이름이 name인 스트림을 읽을 수 있는 스트림 리더 객체를 반환한다.
*
* @param name
* 찾는 스트림 이름
* @param compress
* 압축 여부(한글에서 지원)
* @param fileVersion
* 파일 버전
* @return 이름이 name인 스트림을 읽을 수 있는 스트림 리더 객체
* @throws Exception
*/
public StreamReader getChildStreamReader(String name, boolean compress,
FileVersion fileVersion) throws Exception {
Entry e = currentStorage.getEntry(name);
if (e != null && e.isDocumentEntry()) {
if (compress == true) {
return new StreamReaderForCompress((DocumentEntry) e,
fileVersion);
} else {
return new StreamReaderForNormal((DocumentEntry) e, fileVersion);
}
} else {
throw new Exception("this is not stream.");
}
}
开发者ID:neolord0,项目名称:hwplib,代码行数:27,代码来源:CompoundFileReader.java
示例17: setByteArrayInputStream
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* 압축된 스트림을 읽어 압축을 풀어서 압축 풀린 데이터로 InputStream을 만든다.
*
* @param de
* 스트림을 가리키는 Apache POI 객체
* @throws Exception
*/
private void setByteArrayInputStream(DocumentEntry de) throws Exception {
DocumentInputStream dis = new DocumentInputStream(de);
byte[] compressed = getCompressedBytes(dis, de.getSize());
dis.close();
byte[] decompressed = decompress(compressed);
bis = new ByteArrayInputStream(decompressed);
setSize(decompressed.length);
}
开发者ID:neolord0,项目名称:hwplib,代码行数:17,代码来源:StreamReaderForCompress.java
示例18: getEntries
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
private List<Entry> getEntries(List<Entry> entries, DirectoryEntry dir,
String prefix) {
for(org.apache.poi.poifs.filesystem.Entry entry : dir) {
if (entry instanceof DirectoryEntry) {
// .. recurse into this directory
getEntries(entries, (DirectoryEntry)entry, prefix + ENTRY_SEPARATOR);
} else if(entry instanceof DocumentEntry) {
// grab the entry name/detils
DocumentEntry de = (DocumentEntry)entry;
String entryName = prefix + encodeEntryName(entry.getName());
entries.add(new EntryImpl(entryName, de));
}
}
return entries;
}
开发者ID:jahlborn,项目名称:jackcess,代码行数:16,代码来源:CompoundOleUtil.java
示例19: checkCompoundStorage
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
private static void checkCompoundStorage(OleBlob.CompoundContent cc,
Attachment attach)
throws Exception
{
File tmpData = File.createTempFile("attach_", ".dat");
try {
FileOutputStream fout = new FileOutputStream(tmpData);
fout.write(attach.getFileData());
fout.close();
NPOIFSFileSystem attachFs = new NPOIFSFileSystem(tmpData, true);
for(OleBlob.CompoundContent.Entry e : cc) {
DocumentEntry attachE = null;
try {
attachE = CompoundOleUtil.getDocumentEntry(e.getName(), attachFs.getRoot());
} catch(FileNotFoundException fnfe) {
// ignored, the ole data has extra entries
continue;
}
byte[] attachEBytes = toByteArray(new DocumentInputStream(attachE),
attachE.getSize());
byte[] entryBytes = toByteArray(e.getStream(), e.length());
assertTrue(Arrays.equals(attachEBytes, entryBytes));
}
ByteUtil.closeQuietly(attachFs);
} finally {
tmpData.delete();
}
}
开发者ID:jahlborn,项目名称:jackcess,代码行数:36,代码来源:OleBlobTest.java
示例20: readFIB
import org.apache.poi.poifs.filesystem.DocumentEntry; //导入依赖的package包/类
/**
* Extracts the main document stream from the POI file then hands off to other
* functions that parse other areas.
*
* @throws IOException
*/
private void readFIB() throws IOException
{
//get the main document stream
DocumentEntry headerProps =
(DocumentEntry)filesystem.getRoot().getEntry("WordDocument");
//I call it the header but its also the main document stream
_header = new byte[headerProps.getSize()];
filesystem.createDocumentInputStream("WordDocument").read(_header);
//Get the information we need from the header
int info = LittleEndian.getShort(_header, 0xa);
_fcMin = LittleEndian.getInt(_header, 0x18);
_ccpText = LittleEndian.getInt(_header, 0x4c);
_ccpFtn = LittleEndian.getInt(_header, 0x50);
int charPLC = LittleEndian.getInt(_header, 0xfa);
int charPlcSize = LittleEndian.getInt(_header, 0xfe);
int parPLC = LittleEndian.getInt(_header, 0x102);
int parPlcSize = LittleEndian.getInt(_header, 0x106);
boolean useTable1 = (info & 0x200) != 0;
//process the text and formatting properties
processComplexFile(useTable1, charPLC, charPlcSize, parPLC, parPlcSize);
}
开发者ID:rmage,项目名称:gnvc-ims,代码行数:33,代码来源:WordDocument.java
注:本文中的org.apache.poi.poifs.filesystem.DocumentEntry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论