Summary: | CustomProperties.containsKey(key) | ||
---|---|---|---|
Product: | POI | Reporter: | Daniel Treacy <daniel.treacy> |
Component: | HPSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED LATER | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP |
Description
Daniel Treacy
2009-02-25 18:03:08 UTC
*** Bug 46769 has been marked as a duplicate of this bug. *** Please provide details about how this fails for you. Which version of POI are you using? Do you have a simple test file and/or a code fragment that shows your trouble? Without such we cannot know how to respond. Hi, Sorry for not providing more information. I have since worked around th potential issue that I found. The jar I am using version 3.0.2 final. The example code that I was trying (Not like this, but this is the same sort of thing): CustomProperties customProperties = documentSummaryInformation .getCustomProperties(); customProperties.put("key", "value"); \* Extraction of data by a diff class, from a different event *\ if(customProperties.containsKey("key")) { String value = (String) customProperties.get("key"); } The condition returns false resulting in the value not being extracted. I'm probably missing something. I wrote the following method as a temp work around: (I'm not a programming or java expert, dont be too harsh on me :-)) private static boolean isCustomProperty(CustomProperties customProperties, String property) { if (logger.isDebugEnabled()) { logger.debug("isCustomProperty(CustomProperties, String) - start"); } try { Set<Map.Entry<?, CustomProperty>> set = customProperties.entrySet(); for (Map.Entry<?, CustomProperty> me : set) { CustomProperty cP = (CustomProperty) me.getValue(); String key = cP.getName(); if (key.contains(property)) { if (logger.isDebugEnabled()) { logger .debug("isCustomProperty(CustomProperties, String) - end"); } return true; } } } catch (Exception e) { logger.error("isCustomProperty(CustomProperties, String)", e); } Thanks for your assistance. Could you please try an unconditional Object value = customProperties.get("key"); and after doing the get() check whether the result is null (value not in properties) or not null (you retrieved the value successfully)? If the custom properties indeed do not contain your value the question is whether your key/value pair a) entered the custom properties successfully b) had been deleted by your application or c) had been deleted by a HPSF failure. In case c) we'd need a sample program demonstrating the error. Ideally it would be in the form of a JUnit test case, but this is not required. No response here for a long time, therefore I am resolving this as LATER for now, if you still see this problem with the latest version of POI, then please reopen this bug with more information, preferably a unit test and sample documents which allow us to reproduce the problem more easily. |