List of usage examples for org.apache.poi.hpsf.wellknown PropertyIDMap PID_TITLE
int PID_TITLE
To view the source code for org.apache.poi.hpsf.wellknown PropertyIDMap PID_TITLE.
Click Source Link
From source file:org.jlibrary.core.search.extraction.MSOfficeExtractor.java
License:Open Source License
/** * Returns a map with the extracted meta information from the document.<p> * // ww w. jav a 2 s .c om * @return a map with the extracted meta information from the document */ protected HeaderMetaData extractMetaInformation() { HeaderMetaData metadata = new HeaderMetaData(); String meta; if (m_summary != null) { // can't use convenience methods on summary since they can't deal with multiple sections Section section = (Section) m_summary.getSections().get(0); meta = (String) section.getProperty(PropertyIDMap.PID_TITLE); if ((meta != null) && !meta.equals("")) { metadata.setTitle(meta); metadata.setDescription(meta); } meta = (String) section.getProperty(PropertyIDMap.PID_KEYWORDS); if ((meta != null) && !meta.equals("")) { metadata.setKeywords(meta); } meta = (String) section.getProperty(PropertyIDMap.PID_SUBJECT); if ((meta != null) && !meta.equals("")) { metadata.setDescription(meta); } meta = (String) section.getProperty(PropertyIDMap.PID_COMMENTS); if ((meta != null) && !meta.equals("")) { // Not handled } // extract other available meta information meta = (String) section.getProperty(PropertyIDMap.PID_AUTHOR); if ((meta != null) && !meta.equals("")) { metadata.setAuthor(meta); } Date date; date = (Date) section.getProperty(PropertyIDMap.PID_CREATE_DTM); if ((date != null) && (date.getTime() > 0)) { // Not handled } date = (Date) section.getProperty(PropertyIDMap.PID_LASTSAVE_DTM); if ((date != null) && (date.getTime() > 0)) { // Not handled } } if (m_documentSummary != null) { // can't use convenience methods on document since they can't deal with multiple sections Section section = (Section) m_documentSummary.getSections().get(0); // extract available meta information from document summary meta = (String) section.getProperty(PropertyIDMap.PID_COMPANY); if ((meta != null) && !meta.equals("")) { // Not handled } meta = (String) section.getProperty(PropertyIDMap.PID_MANAGER); if ((meta != null) && !meta.equals("")) { // Not handled } meta = (String) section.getProperty(PropertyIDMap.PID_CATEGORY); if ((meta != null) && !meta.equals("")) { // Not handled } } return metadata; }
From source file:org.opencms.search.extractors.A_CmsTextExtractorMsOfficeBase.java
License:Open Source License
/** * Creates the extraction result for this MS Office document.<p> * // w w w. j a va2 s.co m * The extraction result contains the raw content, plus additional meta information * as content items read from the MS Office document properties.<p> * * @param rawContent the raw content extracted from the document * * @return the extraction result for this MS Office document */ protected I_CmsExtractionResult createExtractionResult(String rawContent) { Map contentItems = new HashMap(); if (CmsStringUtil.isNotEmpty(rawContent)) { contentItems.put(I_CmsExtractionResult.ITEM_RAW, rawContent); } StringBuffer content = new StringBuffer(rawContent); if (m_summary != null) { // can't use convenience methods on summary since they can't deal with multiple sections Section section = (Section) m_summary.getSections().get(0); combineContentItem((String) section.getProperty(PropertyIDMap.PID_TITLE), I_CmsExtractionResult.ITEM_TITLE, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_KEYWORDS), I_CmsExtractionResult.ITEM_KEYWORDS, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_SUBJECT), I_CmsExtractionResult.ITEM_SUBJECT, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_COMMENTS), I_CmsExtractionResult.ITEM_COMMENTS, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_AUTHOR), I_CmsExtractionResult.ITEM_AUTHOR, content, contentItems); } if (m_documentSummary != null) { // can't use convenience methods on document since they can't deal with multiple sections Section section = (Section) m_documentSummary.getSections().get(0); // extract available meta information from document summary combineContentItem((String) section.getProperty(PropertyIDMap.PID_COMPANY), I_CmsExtractionResult.ITEM_COMPANY, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_MANAGER), I_CmsExtractionResult.ITEM_MANAGER, content, contentItems); combineContentItem((String) section.getProperty(PropertyIDMap.PID_CATEGORY), I_CmsExtractionResult.ITEM_CATEGORY, content, contentItems); } // free some memory cleanup(); return new CmsExtractionResult(content.toString(), contentItems); }
From source file:poi.hpsf.examples.WriteTitle.java
License:Apache License
/** * <p>Runs the example program.</p> * * @param args Command-line arguments. The first and only command-line * argument is the name of the POI file system to create. * @throws java.io.IOException if any I/O exception occurs. * @throws WritingNotSupportedException if HPSF does not (yet) support * writing a certain property type.//from w w w .j a v a 2 s .co m */ public static void main(final String[] args) throws WritingNotSupportedException, IOException { /* Check whether we have exactly one command-line argument. */ if (args.length != 1) { System.err.println("Usage: " + WriteTitle.class.getName() + "destinationPOIFS"); System.exit(1); } final String fileName = args[0]; /* Create a mutable property set. Initially it contains a single section * with no properties. */ final MutablePropertySet mps = new MutablePropertySet(); /* Retrieve the section the property set already contains. */ final MutableSection ms = (MutableSection) mps.getSections().get(0); /* Turn the property set into a summary information property. This is * done by setting the format ID of its first section to * SectionIDMap.SUMMARY_INFORMATION_ID. */ ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID); /* Create an empty property. */ final MutableProperty p = new MutableProperty(); /* Fill the property with appropriate settings so that it specifies the * document's title. */ p.setID(PropertyIDMap.PID_TITLE); p.setType(Variant.VT_LPWSTR); p.setValue("Sample title"); /* Place the property into the section. */ ms.setProperty(p); /* Create the POI file system the property set is to be written to. */ final POIFSFileSystem poiFs = new POIFSFileSystem(); /* For writing the property set into a POI file system it has to be * handed over to the POIFS.createDocument() method as an input stream * which produces the bytes making out the property set stream. */ final InputStream is = mps.toInputStream(); /* Create the summary information property set in the POI file * system. It is given the default name most (if not all) summary * information property sets have. */ poiFs.createDocument(is, SummaryInformation.DEFAULT_STREAM_NAME); /* Write the whole POI file system to a disk file. */ poiFs.writeFilesystem(new FileOutputStream(fileName)); }