private function writeClass( $dir, $tableName, ezcDbSchemaTable $table )
    {
        $file = $this->openFile( $dir, $tableName );

        fwrite( $file, "/**\n" );
        fwrite( $file, " * Data class $tableName.\n" );
        fwrite( $file, " * Class to be used with eZ Components PersistentObject.\n" );
        fwrite( $file, " */\n" );
        fwrite( $file, "class {$this->prefix}$tableName\n" );
        fwrite( $file, "{\n" );

        // attributes 
        $this->writeAttributes( $file, $table->fields );
        fwrite( $file, "\n" );

        // methods
        $this->writeSetState( $file );
        fwrite( $file, "\n" );
        $this->writeGetState( $file, $table->fields );

        fwrite( $file, "}\n" );
        $this->closeFile( $file );
    }