本文整理汇总了Java中org.apache.poi.poifs.filesystem.DirectoryEntry类的典型用法代码示例。如果您正苦于以下问题:Java DirectoryEntry类的具体用法?Java DirectoryEntry怎么用?Java DirectoryEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DirectoryEntry类属于org.apache.poi.poifs.filesystem包,在下文中一共展示了DirectoryEntry类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRecipientDirectoryEntry
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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);
}
示例2: dumpFileSystem
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
private String dumpFileSystem( DirectoryEntry directory )
{
StringBuilder result = new StringBuilder();
result.append( "+ " );
result.append( directory.getName() );
for ( Iterator<Entry> iterator = directory.getEntries(); iterator
.hasNext(); )
{
Entry entry = iterator.next();
String entryToString = "\n" + dumpFileSystem( entry );
entryToString = entryToString.replaceAll( "\n", "\n+---" );
result.append( entryToString );
}
result.append( "\n" );
return result.toString();
}
示例3: parseAttachment
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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);
}
}
示例4: isContentIdentical
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
private boolean isContentIdentical(NPOIFSFileSystem fs1, NPOIFSFileSystem fs2, Collection<String> excludes) throws IOException
{
DirectoryEntry de1 = fs1.getRoot();
DirectoryEntry de2 = fs2.getRoot();
FilteringDirectoryNode fs1Filtered = new FilteringDirectoryNode(de1, excludes);
FilteringDirectoryNode fs2Filtered = new FilteringDirectoryNode(de2, excludes);
boolean retVal = EntryUtils.areDirectoriesIdentical(fs1Filtered, fs2Filtered);
if(logger.isDebugEnabled())
{
logger.debug("returning equal="+ retVal);
}
return retVal;
}
示例5: test
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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;
}
示例6: test
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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;
}
示例7: writeWordFile
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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;
}
示例8: getEntries
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的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;
}
示例9: detectType
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
public static POIFSDocumentType detectType(DirectoryEntry node) {
Set<String> names = new HashSet<String>();
for (Entry entry : node) {
names.add(entry.getName());
}
MediaType type = POIFSContainerDetector.detect(names, node);
for (POIFSDocumentType poifsType : values()) {
if (type.equals(poifsType.type)) {
return poifsType;
}
}
return UNKNOWN;
}
示例10: createSummaryInformation
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
public static void createSummaryInformation(String filePath, String title) {
if (filePath == null) {
return;
}
try {
File poiFilesystem = new File(filePath);
InputStream is = new FileInputStream(poiFilesystem);
POIFSFileSystem poifs = new POIFSFileSystem(is);
is.close();
DirectoryEntry dir = poifs.getRoot();
SummaryInformation si = PropertySetFactory.newSummaryInformation();
si.setTitle(title);
si.setAuthor(ReleaseInfoAdapter.getCompany());
si.setApplicationName("NextReports " + ReleaseInfoAdapter.getVersionNumber());
si.setSubject("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
si.setCreateDateTime(new Date());
si.setKeywords(ReleaseInfoAdapter.getHome());
si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
OutputStream out = new FileOutputStream(poiFilesystem);
poifs.writeFilesystem(out);
out.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
示例11: ObjectPoolImpl
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
public ObjectPoolImpl( DirectoryEntry _objectPool )
{
super();
this._objectPool = _objectPool;
}
示例12: writeTo
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
@Internal
public void writeTo( DirectoryEntry directoryEntry ) throws IOException
{
if ( _objectPool != null )
EntryUtils.copyNodeRecursively( _objectPool, directoryEntry );
}
示例13: getParent
import org.apache.poi.poifs.filesystem.DirectoryEntry; //导入依赖的package包/类
/**
* get this Entry's parent (the DocumentEntry that owns this
* Entry). All Entry objects, except the root Entry, has a parent.
*
* @return this Entry's parent; null iff this is the root Entry
*/
public DirectoryEntry getParent() {
throw new IllegalStateException("Not Implemented");
}