Interface CharacterProvider


public interface CharacterProvider

This interface controls the storage of character related documents. The basic concept is that each character can have attachments of a specific

invalid reference
format
and
invalid reference
type
. Examples for those attachments may be portrait image (type CHARACTER, format IMAGE) serialized character data (type CHARACTER, format RULESPECIFIC) or a background story (type BACKGROUND, format PDF).

All the attachments are collected in a CharacterHandle. CharacterHandles itself belong to a

invalid reference
de.rpgframework.core.Player
and have a RoleplayingSystem assigned.

  // Get the player that represents yourself
 Player myself = RPGFrameworkLoader.getInstance().getPlayerService().getMyself();

  // Obtain an instance of the character provider ...
 CharacterProvider charProv = RPGFrameworkLoader.getInstance().getCharacterProvider();

  // Obtain an instance of the character provider ...
 for (CharacterHandle handle : charProv.getCharacters(myself)) {
    // ... do something
 }
 
  • Method Details

    • setListener

      void setListener(CharacterProviderListener callback)
    • getCharacter

      CharacterHandle getCharacter(String charName, RoleplayingSystem ruleSystem) throws IOException
      Return an eventually existing character - or null if it doesn't exist yet.
      Parameters:
      charName - Name of the character
      ruleSystem - The roleplaying system of the character
      Returns:
      The created handle
      Throws:
      IOException - Error executing operation - e.g. on directory creation or missing internet connection
    • createCharacter

      CharacterHandle createCharacter(String charName, RoleplayingSystem ruleSystem) throws IOException
      Create a new CharacterHandle as a container for attachments for the local user.
      Parameters:
      charName - Name of the character
      ruleSystem - The roleplaying system of the character
      Returns:
      The created handle
      Throws:
      IOException - Error executing operation - e.g. on directory creation or missing internet connection
    • listAttachments

      List<Attachment> listAttachments(CharacterHandle handle) throws IOException
      Get a list of attachments without loading the data
      Parameters:
      handle -
      Returns:
      Throws:
      IOException
    • getFirstAttachment

      Attachment getFirstAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format) throws IOException
      Get a specific attachment with data
      Throws:
      IOException
    • addAttachment

      Attachment addAttachment(CharacterHandle handle, Attachment.Type type, Attachment.Format format, String filename, byte[] data) throws IOException
      Adding an attachment to a character. Though the primary focus of this method is adding attachments only to characters of the local player, it may also be used for characters of other players as well. If this works is implementation dependant. How many instances (per format) of attachments are allowed, depends on the type: CHARACTER and BACKGROUND may only exist once, while REPORT may exist multiple times.
      Parameters:
      handle - Character to modify
      type - What us described in this attachment
      format - What kind of data is it
      filename - A proposed file name. May be null. May be ignored by the implementation
      data - Binary data of the attachment
      Returns:
      The created attachment
      Throws:
      IOException - Error executing operation
    • modifyAttachment

      void modifyAttachment(CharacterHandle handle, Attachment attach) throws IOException
      Write modifications made to this attachment to storage.
      Parameters:
      handle - Character to modify
      attach - Attachment that has been modified
      Throws:
      IOException
    • deleteAttachment

      void deleteAttachment(CharacterHandle handle, Attachment attach) throws IOException
      Remove an attachment from a character.
      Parameters:
      handle - Character to modify
      attach - Attachment to remove
      Throws:
      IOException
    • deleteCharacter

      void deleteCharacter(CharacterHandle handle) throws IOException
      Delete a character and all his attachments,
      Parameters:
      handle - Character to remove
      Throws:
      IOException
    • renameCharacter

      void renameCharacter(CharacterHandle handle, String newName) throws IOException
      Rename a character and all his attachments,
      Parameters:
      handle - Character to remove
      Throws:
      IOException
    • getMyCharacters

      List<CharacterHandle> getMyCharacters() throws IOException
      Throws:
      IOException
    • getMyCharacters

      List<CharacterHandle> getMyCharacters(RoleplayingSystem ruleSystem) throws IOException
      Get all characters of a given player belonging to a specific roleplaying system.
      Parameters:
      ruleSystem - Roleplaying system to get characters for.
      player - Player to get characters from
      Returns:
      A list of characters in no granted order.
      Throws:
      IOException
    • isSynchronizeSupported

      boolean isSynchronizeSupported()
    • initiateCharacterSynchronization

      void initiateCharacterSynchronization()