/**
 * Copyright 2010 - 2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jetbrains.exodus.env;

import jetbrains.exodus.bindings.StringBinding;
import org.jetbrains.annotations.NotNull;

/**
 * This example shows low level key/value store access.
 */
public class EnvironmentReadWriteExample {

    public static void main(String[] args) {

        //Create environment or open existing one
        final Environment env = Environments.newInstance("data", EnvironmentConfig.DEFAULT);

        //Create or open existing store in environment
        final Store store = env.computeInTransaction(new TransactionalComputable<Store>() {
            @Override
            public Store compute(@NotNull final Transaction txn) {
                return env.openStore("MyStore", StoreConfiguration.WITHOUT_DUPLICATES, txn);
            }
        });

        // Put "myValue" string under the key "myKey"
        env.executeInTransaction(new TransactionalExecutable() {
            @Override
            public void execute(@NotNull final Transaction txn) {
                store.put(txn, StringBinding.stringToEntry("myKey"), StringBinding.stringToEntry("myValue"));
            }
        });

        // Read value by key "myKey"
        env.executeInTransaction(new TransactionalExecutable() {
            @Override
            public void execute(@NotNull final Transaction txn) {
                System.out.println(StringBinding.entryToString(store.get(txn, StringBinding.stringToEntry("myKey"))));
            }
        });

        // Close environment when we are done
        env.close();
    }
}

@@ -628,16 +628,97 @@
 s.env;%0A%0A
+import jetbrains.exodus.ArrayByteIterable;%0Aimport jetbrains.exodus.ByteIterable;%0A
 import j
@@ -798,16 +798,59 @@
 NotNull;
+%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0A/**%0A *
@@ -1228,277 +1228,21 @@
 e = 
-env.computeInTransaction(new TransactionalComputable%3CStore%3E() %7B%0A            @Override%0A            public Store compute(@NotNull final Transaction txn) %7B%0A                return env.openStore(%22MyStore%22, StoreConfiguration.WITHOUT_DUPLICATES, txn);%0A            %7D%0A        %7D
+initStore(env
 );%0A%0A
@@ -1483,69 +1483,25 @@
 xn, 
-StringBinding.stringToEntry(%22myKey%22), StringBinding.stringToE
+entry(%22myKey%22), e
 ntry
@@ -1770,50 +1770,367 @@
 tln(
-StringBinding.entryToString(store.get(txn,
+string(store.get(txn, entry(%22myKey%22))));%0A            %7D%0A        %7D);%0A%0A        // Close environment when we are done%0A        env.close();%0A    %7D%0A%0A    private static String string(@Nullable ByteIterable myKey) %7B%0A        return myKey == null ? null : StringBinding.entryToString(myKey);%0A    %7D%0A%0A    private static ArrayByteIterable entry(String key) %7B%0A        return
  Str
@@ -2158,112 +2158,365 @@
 try(
-%22myKey%22)))
+key
 );%0A    
+%7D%0A%0A
     
-    %7D%0A        %7D);%0A%0A        // Close environment when we are done%0A        env.close(
+private static Store initStore(final Environment env) %7B%0A        return env.computeInTransaction(new TransactionalComputable%3CStore%3E() %7B%0A            @Override%0A            public Store compute(@NotNull final Transaction txn) %7B%0A                return env.openStore(%22MyStore%22, StoreConfiguration.WITHOUT_DUPLICATES, txn);%0A            %7D%0A        %7D
 );%0A 

simplify sample