List of usage examples for org.apache.poi.hpsf PropertySetFactory create
public static PropertySet create(final InputStream stream) throws NoPropertySetStreamException, MarkUnsupportedException, UnsupportedEncodingException, IOException
From source file:com.duroty.lucene.parser.utils.POIFSListener.java
License:Apache License
/** * DOCUMENT ME!/*from w w w.java2 s . com*/ * * @param arg0 DOCUMENT ME! */ public void processPOIFSReaderEvent(POIFSReaderEvent readerEvent) { org.apache.poi.hpsf.PropertySet propertySet; try { propertySet = PropertySetFactory.create(readerEvent.getStream()); SummaryInformation info = (SummaryInformation) propertySet; this.author = info.getAuthor(); this.title = info.getTitle(); this.keywords = info.getKeywords(); this.subject = info.getSubject(); } catch (NoPropertySetStreamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MarkUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnexpectedPropertySetTypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.flexive.extractor.ExcelExtractor.java
License:Open Source License
/** * Proccesses the Summary section.// ww w .j a va 2 s . c om * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { // } }
From source file:com.flexive.extractor.FxSummaryInformation.java
License:Open Source License
/** * Reads the summary information from a document. * * @param input the input stream to read from, will not be closed at the end * @return the summary information// w w w . j a va2 s.c om */ public static FxSummaryInformation getSummaryInformation(InputStream input) { class SummaryStore implements POIFSReaderListener { private FxSummaryInformation fxsi = null; /** * Processes the Summary section. * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { /* ignore */ } } protected FxSummaryInformation getFxSummaryInformation() { return fxsi; } } try { POIFSReader reader = new POIFSReader(); SummaryStore st = new SummaryStore(); reader.registerListener(st, "\005SummaryInformation"); reader.read(input); return st.getFxSummaryInformation(); } catch (Exception ex) { return null; } }
From source file:com.flexive.extractor.PowerpointExtractor.java
License:Open Source License
@Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try {/*w w w. java 2 s.c o m*/ if (event.getName().equalsIgnoreCase("PowerPoint Document")) { DocumentInputStream input = event.getStream(); byte[] buffer = new byte[input.available()]; //noinspection ResultOfMethodCallIgnored input.read(buffer, 0, input.available()); processContent(buffer, 0, buffer.length); } else if (event.getName().equals("\005SummaryInformation")) { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.flexive.extractor.WordExtractor.java
License:Open Source License
/** * Proccesses the Summary section./*from www.j av a 2s . co m*/ * * @param event the summary section event. */ @Override public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { SummaryInformation si = (SummaryInformation) PropertySetFactory.create(event.getStream()); fxsi = new FxSummaryInformation(si); } catch (Exception ex) { // } }
From source file:com.frameworkset.platform.cms.searchmanager.extractors.A_CmsTextExtractorMsOfficeBase.java
License:Open Source License
/** * @see org.apache.poi.poifs.eventfilesystem.POIFSReaderListener#processPOIFSReaderEvent(org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent) *///from w w w . jav a 2 s. c o m public void processPOIFSReaderEvent(POIFSReaderEvent event) { try { if ((m_summary == null) && event.getName().startsWith(SummaryInformation.DEFAULT_STREAM_NAME)) { m_summary = (SummaryInformation) PropertySetFactory.create(event.getStream()); return; } if ((m_documentSummary == null) && event.getName().startsWith(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) { m_documentSummary = (DocumentSummaryInformation) PropertySetFactory.create(event.getStream()); return; } } catch (Exception e) { // ignore } }
From source file:com.knowgate.ole.OLEListener.java
License:Open Source License
public void processPOIFSReaderEvent(POIFSReaderEvent event) { try {// ww w .j a v a 2s . com si = (SummaryInformation) PropertySetFactory.create(event.getStream()); } catch (MarkUnsupportedException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener MarkUnsupportedException " + event.getPath() + event.getName() + " " + ex.getMessage()); } catch (NoPropertySetStreamException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener NoPropertySetStreamException " + event.getPath() + event.getName() + " " + ex.getMessage()); } catch (IOException ex) { if (DebugFile.trace) DebugFile.writeln("com.knowgate.ole.OLEListener IOException " + event.getPath() + event.getName() + " " + ex.getMessage()); } }
From source file:com.pnf.plugin.ole.parser.StreamReader.java
License:Apache License
private List<INode> readDocSummaryStream(ByteBuffer stream) { List<INode> roots = new LinkedList<>(); String propType = "Property"; try {//www. ja v a 2 s. c o m DocumentSummaryInformation info = (DocumentSummaryInformation) PropertySetFactory .create(new ByteArrayInputStream(stream.array())); propType = "int"; StreamEntry counts = new StreamEntry("Counts"); if (info.getLineCount() != 0) counts.addChild(new StreamEntry("Line count", propType, String.valueOf(info.getLineCount()))); if (info.getByteCount() != 0) counts.addChild(new StreamEntry("Byte count", propType, String.valueOf(info.getByteCount()))); if (info.getHiddenCount() != 0) counts.addChild(new StreamEntry("Hidden count", propType, String.valueOf(info.getHiddenCount()))); if (info.getMMClipCount() != 0) counts.addChild(new StreamEntry("MMClip count", propType, String.valueOf(info.getMMClipCount()))); if (info.getNoteCount() != 0) counts.addChild(new StreamEntry("Note count", propType, String.valueOf(info.getNoteCount()))); if (info.getParCount() != 0) counts.addChild(new StreamEntry("Par count", propType, String.valueOf(info.getParCount()))); if (info.getSlideCount() != 0) counts.addChild(new StreamEntry("Slide count", propType, String.valueOf(info.getSlideCount()))); if (counts.size() > 0) roots.add(counts); propType = "String"; StreamEntry strings = new StreamEntry("Strings"); strings.addChild(new StreamEntry("Category", propType, info.getCategory())); strings.addChild(new StreamEntry("Company", propType, info.getCompany())); strings.addChild(new StreamEntry("Manager", propType, info.getManager())); strings.addChild(new StreamEntry("Presentation Format", propType, info.getPresentationFormat())); roots.add(strings); propType = "Custom"; StreamEntry custom = new StreamEntry("User-defined properties"); CustomProperties props = info.getCustomProperties(); if (props != null) { Set<Entry<Object, CustomProperty>> entries = props.entrySet(); for (Entry<Object, CustomProperty> e : entries) { try { custom.addChild(new StreamEntry(e.getValue().getName(), propType, e.getValue().getValue().toString())); } catch (NullPointerException ex) { // ignore any errors } } } } catch (Throwable t) { addMessage("Attempted to read " + DOC_SUMM + " stream but no property sets were found.", null, Message.CORRUPT); } return roots; }
From source file:com.villemos.ispace.aperture.enricher.MicrosoftPropertyReader.java
License:Open Source License
public void processPOIFSReaderEvent(final POIFSReaderEvent event) { PropertySet ps = null;//from w w w.j a v a 2 s .co m try { ps = PropertySetFactory.create(event.getStream()); } catch (NoPropertySetStreamException ex) { LOG.debug("No property set stream: \"" + event.getPath() + event.getName() + "\""); return; } catch (Exception ex) { LOG.error("Exception while processing microsoft property set " + ex); } /* Print the name of the property set stream: */ LOG.debug("Property set stream \"" + event.getPath() + event.getName() + "\":"); /* Print the list of sections: */ List<Section> sections = ps.getSections(); int nr = 0; for (Section sec : sections) { String s = HexDump.dump(sec.getFormatID().getBytes(), 0L, 0); s = s.substring(0, s.length() - 1); /* Print the number of properties in this section. */ int propertyCount = sec.getPropertyCount(); /* Print the properties: */ Property[] properties = sec.getProperties(); for (int i2 = 0; i2 < properties.length; i2++) { /* Print a single property: */ Property p = properties[i2]; long id = p.getID(); long type = p.getType(); Object value = p.getValue(); String propertyName = sec.getPIDString(id); if (msProperties.containsKey(propertyName) == false) { String valueStr = value.toString(); if (valueStr.equals("") == false) { msProperties.put(propertyName, valueStr); } } } } }
From source file:net.sf.mmm.content.parser.impl.poi.AbstractContentParserPoi.java
License:Apache License
/** * {@inheritDoc}/*w ww . j a va2s . c o m*/ */ @Override public void parse(InputStream inputStream, long filesize, ContentParserOptions options, MutableGenericContext context) throws Exception { POIFSFileSystem poiFs = new POIFSFileSystem(inputStream); SummaryInformation summaryInfo = (SummaryInformation) PropertySetFactory .create(poiFs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); String title = summaryInfo.getTitle(); if (title != null) { context.setVariable(VARIABLE_NAME_TITLE, title); } String author = summaryInfo.getAuthor(); if (author != null) { context.setVariable(VARIABLE_NAME_CREATOR, author); } String keywords = summaryInfo.getKeywords(); if (keywords != null) { context.setVariable(VARIABLE_NAME_KEYWORDS, keywords); } context.setVariable(VARIABLE_NAME_TEXT, extractText(poiFs, filesize, options)); }