/** * 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. * * @throws IOException If retrieving properties fails */ @SuppressWarnings("WeakerAccess") protected PropertySet getPropertySet(String setName) throws IOException { return getPropertySet(setName, getEncryptionInfo()); }
@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; }
/** * 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. * * @throws IOException If retrieving properties fails */ @SuppressWarnings("WeakerAccess") protected PropertySet getPropertySet(String setName) throws IOException { return getPropertySet(setName, getEncryptionInfo()); }
/** * Find, and create objects for, the standard * Documment Information Properties (HPSF). * If a given property set is missing or corrupt, * it will remain null; */ protected void readProperties() { PropertySet ps; // DocumentSummaryInformation ps = getPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME); if(ps != null && ps instanceof DocumentSummaryInformation) { dsInf = (DocumentSummaryInformation)ps; } else if(ps != null) { logger.log(POILogger.WARN, "DocumentSummaryInformation property set came back with wrong class - ", ps.getClass()); } // SummaryInformation ps = getPropertySet(SummaryInformation.DEFAULT_STREAM_NAME); if(ps instanceof SummaryInformation) { sInf = (SummaryInformation)ps; } else if(ps != null) { logger.log(POILogger.WARN, "SummaryInformation property set came back with wrong class - ", ps.getClass()); } // Mark the fact that we've now loaded up the properties initialized = true; }
/** * Find, and create objects for, the standard * Documment Information Properties (HPSF). * If a given property set is missing or corrupt, * it will remain null; */ protected void readProperties() { PropertySet ps; // DocumentSummaryInformation ps = getPropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME); if(ps != null && ps instanceof DocumentSummaryInformation) { dsInf = (DocumentSummaryInformation)ps; } else if(ps != null) { logger.log(POILogger.WARN, "DocumentSummaryInformation property set came back with wrong class - ", ps.getClass()); } // SummaryInformation ps = getPropertySet(SummaryInformation.DEFAULT_STREAM_NAME); if(ps instanceof SummaryInformation) { sInf = (SummaryInformation)ps; } else if(ps != null) { logger.log(POILogger.WARN, "SummaryInformation property set came back with wrong class - ", ps.getClass()); } // Mark the fact that we've now loaded up the properties initialized = true; }
@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; }