/*
   author:     Rony G. Flatscher (c) 2011
   purpose:    implement a LocationProvider in Rexx instead of Java by implementing
               the interface methods "org.mozilla.xpcom.IAppFileLocProvider"
   needs:      BSF4ooRexx
   date:       2011-08-02
   license:    AL 2.0 or CPL 1.0

-- usage-example (snippet):

-- ... cut ....
grePathName="C:\libs\xul\xulrunner-sdk\bin"     -- give path to xulrunner's bin directory
grePath=.bsf~new("java.io.File", grePathName)   -- create a File object

mozilla=.Mozilla~getInstance~~initialize(grePath)  -- create Mozilla instance and initialize it

   -- create instance of Rexx class, supply 'grePath' File object
lp=.LocationProvider~new(grePath)               -- create a Rexx object

   -- create a Java Rexx proxy: allow it to be used in Java wherever a "org.mozilla.xpcom.IAppFileLocProvider"
   -- is needed as an argument; all Java method invocations will be forwarded to the Rexx object:
rp=.BSFCreateRexxProxy(lp,,"org.mozilla.xpcom.IAppFileLocProvider")

mozilla~initXPCOM(grePath,rp)    -- "rp" is the Java Rexx proxy forwarding messages to its proxy, the "lp" Rexx object

-- ... cut ...
*/



/* Rexx implementation of the interface "org.mozilla.xpcom.IAppFileLocProvider". */
::class LocationProvider public

::attribute libXULPath  -- allow Rexx direct access to this attribute (just a convenience)

::method '<init>'       -- Java constructor (just for completeness here)
  expose  libXULPath
  use arg libXULPath
  say "in '<init>' (Java constructor), received and memorized:" libXULPath~toString


::method init           -- Rexx constructor
  expose  libXULPath
  use arg libXULPath
  say "in 'init' (Rexx constructor), received and memorized:" libXULPath~toString


::method getFile        -- interface method implementation
  expose libXULPath
  use arg aProp, aPersistent

  file=.nil
  if wordpos(aProp,"ComsD CurProcD GreComsD GreD MozBinD ProfD")>0 then
  do
     file=libXULPath    -- point to directory
     if wordpos(aProp,"ComsD GreComsD")>0 then
        file=.bsf~new("java.io.File", file, "components")
  end
  return file


::method getFiles       -- interface method implementation
  expose libXULPath
  use arg aProp

  files=.nil
  if aProp="APluginsDL" then
     files=bsf.javaArrayOf(.bsf~new("java.io.File", libXULPath, "plugins"))

  return files

