cancel
Showing results for 
Search instead for 
Did you mean: 

There is a possible BUG?

durdy48
Champ in-the-making
Champ in-the-making
Hi.
when i try recovery metadata from a OpenOffice documents and fill a map, that's always coming empty.
And i'm debugging the code and noted a possible bug in ODFMetaFileAnalyzer.java in 'com.catcode.odf' package because:

protected void processUserDefined( Element element, OpenDocumentMetadata
      metaDataResult )
   {
      String dataType;
      String content;
      String key;
      
      if (element.hasChildNodes())
      {
         content = element.getFirstChild().getNodeValue();
         dataType = element.getAttribute( metaNamespace + "value-type" );
         dataType = (dataType.equals("")) ? "string" : dataType;

         key = element.getAttribute( metaNamespace + "name" );
         if (key != "")
         {
            if (dataType == "string" || dataType == "date")
            {
               metaDataResult.setUserDefined( key, content );
            }
            else if (dataType == "float")
            {
               metaDataResult.setUserDefined( key,
                  Double.valueOf( content ) );
            }
            else if (dataType == "boolean")
            {
               metaDataResult.setUserDefined( key,
                  Boolean.valueOf( content ) );
            }
            else if (dataType == "time")
            {
               metaDataResult.setUserDefined( key,
                  Duration.parseDuration( content ) );
            }
         }
      }
   }

Is "if (dataType == "string" || dataType == "date")" a coding error ?

It is more correct "dataType.equals("string")" , right?

Helpme please.
Thanks.
3 REPLIES 3

stijndereede
Champ in-the-making
Champ in-the-making
I think you're right. In Java the .equals() method should be used to compare Strings. With == you check if both variables point to the same object (which obviously isn't the case with the newly created "string" object).

kevinr
Star Contributor
Star Contributor
Looks like a bug to me - I suggest you contact the author of the code (his address is in the comment at the top of the java code - i won't post it here for obvious reasons).

Thanks,

Kevin

durdy48
Champ in-the-making
Champ in-the-making
Pefect!
Thank you very much.

I have sent a mail and expect to take luck!

Bye,