AnsweredAssumed Answered

There is a possible BUG?

Question asked by durdy48 on Dec 3, 2007
Latest reply on Jan 3, 2008 by durdy48
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.

Outcomes