Interface Alias

  • All Known Implementing Classes:
    TypeAlias, WildcardAlias

    public interface Alias
    Implement this interface when implementing special custom Aliases for classes, packages or namespaces.

    Aliases can be used to persist classes in the running application to different persistent classes in a database file or on a db4o server.

    Two simple Alias implementations are supplied along with db4o:
    - TypeAlias provides an #equals() resolver to match names directly.
    - WildcardAlias allows simple pattern matching with one single '*' wildcard character.

    It is possible to create own complex Alias constructs by creating own resolvers that implement the Alias interface.

    Examples of concrete usecases:

    EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();
    // Creating an Alias for a single class
    config.common().addAlias(
      new TypeAlias("com.f1.Pilot", "com.f1.Driver"));

    // Mapping a Java package onto another
    config.common().addAlias(
      new WildcardAlias(
        "com.f1.*",
        "com.f1.client*"));


    Aliases that translate the persistent name of a class to a name that already exists as a persistent name in the database (or on the server) are not permitted and will throw an exception when the database file is opened.

    Aliases should be configured before opening a database file or connecting to a server.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String resolveRuntimeName​(java.lang.String runtimeTypeName)
      return the stored name for a runtime name or null if not handled.
      java.lang.String resolveStoredName​(java.lang.String storedTypeName)
      return the runtime name for a stored name or null if not handled.
    • Method Detail

      • resolveRuntimeName

        java.lang.String resolveRuntimeName​(java.lang.String runtimeTypeName)
        return the stored name for a runtime name or null if not handled.
      • resolveStoredName

        java.lang.String resolveStoredName​(java.lang.String storedTypeName)
        return the runtime name for a stored name or null if not handled.