text:
package org.apache.curator.framework.imps;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import org.apache.curator.RetryLoop;
import org.apache.curator.drivers.OperationTrace;
import org.apache.curator.framework.api.*;
import org.apache.curator.framework.api.transaction.OperationType;
import org.apache.curator.framework.api.transaction.TransactionCreateBuilder;
import org.apache.curator.framework.api.transaction.TransactionCreateBuilder2;
import org.apache.curator.utils.InternalACLProvider;
import org.apache.curator.utils.ThreadUtils;
import org.apache.curator.utils.ZKPaths;
import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Op;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.DataTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

public class CreateBuilderImpl implements CreateBuilder, CreateBuilder2, BackgroundOperation<PathAndBytes>, ErrorListenerPathAndBytesable<String>
{
    private final Logger log = LoggerFactory.getLogger(getClass());
    private final CuratorFrameworkImpl client;
    private final ProtectedMode protectedMode = new ProtectedMode();
    private CreateMode createMode;
    private Backgrounding backgrounding;
    private boolean createParentsIfNeeded;
    private boolean createParentsAsContainers;
    private boolean compress;
    private boolean setDataIfExists;
    private int setDataIfExistsVersion = -1;
    private boolean idempotent = false;
    private ACLing acling;
    private Stat storingStat;
    private long ttl;

    @VisibleForTesting
    boolean failNextCreateForTesting = false;
    @VisibleForTesting
    boolean failBeforeNextCreateForTesting = false;
    @VisibleForTesting
    boolean failNextIdempotentCheckForTesting = false;

    CreateBuilderImpl(CuratorFrameworkImpl client)
    {
        this.client = client;
        createMode = CreateMode.PERSISTENT;
        backgrounding = new Backgrounding();
        acling = new ACLing(client.getAclProvider());
        createParentsIfNeeded = false;
        createParentsAsContainers = false;
        compress = false;
        setDataIfExists = false;
        storingStat = null;
        ttl = -1;
    }

    public CreateBuilderImpl(CuratorFrameworkImpl client, CreateMode createMode, Backgrounding backgrounding, boolean createParentsIfNeeded, boolean createParentsAsContainers, boolean doProtected, boolean compress, boolean setDataIfExists, List<ACL> aclList, Stat storingStat, long ttl)
    {
        this.client = client;
        this.createMode = createMode;
        this.backgrounding = backgrounding;
        this.createParentsIfNeeded = createParentsIfNeeded;
        this.createParentsAsContainers = createParentsAsContainers;
        this.compress = compress;
        this.setDataIfExists = setDataIfExists;
        this.acling = new ACLing(client.getAclProvider(), aclList);
        this.storingStat = storingStat;
        this.ttl = ttl;
        if ( doProtected )
        {
            protectedMode.setProtectedMode();
        }
    }

    public void setSetDataIfExistsVersion(int version)
    {
        this.setDataIfExistsVersion = version;
    }

    @Override
    public CreateBuilder2 orSetData()
    {
        return orSetData(-1);
    }

    @Override
    public CreateBuilder2 orSetData(int version)
    {
        setDataIfExists = true;
        setDataIfExistsVersion = version;
        return this;
    }

    @Override
    public CreateBuilder2 idempotent()
    {
        this.idempotent = true;
        return this;
    }

    @Override
    public CreateBuilderMain withTtl(long ttl)
    {
        this.ttl = ttl;
        return this;
    }

    <T> TransactionCreateBuilder<T> asTransactionCreateBuilder(final T context, final CuratorMultiTransactionRecord transaction)
    {
        return new TransactionCreateBuilder<T>()
        {
            @Override
            public PathAndBytesable<T> withACL(List<ACL> aclList)
            {
                return withACL(aclList, false);
            }

            @Override
            public PathAndBytesable<T> withACL(List<ACL> aclList, boolean applyToParents)
            {
                CreateBuilderImpl.this.withACL(aclList, applyToParents);
                return this;
            }

            @Override
            public TransactionCreateBuilder2<T> withTtl(long ttl)
            {
                CreateBuilderImpl.this.withTtl(ttl);
                return this;
            }

            @Override
            public ACLPathAndBytesable<T> withMode(CreateMode mode)
            {
                CreateBuilderImpl.this.withMode(mode);
                return this;
            }

            @Override
            public ACLCreateModePathAndBytesable<T> compressed()
            {
                CreateBuilderImpl.this.compressed();
                return this;
            }

            @Override
            public T forPath(String path) throws Exception
            {
                return forPath(path, client.getDefaultData());
            }

            @Override
            public T forPath(String path, byte[] data) throws Exception
            {
                if ( compress )
                {
                    data = client.getCompressionProvider().compress(path, data);
                }

                String fixedPath = client.fixForNamespace(path);
                transaction.add(Op.create(fixedPath, data, acling.getAclList(path), createMode, ttl), OperationType.CREATE, path);
                return context;
            }
        };
    }

    @Override
    public CreateBackgroundModeStatACLable compressed()
    {
        compress = true;
        return new CreateBackgroundModeStatACLable()
        {
            @Override
            public CreateBackgroundModeACLable storingStatIn(Stat stat)
            {
                storingStat = stat;
                return asCreateBackgroundModeACLable();
            }

            @Override
            public ACLCreateModePathAndBytesable<String> creatingParentsIfNeeded()
            {
                createParentsIfNeeded = true;
                return asACLCreateModePathAndBytesable();
            }

            @Override
            public ACLCreateModePathAndBytesable<String> creatingParentContainersIfNeeded()
            {
                setCreateParentsAsContainers();
                return creatingParentsIfNeeded();
            }

            @Override
            public ACLPathAndBytesable<String> withProtectedEphemeralSequential()
            {
                return CreateBuilderImpl.this.withProtectedEphemeralSequential();
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context)
            {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground()
            {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context)
            {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback)
            {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode)
            {
                return CreateBuilderImpl.this.withMode(mode);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path);
            }
        };
    }

    @Override
    public ACLBackgroundPathAndBytesable<String> withACL(List<ACL> aclList)
    {
        return withACL(aclList, false);
    }

    @Override
    public ACLBackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
    {
        acling = new ACLing(client.getAclProvider(), aclList, applyToParents);
        return new ACLBackgroundPathAndBytesable<String>()
        {
            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground()
            {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context)
            {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context)
            {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback)
            {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path);
            }
        };
    }

    @Override
    public ProtectACLCreateModeStatPathAndBytesable<String> creatingParentContainersIfNeeded()
    {
        setCreateParentsAsContainers();
        return creatingParentsIfNeeded();
    }

    private void setCreateParentsAsContainers()
    {
        if ( client.useContainerParentsIfAvailable() )
        {
            createParentsAsContainers = true;
        }
    }

    @Override
    public ProtectACLCreateModeStatPathAndBytesable<String> creatingParentsIfNeeded()
    {
        createParentsIfNeeded = true;
        return new ProtectACLCreateModeStatPathAndBytesable<String>()
        {
            @Override
            public ACLCreateModeBackgroundPathAndBytesable<String> withProtection()
            {
                return CreateBuilderImpl.this.withProtection();
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return withACL(aclList, false);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground()
            {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context)
            {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback)
            {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context)
            {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor)
            {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode)
            {
                return CreateBuilderImpl.this.withMode(mode);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> storingStatIn(Stat stat)
            {
                storingStat = stat;
                return CreateBuilderImpl.this;
            }
        };
    }

    @Override
    public ACLCreateModeStatBackgroundPathAndBytesable<String> withProtection()
    {
        protectedMode.setProtectedMode();
        return asACLCreateModeStatBackgroundPathAndBytesable();
    }

    @Override
    public ACLPathAndBytesable<String> withProtectedEphemeralSequential()
    {
        protectedMode.setProtectedMode();
        createMode = CreateMode.EPHEMERAL_SEQUENTIAL;

        return new ACLPathAndBytesable<String>()
        {
            @Override
            public PathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public PathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path);
            }
        };
    }

    @Override
    public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode)
    {
        createMode = mode;
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context)
    {
        backgrounding = new Backgrounding(callback, context);
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor)
    {
        backgrounding = new Backgrounding(client, callback, context, executor);
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback)
    {
        backgrounding = new Backgrounding(callback);
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor)
    {
        backgrounding = new Backgrounding(client, callback, executor);
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground()
    {
        backgrounding = new Backgrounding(true);
        return this;
    }

    @Override
    public ErrorListenerPathAndBytesable<String> inBackground(Object context)
    {
        backgrounding = new Backgrounding(context);
        return this;
    }

    @Override
    public PathAndBytesable<String> withUnhandledErrorListener(UnhandledErrorListener listener)
    {
        backgrounding = new Backgrounding(backgrounding, listener);
        return this;
    }

    @Override
    public String forPath(String path) throws Exception
    {
        return forPath(path, client.getDefaultData());
    }

    @Override
    public String forPath(final String givenPath, byte[] data) throws Exception
    {
        if ( compress )
        {
            data = client.getCompressionProvider().compress(givenPath, data);
        }

        final String adjustedPath = adjustPath(client.fixForNamespace(givenPath, createMode.isSequential()));
        List<ACL> aclList = acling.getAclList(adjustedPath);
        client.getSchemaSet().getSchema(givenPath).validateCreate(createMode, givenPath, data, aclList);

        String returnPath = null;
        if ( backgrounding.inBackground() )
        {
            pathInBackground(adjustedPath, data, givenPath);
        }
        else
        {
            String path = protectedPathInForeground(adjustedPath, data, aclList);
            returnPath = client.unfixForNamespace(path);
        }
        return returnPath;
    }

    private String protectedPathInForeground(String adjustedPath, byte[] data, List<ACL> aclList) throws Exception
    {
        try
        {
            return pathInForeground(adjustedPath, data, aclList);
        }
        catch ( Exception e)
        {
            ThreadUtils.checkInterrupted(e);
            if ( ( e instanceof KeeperException.ConnectionLossException ||
                !( e instanceof KeeperException )) && protectedMode.doProtected() )
            {
                /*
                 * CURATOR-45 + CURATOR-79: we don't know if the create operation was successful or not,
                 * register the znode to be sure it is deleted later.
                 */
                new FindAndDeleteProtectedNodeInBackground(client, ZKPaths.getPathAndNode(adjustedPath).getPath(), protectedMode.protectedId()).execute();
                /*
                 * The current UUID is scheduled to be deleted, it is not safe to use it again.
                 * If this builder is used again later create a new UUID
                 */
                protectedMode.resetProtectedId();
            }

            throw e;
        }
    }

    @Override
    public void performBackgroundOperation(final OperationAndData<PathAndBytes> operationAndData) throws Exception
    {
        try
        {
            final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("CreateBuilderImpl-Background");
            final byte[] data = operationAndData.getData().getData();

            AsyncCallback.Create2Callback callback = new AsyncCallback.Create2Callback()
            {
                @Override
                public void processResult(int rc, String path, Object ctx, String name, Stat stat)
                {
                    trace.setReturnCode(rc).setRequestBytesLength(data).setPath(path).commit();

                    if ( (stat != null) && (storingStat != null) )
                    {
                        DataTree.copyStat(stat, storingStat);
                    }

                    if ( (rc == KeeperException.Code.NONODE.intValue()) && createParentsIfNeeded )
                    {
                        backgroundCreateParentsThenNode(client, operationAndData, operationAndData.getData().getPath(), backgrounding, acling.getACLProviderForParents(), createParentsAsContainers);
                    }
                    else if ( (rc == KeeperException.Code.NODEEXISTS.intValue()) && setDataIfExists )
                    {
                        backgroundSetData(client, operationAndData, operationAndData.getData().getPath(), backgrounding);
                    }
                    else if ( (rc == KeeperException.Code.NODEEXISTS.intValue()) && idempotent )
                    {
                        backgroundCheckIdempotent(client, operationAndData, operationAndData.getData().getPath(), backgrounding);
                    }
                    else
                    {
                        sendBackgroundResponse(rc, path, ctx, name, stat, operationAndData);
                    }
                }
            };
            client.getZooKeeper().create
                (
                    operationAndData.getData().getPath(),
                    data,
                    acling.getAclList(operationAndData.getData().getPath()),
                    createMode,
                    callback,
                    backgrounding.getContext(),
                    ttl
                );

        }
        catch ( Throwable e )
        {
            backgrounding.checkError(e, null);
        }
    }

    @Override
    public CreateProtectACLCreateModePathAndBytesable<String> storingStatIn(Stat stat) {
        storingStat = stat;

        return new CreateProtectACLCreateModePathAndBytesable<String>() {

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground() {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context) {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback) {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context) {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context,
                                                                      Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception {
                return CreateBuilderImpl.this.forPath(path);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode) {
                return CreateBuilderImpl.this.withMode(mode);
            }

            @Override
            public ACLCreateModeBackgroundPathAndBytesable<String> withProtection() {
                return CreateBuilderImpl.this.withProtection();
            }

            @Override
            public ProtectACLCreateModePathAndBytesable<String> creatingParentsIfNeeded() {
                return CreateBuilderImpl.this.creatingParentsIfNeeded();
            }

            @Override
            public ProtectACLCreateModePathAndBytesable<String> creatingParentContainersIfNeeded() {
                return CreateBuilderImpl.this.creatingParentContainersIfNeeded();
            }
        };
    }

    static <T> void backgroundCreateParentsThenNode(final CuratorFrameworkImpl client, final OperationAndData<T> mainOperationAndData, final String path, Backgrounding backgrounding, final InternalACLProvider aclProvider, final boolean createParentsAsContainers)
    {
        BackgroundOperation<T> operation = new BackgroundOperation<T>()
        {
            @Override
            public void performBackgroundOperation(OperationAndData<T> dummy) throws Exception
            {
                try
                {
                    ZKPaths.mkdirs(client.getZooKeeper(), path, false, aclProvider, createParentsAsContainers);
                }
                catch ( KeeperException e )
                {
                    if ( !client.getZookeeperClient().getRetryPolicy().allowRetry(e) )
                    {
                        throw e;
                    }
                    // otherwise safe to ignore as it will get retried
                }
                client.queueOperation(mainOperationAndData);
            }
        };
        OperationAndData<T> parentOperation = new OperationAndData<>(operation, mainOperationAndData.getData(), null, null, backgrounding.getContext(), null);
        client.queueOperation(parentOperation);
    }

    private void backgroundSetData(final CuratorFrameworkImpl client, final OperationAndData<PathAndBytes> mainOperationAndData, final String path, final Backgrounding backgrounding)
    {
        final AsyncCallback.StatCallback statCallback = new AsyncCallback.StatCallback()
        {
            @Override
            public void processResult(int rc, String path, Object ctx, Stat stat)
            {
                if ( rc == KeeperException.Code.NONODE.intValue() )
                {
                    client.queueOperation(mainOperationAndData);    // try to create it again
                }
                else
                {
                    sendBackgroundResponse(rc, path, ctx, path, stat, mainOperationAndData);
                }
            }
        };
        BackgroundOperation<PathAndBytes> operation = new BackgroundOperation<PathAndBytes>()
        {
            @Override
            public void performBackgroundOperation(OperationAndData<PathAndBytes> op) throws Exception
            {
                try
                {
                    client.getZooKeeper().setData(path, mainOperationAndData.getData().getData(), setDataIfExistsVersion, statCallback, backgrounding.getContext());
                }
                catch ( KeeperException e )
                {
                    // ignore
                }
            }
        };
        client.queueOperation(new OperationAndData<>(operation, null, null, null, null, null));
    }

    private void backgroundCheckIdempotent(final CuratorFrameworkImpl client, final OperationAndData<PathAndBytes> mainOperationAndData, final String path, final Backgrounding backgrounding)
    {
        final AsyncCallback.DataCallback dataCallback = new AsyncCallback.DataCallback()
        {
            @Override
            public void processResult(int rc, String path, Object ctx, byte[] data, Stat stat)
            {
                if ( rc == KeeperException.Code.NONODE.intValue() )
                {
                    client.queueOperation(mainOperationAndData);    // try to create it again
                }
                else
                {
                    if ( rc == KeeperException.Code.OK.intValue() )
                    {
                        if ( failNextIdempotentCheckForTesting )
                        {
                            failNextIdempotentCheckForTesting = false;
                            rc = KeeperException.Code.CONNECTIONLOSS.intValue();
                        }
                        else if ( !IdempotentUtils.matches(0, mainOperationAndData.getData().getData(), stat.getVersion(), data) )
                        {
                            rc = KeeperException.Code.NODEEXISTS.intValue();
                        }
                    }
                    sendBackgroundResponse(rc, path, ctx, path, stat, mainOperationAndData);
                }
            }
        };
        BackgroundOperation<PathAndBytes> operation = new BackgroundOperation<PathAndBytes>()
        {
            @Override
            public void performBackgroundOperation(OperationAndData<PathAndBytes> op) throws Exception
            {
                try
                {
                    client.getZooKeeper().getData(path, false, dataCallback, backgrounding.getContext());
                }
                catch ( KeeperException e )
                {
                    // ignore
                    client.logError("Unexpected exception in async idempotent check for, ignoring: " + path, e);
                }
            }
        };
        client.queueOperation(new OperationAndData<>(operation, null, null, null, null, null));
    }

    private void sendBackgroundResponse(int rc, String path, Object ctx, String name, Stat stat, OperationAndData<PathAndBytes> operationAndData)
    {
        path = client.unfixForNamespace(path);
        name = client.unfixForNamespace(name);

        CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.CREATE, rc, path, name, ctx, stat, null, null, null, null, null);
        client.processBackgroundOperation(operationAndData, event);
    }

    private ACLCreateModePathAndBytesable<String> asACLCreateModePathAndBytesable()
    {
        return new ACLCreateModePathAndBytesable<String>()
        {
            @Override
            public PathAndBytesable<String> withACL(List<ACL> aclList)
            {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public PathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                CreateBuilderImpl.this.withACL(aclList, applyToParents);
                return this;
            }

            @Override
            public ACLPathAndBytesable<String> withMode(CreateMode mode)
            {
                createMode = mode;
                return new ACLPathAndBytesable<String>()
                {
                    @Override
                    public PathAndBytesable<String> withACL(List<ACL> aclList)
                    {
                        return CreateBuilderImpl.this.withACL(aclList);
                    }

                    @Override
                    public PathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
                    {
                        return CreateBuilderImpl.this.withACL(aclList, applyToParents);
                    }

                    @Override
                    public String forPath(String path, byte[] data) throws Exception
                    {
                        return CreateBuilderImpl.this.forPath(path, data);
                    }

                    @Override
                    public String forPath(String path) throws Exception
                    {
                        return CreateBuilderImpl.this.forPath(path);
                    }
                };
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public String forPath(String path) throws Exception
            {
                return CreateBuilderImpl.this.forPath(path);
            }
        };
    }

    private CreateBackgroundModeACLable asCreateBackgroundModeACLable()
    {
        return new CreateBackgroundModeACLable() {

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList) {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                return CreateBuilderImpl.this.withACL(aclList, applyToParents);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode) {
                return CreateBuilderImpl.this.withMode(mode);
            }

            @Override
            public String forPath(String path) throws Exception {
                return CreateBuilderImpl.this.forPath(path);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context) {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback) {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context) {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground() {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ACLPathAndBytesable<String> withProtectedEphemeralSequential() {
                return CreateBuilderImpl.this.withProtectedEphemeralSequential();
            }

            @Override
            public ACLCreateModePathAndBytesable<String> creatingParentsIfNeeded() {
                createParentsIfNeeded = true;
                return asACLCreateModePathAndBytesable();
            }

            @Override
            public ACLCreateModePathAndBytesable<String> creatingParentContainersIfNeeded() {
                setCreateParentsAsContainers();
                return asACLCreateModePathAndBytesable();
            }
        };
    }

    private ACLCreateModeStatBackgroundPathAndBytesable<String> asACLCreateModeStatBackgroundPathAndBytesable()
    {
        return new ACLCreateModeStatBackgroundPathAndBytesable<String>()
        {
            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList) {
                return CreateBuilderImpl.this.withACL(aclList);
            }

            @Override
            public BackgroundPathAndBytesable<String> withACL(List<ACL> aclList, boolean applyToParents)
            {
                CreateBuilderImpl.this.withACL(aclList, applyToParents);
                return this;
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground() {
                return CreateBuilderImpl.this.inBackground();
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context, Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, context, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Executor executor) {
                return CreateBuilderImpl.this.inBackground(callback, executor);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback, Object context) {
                return CreateBuilderImpl.this.inBackground(callback, context);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(BackgroundCallback callback) {
                return CreateBuilderImpl.this.inBackground(callback);
            }

            @Override
            public ErrorListenerPathAndBytesable<String> inBackground(Object context) {
                return CreateBuilderImpl.this.inBackground(context);
            }

            @Override
            public String forPath(String path) throws Exception {
                return CreateBuilderImpl.this.forPath(path);
            }

            @Override
            public String forPath(String path, byte[] data) throws Exception {
                return CreateBuilderImpl.this.forPath(path, data);
            }

            @Override
            public ACLBackgroundPathAndBytesable<String> withMode(CreateMode mode) {
                return CreateBuilderImpl.this.withMode(mode);
            }

            @Override
            public ACLCreateModeBackgroundPathAndBytesable<String> storingStatIn(Stat stat) {
                storingStat = stat;
                return CreateBuilderImpl.this;
            }
        };
    }

    @VisibleForTesting
    volatile boolean debugForceFindProtectedNode = false;

    private void pathInBackground(final String path, final byte[] data, final String givenPath)
    {
        final AtomicBoolean firstTime = new AtomicBoolean(true);
        OperationAndData<PathAndBytes> operationAndData = new OperationAndData<PathAndBytes>(this, new PathAndBytes(path, data), backgrounding.getCallback(),
            new OperationAndData.ErrorCallback<PathAndBytes>()
            {
                public void retriesExhausted(OperationAndData<PathAndBytes> operationAndData)
                {
                    if ( protectedMode.doProtected() )
                    {
                        // all retries have failed, findProtectedNodeInForeground(..) included, schedule a clean up
                        new FindAndDeleteProtectedNodeInBackground(client, ZKPaths.getPathAndNode(path).getPath(), protectedMode.protectedId()).execute();
                        // assign a new id if this builder is used again later
                        protectedMode.resetProtectedId();
                    }
                }
            },
            backgrounding.getContext(),
            null)
        {
            @Override
            void callPerformBackgroundOperation() throws Exception
            {
                boolean callSuper = true;
                boolean localFirstTime = firstTime.getAndSet(false) && !debugForceFindProtectedNode;

                protectedMode.checkSetSessionId(client, createMode);
                if ( !localFirstTime && protectedMode.doProtected() )
                {
                    debugForceFindProtectedNode = false;
                    String createdPath = null;
                    try
                    {
                        createdPath = findProtectedNodeInForeground(path);
                    }
                    catch ( KeeperException.ConnectionLossException e )
                    {
                        sendBackgroundResponse(KeeperException.Code.CONNECTIONLOSS.intValue(), path, backgrounding.getContext(), null, null, this);
                        callSuper = false;
                    }
                    if ( createdPath != null )
                    {
                        try
                        {
                            sendBackgroundResponse(KeeperException.Code.OK.intValue(), createdPath, backgrounding.getContext(), createdPath, null, this);
                        }
                        catch ( Exception e )
                        {
                            ThreadUtils.checkInterrupted(e);
                            client.logError("Processing protected create for path: " + givenPath, e);
                        }
                        callSuper = false;
                    }
                }

                if ( failBeforeNextCreateForTesting )
                {
                    failBeforeNextCreateForTesting = false;
                    throw new KeeperException.ConnectionLossException();
                }

                if ( failNextCreateForTesting )
                {
                    failNextCreateForTesting = false;
                    try
                    {
                        // simulate success on server without notification to client
                        // if another error occurs in pathInForeground that isn't NodeExists, this hangs instead of fully propagating the error. Likely not worth fixing though.
                        pathInForeground(path, data, acling.getAclList(path));
                    }
                    catch ( KeeperException.NodeExistsException e )
                    {
                         client.logError("NodeExists while injecting failure after create, ignoring: " + givenPath, e);
                    }
                    throw new KeeperException.ConnectionLossException();
                }

                if ( callSuper )
                {
                    super.callPerformBackgroundOperation();
                }
            }
        };
        client.processBackgroundOperation(operationAndData, null);
    }

    private String pathInForeground(final String path, final byte[] data, final List<ACL> aclList) throws Exception
    {
        OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("CreateBuilderImpl-Foreground");

        final AtomicBoolean firstTime = new AtomicBoolean(true);
        String returnPath = RetryLoop.callWithRetry
            (
                client.getZookeeperClient(),
                new Callable<String>()
                {
                    @Override
                    public String call() throws Exception
                    {
                        boolean localFirstTime = firstTime.getAndSet(false) && !debugForceFindProtectedNode;
                        protectedMode.checkSetSessionId(client, createMode);

                        String createdPath = null;
                        if ( !localFirstTime && protectedMode.doProtected() )
                        {
                            debugForceFindProtectedNode = false;
                            createdPath = findProtectedNodeInForeground(path);
                        }

                        if ( createdPath == null )
                        {
                            try
                            {
                                if ( failBeforeNextCreateForTesting )
                                {
                                    failBeforeNextCreateForTesting = false;
                                    throw new KeeperException.ConnectionLossException();
                                }
                                createdPath = client.getZooKeeper().create(path, data, aclList, createMode, storingStat, ttl);
                            }
                            catch ( KeeperException.NoNodeException e )
                            {
                                if ( createParentsIfNeeded )
                                {
                                    ZKPaths.mkdirs(client.getZooKeeper(), path, false, acling.getACLProviderForParents(), createParentsAsContainers);
                                    createdPath = client.getZooKeeper().create(path, data, acling.getAclList(path), createMode, storingStat, ttl);
                                }
                                else
                                {
                                    throw e;
                                }
                            }
                            catch ( KeeperException.NodeExistsException e )
                            {
                                if ( setDataIfExists )
                                {
                                    Stat setStat = client.getZooKeeper().setData(path, data, setDataIfExistsVersion);
                                    if ( storingStat != null )
                                    {
                                        DataTree.copyStat(setStat, storingStat);
                                    }
                                    createdPath = path;
                                }
                                else if ( idempotent )
                                {
                                    if ( failNextIdempotentCheckForTesting )
                                    {
                                        failNextIdempotentCheckForTesting = false;
                                        throw new KeeperException.ConnectionLossException();
                                    }
                                    Stat getStat = new Stat();
                                    byte[] existingData = client.getZooKeeper().getData(path, false, getStat);
                                    // check to see if data version == 0 and data matches the idempotent case
                                    if ( IdempotentUtils.matches(0, data, getStat.getVersion(), existingData) )
                                    {
                                        if ( storingStat != null )
                                        {
                                            DataTree.copyStat(getStat, storingStat);
                                        }
                                        createdPath = path;
                                    }
                                    else
                                    {
                                        throw e;
                                    }
                                }
                                else
                                {
                                    throw e;
                                }
                            }
                        }

                        if ( failNextCreateForTesting )
                        {
                            failNextCreateForTesting = false;
                            throw new KeeperException.ConnectionLossException();
                        }
                        return createdPath;
                    }
                }
            );

        trace.setRequestBytesLength(data).setPath(path).commit();
        return returnPath;
    }

    private String findProtectedNodeInForeground(final String path) throws Exception
    {
        OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("CreateBuilderImpl-findProtectedNodeInForeground");

        String returnPath = RetryLoop.callWithRetry
            (
                client.getZookeeperClient(),
                new Callable<String>()
                {
                    @Override
                    public String call() throws Exception
                    {
                        String foundNode = null;
                        try
                        {
                            final ZKPaths.PathAndNode pathAndNode = ZKPaths.getPathAndNode(path);
                            List<String> children = client.getZooKeeper().getChildren(pathAndNode.getPath(), false);

                            foundNode = findNode(children, pathAndNode.getPath(), protectedMode.protectedId());
                            log.debug("Protected mode findNode result: {}", foundNode);

                            foundNode = protectedMode.validateFoundNode(client, createMode, foundNode);
                        }
                        catch ( KeeperException.NoNodeException ignore )
                        {
                            // ignore
                        }
                        return foundNode;
                    }
                }
            );

        trace.setPath(path).commit();
        return returnPath;
    }

    @VisibleForTesting
    String adjustPath(String path) throws Exception
    {
        return ProtectedUtils.toProtectedZNodePath(path, protectedMode.protectedId());
    }

    /**
     * Attempt to find the znode that matches the given path and protected id
     *
     * @param children    a list of candidates znodes
     * @param path        the path
     * @param protectedId the protected id
     * @return the absolute path of the znode or <code>null</code> if it is not found
     */
    static String findNode(final List<String> children, final String path, final String protectedId)
    {
        final String protectedPrefix = ProtectedUtils.getProtectedPrefix(protectedId);
        String foundNode = Iterables.find
            (
                children,
                new Predicate<String>()
                {
                    @Override
                    public boolean apply(String node)
                    {
                        return node.startsWith(protectedPrefix);
                    }
                },
                null
            );
        if ( foundNode != null )
        {
            foundNode = ZKPaths.makePath(path, foundNode);
        }
        return foundNode;
    }
}


text:
class TextureLoadingDDSSample : public SampleApplication
{
  public:
    TextureLoadingDDSSample::TextureLoadingDDSSample()
        : SampleApplication("TextureLoadingDDS", 720, 720)
    {
    }

    virtual bool initialize()
    {
        const std::string vs = SHADER_SOURCE
        (
            attribute vec4 a_position;
            attribute vec2 a_texCoord;
            varying vec2 v_texCoord;
            void main()
            {
                gl_Position = a_position;
                v_texCoord = a_texCoord;
            }
        );

        const std::string fs = SHADER_SOURCE
        (
            precision mediump float;
            varying vec2 v_texCoord;
            uniform sampler2D s_texture;
            void main()
            {
                gl_FragColor = texture2D(s_texture, v_texCoord);
            }
        );

        mProgram = CompileProgram(vs, fs);
        if (!mProgram)
        {
            return false;
        }

        // Get the attribute locations
        mPositionLoc = glGetAttribLocation(mProgram, "a_position");
        mTexCoordLoc = glGetAttribLocation(mProgram, "a_texCoord");

        // Get the sampler location
        mSamplerLoc = glGetUniformLocation(mProgram, "s_texture");

        // Load the texture
        std::string path = GetExecutableDirectory() + "\\bc3compressed.dds";
        std::wstring widePath;
        widePath.assign(path.begin(), path.end());
        if (FAILED(DirectX::CreateDDSTextureFromFile(widePath.c_str(), &mTexture)))
        {
            return false;
        }

        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        return true;
    }

    virtual void destroy()
    {
        glDeleteProgram(mProgram);
        glDeleteTextures(1, &mTexture);
    }

    virtual void draw()
    {
        GLfloat vertices[] =
        {
            -0.5f,  0.5f, 0.0f,  // Position 0
             0.0f,  1.0f,        // TexCoord 0
            -0.5f, -0.5f, 0.0f,  // Position 1
             0.0f,  0.0f,        // TexCoord 1
             0.5f, -0.5f, 0.0f,  // Position 2
             1.0f,  0.0f,        // TexCoord 2
             0.5f,  0.5f, 0.0f,  // Position 3
             1.0f,  1.0f         // TexCoord 3
        };
        GLushort indices[] = { 0, 1, 2, 0, 2, 3 };

        // Set the viewport
        glViewport(0, 0, getWindow()->getWidth(), getWindow()->getHeight());

        // Clear the color buffer
        glClear(GL_COLOR_BUFFER_BIT);

        // Use the program object
        glUseProgram(mProgram);

        // Load the vertex position
        glVertexAttribPointer(mPositionLoc, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vertices);
        // Load the texture coordinate
        glVertexAttribPointer(mTexCoordLoc, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vertices + 3);

        glEnableVertexAttribArray(mPositionLoc);
        glEnableVertexAttribArray(mTexCoordLoc);

        // Set the blend mode
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

        // Bind the texture
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, mTexture);

        // Set the texture sampler to texture unit to 0
        glUniform1i(mSamplerLoc, 0);

        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
    }

  private:
    // Handle to a program object
    GLuint mProgram;

    // Attribute locations
    GLint mPositionLoc;
    GLint mTexCoordLoc;

    // Sampler location
    GLint mSamplerLoc;

    // Texture handle
    GLuint mTexture;
};

int main(int argc, char **argv)
{
    TextureLoadingDDSSample app;
    return app.run();
}

redpajama_set_name: RedPajamaGithub


text:
// ***********************************************************************
// Assembly         : PodioPCL
// Author           : OnsharpRyan
// Created          : 12-09-2014
//
// Last Modified By : OnsharpRyan
// Last Modified On : 12-13-2014
// ***********************************************************************
// <copyright file="Answer.cs" company="Onsharp">
//     Copyright (c) Onsharp. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using Newtonsoft.Json;

namespace PodioPCL.Models
{
	/// <summary>
	/// Class Answer.
	/// </summary>
    public class Answer
    {
		/// <summary>
		/// Gets or sets the question option identifier.
		/// </summary>
		/// <value>The question option identifier.</value>
        [JsonProperty("question_option_id")]
        public int questionOptionId { get; set; }

		/// <summary>
		/// Gets or sets the user.
		/// </summary>
		/// <value>The user.</value>
        [JsonProperty("user")]
        public User User { get; set; }
    }
}


text:
<footer class="container-fluid">
    <article class="row text-center">
        El footer está aquí
    </article>
</footer>
</div>
</body>
</html>


text:
/**
 * @since 2019-09-22 05:58
 * @author vivaxy
 */
export const NEW_GAME = 'NEW_GAME';
export const PLAYING = 'PLAYING';
export const ELIMINATING = 'ELIMINATING';
export const PAUSED = 'PAUSED';
export const GAME_OVER = 'GAME_OVER';


text:
import React from 'react';

class ConfigurePage extends React.Component {

  render() {
    return (

Configuration

        This is the configure page.

        It list content relevant to the Configuration area
        and reveals important actions.

Remote control

          Defines the remote control settings!

Presentational

          Defines the presentational (stuff) settings!

    )
  }

}

export default ConfigurePage;


text: Code for university studies


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.2-b01-fcs
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2007.03.27 at 09:51:27 AM PDT
//

package org.ngbw.sdk.bioutils.blast.blastxml;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for anonymous complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_num"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_bit-score"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_score"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_evalue"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_query-from"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_query-to"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_hit-from"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_hit-to"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_query-frame"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_hit-frame"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_identity"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_positive"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_align-len"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_qseq"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_hseq"/>
 *         <element ref="{http://www.ngbw.org/conversion/impl/blastxml}Hsp_midline"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "hspNum",
    "hspBitScore",
    "hspScore",
    "hspEvalue",
    "hspQueryFrom",
    "hspQueryTo",
    "hspHitFrom",
    "hspHitTo",
    "hspQueryFrame",
    "hspHitFrame",
    "hspIdentity",
    "hspPositive",
    "hspAlignLen",
    "hspQseq",
    "hspHseq",
    "hspMidline"
})
@XmlRootElement(name = "Hsp")
public class Hsp {

    @XmlElement(name = "Hsp_num", required = true)
    protected HspNum hspNum;
    @XmlElement(name = "Hsp_bit-score", required = true)
    protected HspBitScore hspBitScore;
    @XmlElement(name = "Hsp_score", required = true)
    protected HspScore hspScore;
    @XmlElement(name = "Hsp_evalue", required = true)
    protected HspEvalue hspEvalue;
    @XmlElement(name = "Hsp_query-from", required = true)
    protected HspQueryFrom hspQueryFrom;
    @XmlElement(name = "Hsp_query-to", required = true)
    protected HspQueryTo hspQueryTo;
    @XmlElement(name = "Hsp_hit-from", required = true)
    protected HspHitFrom hspHitFrom;
    @XmlElement(name = "Hsp_hit-to", required = true)
    protected HspHitTo hspHitTo;
    @XmlElement(name = "Hsp_query-frame", required = true)
    protected HspQueryFrame hspQueryFrame;
    @XmlElement(name = "Hsp_hit-frame", required = true)
    protected HspHitFrame hspHitFrame;
    @XmlElement(name = "Hsp_identity", required = true)
    protected HspIdentity hspIdentity;
    @XmlElement(name = "Hsp_positive", required = true)
    protected HspPositive hspPositive;
    @XmlElement(name = "Hsp_align-len", required = true)
    protected HspAlignLen hspAlignLen;
    @XmlElement(name = "Hsp_qseq", required = true)
    protected HspQseq hspQseq;
    @XmlElement(name = "Hsp_hseq", required = true)
    protected HspHseq hspHseq;
    @XmlElement(name = "Hsp_midline", required = true)
    protected HspMidline hspMidline;

    /**
     * Gets the value of the hspNum property.
     *
     * @return
     *     possible object is
     *     {@link HspNum }
     *
     */
    public HspNum getHspNum() {
        return hspNum;
    }

    /**
     * Sets the value of the hspNum property.
     *
     * @param value
     *     allowed object is
     *     {@link HspNum }
     *
     */
    public void setHspNum(HspNum value) {
        this.hspNum = value;
    }

    /**
     * Gets the value of the hspBitScore property.
     *
     * @return
     *     possible object is
     *     {@link HspBitScore }
     *
     */
    public HspBitScore getHspBitScore() {
        return hspBitScore;
    }

    /**
     * Sets the value of the hspBitScore property.
     *
     * @param value
     *     allowed object is
     *     {@link HspBitScore }
     *
     */
    public void setHspBitScore(HspBitScore value) {
        this.hspBitScore = value;
    }

    /**
     * Gets the value of the hspScore property.
     *
     * @return
     *     possible object is
     *     {@link HspScore }
     *
     */
    public HspScore getHspScore() {
        return hspScore;
    }

    /**
     * Sets the value of the hspScore property.
     *
     * @param value
     *     allowed object is
     *     {@link HspScore }
     *
     */
    public void setHspScore(HspScore value) {
        this.hspScore = value;
    }

    /**
     * Gets the value of the hspEvalue property.
     *
     * @return
     *     possible object is
     *     {@link HspEvalue }
     *
     */
    public HspEvalue getHspEvalue() {
        return hspEvalue;
    }

    /**
     * Sets the value of the hspEvalue property.
     *
     * @param value
     *     allowed object is
     *     {@link HspEvalue }
     *
     */
    public void setHspEvalue(HspEvalue value) {
        this.hspEvalue = value;
    }

    /**
     * Gets the value of the hspQueryFrom property.
     *
     * @return
     *     possible object is
     *     {@link HspQueryFrom }
     *
     */
    public HspQueryFrom getHspQueryFrom() {
        return hspQueryFrom;
    }

    /**
     * Sets the value of the hspQueryFrom property.
     *
     * @param value
     *     allowed object is
     *     {@link HspQueryFrom }
     *
     */
    public void setHspQueryFrom(HspQueryFrom value) {
        this.hspQueryFrom = value;
    }

    /**
     * Gets the value of the hspQueryTo property.
     *
     * @return
     *     possible object is
     *     {@link HspQueryTo }
     *
     */
    public HspQueryTo getHspQueryTo() {
        return hspQueryTo;
    }

    /**
     * Sets the value of the hspQueryTo property.
     *
     * @param value
     *     allowed object is
     *     {@link HspQueryTo }
     *
     */
    public void setHspQueryTo(HspQueryTo value) {
        this.hspQueryTo = value;
    }

    /**
     * Gets the value of the hspHitFrom property.
     *
     * @return
     *     possible object is
     *     {@link HspHitFrom }
     *
     */
    public HspHitFrom getHspHitFrom() {
        return hspHitFrom;
    }

    /**
     * Sets the value of the hspHitFrom property.
     *
     * @param value
     *     allowed object is
     *     {@link HspHitFrom }
     *
     */
    public void setHspHitFrom(HspHitFrom value) {
        this.hspHitFrom = value;
    }

    /**
     * Gets the value of the hspHitTo property.
     *
     * @return
     *     possible object is
     *     {@link HspHitTo }
     *
     */
    public HspHitTo getHspHitTo() {
        return hspHitTo;
    }

    /**
     * Sets the value of the hspHitTo property.
     *
     * @param value
     *     allowed object is
     *     {@link HspHitTo }
     *
     */
    public void setHspHitTo(HspHitTo value) {
        this.hspHitTo = value;
    }

    /**
     * Gets the value of the hspQueryFrame property.
     *
     * @return
     *     possible object is
     *     {@link HspQueryFrame }
     *
     */
    public HspQueryFrame getHspQueryFrame() {
        return hspQueryFrame;
    }

    /**
     * Sets the value of the hspQueryFrame property.
     *
     * @param value
     *     allowed object is
     *     {@link HspQueryFrame }
     *
     */
    public void setHspQueryFrame(HspQueryFrame value) {
        this.hspQueryFrame = value;
    }

    /**
     * Gets the value of the hspHitFrame property.
     *
     * @return
     *     possible object is
     *     {@link HspHitFrame }
     *
     */
    public HspHitFrame getHspHitFrame() {
        return hspHitFrame;
    }

    /**
     * Sets the value of the hspHitFrame property.
     *
     * @param value
     *     allowed object is
     *     {@link HspHitFrame }
     *
     */
    public void setHspHitFrame(HspHitFrame value) {
        this.hspHitFrame = value;
    }

    /**
     * Gets the value of the hspIdentity property.
     *
     * @return
     *     possible object is
     *     {@link HspIdentity }
     *
     */
    public HspIdentity getHspIdentity() {
        return hspIdentity;
    }

    /**
     * Sets the value of the hspIdentity property.
     *
     * @param value
     *     allowed object is
     *     {@link HspIdentity }
     *
     */
    public void setHspIdentity(HspIdentity value) {
        this.hspIdentity = value;
    }

    /**
     * Gets the value of the hspPositive property.
     *
     * @return
     *     possible object is
     *     {@link HspPositive }
     *
     */
    public HspPositive getHspPositive() {
        return hspPositive;
    }

    /**
     * Sets the value of the hspPositive property.
     *
     * @param value
     *     allowed object is
     *     {@link HspPositive }
     *
     */
    public void setHspPositive(HspPositive value) {
        this.hspPositive = value;
    }

    /**
     * Gets the value of the hspAlignLen property.
     *
     * @return
     *     possible object is
     *     {@link HspAlignLen }
     *
     */
    public HspAlignLen getHspAlignLen() {
        return hspAlignLen;
    }

    /**
     * Sets the value of the hspAlignLen property.
     *
     * @param value
     *     allowed object is
     *     {@link HspAlignLen }
     *
     */
    public void setHspAlignLen(HspAlignLen value) {
        this.hspAlignLen = value;
    }

    /**
     * Gets the value of the hspQseq property.
     *
     * @return
     *     possible object is
     *     {@link HspQseq }
     *
     */
    public HspQseq getHspQseq() {
        return hspQseq;
    }

    /**
     * Sets the value of the hspQseq property.
     *
     * @param value
     *     allowed object is
     *     {@link HspQseq }
     *
     */
    public void setHspQseq(HspQseq value) {
        this.hspQseq = value;
    }

    /**
     * Gets the value of the hspHseq property.
     *
     * @return
     *     possible object is
     *     {@link HspHseq }
     *
     */
    public HspHseq getHspHseq() {
        return hspHseq;
    }

    /**
     * Sets the value of the hspHseq property.
     *
     * @param value
     *     allowed object is
     *     {@link HspHseq }
     *
     */
    public void setHspHseq(HspHseq value) {
        this.hspHseq = value;
    }

    /**
     * Gets the value of the hspMidline property.
     *
     * @return
     *     possible object is
     *     {@link HspMidline }
     *
     */
    public HspMidline getHspMidline() {
        return hspMidline;
    }

    /**
     * Sets the value of the hspMidline property.
     *
     * @param value
     *     allowed object is
     *     {@link HspMidline }
     *
     */
    public void setHspMidline(HspMidline value) {
        this.hspMidline = value;
    }

}


text:
package ubuntu

import (
	"github.com/megamsys/megdc/templates"
	"github.com/megamsys/urknall"
)

var ubuntuverticeremove *UbuntuMegamdRemove

func init() {
	ubuntuverticeremove = &UbuntuMegamdRemove{}
	templates.Register("UbuntuMegamdRemove", ubuntuverticeremove)
}

type UbuntuMegamdRemove struct{}

func (tpl *UbuntuMegamdRemove) Render(p urknall.Package) {
	p.AddTemplate("vertice", &UbuntuMegamdRemoveTemplate{})
}

func (tpl *UbuntuMegamdRemove) Options(t *templates.Template) {
}

func (tpl *UbuntuMegamdRemove) Run(target urknall.Target) error {
	return urknall.Run(target, &UbuntuMegamdRemove{})
}

type UbuntuMegamdRemoveTemplate struct{}

func (m *UbuntuMegamdRemoveTemplate) Render(pkg urknall.Package) {

	pkg.AddCommands("vertice",
		RemovePackage("vertice"),
		RemovePackages(""),
		PurgePackages("vertice"),
		Shell("dpkg --get-selections megam*"),
	)
	pkg.AddCommands("vertice-clean",
		Shell("rm -r /var/lib/urknall/vertice*"),
	)
}


text:
<?xml version="1.0" encoding="UTF-8"?>

<recipeml version="0.5">
  <recipe>
    <head>
      <title>"Milk" Pudding</title>
      <categories>
        <cat>None</cat></categories>
      <yield>4</yield></head>
    <ingredients>
      <ing>
        <amt>
          <qty>6</qty>
          <unit>cups</unit></amt>
        <item>Lowfat rice milk</item></ing>
      <ing>
        <amt>
          <qty>2</qty>
          <unit/></amt>
        <item>Bananas; pur'ed</item></ing>
      <ing>
        <amt>
          <qty>2</qty>
          <unit>teaspoons</unit></amt>
        <item>Apple butter</item></ing>
      <ing>
        <amt>
          <qty>2</qty>
          <unit>tablespoons</unit></amt>
        <item>Brown rice syrup</item></ing>
      <ing>
        <amt>
          <qty>1/2</qty>
          <unit>teaspoons</unit></amt>
        <item>Ground cardamom</item></ing></ingredients>
    <directions>
      <step>  http://www.vrg.org/recipes/vjindian.htm

  LOWFAT INDIAN CUISINE

  By Kumar Ramanathan

  Children will love this pudding.

  Boil rice milk and reduce the heat to low. Stir the milk occasionally.
  Simmer the milk for about 30 minutes until the milk is reduced by about 2/3
  of its volume. Add banana pur'e and apple butter. Add brown rice syrup and
  cardamom. Cool and keep in a refrigerator. Serve chilled.
  Hints:

  Add dried fruits and 1/4 teaspoon pistachios or almonds or cashews for
  variety (optional).
  Total calories per serving: 194

  Fat: 3 grams

  Posted to recipelu-digest by LSHW <shusky@erols.com> on Feb 17, 1998

</step></directions></recipe></recipeml>


text:
package pb138.service.services;

import com.google.common.collect.Lists;
import pb138.dal.entities.Sale;
import pb138.dal.repository.SaleRepository;
import pb138.dal.repository.validation.EntityValidationException;
import pb138.service.exceptions.ServiceException;
import pb138.service.filters.SaleFilter;

import java.util.List;

/**
 * Implements sale service
 *
 */
public class SaleServiceImpl implements SaleService{
    private SaleRepository saleRepository;

    /**
     * Constructor
     * @param saleRepository sale repository
     */
    public SaleServiceImpl(SaleRepository saleRepository) {
        this.saleRepository = saleRepository;
    }

    @Override
    public long create(Sale sale) throws ServiceException {
        try {
            saleRepository.create(sale);
            return sale.getId();
        } catch (EntityValidationException e) {
            throw new ServiceException("Problem with validating the sale", e);
        }
    }

    @Override
    public void delete(Sale sale) throws ServiceException {
        try {
            saleRepository.delete(sale);
        } catch (EntityValidationException e) {
            throw new ServiceException("Problem with validating the sale", e);
        }
    }

    @Override
    public void update(Sale sale) throws ServiceException {
        try {
            saleRepository.update(sale);
        } catch (EntityValidationException e) {
            throw new ServiceException("Problem with validating the sale", e);
        }
    }

    @Override
    public Sale getById(long id) {
        return saleRepository.getById(id);
    }

    @Override
    public List<Sale> getByFilter(SaleFilter filter) {
        Iterable<Sale> result = saleRepository.find(filter);
        return Lists.newArrayList(result);
    }
}


text:
<!DOCTYPE html>
<meta charset="utf-8">
<body>
Hello, world!


text:
<?php
/**
 * Automatically generated
 *
 * @author: Viskov Sergey
 * @date: 07.05.15
 */

namespace LTDBeget\apacheConfigurator\directives\available;

use LTDBeget\apacheConfigurator\ConfigurationFile;
use LTDBeget\apacheConfigurator\directives\Directive;

class CoreDumpDirectory extends Directive
{
    /**
     * Return link to full description of apache directive
     * @return String
     */
    public static function getApacheDocLink()
    {
        return Directive::$apacheSite."/docs/2.4/mod/mpm_common.html#coredumpdirectory";
    }

    /**
     * the source module which defines the directive
     * @return String
     */
    public static function getModule()
    {
        return " event, prefork, worker ";
    }

    /**
     * Return text description of apache directive
     * @return String
     */
    public static function getDescription()
    {
        return "Directory where Apache HTTP Server attempts to switch before dumping core";
    }

    /**
     * Return Apache directive Syntax
     * @return String
     */
    public static function getSyntax()
    {
        return 'CoreDumpDirectory directory';
    }

    /**
     * is this directive can include inner directives
     * @return boolean
     */
    public function isSection()
    {
        return false;
    }

    /**
     * Set allowed context of concrete directive
     */
    protected function setAllowedContext()
    {
        $this->allowedContext = [
            ConfigurationFile::SERVER_CONFIG,
        ];
    }

}


text:
/**
 * This class is generated by jOOQ
 */
package edu.kit.ipd.crowdcontrol.workerservice.database.model.tables;

import com.google.gson.JsonElement;

import edu.kit.ipd.crowdcontrol.workerservice.database.bindings.JSONGsonBinding;
import edu.kit.ipd.crowdcontrol.workerservice.database.model.Crowdcontrol;
import edu.kit.ipd.crowdcontrol.workerservice.database.model.Keys;
import edu.kit.ipd.crowdcontrol.workerservice.database.model.tables.records.WorkerRecord;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Generated;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Identity;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.UniqueKey;
import org.jooq.impl.TableImpl;

/**
 * This class is generated by jOOQ.
 */
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.3"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Worker extends TableImpl<WorkerRecord> {

	private static final long serialVersionUID = -477486378;

	/**
	 * The reference instance of crowdcontrol.Worker
	 */
	public static final Worker WORKER = new Worker();

	/**
	 * The class holding records for this type
	 */
	@Override
	public Class<WorkerRecord> getRecordType() {
		return WorkerRecord.class;
	}

	/**
	 * The column crowdcontrol.Worker.id_worker.
	 */
	public final TableField<WorkerRecord, Integer> ID_WORKER = createField("id_worker", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");

	/**
	 * The column crowdcontrol.Worker.platform_data.
	 */
	public final TableField<WorkerRecord, JsonElement> PLATFORM_DATA = createField("platform_data", org.jooq.impl.DefaultDataType.getDefaultDataType("json"), this, "", new JSONGsonBinding());

	/**
	 * The column crowdcontrol.Worker.platform.
	 */
	public final TableField<WorkerRecord, String> PLATFORM = createField("platform", org.jooq.impl.SQLDataType.VARCHAR.length(191).nullable(false), this, "");

	/**
	 * The column crowdcontrol.Worker.email.
	 */
	public final TableField<WorkerRecord, String> EMAIL = createField("email", org.jooq.impl.SQLDataType.VARCHAR.length(191), this, "");

	/**
	 * The column crowdcontrol.Worker.quality.
	 */
	public final TableField<WorkerRecord, Integer> QUALITY = createField("quality", org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this, "");

	/**
	 * The column crowdcontrol.Worker.identification.
	 */
	public final TableField<WorkerRecord, String> IDENTIFICATION = createField("identification", org.jooq.impl.SQLDataType.VARCHAR.length(191), this, "");

	/**
	 * Create a crowdcontrol.Worker table reference
	 */
	public Worker() {
		this("Worker", null);
	}

	/**
	 * Create an aliased crowdcontrol.Worker table reference
	 */
	public Worker(String alias) {
		this(alias, WORKER);
	}

	private Worker(String alias, Table<WorkerRecord> aliased) {
		this(alias, aliased, null);
	}

	private Worker(String alias, Table<WorkerRecord> aliased, Field<?>[] parameters) {
		super(alias, Crowdcontrol.CROWDCONTROL, aliased, parameters, "");
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Identity<WorkerRecord, Integer> getIdentity() {
		return Keys.IDENTITY_WORKER;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public UniqueKey<WorkerRecord> getPrimaryKey() {
		return Keys.KEY_WORKER_PRIMARY;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<UniqueKey<WorkerRecord>> getKeys() {
		return Arrays.<UniqueKey<WorkerRecord>>asList(Keys.KEY_WORKER_PRIMARY);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<ForeignKey<WorkerRecord, ?>> getReferences() {
		return Arrays.<ForeignKey<WorkerRecord, ?>>asList(Keys.WORKERORIGIN);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Worker as(String alias) {
		return new Worker(alias, this);
	}

	/**
	 * Rename this table
	 */
	public Worker rename(String name) {
		return new Worker(name, null);
	}
}


text:
package acceptance

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/http/httptest"
	"net/http/httputil"
	"os/exec"

	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("configure-authentication command", func() {
	It("configures the admin user account on OpsManager", func() {
		var auth struct {
			Setup struct {
				IdentityProvider       string `json:"identity_provider"`
				Username               string `json:"admin_user_name"`
				Password               string `json:"admin_password"`
				PasswordConfirmation   string `json:"admin_password_confirmation"`
				Passphrase             string `json:"decryption_passphrase"`
				PassphraseConfirmation string `json:"decryption_passphrase_confirmation"`
				EULAAccepted           string `json:"eula_accepted"`
			} `json:"setup"`
		}
		var ensureAvailabilityCallCount int

		server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			switch req.URL.Path {
			case "/api/v0/setup":
				err := json.NewDecoder(req.Body).Decode(&auth)
				Expect(err).NotTo(HaveOccurred())
			case "/login/ensure_availability":
				ensureAvailabilityCallCount++

				if ensureAvailabilityCallCount == 1 {
					w.Header().Set("Location", "/setup")
					w.WriteHeader(http.StatusFound)
					return
				}

				if ensureAvailabilityCallCount < 3 {
					w.WriteHeader(http.StatusOK)
					return
				}

				w.Header().Set("Location", "/auth/cloudfoundry")
				w.WriteHeader(http.StatusFound)
			default:
				out, err := httputil.DumpRequest(req, true)
				Expect(err).NotTo(HaveOccurred())
				Fail(fmt.Sprintf("unexpected request: %s", out))
			}
		}))

		command := exec.Command(pathToMain,
			"--target", server.URL,
			"--skip-ssl-validation",
			"configure-authentication",
			"--username", "username",
			"--password", "password",
			"--decryption-passphrase", "passphrase",
		)

		session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
		Expect(err).NotTo(HaveOccurred())

		Eventually(session, "5s").Should(gexec.Exit(0))

		Expect(auth.Setup.IdentityProvider).To(Equal("internal"))
		Expect(auth.Setup.Username).To(Equal("username"))
		Expect(auth.Setup.Password).To(Equal("password"))
		Expect(auth.Setup.PasswordConfirmation).To(Equal("password"))
		Expect(auth.Setup.Passphrase).To(Equal("passphrase"))
		Expect(auth.Setup.PassphraseConfirmation).To(Equal("passphrase"))
		Expect(auth.Setup.EULAAccepted).To(Equal("true"))

		Expect(ensureAvailabilityCallCount).To(Equal(3))

		Expect(session.Out).To(gbytes.Say("configuring internal userstore..."))
		Expect(session.Out).To(gbytes.Say("waiting for configuration to complete..."))
		Expect(session.Out).To(gbytes.Say("configuration complete"))
	})
})


text:
var bs = zsi.bs.ctrl;

$("#frm").submit(function(){ this.action = controller_url + "update"; });

$(document).ready(function(){
    displayRecords();
});

function displayRecords(){
    var rownum=0;
    zsi.json.loadGrid({
         table  : "#grid"
        ,url   : controller_url +  "getdata"
        ,td_body: [
            function(d){
                return     bs({name:"conv_id[]",type:"hidden",value: d.conv_id})
                        +  bs({name:"cb[]",type:"checkbox"});
            }
            ,function(d){ return bs({name:"from_unit_id[]",value: d.from_unit_id,type:"select"}); }
            ,function(d){ return bs({name:"conv_unit_id[]",value: d.conv_unit_id,type:"select"}); }
            ,function(d){ return bs({name:"conv_unit_qty[]",value: d.conv_unit_qty}); }

        ]
        ,onComplete : function(){
            displayBlankRows();
        }
    });
}

function displayBlankRows(){
    var inputCls = "form-control input-sm";
    zsi.json.loadGrid({
         table  : "#grid"
        ,td_body: [
            function(d){
                return     bs({name:"conv_id[]",type:"hidden"})
                        +  bs({name:"cb[]",type:"checkbox"});
            }
            ,function(d){ return bs({name:"from_unit_id[]",type:"select"}); }
            ,function(d){ return bs({name:"conv_unit_id[]",type:"select"}); }
            ,function(d){ return bs({name:"conv_unit_qty[]"}); }
        ]
    });

    $("select[name='p_from_unit_id[]']").dataBind( base_url + "select_options/code/units");
    $("select[name='p_conv_unit_id[]']").dataBind( base_url + "select_options/code/units");
}

function checkDelete() {
   var l_stmt=[], l_count;

   var data = zsi.table.getCheckBoxesValues("input[name='p_cb[]']:checked");
    for(var x=0;x<data.length; x++){
        l_stmt.push( { name:"p_del_id[]",value : data[x] }  );
    }
   if (l_stmt.length >0) {
      if(confirm("Are you sure you want to delete selected items?")) {
      $.post( controller_url + "delete" , l_stmt, function(d){
            window.location.reload();
         }).fail(function(d) {
            alert("Sorry, the curent transaction is not successfull.");
        });
      }
   }
return false;
}


text:
package org.apache.nifi.provenance;

import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.provenance.search.Query;
import org.apache.nifi.provenance.search.QuerySubmission;
import org.apache.nifi.provenance.search.SearchTerms;
import org.apache.nifi.util.NiFiProperties;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import static org.junit.Assert.assertEquals;

public class TestVolatileProvenanceRepository {

    private VolatileProvenanceRepository repo;

    @BeforeClass
    public static void setup() {
        System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, TestVolatileProvenanceRepository.class.getResource("/nifi.properties").getFile());
    }

    @Test
    public void testAddAndGet() throws IOException, InterruptedException {
        repo = new VolatileProvenanceRepository(NiFiProperties.createBasicNiFiProperties(null));

        final Map<String, String> attributes = new HashMap<>();
        attributes.put("abc", "xyz");
        attributes.put("xyz", "abc");
        attributes.put("uuid", UUID.randomUUID().toString());

        final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder();
        builder.setEventTime(System.currentTimeMillis());
        builder.setEventType(ProvenanceEventType.RECEIVE);
        builder.setTransitUri("nifi://unit-test");
        builder.fromFlowFile(createFlowFile(3L, 3000L, attributes));
        builder.setComponentId("1234");
        builder.setComponentType("dummy processor");

        for (int i = 0; i < 10; i++) {
            repo.registerEvent(builder.build());
        }

        final List<ProvenanceEventRecord> retrieved = repo.getEvents(0L, 12);

        assertEquals(10, retrieved.size());
        for (int i = 0; i < 10; i++) {
            final ProvenanceEventRecord recovered = retrieved.get(i);
            assertEquals(i, recovered.getEventId());
            assertEquals("nifi://unit-test", recovered.getTransitUri());
            assertEquals(ProvenanceEventType.RECEIVE, recovered.getEventType());
            assertEquals(attributes, recovered.getAttributes());
        }
    }

    @Test
    public void testIndexAndCompressOnRolloverAndSubsequentSearchAsync() throws InterruptedException {
        repo = new VolatileProvenanceRepository(NiFiProperties.createBasicNiFiProperties(null));

        final String uuid = "00000000-0000-0000-0000-000000000000";
        final Map<String, String> attributes = new HashMap<>();
        attributes.put("abc", "xyz");
        attributes.put("xyz", "abc");
        attributes.put("filename", "file-" + uuid);

        final ProvenanceEventBuilder builder = new StandardProvenanceEventRecord.Builder();
        builder.setEventTime(System.currentTimeMillis());
        builder.setEventType(ProvenanceEventType.RECEIVE);
        builder.setTransitUri("nifi://unit-test");
        builder.fromFlowFile(createFlowFile(3L, 3000L, attributes));
        builder.setComponentId("1234");
        builder.setComponentType("dummy processor");

        for (int i = 0; i < 10; i++) {
            attributes.put("uuid", "00000000-0000-0000-0000-00000000000" + i);
            builder.fromFlowFile(createFlowFile(i, 3000L, attributes));
            repo.registerEvent(builder.build());
        }

        final Query query = new Query(UUID.randomUUID().toString());
        query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.FlowFileUUID, "00000*"));
        query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.Filename, "file-*"));
        query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.ComponentID, "12?4"));
        query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.TransitURI, "nifi://*"));
        query.setMaxResults(100);

        final QuerySubmission submission = repo.submitQuery(query, createUser());
        while (!submission.getResult().isFinished()) {
            Thread.sleep(100L);
        }

        assertEquals(10, submission.getResult().getMatchingEvents().size());
        for (final ProvenanceEventRecord match : submission.getResult().getMatchingEvents()) {
            System.out.println(match);
        }
    }

    private FlowFile createFlowFile(final long id, final long fileSize, final Map<String, String> attributes) {
        final Map<String, String> attrCopy = new HashMap<>(attributes);

        return new FlowFile() {
            @Override
            public long getId() {
                return id;
            }

            @Override
            public long getEntryDate() {
                return System.currentTimeMillis();
            }

            @Override
            public long getLineageStartDate() {
                return System.currentTimeMillis();
            }

            @Override
            public boolean isPenalized() {
                return false;
            }

            @Override
            public String getAttribute(final String s) {
                return attrCopy.get(s);
            }

            @Override
            public long getSize() {
                return fileSize;
            }

            @Override
            public Map<String, String> getAttributes() {
                return attrCopy;
            }

            @Override
            public int compareTo(final FlowFile o) {
                return 0;
            }

            @Override
            public Long getLastQueueDate() {
                return System.currentTimeMillis();
            }

            @Override
            public long getLineageStartIndex() {
                return 0;
            }

            @Override
            public long getQueueDateIndex() {
                return 0;
            }
        };
    }

    private NiFiUser createUser() {
        return new NiFiUser() {
            @Override
            public String getIdentity() {
                return "unit-test";
            }

            @Override
            public Set<String> getGroups() {
                return Collections.EMPTY_SET;
            }

            @Override
            public Set<String> getIdentityProviderGroups() {
                return Collections.EMPTY_SET;
            }

            @Override
            public Set<String> getAllGroups() {
                return Collections.EMPTY_SET;
            }

            @Override
            public NiFiUser getChain() {
                return null;
            }

            @Override
            public boolean isAnonymous() {
                return false;
            }

            @Override
            public String getClientAddress() {
                return null;
            }
        };
    }
}


text:
<?php

namespace Pastum\Component\PAGI\Client\Result;

/**
 * A result decorator.
 */
abstract class ResultDecorator implements ResultInterface
{
    /**
     * Our decorated result.
     *
     * @var ResultInterface
     */
    private $result;

    /**
     * Constructor.
     *
     * @param ResultInterface $result Result to decorate
     */
    public function __construct(ResultInterface $result)
    {
        $this->result = $result;
    }

    /**
     * {@inheritdoc}
     */
    public function getOriginalLine()
    {
        return $this->result->getOriginalLine();
    }

    /**
     * {@inheritdoc}
     */
    public function getCode()
    {
        return $this->result->getCode();
    }

    /**
     * {@inheritdoc}
     */
    public function getResult()
    {
        return $this->result->getResult();
    }

    /**
     * {@inheritdoc}
     */
    public function isResult($value)
    {
        return $this->result->isResult($value);
    }

    /**
     * {@inheritdoc}
     */
    public function hasData()
    {
        return $this->result->hasData();
    }

    /**
     * {@inheritdoc}
     */
    public function getData()
    {
        return $this->result->getData();
    }

    /**
     * Standard procedure.
     *
     * @return string
     */
    public function __toString()
    {
        return $this->result->__toString();
    }
}


text:
using System;
using System.Reactive;

namespace ReactiveUI.Routing.Presentation
{
    /// <summary>
    /// Defines a presenter that is able to keep track of view states to help perform app suspension.
    /// </summary>
    public interface IAppPresenter : IPresenter
    {
        /// <summary>
        /// Gets the list of currently active views.
        /// </summary>
        ReactiveList<PresentedView> ActiveViews { get; }

        /// <summary>
        /// Loads the given presentation state into the app.
        /// </summary>
        /// <param name="state"></param>
        IObservable<Unit> LoadState(AppPresentationState state);
    }
}


text:
/*-------------------------------------------------------------------------
  Copyright 2008 Sandia Corporation.
  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
  the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/

/// \file vtkQtPolylineItem.h
/// \date February 6, 2008

#ifndef _vtkQtPolylineItem_h
#define _vtkQtPolylineItem_h

#include "vtkQtChartExport.h"
#include <QGraphicsItem>

#include "vtkQtChartGraphicsItemTypes.h" // needed for enum

class QPen;
class QPolygonF;

class VTKQTCHART_EXPORT vtkQtPolylineItem : public QGraphicsItem
{
public:
  enum {Type = vtkQtChart_PolylineItemType};

public:
  vtkQtPolylineItem(QGraphicsItem *parent=0, QGraphicsScene *scene=0);
  virtual ~vtkQtPolylineItem();

  const QPen& pen() const;
  void setPen(const QPen& p);

  void setPolyline(const QPolygonF& line);
  const QPolygonF& polyline() const;

  virtual int type() const {return vtkQtPolylineItem::Type;}
  virtual QRectF boundingRect() const;
  virtual QPainterPath shape() const;
  virtual bool contains(const QPointF &point) const;

  virtual void paint(QPainter* p, const QStyleOptionGraphicsItem* option,
      QWidget* widget);

private:
  bool doesLineCrossBox(const QPointF &point1, const QPointF &point2,
      const QRectF &box) const;

protected:
  QPen* Pen;
  QPolygonF* Polyline;
};

#endif


text:
/* 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 org.activiti5.engine.impl.transformer;

import java.util.Date;

import org.apache.commons.lang3.time.FastDateFormat;

/**
 * Transforms a {@link String} to a {@link Date}
 *
 * @author Esteban Robles Luna
 */
public class StringToDate extends AbstractTransformer {

  protected FastDateFormat format = FastDateFormat.getInstance("dd/MM/yyyy");

  @Override
  protected Object primTransform(Object anObject) throws Exception {
    return format.parse((String) anObject);
  }
}


text:
<<<<<<< HEAD
<<<<<<< HEAD
/**
@constructor
*/
function LibraryItem() {
	this.reserve = function() {
	}
}

/**
@constructor
*/
function Junkmail() {
	this.annoy = function() {
	}
}

/**
@inherits Junkmail.prototype.annoy as pester
@augments ThreeColumnPage
@augments LibraryItem
@constructor
*/
function NewsletterPage() {
	this.getHeadline = function() {
	}
}
=======
/**
@constructor
*/
function LibraryItem() {
	this.reserve = function() {
	}
}

/**
@constructor
*/
function Junkmail() {
	this.annoy = function() {
	}
}

/**
@inherits Junkmail.prototype.annoy as pester
@augments ThreeColumnPage
@augments LibraryItem
@constructor
*/
function NewsletterPage() {
	this.getHeadline = function() {
	}
}
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453
=======
/**
@constructor
*/
function LibraryItem() {
	this.reserve = function() {
	}
}

/**
@constructor
*/
function Junkmail() {
	this.annoy = function() {
	}
}

/**
@inherits Junkmail.prototype.annoy as pester
@augments ThreeColumnPage
@augments LibraryItem
@constructor
*/
function NewsletterPage() {
	this.getHeadline = function() {
	}
}
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453


text:
namespace csapex
{
class Response : public Streamable
{
public:
    Response(uint8_t id);

    static const uint8_t PACKET_TYPE_ID = 3;

    uint8_t getPacketType() const override;
    virtual std::string getType() const = 0;

    uint8_t getRequestID() const;

protected:
    uint8_t request_id_;
};

}  // namespace csapex

#endif  // RESPONSE_H