org.apache.poi.hpsf.PropertySet Java Examples
The following examples show how to use
org.apache.poi.hpsf.PropertySet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HPSFPropertiesExtractor.java From lams with GNU General Public License v2.0 | 6 votes |
private static String getPropertiesText(PropertySet ps) { if (ps == null) { // Not defined, oh well return ""; } StringBuilder text = new StringBuilder(); PropertyIDMap idMap = ps.getPropertySetIDMap(); Property[] props = ps.getProperties(); for (Property prop : props) { String type = Long.toString(prop.getID()); Object typeObj = (idMap == null) ? null : idMap.get(prop.getID()); if (typeObj != null) { type = typeObj.toString(); } String val = getPropertyValueText(prop.getValue()); text.append(type).append(" = ").append(val).append("\n"); } return text.toString(); }
Example #2
Source File: POIDocument.java From lams with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") private <T> T readPropertySet(Class<T> clazz, String name) { String localName = clazz.getName().substring(clazz.getName().lastIndexOf('.')+1); try { PropertySet ps = getPropertySet(name); if (clazz.isInstance(ps)) { return (T)ps; } else if (ps != null) { logger.log(POILogger.WARN, localName+" property set came back with wrong class - "+ps.getClass().getName()); } else { logger.log(POILogger.WARN, localName+" property set came back as null"); } } catch (IOException e) { logger.log(POILogger.ERROR, "can't retrieve property set", e); } return null; }
Example #3
Source File: POIDocument.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Writes out a given ProperySet * @param name the (POIFS Level) name of the property to write * @param set the PropertySet to write out * @param outFS the NPOIFSFileSystem to write the property into * * @throws IOException if an error when writing to the * {@link NPOIFSFileSystem} occurs */ protected void writePropertySet(String name, PropertySet set, NPOIFSFileSystem outFS) throws IOException { try { PropertySet mSet = new PropertySet(set); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); mSet.write(bOut); byte[] data = bOut.toByteArray(); ByteArrayInputStream bIn = new ByteArrayInputStream(data); // Create or Update the Property Set stream in the POIFS outFS.createOrUpdateDocument(bIn, name); logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length); } catch(org.apache.poi.hpsf.WritingNotSupportedException wnse) { logger.log( POILogger.ERROR, "Couldn't write property set with name " + name + " as not supported by HPSF yet"); } }
Example #4
Source File: SummaryInformationSanitiser.java From DocBleach with MIT License | 6 votes |
protected void sanitizeSummaryInformation(BleachSession session, DocumentEntry dsiEntry) { if (dsiEntry.getSize() <= 0) { return; } 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 | IOException e) { LOGGER.error("An error occured while trying to sanitize the document entry", e); } }
Example #5
Source File: HPSFPropertiesExtractor.java From lams with GNU General Public License v2.0 | 4 votes |
private static String getPropertyValueText(Object val) { return (val == null) ? "(not set)" : PropertySet.getPropertyStringValue(val); }
Example #6
Source File: POIDocument.java From lams with GNU General Public License v2.0 | 2 votes |
/** * For a given named property entry, either return it or null if * if it wasn't found * * @param setName The property to read * @return The value of the given property or null if it wasn't found. */ protected PropertySet getPropertySet(String setName) throws IOException { return getPropertySet(setName, getEncryptionInfo()); }