class DatabaseDelegate extends AbstractDelegate implements ITransformer, SharedObjectAssembler<DatabaseMeta>,
    java.io.Serializable {

  public DataNode elementToDataNode( final RepositoryElementInterface element ) throws KettleException {
    DatabaseMeta databaseMeta = (DatabaseMeta) element;
    DataNode rootNode = new DataNode( NODE_ROOT );

    // Then the basic db information
    //
    rootNode.setProperty( PROP_TYPE, databaseMeta.getPluginId() );
    rootNode.setProperty( PROP_CONTYPE, DatabaseMeta.getAccessTypeDesc( databaseMeta.getAccessType() ) );
    rootNode.setProperty( PROP_HOST_NAME, databaseMeta.getHostname() );
    rootNode.setProperty( PROP_DATABASE_NAME, databaseMeta.getDatabaseName() );
    rootNode.setProperty( PROP_PORT, new Long( Const.toInt( databaseMeta.getDatabasePortNumberString(), -1 ) ) );
    rootNode.setProperty( PROP_USERNAME, databaseMeta.getUsername() );
    rootNode.setProperty( PROP_PASSWORD, Encr.encryptPasswordIfNotUsingVariables( databaseMeta.getPassword() ) );
    rootNode.setProperty( PROP_SERVERNAME, databaseMeta.getServername() );
    rootNode.setProperty( PROP_DATA_TBS, databaseMeta.getDataTablespace() );
    rootNode.setProperty( PROP_INDEX_TBS, databaseMeta.getIndexTablespace() );

    DataNode attrNode = rootNode.addNode( NODE_ATTRIBUTES );

    // Now store all the attributes set on the database connection...
    //
    Properties attributes = databaseMeta.getAttributes();
    Enumeration<Object> keys = databaseMeta.getAttributes().keys();
    while ( keys.hasMoreElements() ) {
      String code = (String) keys.nextElement();
      String attribute = (String) attributes.get( code );

      // Save this attribute
      //
      // Escape the code as it might contain invalid JCR characters like '/' as in AS/400
      String escapedCode = RepositoryFilenameUtils.escape( code, repo.getUnderlyingRepository().getReservedChars() );
      attrNode.setProperty( escapedCode, attribute );
    }
    return rootNode;

  }

  public  DatabaseDelegate( final PurRepository repo );

}