本文整理汇总了Java中org.apache.poi.hpsf.SummaryInformation类的典型用法代码示例。如果您正苦于以下问题:Java SummaryInformation类的具体用法?Java SummaryInformation怎么用?Java SummaryInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SummaryInformation类属于org.apache.poi.hpsf包,在下文中一共展示了SummaryInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test1
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的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);
}
示例2: main
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
HWPFDocument doc = new HWPFDocument(new FileInputStream(
"data/document.doc"));
SummaryInformation summaryInfo = doc.getSummaryInformation();
System.out.println(summaryInfo.getApplicationName());
System.out.println(summaryInfo.getAuthor());
System.out.println(summaryInfo.getComments());
System.out.println(summaryInfo.getCharCount());
System.out.println(summaryInfo.getEditTime());
System.out.println(summaryInfo.getKeywords());
System.out.println(summaryInfo.getLastAuthor());
System.out.println(summaryInfo.getPageCount());
System.out.println(summaryInfo.getRevNumber());
System.out.println(summaryInfo.getSecurity());
System.out.println(summaryInfo.getSubject());
System.out.println(summaryInfo.getTemplate());
}
示例3: main
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
String dataPath = "src/featurescomparison/workingwithdocuments/getdocumentproperties/data/";
HWPFDocument doc = new HWPFDocument(new FileInputStream(
dataPath + "document.doc"));
SummaryInformation summaryInfo = doc.getSummaryInformation();
System.out.println(summaryInfo.getApplicationName());
System.out.println(summaryInfo.getAuthor());
System.out.println(summaryInfo.getComments());
System.out.println(summaryInfo.getCharCount());
System.out.println(summaryInfo.getEditTime());
System.out.println(summaryInfo.getKeywords());
System.out.println(summaryInfo.getLastAuthor());
System.out.println(summaryInfo.getPageCount());
System.out.println(summaryInfo.getRevNumber());
System.out.println(summaryInfo.getSecurity());
System.out.println(summaryInfo.getSubject());
System.out.println(summaryInfo.getTemplate());
}
示例4: getAuthor
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
private static String getAuthor(Workbook wb) {
if (HSSFWorkbook.class.isInstance(wb)) {
HSSFWorkbook hssf = (HSSFWorkbook) wb;
SummaryInformation info = hssf.getSummaryInformation();
if (info != null) {
return info.getAuthor();
}
} else if (XSSFWorkbook.class.isInstance(wb)) {
XSSFWorkbook xssf = (XSSFWorkbook) wb;
POIXMLProperties xmlProps = xssf.getProperties();
if (xmlProps != null) {
POIXMLProperties.CoreProperties coreProps = xmlProps.getCoreProperties();
if (coreProps != null) {
return coreProps.getCreator();
}
}
}
return null;
}
示例5: processDocumentInformation
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
protected void processDocumentInformation(
SummaryInformation summaryInformation )
{
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getTitle() ) )
foDocumentFacade.setTitle( summaryInformation.getTitle() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getAuthor() ) )
foDocumentFacade.setCreator( summaryInformation.getAuthor() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getKeywords() ) )
foDocumentFacade.setKeywords( summaryInformation.getKeywords() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getComments() ) )
foDocumentFacade.setDescription( summaryInformation.getComments() );
}
示例6: processDocumentInformation
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
protected void processDocumentInformation(
SummaryInformation summaryInformation )
{
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getTitle() ) )
htmlDocumentFacade.setTitle( summaryInformation.getTitle() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getAuthor() ) )
htmlDocumentFacade.addAuthor( summaryInformation.getAuthor() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getKeywords() ) )
htmlDocumentFacade.addKeywords( summaryInformation.getKeywords() );
if ( WordToHtmlUtils.isNotEmpty( summaryInformation.getComments() ) )
htmlDocumentFacade
.addDescription( summaryInformation.getComments() );
}
示例7: processDocumentInformation
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
protected void processDocumentInformation(
SummaryInformation summaryInformation )
{
if ( isOutputSummaryInformation() )
{
if ( AbstractWordUtils.isNotEmpty( summaryInformation.getTitle() ) )
textDocumentFacade.setTitle( summaryInformation.getTitle() );
if ( AbstractWordUtils.isNotEmpty( summaryInformation.getAuthor() ) )
textDocumentFacade.addAuthor( summaryInformation.getAuthor() );
if ( AbstractWordUtils
.isNotEmpty( summaryInformation.getComments() ) )
textDocumentFacade.addDescription( summaryInformation
.getComments() );
if ( AbstractWordUtils
.isNotEmpty( summaryInformation.getKeywords() ) )
textDocumentFacade.addKeywords( summaryInformation
.getKeywords() );
}
}
示例8: processDocumentInformation
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
protected void processDocumentInformation(
SummaryInformation summaryInformation )
{
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getTitle() ) )
htmlDocumentFacade.setTitle( summaryInformation.getTitle() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getAuthor() ) )
htmlDocumentFacade.addAuthor( summaryInformation.getAuthor() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getKeywords() ) )
htmlDocumentFacade.addKeywords( summaryInformation.getKeywords() );
if ( ExcelToHtmlUtils.isNotEmpty( summaryInformation.getComments() ) )
htmlDocumentFacade
.addDescription( summaryInformation.getComments() );
}
示例9: oldWordExtraction
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
private void oldWordExtraction(ParserResultItem result,
InputStream inputStream) throws IOException {
Word6Extractor word6 = null;
try {
word6 = new Word6Extractor(inputStream);
SummaryInformation si = word6.getSummaryInformation();
if (si != null) {
result.addField(ParserFieldEnum.title, si.getTitle());
result.addField(ParserFieldEnum.author, si.getAuthor());
result.addField(ParserFieldEnum.subject, si.getSubject());
}
String text = word6.getText();
String[] frags = text.split("\\n");
for (String frag : frags)
result.addField(ParserFieldEnum.content,
StringUtils.replaceConsecutiveSpaces(frag, " "));
} finally {
IOUtils.close(word6);
}
}
示例10: parseContent
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang)
throws IOException {
VisioTextExtractor extractor = null;
try {
extractor = new VisioTextExtractor(
streamLimiter.getNewInputStream());
SummaryInformation info = extractor.getSummaryInformation();
ParserResultItem result = getNewParserResultItem();
if (info != null) {
result.addField(ParserFieldEnum.title, info.getTitle());
result.addField(ParserFieldEnum.author, info.getAuthor());
result.addField(ParserFieldEnum.subject, info.getSubject());
}
String[] texts = extractor.getAllText();
if (texts == null)
return;
for (String text : texts)
result.addField(ParserFieldEnum.content,
StringUtils.replaceConsecutiveSpaces(text, " "));
result.langDetection(10000, ParserFieldEnum.content);
} finally {
IOUtils.close(extractor);
}
}
示例11: parseContent
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang)
throws IOException {
PublisherTextExtractor extractor = null;
try {
extractor = new PublisherTextExtractor(
streamLimiter.getNewInputStream());
SummaryInformation info = extractor.getSummaryInformation();
ParserResultItem result = getNewParserResultItem();
if (info != null) {
result.addField(ParserFieldEnum.title, info.getTitle());
result.addField(ParserFieldEnum.author, info.getAuthor());
result.addField(ParserFieldEnum.subject, info.getSubject());
}
result.addField(ParserFieldEnum.content, StringUtils
.replaceConsecutiveSpaces(extractor.getText(), " "));
result.langDetection(10000, ParserFieldEnum.content);
} finally {
IOUtils.close(extractor);
}
}
示例12: create
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Override
public TreeModelSource create(final POIFSFileSystem poifs, final DefaultMutableTreeNode parent) {
final DirectoryNode dn = poifs.getRoot();
if (dn.hasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME) ||
dn.hasEntry(SummaryInformation.DEFAULT_STREAM_NAME)) {
return appContext.getBean(HPSFTreeModel.class, parent);
}
return null;
}
示例13: testKeepsEverythingElse
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Test
void testKeepsEverythingElse() {
Entry entry = mock(Entry.class);
doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(entry).getName();
assertTrue(instance.test(entry), "Non-macro streams should be ignored");
BleachTestBase.assertThreatsFound(session, 0);
reset(session);
doReturn("RandomName").when(entry).getName();
assertTrue(instance.test(entry), "Non-macro streams should be ignored");
BleachTestBase.assertThreatsFound(session, 0);
reset(session);
}
示例14: sanitizeComments
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Test
void sanitizeComments() {
SummaryInformation si = new SummaryInformation();
// When no comment is set, no error/threat is thrown
instance.sanitizeComments(session, si);
assertThreatsFound(session, 0);
// When a comment is set, it should be removed
si.setComments("Hello!");
instance.sanitizeComments(session, si);
assertNull(si.getComments());
assertThreatsFound(session, 1);
}
示例15: testKeepsEverythingElse
import org.apache.poi.hpsf.SummaryInformation; //导入依赖的package包/类
@Test
void testKeepsEverythingElse() {
Entry entry = mock(Entry.class);
doReturn(SummaryInformation.DEFAULT_STREAM_NAME).when(entry).getName();
assertTrue(instance.test(entry), "Non-object entries should be ignored");
BleachTestBase.assertThreatsFound(session, 0);
reset(session);
doReturn("RandomName").when(entry).getName();
assertTrue(instance.test(entry), "Non-object entries should be ignored");
BleachTestBase.assertThreatsFound(session, 0);
reset(session);
}