Interface DocumentProviderBridge


public interface DocumentProviderBridge

The platform seam of the document provider framework, implemented by ports and returned from CodenameOneImplementation.getDocumentProviderBridge() (null on unsupported ports, making the whole public API an inert no-op).

Everything crosses this boundary as data -- a JSON index produced by the core serializer and files on disk -- never as live model objects. On iOS the reader is an app extension in a separate process that runs while the app is dead, so implementations MUST persist what they are given into a container both processes can reach (the App Group container on Apple platforms; ordinary app storage on Android, where the provider shares the app's process).

Nothing here blocks on the platform browser: publishing writes the index, and signalChange is a hint that the browser should re-enumerate at its own convenience.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Forgets the published index, the endpoint and the token, and empties the shared directory.
    Returns the absolute com.codename1.io.FileSystemStorage path of the directory whose contents both the app and the platform reader can see, creating it if needed.
    boolean
    Returns true when this port can expose the app's documents to the system file browser.
    void
    publishIndex(String indexJson)
    Atomically replaces the persisted document index and leaves it where the platform reader will find it.
    void
    setRemoteEndpoint(String endpoint, String authToken)
    Records where the platform reader should fetch content it cannot find locally.
    void
    Hints that the published index changed and the platform browser should re-enumerate.
  • Method Details

    • isDocumentProviderSupported

      boolean isDocumentProviderSupported()
      Returns true when this port can expose the app's documents to the system file browser.
    • getSharedDirectory

      String getSharedDirectory()

      Returns the absolute com.codename1.io.FileSystemStorage path of the directory whose contents both the app and the platform reader can see, creating it if needed.

      Returns

      the shared directory path, or null when this port has nowhere to put one

    • publishIndex

      void publishIndex(String indexJson)

      Atomically replaces the persisted document index and leaves it where the platform reader will find it.

      Atomically matters: the reader may wake at any moment, including midway through this call, and a half-written index is a file browser showing half a tree.

      Parameters
      • indexJson: the serialized tree
    • setRemoteEndpoint

      void setRemoteEndpoint(String endpoint, String authToken)

      Records where the platform reader should fetch content it cannot find locally.

      Parameters
      • endpoint: the HTTPS base URL, or null to serve only from the shared directory
      • authToken: a bearer token sent with each request, or null for none
    • signalChange

      void signalChange()
      Hints that the published index changed and the platform browser should re-enumerate.
    • clear

      void clear()
      Forgets the published index, the endpoint and the token, and empties the shared directory.