text:
<?php

namespace Twig\Node\Expression;

use Twig\Compiler;

class NameExpression extends AbstractExpression
{
    protected $specialVars = [
        '_self' => '$this',
        '_context' => '$context',
        '_charset' => '$this->env->getCharset()',
    ];

    public function __construct($name, $lineno)
    {
        parent::__construct([], ['name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false], $lineno);
    }

    public function compile(Compiler $compiler)
    {
        $name = $this->getAttribute('name');

        $compiler->addDebugInfo($this);

        if ($this->getAttribute('is_defined_test')) {
            if ($this->isSpecial()) {
                $compiler->repr(true);
            } elseif (\PHP_VERSION_ID >= 70400) {
                $compiler
                    ->raw('array_key_exists(')
                    ->string($name)
                    ->raw(', $context)')
                ;
            } else {
                $compiler
                    ->raw('(isset($context[')
                    ->string($name)
                    ->raw(']) || array_key_exists(')
                    ->string($name)
                    ->raw(', $context))')
                ;
            }
        } elseif ($this->isSpecial()) {
            $compiler->raw($this->specialVars[$name]);
        } elseif ($this->getAttribute('always_defined')) {
            $compiler
                ->raw('$context[')
                ->string($name)
                ->raw(']')
            ;
        } else {
            if (\PHP_VERSION_ID >= 70000) {
                // use PHP 7 null coalescing operator
                $compiler
                    ->raw('($context[')
                    ->string($name)
                    ->raw('] ?? ')
                ;

                if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
                    $compiler->raw('null)');
                } else {
                    $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
                }
            } elseif (\PHP_VERSION_ID >= 50400) {
                // PHP 5.4 ternary operator performance was optimized
                $compiler
                    ->raw('(isset($context[')
                    ->string($name)
                    ->raw(']) ? $context[')
                    ->string($name)
                    ->raw('] : ')
                ;

                if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
                    $compiler->raw('null)');
                } else {
                    $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
                }
            } else {
                $compiler
                    ->raw('$this->getContext($context, ')
                    ->string($name)
                ;

                if ($this->getAttribute('ignore_strict_check')) {
                    $compiler->raw(', true');
                }

                $compiler
                    ->raw(')')
                ;
            }
        }
    }

    public function isSpecial()
    {
        return isset($this->specialVars[$this->getAttribute('name')]);
    }

    public function isSimple()
    {
        return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
    }
}

class_alias('Twig\Node\Expression\NameExpression', 'Twig_Node_Expression_Name');


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

    Provides classes and interfaces for dealing with
    org.jdesktop.swingx.JXTipOfTheDay.

Related Documentation

redpajama_set_name: RedPajamaGithub


text:
package org.skyscreamer.nevado.jms;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.skyscreamer.nevado.jms.destination.*;
import org.skyscreamer.nevado.jms.message.*;
import org.skyscreamer.nevado.jms.util.MessageIdUtil;

import javax.jms.*;
import javax.jms.IllegalStateException;
import javax.jms.Queue;
import java.io.Serializable;
import java.util.*;

/**
 * Nevado implementation of the general JMS Session interface.
 *
 * @author Carter Page <carter@skyscreamer.org>
 */
public class NevadoSession implements Session {
    private final Log _log = LogFactory.getLog(getClass());

    protected boolean _closed = false;
    private final NevadoConnection _connection;
    private boolean _transacted;
    private int _acknowledgeMode;
    private Integer _overrideJMSDeliveryMode;
    private Long _overrideJMSTTL;
    private Integer _overrideJMSPriority;
    private MessageListener _messageListener;
    private final AsyncConsumerRunner _asyncConsumerRunner;
    private final MessageHolder _incomingStagedMessages = new MessageHolder(this);
    private final Map<NevadoDestination, List<NevadoMessage>> _outgoingTxMessages
            = new HashMap<NevadoDestination, List<NevadoMessage>>();
    private final Set<NevadoMessageConsumer> _consumers = new HashSet<NevadoMessageConsumer>();
    private final Set<NevadoMessageProducer> _producers = new HashSet<NevadoMessageProducer>();
    private boolean _TESTING_ONLY_break = false;

    protected NevadoSession(NevadoConnection connection, boolean transacted, int acknowledgeMode)
    {
        _connection = connection;
        _transacted = transacted;
        _acknowledgeMode = acknowledgeMode;
        _asyncConsumerRunner = new AsyncConsumerRunner(_connection);
    }

    @Override
    public NevadoBytesMessage createBytesMessage() throws JMSException
    {
        checkClosed();
        NevadoBytesMessage message = new NevadoBytesMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoMapMessage createMapMessage() throws JMSException
    {
        checkClosed();
        NevadoMapMessage message = new NevadoMapMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoMessage createMessage() throws JMSException
    {
        checkClosed();
        NevadoMessage message = new NevadoBlankMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoObjectMessage createObjectMessage() throws JMSException
    {
        checkClosed();
        NevadoObjectMessage message = new NevadoObjectMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoObjectMessage createObjectMessage(Serializable serializable) throws JMSException
    {
        checkClosed();
        NevadoObjectMessage message = createObjectMessage();
        message.setObject(serializable);
        return message;
    }

    @Override
    public NevadoStreamMessage createStreamMessage() throws JMSException
    {
        checkClosed();
        NevadoStreamMessage message = new NevadoStreamMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoTextMessage createTextMessage() throws JMSException
    {
        checkClosed();
        NevadoTextMessage message = new NevadoTextMessage();
        message.setNevadoSession(this);
        return message;
    }

    @Override
    public NevadoTextMessage createTextMessage(String text) throws JMSException
    {
        checkClosed();
        NevadoTextMessage message = createTextMessage();
        message.setText(text);
        return message;
    }

    @Override
    public boolean getTransacted() throws JMSException
    {
        return _transacted;
    }

    @Override
    public int getAcknowledgeMode() throws JMSException
    {
        return _acknowledgeMode;
    }

    // TODO - Think about how to handle a failure during commit (a break mid-way would fool atomicity)
    @Override
    public void commit() throws JMSException
    {
        checkClosed();
        if (!_transacted)
        {
            throw new IllegalStateException("Cannot commit an untransacted session");
        }
        for(NevadoDestination destination : _outgoingTxMessages.keySet())
        {
            List<NevadoMessage> outgoingMessages = _outgoingTxMessages.get(destination);
            _connection.getSQSConnector().sendMessages(destination, outgoingMessages);
        }
        _outgoingTxMessages.clear();
        _incomingStagedMessages.acknowledgeConsumedMessages();
    }

    @Override
    public void rollback() throws JMSException
    {
        checkClosed();
        if (!_transacted)
        {
            throw new IllegalStateException("Cannot rollback an untransacted session");
        }
        _outgoingTxMessages.clear();
        _incomingStagedMessages.reset();
    }

    @Override
    public synchronized void close() throws JMSException
    {
        if (!_closed)
        {
            stop();
            _incomingStagedMessages.close();
            for(NevadoMessageProducer producer : _producers)
            {
                producer.close();
            }
            for(NevadoMessageConsumer consumer : _consumers)
            {
                consumer.close();
            }
            _closed = true;
        }
    }

    @Override
    public void recover() throws JMSException
    {
        checkClosed();
        if (_acknowledgeMode == CLIENT_ACKNOWLEDGE) {
            _incomingStagedMessages.reset();
        }
    }

    @Override
    public MessageListener getMessageListener() throws JMSException
    {
        checkClosed();
        return null;  // TODO
    }

    @Override
    public void setMessageListener(MessageListener messageListener) throws JMSException
    {
        checkClosed();
        // TODO
    }

    @Override
    public void run()
    {
        // TODO
    }

    @Override
    public NevadoMessageProducer createProducer(Destination destination) throws JMSException
    {
        checkClosed();
        NevadoMessageProducer producer = new NevadoMessageProducer(this, NevadoDestination.getInstance(destination));
        _producers.add(producer);
        return producer;
    }

    @Override
    public NevadoMessageConsumer createConsumer(Destination destination) throws JMSException
    {
        return createConsumer(destination, null);
    }

    @Override
    public NevadoMessageConsumer createConsumer(Destination destination, String selector) throws JMSException
    {
        return createConsumer(destination, selector, false);
    }

    @Override
    public NevadoMessageConsumer createConsumer(Destination destination, String selector, boolean noLocal) throws JMSException
    {
        checkClosed();
        checkValidDestination(destination);
        NevadoMessageConsumer consumer = new NevadoMessageConsumer(this, NevadoDestination.getInstance(destination),
                selector, noLocal);
        _asyncConsumerRunner.addAsyncConsumer(consumer);
        _consumers.add(consumer);
        return consumer;
    }

    @Override
    public QueueBrowser createBrowser(Queue queue) throws JMSException
    {
        throw new UnsupportedOperationException("QueueBrowsers are currently not supported");
    }

    @Override
    public QueueBrowser createBrowser(Queue queue, String s) throws JMSException
    {
        throw new UnsupportedOperationException("QueueBrowsers are currently not supported");
    }

    @Override
    public NevadoTemporaryQueue createTemporaryQueue() throws JMSException
    {
        checkClosed();
        return _connection.createTemporaryQueue();
    }

    @Override
    public NevadoQueue createQueue(String name) throws JMSException
    {
        if (!NevadoProviderQueuePrefix.isValidQueueName(name))
        {
            throw new InvalidDestinationException("Queue name is not valid: " + name);
        }
        return createInternalQueue(name);
    }

    protected NevadoQueue createInternalQueue(String name) throws JMSException
    {
        checkClosed();
        return new NevadoQueue(name);
    }

    @Override
    public NevadoTopic createTopic(String name) throws JMSException
    {
        checkClosed();
        return new NevadoTopic(name);
    }

    @Override
    public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
    {
        checkClosed();
        return createDurableSubscriber(topic, name, null, false);
    }

    @Override
    public TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal) throws JMSException
    {
        checkClosed();
        checkValidDestination(topic);
        String queueName = getDurableEndpointQueueName(name);
        if (hasActiveDurableSubscriber(queueName))
        {
            throw new JMSException("There is already a durable subscriber with name " + name);
        }
        NevadoMessageConsumer consumer = new NevadoMessageConsumer(this, NevadoTopic.getInstance(topic), name, selector,
                noLocal);
        _asyncConsumerRunner.addAsyncConsumer(consumer);
        _consumers.add(consumer);
        return consumer;
    }

    @Override
    public NevadoTemporaryTopic createTemporaryTopic() throws JMSException
    {
        checkClosed();
        return _connection.createTemporaryTopic();
    }

    @Override
    public void unsubscribe(String name) throws JMSException
    {
        checkClosed();

        String queueName = getDurableEndpointQueueName(name);
        if (hasActiveDurableSubscriber(queueName))
        {
            throw new JMSException("Cannot unsubscribe durable topic-subscription '"
                    + name + "': There is an active TopicSubscriber");
        }

        // Check for unacknowledged/uncommitted messaages
        for (NevadoMessage message : _incomingStagedMessages.getConsumedMessages())
        {
            if (message.getJMSDestination() instanceof NevadoTopic)
            {
                NevadoTopic topic = (NevadoTopic)message.getJMSDestination();
                if (topic.isDurable() && queueName.equals(topic.getTopicEndpoint().getQueueName()))
                {
                    throw new JMSException("Cannot unsubscribe durable topic-subscription '"
                            + name + "': There is an unacknowledged or uncommitted message from the topic");
                }
            }
        }

        NevadoQueue durableQueue = new NevadoQueue(queueName);
        _connection.deleteQueue(durableQueue);
    }

    protected String getDurableEndpointQueueName(String durableSubscriptionName) {
        String queueName;
        if (_connection.getDurableSubcriptionPrefixOveride() != null)
        {
            queueName = _connection.getDurableSubcriptionPrefixOveride() + durableSubscriptionName;
        }
        else
        {
            queueName = NevadoProviderQueuePrefix.DURABLE_SUBSCRIPTION_PREFIX + durableSubscriptionName;
        }

        if (_connection.getClientID() != null)
        {
            queueName += "_client-" + _connection.getClientID() + "";
        }
        return queueName;
    }

    private boolean hasActiveDurableSubscriber(String queueName) throws JMSException {
        for(NevadoMessageConsumer consumer : _consumers)
        {
            if (consumer.isClosed() || consumer.getDestination() == null
                    || !(consumer.getDestination() instanceof NevadoTopic))
            {
                continue;
            }

            NevadoTopic topic = (NevadoTopic)consumer.getDestination();
            if (topic.isDurable() && queueName.equals(topic.getTopicEndpoint().getQueueName()))
            {
                return true;
            }
        }
        return false;
    }

    protected void sendMessage(NevadoDestination destination, NevadoMessage message) throws JMSException
    {
        if (destination == null)
        {
            throw new NullPointerException("Destination is null");
        }
        if (destination instanceof NevadoTopic)
        {
            message.setNevadoProperty(NevadoProperty.ConnectionID, _connection.getConnectionID());
        }
        if (_overrideJMSDeliveryMode != null) {
            message.setJMSDeliveryMode(_overrideJMSDeliveryMode);
        }
        if (_overrideJMSPriority != null) {
            message.setJMSPriority(_overrideJMSPriority);
        }
        if (_overrideJMSTTL != null) {
            message.setJMSExpiration(_overrideJMSTTL > 0 ? System.currentTimeMillis() + _overrideJMSTTL : 0);
        }
        message.onSend();
        if (_transacted)
        {
            if (!_outgoingTxMessages.containsKey(destination))
            {
                _outgoingTxMessages.put(destination, new ArrayList<NevadoMessage>());
            }
            // We aren't calling SQS yet, so we'll need to create our own message ID
            if (!message.isDisableMessageID())
            {
                message.setJMSMessageID(MessageIdUtil.createMessageId());
            }
            _outgoingTxMessages.get(destination).add(message.copyOf());
        }
        else
        {
            _connection.getSQSConnector().sendMessage(destination, message);
        }
    }

    protected NevadoMessage receiveMessage(NevadoDestination destination, long timeoutMs, boolean noLocal)
            throws JMSException, InterruptedException {
        testBreak();
        long startTime = System.currentTimeMillis();
        NevadoMessage message = null;
        boolean firstPass = true;
        long elapsed = 0;

        while(firstPass
                || (message == null
                    && (timeoutMs < 0 || (elapsed = System.currentTimeMillis() - startTime) < timeoutMs)))
        {
            firstPass = false;
            long adjustedTimeout = timeoutMs < 0 ? timeoutMs : (timeoutMs - elapsed);
            message = getUnfilteredMessage(destination, adjustedTimeout);

            // Filter expired messages
            if (message != null && message.getJMSExpiration() > 0
                    && System.currentTimeMillis() > message.getJMSExpiration())
            {
                message.expire();
                _log.info("Skipped expired message (" + message.getJMSMessageID() + ")");
                message = null;
            }

            // Filter noLocal matches
            if (message != null && destination instanceof NevadoTopic && noLocal && _connection.getConnectionID()
                    .equals(message.getNevadoProperty(NevadoProperty.ConnectionID)))
            {
                deleteMessage(message);
                message = null;
            }
        }

        // Set session and destination
        return message;
    }

    private NevadoMessage getUnfilteredMessage(NevadoDestination destination, long timeoutMs)
            throws JMSException, InterruptedException {
        NevadoMessage message = null;

        // First check the holder in case there was a recover or rollback
        if (_acknowledgeMode == CLIENT_ACKNOWLEDGE || _transacted)
        {
            message = _incomingStagedMessages.getNextMessage(destination);
        }

        // Else grab a message from the queue
        if (message == null)
        {
            message = _connection.getSQSConnector().receiveMessage(_connection, destination, timeoutMs);

            // Hold onto messages in a transaction or in CLIENT_ACKNOWLEDGE mode
            if (message != null && (_acknowledgeMode == CLIENT_ACKNOWLEDGE || _transacted))
            {
                _incomingStagedMessages.add(destination, message);
            }
        }

        // If we've got a message decorate it appropriately
        if (message != null) {
            message.setNevadoSession(this);
            message.setNevadoDestination(destination);
            int deliveryCount = message.propertyExists(JMSXProperty.JMSXDeliveryCount + "")
                ? (Integer)message.getJMSXProperty(JMSXProperty.JMSXDeliveryCount) : 1;
            deliveryCount += message.getLocalDeliveryCount();
            message.incrementLocalDeliveryCount();  // Do this after adding to redelivery count
            message.setJMSXProperty(JMSXProperty.JMSXDeliveryCount, deliveryCount);
            if (deliveryCount > 1) {
                message.setJMSRedelivered(true);
            }
        }

        return message;
    }

    public void acknowledgeMessage(NevadoMessage message) throws JMSException
    {
        checkClosed();
        if (this != message.getNevadoSession())
        {
            throw new IllegalStateException("Session should only acknowledge its own messages");
        }
        if (!_transacted) {
            if (_acknowledgeMode == CLIENT_ACKNOWLEDGE)
            {
                _incomingStagedMessages.acknowledgeConsumedMessages();
            }
            else
            {
                deleteMessage(message);
            }
        }
    }

    public void expireMessage(NevadoMessage message) throws JMSException
    {
        checkClosed();
        if (this != message.getNevadoSession())
        {
            throw new IllegalStateException("Session should only expire its own messages");
        }
        deleteMessage(message);
    }

    protected void deleteMessage(NevadoMessage... messages) throws JMSException
    {
        for(NevadoMessage message : messages)
        {
            _connection.getSQSConnector().deleteMessage(message);
        }
    }

    protected void resetMessage(NevadoMessage... messages)
    {
        for(NevadoMessage message : messages)
        {
            try {
                _connection.getSQSConnector().resetMessage(message);
            }
            catch(Throwable t) {
                // Not worth breaking over, since this is typically called in recovery or commit mode, and
                // it will eventually reset on its own.  Worst case is that messages will be delayed or mis-sequenced
                // in certain cases where the specification does not define specific behavior.
                _log.warn("Unable to reset message: " + message, t);
            }
        }
    }

    public void setOverrideJMSDeliveryMode(Integer jmsDeliveryMode)
    {
        _overrideJMSDeliveryMode = jmsDeliveryMode;
    }

    public void setOverrideJMSTTL(Long jmsTTL)
    {
        _overrideJMSTTL = jmsTTL;
    }

    public void setOverrideJMSPriority(Integer jmsPriority)
    {
        _overrideJMSPriority = jmsPriority;
    }

    public boolean isClosed() {
        return _closed;
    }

    protected NevadoConnection getConnection()
    {
        return _connection;
    }

    protected synchronized void start()
    {
        _asyncConsumerRunner.start();
    }

    protected synchronized void stop()
    {
        try {
            _asyncConsumerRunner.stop();
        } catch (InterruptedException e) {
            String exMessage = "Session threads may not have closed yet: " + e.getMessage();
            _log.warn(exMessage, e);
            Thread.currentThread().interrupt();
        }
    }

    protected void checkClosed() throws IllegalStateException
    {
        if (_closed)
        {
            throw new IllegalStateException("This session has been closed");
        }
    }

    private void checkValidDestination(Destination destination) throws JMSException
    {
        if (destination instanceof TemporaryQueue || destination instanceof TemporaryTopic)
        {
            if (!_connection.ownsTemporaryDestination(destination))
            {
                throw new InvalidDestinationException("Consumers for temporary destinations cannot be created " +
                        "outside of the connection where the destination was created.");
            }
        }
    }

    protected void setBreakSessionForTesting(boolean value)
    {
        _TESTING_ONLY_break = value;
    }

    private void testBreak() throws JMSException {
        if (_TESTING_ONLY_break)
        {
            throw new JMSException("SESSION DELIBERATELY THROWING EXCEPTION - EXPECTED BEHAVIOR - FOR TESTING MODE ONLY");
        }
    }

    AsyncConsumerRunner getAsyncConsumerRunner(){
      return _asyncConsumerRunner;
    }
}


text:
module.exports = function (sequelize, DataTypes) {

    let notificationModel = sequelize.define("notification", {
        notification: {
            type: DataTypes.STRING,
            validate: {
            }
        },
        notificationTime: {
            type: DataTypes.DATE,
            validate: {
            }
        },
        notificationType: {
            type: DataTypes.INTEGER,
            validate: {
            }
        }
    }, {
        classMethods: {
            associate: function (models) {
                let tenantIDOptions = {
                    foreignKey: 'tenantID'
                };
                notificationModel.belongsTo(models.tenant, tenantIDOptions);

                let configIDOptions = {
                    foreignKey: 'configID'
                };
                notificationModel.belongsTo(models.config, configIDOptions);
            }
        }
    });

    return notificationModel;
};


text:
package com.microsoft.azure.management.peering.v2019_08_01_preview.implementation;

import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.AzureServiceFuture;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.peering.v2019_08_01_preview.ErrorResponseException;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.Validator;
import java.io.IOException;
import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.HTTP;
import retrofit2.http.Path;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import retrofit2.http.Url;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
 * An instance of this class provides access to all the operations defined
 * in PeerAsns.
 */
public class PeerAsnsInner {
    /** The Retrofit service to perform REST calls. */
    private PeerAsnsService service;
    /** The service client containing this operation class. */
    private PeeringManagementClientImpl client;

    /**
     * Initializes an instance of PeerAsnsInner.
     *
     * @param retrofit the Retrofit instance built from a Retrofit Builder.
     * @param client the instance of the service client containing this operation class.
     */
    public PeerAsnsInner(Retrofit retrofit, PeeringManagementClientImpl client) {
        this.service = retrofit.create(PeerAsnsService.class);
        this.client = client;
    }

    /**
     * The interface defining all the services for PeerAsns to be
     * used by Retrofit to perform actually REST calls.
     */
    interface PeerAsnsService {
        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.peering.v2019_08_01_preview.PeerAsns get" })
        @GET("subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}")
        Observable<Response<ResponseBody>> get(@Path("peerAsnName") String peerAsnName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.peering.v2019_08_01_preview.PeerAsns createOrUpdate" })
        @PUT("subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}")
        Observable<Response<ResponseBody>> createOrUpdate(@Path("peerAsnName") String peerAsnName, @Path("subscriptionId") String subscriptionId, @Body PeerAsnInner peerAsn, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.peering.v2019_08_01_preview.PeerAsns delete" })
        @HTTP(path = "subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns/{peerAsnName}", method = "DELETE", hasBody = true)
        Observable<Response<ResponseBody>> delete(@Path("peerAsnName") String peerAsnName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.peering.v2019_08_01_preview.PeerAsns list" })
        @GET("subscriptions/{subscriptionId}/providers/Microsoft.Peering/peerAsns")
        Observable<Response<ResponseBody>> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.peering.v2019_08_01_preview.PeerAsns listNext" })
        @GET
        Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

    }

    /**
     * Gets the peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorResponseException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PeerAsnInner object if successful.
     */
    public PeerAsnInner get(String peerAsnName) {
        return getWithServiceResponseAsync(peerAsnName).toBlocking().single().body();
    }

    /**
     * Gets the peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<PeerAsnInner> getAsync(String peerAsnName, final ServiceCallback<PeerAsnInner> serviceCallback) {
        return ServiceFuture.fromResponse(getWithServiceResponseAsync(peerAsnName), serviceCallback);
    }

    /**
     * Gets the peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PeerAsnInner object
     */
    public Observable<PeerAsnInner> getAsync(String peerAsnName) {
        return getWithServiceResponseAsync(peerAsnName).map(new Func1<ServiceResponse<PeerAsnInner>, PeerAsnInner>() {
            @Override
            public PeerAsnInner call(ServiceResponse<PeerAsnInner> response) {
                return response.body();
            }
        });
    }

    /**
     * Gets the peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PeerAsnInner object
     */
    public Observable<ServiceResponse<PeerAsnInner>> getWithServiceResponseAsync(String peerAsnName) {
        if (peerAsnName == null) {
            throw new IllegalArgumentException("Parameter peerAsnName is required and cannot be null.");
        }
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.get(peerAsnName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<PeerAsnInner>>>() {
                @Override
                public Observable<ServiceResponse<PeerAsnInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PeerAsnInner> clientResponse = getDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PeerAsnInner> getDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PeerAsnInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PeerAsnInner>() { }.getType())
                .registerError(ErrorResponseException.class)
                .build(response);
    }

    /**
     * Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param peerAsn The peer ASN.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorResponseException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PeerAsnInner object if successful.
     */
    public PeerAsnInner createOrUpdate(String peerAsnName, PeerAsnInner peerAsn) {
        return createOrUpdateWithServiceResponseAsync(peerAsnName, peerAsn).toBlocking().single().body();
    }

    /**
     * Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param peerAsn The peer ASN.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<PeerAsnInner> createOrUpdateAsync(String peerAsnName, PeerAsnInner peerAsn, final ServiceCallback<PeerAsnInner> serviceCallback) {
        return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(peerAsnName, peerAsn), serviceCallback);
    }

    /**
     * Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param peerAsn The peer ASN.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PeerAsnInner object
     */
    public Observable<PeerAsnInner> createOrUpdateAsync(String peerAsnName, PeerAsnInner peerAsn) {
        return createOrUpdateWithServiceResponseAsync(peerAsnName, peerAsn).map(new Func1<ServiceResponse<PeerAsnInner>, PeerAsnInner>() {
            @Override
            public PeerAsnInner call(ServiceResponse<PeerAsnInner> response) {
                return response.body();
            }
        });
    }

    /**
     * Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param peerAsn The peer ASN.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PeerAsnInner object
     */
    public Observable<ServiceResponse<PeerAsnInner>> createOrUpdateWithServiceResponseAsync(String peerAsnName, PeerAsnInner peerAsn) {
        if (peerAsnName == null) {
            throw new IllegalArgumentException("Parameter peerAsnName is required and cannot be null.");
        }
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (peerAsn == null) {
            throw new IllegalArgumentException("Parameter peerAsn is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(peerAsn);
        return service.createOrUpdate(peerAsnName, this.client.subscriptionId(), peerAsn, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<PeerAsnInner>>>() {
                @Override
                public Observable<ServiceResponse<PeerAsnInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PeerAsnInner> clientResponse = createOrUpdateDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PeerAsnInner> createOrUpdateDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PeerAsnInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PeerAsnInner>() { }.getType())
                .register(201, new TypeToken<PeerAsnInner>() { }.getType())
                .registerError(ErrorResponseException.class)
                .build(response);
    }

    /**
     * Deletes an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorResponseException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     */
    public void delete(String peerAsnName) {
        deleteWithServiceResponseAsync(peerAsnName).toBlocking().single().body();
    }

    /**
     * Deletes an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<Void> deleteAsync(String peerAsnName, final ServiceCallback<Void> serviceCallback) {
        return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(peerAsnName), serviceCallback);
    }

    /**
     * Deletes an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<Void> deleteAsync(String peerAsnName) {
        return deleteWithServiceResponseAsync(peerAsnName).map(new Func1<ServiceResponse<Void>, Void>() {
            @Override
            public Void call(ServiceResponse<Void> response) {
                return response.body();
            }
        });
    }

    /**
     * Deletes an existing peer ASN with the specified name under the given subscription.
     *
     * @param peerAsnName The peer ASN name.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String peerAsnName) {
        if (peerAsnName == null) {
            throw new IllegalArgumentException("Parameter peerAsnName is required and cannot be null.");
        }
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.delete(peerAsnName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
                @Override
                public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<Void> clientResponse = deleteDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<Void> deleteDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<Void, ErrorResponseException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<Void>() { }.getType())
                .register(204, new TypeToken<Void>() { }.getType())
                .registerError(ErrorResponseException.class)
                .build(response);
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorResponseException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList<PeerAsnInner> object if successful.
     */
    public PagedList<PeerAsnInner> list() {
        ServiceResponse<Page<PeerAsnInner>> response = listSinglePageAsync().toBlocking().single();
        return new PagedList<PeerAsnInner>(response.body()) {
            @Override
            public Page<PeerAsnInner> nextPage(String nextPageLink) {
                return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<PeerAsnInner>> listAsync(final ListOperationCallback<PeerAsnInner> serviceCallback) {
        return AzureServiceFuture.fromPageResponse(
            listSinglePageAsync(),
            new Func1<String, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(String nextPageLink) {
                    return listNextSinglePageAsync(nextPageLink);
                }
            },
            serviceCallback);
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList<PeerAsnInner> object
     */
    public Observable<Page<PeerAsnInner>> listAsync() {
        return listWithServiceResponseAsync()
            .map(new Func1<ServiceResponse<Page<PeerAsnInner>>, Page<PeerAsnInner>>() {
                @Override
                public Page<PeerAsnInner> call(ServiceResponse<Page<PeerAsnInner>> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList<PeerAsnInner> object
     */
    public Observable<ServiceResponse<Page<PeerAsnInner>>> listWithServiceResponseAsync() {
        return listSinglePageAsync()
            .concatMap(new Func1<ServiceResponse<Page<PeerAsnInner>>, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(ServiceResponse<Page<PeerAsnInner>> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
                }
            });
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList<PeerAsnInner> object wrapped in {@link ServiceResponse} if successful.
     */
    public Observable<ServiceResponse<Page<PeerAsnInner>>> listSinglePageAsync() {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.list(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl<PeerAsnInner>> result = listDelegate(response);
                        return Observable.just(new ServiceResponse<Page<PeerAsnInner>>(result.body(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl<PeerAsnInner>> listDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PageImpl<PeerAsnInner>, ErrorResponseException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PageImpl<PeerAsnInner>>() { }.getType())
                .registerError(ErrorResponseException.class)
                .build(response);
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorResponseException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList<PeerAsnInner> object if successful.
     */
    public PagedList<PeerAsnInner> listNext(final String nextPageLink) {
        ServiceResponse<Page<PeerAsnInner>> response = listNextSinglePageAsync(nextPageLink).toBlocking().single();
        return new PagedList<PeerAsnInner>(response.body()) {
            @Override
            public Page<PeerAsnInner> nextPage(String nextPageLink) {
                return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param serviceFuture the ServiceFuture object tracking the Retrofit calls
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<PeerAsnInner>> listNextAsync(final String nextPageLink, final ServiceFuture<List<PeerAsnInner>> serviceFuture, final ListOperationCallback<PeerAsnInner> serviceCallback) {
        return AzureServiceFuture.fromPageResponse(
            listNextSinglePageAsync(nextPageLink),
            new Func1<String, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(String nextPageLink) {
                    return listNextSinglePageAsync(nextPageLink);
                }
            },
            serviceCallback);
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList<PeerAsnInner> object
     */
    public Observable<Page<PeerAsnInner>> listNextAsync(final String nextPageLink) {
        return listNextWithServiceResponseAsync(nextPageLink)
            .map(new Func1<ServiceResponse<Page<PeerAsnInner>>, Page<PeerAsnInner>>() {
                @Override
                public Page<PeerAsnInner> call(ServiceResponse<Page<PeerAsnInner>> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList<PeerAsnInner> object
     */
    public Observable<ServiceResponse<Page<PeerAsnInner>>> listNextWithServiceResponseAsync(final String nextPageLink) {
        return listNextSinglePageAsync(nextPageLink)
            .concatMap(new Func1<ServiceResponse<Page<PeerAsnInner>>, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(ServiceResponse<Page<PeerAsnInner>> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink));
                }
            });
    }

    /**
     * Lists all of the peer ASNs under the given subscription.
     *
    ServiceResponse<PageImpl<PeerAsnInner>> * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList<PeerAsnInner> object wrapped in {@link ServiceResponse} if successful.
     */
    public Observable<ServiceResponse<Page<PeerAsnInner>>> listNextSinglePageAsync(final String nextPageLink) {
        if (nextPageLink == null) {
            throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
        }
        String nextUrl = String.format("%s", nextPageLink);
        return service.listNext(nextUrl, this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<PeerAsnInner>>>>() {
                @Override
                public Observable<ServiceResponse<Page<PeerAsnInner>>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<PageImpl<PeerAsnInner>> result = listNextDelegate(response);
                        return Observable.just(new ServiceResponse<Page<PeerAsnInner>>(result.body(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse<PageImpl<PeerAsnInner>> listNextDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PageImpl<PeerAsnInner>, ErrorResponseException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PageImpl<PeerAsnInner>>() { }.getType())
                .registerError(ErrorResponseException.class)
                .build(response);
    }

}


text:
package chat;

import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.*;

class ListUtil {

    static void remove(List l, Object o) // Like l.remove(o), except uses identity comparison instead of .equals().
        //@ requires l.List(?es);
        //@ ensures l.List(remove(o, es));
    {
        for (int i = 0; i < l.size(); i++)
            //@ invariant l.List(es) &*& 0 <= i &*& i <= index_of(o, es);
        {
            if (l.get(i) == o) {
                l.remove(i);
                //@ remove_remove_nth(o, es);
                //@ index_of_nth(i, es);
                break;
            }
            //@ if (index_of(o, es) == i) { nth_index_of(o, es); }
        }
        //@ if (mem(o, es)) { mem_index_of(o, es); } else { mem_remove_eq(o, es); }
    }

}

/*@

predicate_ctor room_ctor(Room room)() = room(room);

predicate session(Session session;) =
    session.room |-> ?room &*& session.room_lock |-> ?roomLock &*& session.socket |-> ?socket &*& socket != null &*& socket.Socket(?i, ?o)
    &*& roomLock != null &*& [_]roomLock.Semaphore(room_ctor(room)) &*& i.InputStream() &*& o.OutputStream();

@*/

public final class Session implements Runnable {
    Room room;
    Semaphore room_lock;
    Socket socket;

    //@ predicate pre() = session(this);
    //@ predicate post() = true;

    public Session(Room room, Semaphore roomLock, Socket socket)
        /*@
        requires
            roomLock != null &*& [_]roomLock.Semaphore(room_ctor(room)) &*&
            socket != null &*& socket.Socket(?i, ?o) &*& i.InputStream() &*& o.OutputStream();
        @*/
        //@ ensures session(this);
    {
        this.room = room;
        this.room_lock = roomLock;
        this.socket = socket;
        //@ close session(this);
    }

    public void run_with_nick(Room room, Semaphore roomLock, BufferedReader reader, Writer writer, String nick) throws InterruptedException /*@ ensures true; @*/, IOException /*@ ensures true; @*/
        /*@
        requires
            roomLock != null &*& [_]roomLock.Semaphore(room_ctor(room)) &*& room != null &*& room(room) &*&
            reader != null &*& reader.Reader() &*&
            writer != null &*& writer.Writer();
        @*/
        //@ ensures [_]roomLock.Semaphore(room_ctor(room)) &*& reader.Reader() &*& writer.Writer();
    {
        Member member = null;
        String joinMessage = nick + " has joined the room.";
        room.broadcast_message(joinMessage);
        {
            //@ open room(room);
            member = new Member(nick, writer);
            List list = room.members;
            list.add(member);
            //@ open foreach<Member>(?members, @member);
            //@ close foreach(members, @member);
            //@ foreach_member_not_contains(members, member);
            //@ close foreach<Member>(nil, @member);
            //@ close foreach<Member>(cons<Member>(member, nil), @member);
            //@ foreach_append<Member>(members, cons<Member>(member, nil));
            //@ close room(room);
        }
        //@ close room_ctor(room)();
        //@ roomLock.makeHandle();
        roomLock.release();

        {
            String message = reader.readLine();
            while (message != null)
                //@ invariant reader.Reader() &*& [_]roomLock.Semaphore(room_ctor(room));
            {
                //@ roomLock.makeHandle();
                roomLock.acquire();
                //@ open room_ctor(room)();
                room.broadcast_message(nick + " says: " + message);
                //@ close room_ctor(room)();
                roomLock.release();
                message = reader.readLine();
            }
        }

        roomLock.acquire();
        //@ open room_ctor(room)();
        //@ open room(room);
        {
            List membersList = room.members;
            //@ assert foreach<Member>(?members, @member);
            //@ assume(mem<Member>(member, members)); // TODO: Eliminate using a ghost list.
            ListUtil.remove(membersList, member);
            //@ foreach_remove<Member>(member, members);
        }
        //@ close room(room);
        {
            room.broadcast_message(nick + " left the room.");
        }
        //@ close room_ctor(room)();
        roomLock.release();

        //@ open member(member);
    }

    public void run()
        //@ requires pre();
        //@ ensures post();
    {
        try {
            this.runCore();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void runCore() throws InterruptedException /*@ ensures true; @*/, IOException /*@ ensures true; @*/
        //@ requires pre();
        //@ ensures post();
    {
        //@ open pre();
        //@ open session(this);
        Room room = this.room;
        Semaphore roomLock = this.room_lock;
        Socket socket = this.socket;
        InputStream in = socket.getInputStream();
        InputStreamReader reader0 = new InputStreamReader(in);
        BufferedReader reader = new BufferedReader(reader0);
        OutputStream out = socket.getOutputStream();
        OutputStreamWriter writer0 = new OutputStreamWriter(out);
        BufferedWriter writer1 = new BufferedWriter(writer0);
        Writer writer = writer1;

        writer.write("Welcome to the chat room.\r\n");
        writer.write("The following members are present: ");

        //@ roomLock.makeHandle();
        roomLock.acquire();
        //@ open room_ctor(room)();
        //@ open room(room);
        {
            List membersList = room.members;
            //@ assert foreach<Member>(?members, @member);
            //@ membersList.listToIterable();
            Iterator iter = membersList.iterator();
            boolean hasNext = iter.hasNext();
            while (hasNext)
                /*@
                invariant
                    writer.Writer() &*&
                    iter.Iterator((seq_of_list)(members), _, ?i) &*& Iterable_iterating(membersList.getClass())(membersList, members, 1, iter)
                    &*& foreach(members, @member) &*& hasNext == (i < length(members)) &*& 0 <= i &*& i <= length(members);
                @*/
            {
                Object o = iter.next();
                Member member = (Member)o;
                //@ foreach_remove<Member>(member, members);
                //@ open member(member);
                writer.write(member.nick);
                writer.write("  ");
                //@ close member(member);
                //@ foreach_unremove<Member>(member, members);
                hasNext = iter.hasNext();
            }
            writer.write("\r\n");
            writer.flush();
            //@ membersList.destroyIterator();
            //@ membersList.iterableToList();
        }

        //@ close room(room);
        //@ close room_ctor(room)();
        roomLock.release();

        {
            boolean done = false;
            while (!done)
                //@ invariant writer.Writer() &*& reader.Reader() &*& [_]roomLock.Semaphore(room_ctor(room));
            {
                writer.write("Please enter your nick: \r\n");
                writer.flush();
                {
                    String nick = reader.readLine();
                    if (nick == null) {
                        done = true;
                    } else {
                        //@ roomLock.makeHandle();
                        roomLock.acquire();
                        //@ open room_ctor(room)();
                        {
                            if (room.has_member(nick)) {
                                //@ close room_ctor(room)();
                                roomLock.release();
                                writer.write("Error: This nick is already in use.\r\n");
                                writer.flush();
                            } else {
                                this.run_with_nick(room, roomLock, reader, writer, nick);
                                done = true;
                            }
                        }
                    }
                }
            }
        }

        //@ reader.destroy();
        //@ reader0.destroy();
        //@ writer1.destroy();
        //@ writer0.destroy();
        socket.close();
        //@ close post();
    }
}


text:
#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, ABI7_0_0RCTTextDecorationLineType) {
  ABI7_0_0RCTTextDecorationLineTypeNone = 0,
  ABI7_0_0RCTTextDecorationLineTypeUnderline,
  ABI7_0_0RCTTextDecorationLineTypeStrikethrough,
  ABI7_0_0RCTTextDecorationLineTypeUnderlineStrikethrough,
};


text:
alter table lastlike_course_demand modify course_nbr varchar2(40 char);

/*
 * Update database version
 */

update application_config set value='240' where name='tmtbl.db.version';

commit;


text:
package org.apache.jena.sdb.store;
//import java.lang.String.format

import org.apache.jena.graph.Node ;
import org.apache.jena.graph.Triple ;
import org.apache.jena.sdb.shared.SDBInternalError ;
import org.apache.jena.sdb.shared.SDBNotImplemented ;

/** Adapter from a tuple loader to a graph loader.*/
public class TupleGraphLoader implements StoreLoader
{
    private TupleLoader loader ;

    /** The loader must be for a triple table of some kind */
    public TupleGraphLoader(TupleLoader loader)
    {
        if ( loader.getTableDesc() == null )
            throw new SDBInternalError("No table description for loader") ;
        if ( loader.getTableDesc().getWidth() != 3 )
        {
            String x = String.format("Table description width is %d, not 3",
                                     loader.getTableDesc().getWidth()) ;
            throw new SDBInternalError(x) ;
        }
        this.loader = loader ;
    }

    @Override
    public void addTriple(Triple triple)
    { loader.load(row(triple)) ; }

    @Override
    public void deleteTriple(Triple triple)
    { loader.unload(row(triple)) ; }

    private static Node[] row(Triple triple)
    {
        Node[] nodes = new Node[3] ;
        nodes[0] = triple.getSubject() ;
        nodes[1] = triple.getPredicate() ;
        nodes[2] = triple.getObject() ;
        return nodes ;
    }

    @Override
    public void close()
    { loader.finish() ; }

    @Override
    public void startBulkUpdate()
    { loader.start() ; }

    @Override
    public void finishBulkUpdate()
    { loader.finish() ; }

    @Override
    public int getChunkSize()
    { throw new SDBNotImplemented("TupleGraphLoader.getChunkSize") ; }

    @Override
    public void setChunkSize(int chunks)
    { throw new SDBNotImplemented("TupleGraphLoader.setChunkSize") ; }

    @Override
    public boolean getUseThreading()
    { throw new SDBNotImplemented("TupleGraphLoader.getUseThreading") ; }

    @Override
    public void setUseThreading(boolean useThreading)
    { throw new SDBNotImplemented("TupleGraphLoader.setUseThreading") ; }

	@Override
    public void deleteAll()
	{ throw new SDBNotImplemented("TupleGraphLoader.deleteAll"); }
}


text:
-- check table joins for multiple range optimization

--+ holdcas on;

set system parameters 'dont_reuse_heap_file=yes';
drop table if exists t,s,u;

create table t (a int, b int, c int, d int, e int);

insert into t select * from
	(select 1 union select 2 union select 3) as t1,
	(select 1 union select 2) as t2,
	(select 1 union select 2) as t3,
	(select 1 union select 2) as t4,
	(select 1 union select 2 union select 3) as t5;

create index idx_a_b_cd_d on t (a, b, c desc, d);

create table s (a int, b int);

insert into s select * from
	(select 1 union select 2 union select 3) as t1,
	(select 1 union select 2) as t2;

create table u (a int, b int);

insert into u values (1,1),(1,3),(3,1),(3,3);

create index idx_u_a on u(a);

update statistics on all classes;

-- when the multi range optimized scan is the innermost, it may be invalidated only by "data filtering" joins
select /*+ recompile ordered */ * from s join t
	on s.a = t.a and s.b = t.b
	where t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;
select /*+ recompile ordered */ * from s join t
	on s.b = t.c
	where t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;
select /*+ recompile ordered */ * from s join t
	on s.a = t.e
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;

-- when the multi range optimized scan is not the innermost
-- the join conditions must be on attributes that are previous to the first sorting column in index
-- and that are in eq terms
select /*+ recompile ordered */ * from t join s
	on s.b = t.b
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;
select /*+ recompile ordered */ * from t join s
	on s.a = t.a
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;
select /*+ recompile ordered */ * from t join s
	on s.a = t.b and s.b = t.c
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;
select /*+ recompile ordered */ * from t join s
	on s.a = t.e
	where t.a in (1,3) and t.b = 1
	order by t.c, t.d desc limit 10;

-- hint NO_MULTI_RANGE_OPT
select /*+ recompile */ * from t join s
	on s.a = t.a
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;
select /*+ recompile NO_MULTI_RANGE_OPT */ * from t join s
	on s.a = t.a
	where t.a in (1,3) and t.b = 1
	order by t.c desc, d limit 10;

-- check multi range optimization for complex joins
-- multi range optimization sort plan should be "outer-most"
select /*+ recompile */ t.*, s.a as sa, s.b as sb, u.a as ua, u.b as ub from t,s,u
	where t.b = s.b and t.b = u.a and s.b = u.b and t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;

-- multi range optimization sort plan should be second
select /*+ recompile */ t.*, s.a as sa, s.b as sb, u.a as ua, u.b as ub from t,s,u
	where t.a = s.a and t.b = u.a and s.b = u.b and t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;

-- multi range optimization sort plan should be innermost
select /*+ recompile */ t.*, s.a as sa, s.b as sb, u.a as ua, u.b as ub from t,s,u
	where t.a = s.a and t.d = u.a and s.b = u.b and t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;

-- there is a join that acts as data filter... multi range optimization will not be used
select /*+ recompile */ t.*, s.a as sa, s.b as sb, u.a as ua, u.b as ub from t,s,u
	where t.e = s.a and t.b = u.a and s.b= u.b and t.a in (1,3) and t.b = 1
	order by t.c desc, t.d limit 10;

drop s,t,u;

set  system parameters 'dont_reuse_heap_file=no';
commit;
--+ holdcas off;


text:
static tBoolean
GPIOBaseValid(unsigned long ulPort)
{
    return((ulPort == GPIOA0_BASE) ||
           (ulPort == GPIOA1_BASE) ||
           (ulPort == GPIOA2_BASE) ||
           (ulPort == GPIOA3_BASE) ||
           (ulPort == GPIOA4_BASE));
}
#endif

//*****************************************************************************
//
//! \internal
//! Gets the GPIO interrupt number.
//!
//! \param ulPort is the base address of the GPIO port.
//!
//! Given a GPIO base address, returns the corresponding interrupt number.
//!
//! \return Returns a GPIO interrupt number, or -1 if \e ulPort is invalid.
//
//*****************************************************************************
static long
GPIOGetIntNumber(unsigned long ulPort)
{
    unsigned int ulInt;

    //
    // Determine the GPIO interrupt number for the given module.
    //
    switch(ulPort)
    {
        case GPIOA0_BASE:
        {
            ulInt = INT_GPIOA0;
            break;
        }

        case GPIOA1_BASE:
        {
            ulInt = INT_GPIOA1;
            break;
        }

        case GPIOA2_BASE:
        {
            ulInt = INT_GPIOA2;
            break;
        }

        case GPIOA3_BASE:
        {
            ulInt = INT_GPIOA3;
            break;
        }

        default:
        {
            return(-1);
        }
    }

    //
    // Return GPIO interrupt number.
    //
    return(ulInt);
}

//*****************************************************************************
//
//! Sets the direction and mode of the specified pin(s).
//!
//! \param ulPort is the base address of the GPIO port
//! \param ucPins is the bit-packed representation of the pin(s).
//! \param ulPinIO is the pin direction and/or mode.
//!
//! This function will set the specified pin(s) on the selected GPIO port
//! as either an input or output under software control, or it will set the
//! pin to be under hardware control.
//!
//! The parameter \e ulPinIO is an enumerated data type that can be one of
//! the following values:
//!
//! - \b GPIO_DIR_MODE_IN
//! - \b GPIO_DIR_MODE_OUT
//!
//! where \b GPIO_DIR_MODE_IN specifies that the pin will be programmed as
//! a software controlled input, \b GPIO_DIR_MODE_OUT specifies that the pin
//! will be programmed as a software controlled output.
//!
//! The pin(s) are specified using a bit-packed byte, where each bit that is
//! set identifies the pin to be accessed, and where bit 0 of the byte
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//!
//! \note GPIOPadConfigSet() must also be used to configure the corresponding
//! pad(s) in order for them to propagate the signal to/from the GPIO.
//!
//! \return None.
//
//*****************************************************************************
void
GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
               unsigned long ulPinIO)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));
    ASSERT((ulPinIO == GPIO_DIR_MODE_IN) || (ulPinIO == GPIO_DIR_MODE_OUT));

    //
    // Set the pin direction and mode.
    //
    HWREG(ulPort + GPIO_O_GPIO_DIR) = ((ulPinIO & 1) ?
                                  (HWREG(ulPort + GPIO_O_GPIO_DIR) | ucPins) :
                                  (HWREG(ulPort + GPIO_O_GPIO_DIR) & ~(ucPins)));
}

//*****************************************************************************
//
//! Gets the direction and mode of a pin.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ucPin is the pin number.
//!
//! This function gets the direction and control mode for a specified pin on
//! the selected GPIO port.  The pin can be configured as either an input or
//! output under software control, or it can be under hardware control.  The
//! type of control and direction are returned as an enumerated data type.
//!
//! \return Returns one of the enumerated data types described for
//! GPIODirModeSet().
//
//*****************************************************************************
unsigned long
GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
{
    unsigned long ulDir;

    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));
    ASSERT(ucPin < 8);

    //
    // Convert from a pin number to a bit position.
    //
    ucPin = 1 << ucPin;

    //
    // Return the pin direction and mode.
    //
    ulDir = HWREG(ulPort + GPIO_O_GPIO_DIR);
    return(((ulDir & ucPin) ? 1 : 0));
}

//*****************************************************************************
//
//! Sets the interrupt type for the specified pin(s).
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ucPins is the bit-packed representation of the pin(s).
//! \param ulIntType specifies the type of interrupt trigger mechanism.
//!
//! This function sets up the various interrupt trigger mechanisms for the
//! specified pin(s) on the selected GPIO port.
//!
//! The parameter \e ulIntType is an enumerated data type that can be one of
//! the following values:
//!
//! - \b GPIO_FALLING_EDGE
//! - \b GPIO_RISING_EDGE
//! - \b GPIO_BOTH_EDGES
//! - \b GPIO_LOW_LEVEL
//! - \b GPIO_HIGH_LEVEL
//!
//! The pin(s) are specified using a bit-packed byte, where each bit that is
//! set identifies the pin to be accessed, and where bit 0 of the byte
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//!
//! \note In order to avoid any spurious interrupts, the user must
//! ensure that the GPIO inputs remain stable for the duration of
//! this function.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntTypeSet(unsigned long ulPort, unsigned char ucPins,
               unsigned long ulIntType)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));
    ASSERT((ulIntType == GPIO_FALLING_EDGE) ||
           (ulIntType == GPIO_RISING_EDGE) || (ulIntType == GPIO_BOTH_EDGES) ||
           (ulIntType == GPIO_LOW_LEVEL) || (ulIntType == GPIO_HIGH_LEVEL));

    //
    // Set the pin interrupt type.
    //
    HWREG(ulPort + GPIO_O_GPIO_IBE) = ((ulIntType & 1) ?
                                  (HWREG(ulPort + GPIO_O_GPIO_IBE) | ucPins) :
                                  (HWREG(ulPort + GPIO_O_GPIO_IBE) & ~(ucPins)));
    HWREG(ulPort + GPIO_O_GPIO_IS) = ((ulIntType & 2) ?
                                 (HWREG(ulPort + GPIO_O_GPIO_IS) | ucPins) :
                                 (HWREG(ulPort + GPIO_O_GPIO_IS) & ~(ucPins)));
    HWREG(ulPort + GPIO_O_GPIO_IEV) = ((ulIntType & 4) ?
                                  (HWREG(ulPort + GPIO_O_GPIO_IEV) | ucPins) :
                                  (HWREG(ulPort + GPIO_O_GPIO_IEV) & ~(ucPins)));
}

//*****************************************************************************
//
//! Gets the interrupt type for a pin.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ucPin is the pin number.
//!
//! This function gets the interrupt type for a specified pin on the selected
//! GPIO port.  The pin can be configured as a falling edge, rising edge, or
//! both edge detected interrupt, or it can be configured as a low level or
//! high level detected interrupt.  The type of interrupt detection mechanism
//! is returned as an enumerated data type.
//!
//! \return Returns one of the enumerated data types described for
//! GPIOIntTypeSet().
//
//*****************************************************************************
unsigned long
GPIOIntTypeGet(unsigned long ulPort, unsigned char ucPin)
{
    unsigned long ulIBE, ulIS, ulIEV;

    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));
    ASSERT(ucPin < 8);

    //
    // Convert from a pin number to a bit position.
    //
    ucPin = 1 << ucPin;

    //
    // Return the pin interrupt type.
    //
    ulIBE = HWREG(ulPort + GPIO_O_GPIO_IBE);
    ulIS = HWREG(ulPort + GPIO_O_GPIO_IS);
    ulIEV = HWREG(ulPort + GPIO_O_GPIO_IEV);
    return(((ulIBE & ucPin) ? 1 : 0) | ((ulIS & ucPin) ? 2 : 0) |
           ((ulIEV & ucPin) ? 4 : 0));
}

//*****************************************************************************
//
//! Enables the specified GPIO interrupts.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ulIntFlags is the bit mask of the interrupt sources to enable.
//!
//! This function enables the indicated GPIO interrupt sources.  Only the
//! sources that are enabled can be reflected to the processor interrupt;
//! disabled sources have no effect on the processor.
//!
//! The \e ulIntFlags parameter is the logical OR of any of the following:
//!
//! - \b GPIO_INT_DMA   - interrupt due to GPIO triggered DMA Done
//! - \b GPIO_INT_PIN_0 - interrupt due to activity on Pin 0.
//! - \b GPIO_INT_PIN_1 - interrupt due to activity on Pin 1.
//! - \b GPIO_INT_PIN_2 - interrupt due to activity on Pin 2.
//! - \b GPIO_INT_PIN_3 - interrupt due to activity on Pin 3.
//! - \b GPIO_INT_PIN_4 - interrupt due to activity on Pin 4.
//! - \b GPIO_INT_PIN_5 - interrupt due to activity on Pin 5.
//! - \b GPIO_INT_PIN_6 - interrupt due to activity on Pin 6.
//! - \b GPIO_INT_PIN_7 - interrupt due to activity on Pin 7.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntEnable(unsigned long ulPort, unsigned long ulIntFlags)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Enable the interrupts.
    //
    HWREG(ulPort + GPIO_O_GPIO_IM) |= ulIntFlags;
}

//*****************************************************************************
//
//! Disables the specified GPIO interrupts.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ulIntFlags is the bit mask of the interrupt sources to disable.
//!
//! This function disables the indicated GPIO interrupt sources.  Only the
//! sources that are enabled can be reflected to the processor interrupt;
//! disabled sources have no effect on the processor.
//!
//! The \e ulIntFlags parameter is the logical OR of any of the following:
//!
//! - \b GPIO_INT_DMA   - interrupt due to GPIO triggered DMA Done
//! - \b GPIO_INT_PIN_0 - interrupt due to activity on Pin 0.
//! - \b GPIO_INT_PIN_1 - interrupt due to activity on Pin 1.
//! - \b GPIO_INT_PIN_2 - interrupt due to activity on Pin 2.
//! - \b GPIO_INT_PIN_3 - interrupt due to activity on Pin 3.
//! - \b GPIO_INT_PIN_4 - interrupt due to activity on Pin 4.
//! - \b GPIO_INT_PIN_5 - interrupt due to activity on Pin 5.
//! - \b GPIO_INT_PIN_6 - interrupt due to activity on Pin 6.
//! - \b GPIO_INT_PIN_7 - interrupt due to activity on Pin 7.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntDisable(unsigned long ulPort, unsigned long ulIntFlags)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Disable the interrupts.
    //
    HWREG(ulPort + GPIO_O_GPIO_IM) &= ~(ulIntFlags);
}

//*****************************************************************************
//
//! Gets interrupt status for the specified GPIO port.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param bMasked specifies whether masked or raw interrupt status is
//! returned.
//!
//! If \e bMasked is set as \b true, then the masked interrupt status is
//! returned; otherwise, the raw interrupt status will be returned.
//!
//! \return Returns the current interrupt status, enumerated as a bit field of
//! values described in GPIOIntEnable().
//
//*****************************************************************************
long
GPIOIntStatus(unsigned long ulPort, tBoolean bMasked)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Return the interrupt status.
    //
    if(bMasked)
    {
        return(HWREG(ulPort + GPIO_O_GPIO_MIS));
    }
    else
    {
        return(HWREG(ulPort + GPIO_O_GPIO_RIS));
    }
}

//*****************************************************************************
//
//! Clears the interrupt for the specified pin(s).
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ulIntFlags is a bit mask of the interrupt sources to be cleared.
//!
//! Clears the interrupt for the specified pin(s).
//!
//! The \e ulIntFlags parameter has the same definition as the \e ulIntFlags
//! parameter to GPIOIntEnable().
//!
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntClear(unsigned long ulPort, unsigned long ulIntFlags)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Clear the interrupts.
    //
    HWREG(ulPort + GPIO_O_GPIO_ICR) = ulIntFlags;
}

//*****************************************************************************
//
//! Registers an interrupt handler for a GPIO port.
//!
//! \param ulPort is the base address of the GPIO port.
//! \param pfnIntHandler is a pointer to the GPIO port interrupt handling
//! function.
//!
//! This function will ensure that the interrupt handler specified by
//! \e pfnIntHandler is called when an interrupt is detected from the selected
//! GPIO port.  This function will also enable the corresponding GPIO interrupt
//! in the interrupt controller; individual pin interrupts and interrupt
//! sources must be enabled with GPIOIntEnable().
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntRegister(unsigned long ulPort, void (*pfnIntHandler)(void))
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Get the interrupt number associated with the specified GPIO.
    //
    ulPort = GPIOGetIntNumber(ulPort);

    //
    // Register the interrupt handler.
    //
    IntRegister(ulPort, pfnIntHandler);

    //
    // Enable the GPIO interrupt.
    //
    IntEnable(ulPort);
}

//*****************************************************************************
//
//! Removes an interrupt handler for a GPIO port.
//!
//! \param ulPort is the base address of the GPIO port.
//!
//! This function will unregister the interrupt handler for the specified
//! GPIO port.  This function will also disable the corresponding
//! GPIO port interrupt in the interrupt controller; individual GPIO interrupts
//! and interrupt sources must be disabled with GPIOIntDisable().
//!
//! \sa IntRegister() for important information about registering interrupt
//! handlers.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOIntUnregister(unsigned long ulPort)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Get the interrupt number associated with the specified GPIO.
    //
    ulPort = GPIOGetIntNumber(ulPort);

    //
    // Disable the GPIO interrupt.
    //
    IntDisable(ulPort);

    //
    // Unregister the interrupt handler.
    //
    IntUnregister(ulPort);
}

//*****************************************************************************
//
//! Reads the values present of the specified pin(s).
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ucPins is the bit-packed representation of the pin(s).
//!
//! The values at the specified pin(s) are read, as specified by \e ucPins.
//! Values are returned for both input and output pin(s), and the value
//! for pin(s) that are not specified by \e ucPins are set to 0.
//!
//! The pin(s) are specified using a bit-packed byte, where each bit that is
//! set identifies the pin to be accessed, and where bit 0 of the byte
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//!
//! \return Returns a bit-packed byte providing the state of the specified
//! pin, where bit 0 of the byte represents GPIO port pin 0, bit 1 represents
//! GPIO port pin 1, and so on.  Any bit that is not specified by \e ucPins
//! is returned as a 0.  Bits 31:8 should be ignored.
//
//*****************************************************************************
long
GPIOPinRead(unsigned long ulPort, unsigned char ucPins)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Return the pin value(s).
    //
    return(HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))));
}

//*****************************************************************************
//
//! Writes a value to the specified pin(s).
//!
//! \param ulPort is the base address of the GPIO port.
//! \param ucPins is the bit-packed representation of the pin(s).
//! \param ucVal is the value to write to the pin(s).
//!
//! Writes the corresponding bit values to the output pin(s) specified by
//! \e ucPins.  Writing to a pin configured as an input pin has no effect.
//!
//! The pin(s) are specified using a bit-packed byte, where each bit that is
//! set identifies the pin to be accessed, and where bit 0 of the byte
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//!
//! \return None.
//
//*****************************************************************************
void
GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Write the pins.
    //
    HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))) = ucVal;
}

//*****************************************************************************
//
//! Enables a GPIO port as a trigger to start a DMA transaction.
//!
//! \param ulPort is the base address of the GPIO port.
//!
//! This function enables a GPIO port to be used as a trigger to start a uDMA
//! transaction. The GPIO pin will still generate interrupts if the interrupt is
//! enabled for the selected pin.
//!
//! \return None.
//
//*****************************************************************************
void
GPIODMATriggerEnable(unsigned long ulPort)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Set the pin as a DMA trigger.
    //
    if(ulPort == GPIOA0_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x1;
    }
    else if(ulPort == GPIOA1_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x2;
    }
    else if(ulPort == GPIOA2_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x4;
    }
    else if(ulPort == GPIOA3_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) |= 0x8;
    }
}

//*****************************************************************************
//
//! Disables a GPIO port as a trigger to start a DMA transaction.
//!
//! \param ulPort is the base address of the GPIO port.
//!
//! This function disables a GPIO port to be used as a trigger to start a uDMA
//! transaction.  This function can be used to disable this feature if it was
//! enabled via a call to GPIODMATriggerEnable().
//!
//! \return None.
//
//*****************************************************************************
void
GPIODMATriggerDisable(unsigned long ulPort)
{
    //
    // Check the arguments.
    //
    ASSERT(GPIOBaseValid(ulPort));

    //
    // Set the pin as a DMA trigger.
    //
    if(ulPort == GPIOA0_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x1;
    }
    else if(ulPort == GPIOA1_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x2;
    }
    else if(ulPort == GPIOA2_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x4;
    }
    else if(ulPort == GPIOA3_BASE)
    {
      HWREG(COMMON_REG_BASE + COMMON_REG_O_APPS_GPIO_TRIG_EN) &= ~0x8;
    }
}

//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************


text:
layout: post
title: Reviewing commands history in Vim with q-colon
tags:
  - protip
---

Reviewing commands history in Vim with q:

As with *shell*, in *Vim* you can go back in commands history list with Ctrl p. q: gives you more control, though.

When you press q:, a window with commands history pops up. The list allows you for:

- Searching for commands with regular *Vim* commands, like /
- Running the command under the cursor
- Modifying the command under the cursor and then running it

Next time before you jump straight to typing the command once again, consider using q:.
This protip has been written in 531 seconds


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

using Hyena;
using Hyena.Json;

namespace Lastfm
{
    public enum RequestType {
        Read,
        SessionRequest, // Needs the signature, but we don't have the session key yet
        AuthenticatedRead,
        Write
    }

    public enum ResponseFormat {
        Json,
        Raw
    }

    public class LastfmRequest
    {
        private const string API_ROOT = "http://ws.audioscrobbler.com/2.0/";

        private Dictionary<string, string> parameters = new Dictionary<string, string> ();
        private Stream response_stream;

        public LastfmRequest ()
        {}

        public LastfmRequest (string method) : this (method, RequestType.Read, ResponseFormat.Json)
        {}

        public LastfmRequest (string method, RequestType request_type, ResponseFormat response_format)
        {
            this.method = method;
            this.request_type = request_type;
            this.response_format = response_format;
        }

        private string method;
        public string Method { get; set; }

        private RequestType request_type;
        public RequestType RequestType { get; set; }

        private ResponseFormat response_format;
        public ResponseFormat ResponseFormat { get; set; }

        public void AddParameter (string param_name, string param_value)
        {
            parameters.Add (param_name, param_value);
        }

        public Stream GetResponseStream ()
        {
            return response_stream;
        }

        public void Send ()
        {
            if (method == null) {
                throw new InvalidOperationException ("The method name should be set");
            }

            if (response_format == ResponseFormat.Json) {
                AddParameter ("format", "json");
            } else if (response_format == ResponseFormat.Raw) {
                AddParameter ("raw", "true");
            }

            if (request_type == RequestType.Write) {
                response_stream = Post (API_ROOT, BuildPostData ());
            } else {
                response_stream = Get (BuildGetUrl ());
            }
        }

        public JsonObject GetResponseObject ()
        {
            Deserializer deserializer = new Deserializer (response_stream);
            object obj = deserializer.Deserialize ();
            JsonObject json_obj = obj as Hyena.Json.JsonObject;

            if (json_obj == null) {
                throw new ApplicationException ("Lastfm invalid response : not a JSON object");
            }

            return json_obj;
        }

        public StationError GetError ()
        {
            StationError error = StationError.None;

            string response;
            using (StreamReader sr = new StreamReader (response_stream)) {
                response = sr.ReadToEnd ();
            }

            if (response.Contains ("<lfm status=\"failed\">")) {
                // XML reply indicates an error
                Match match = Regex.Match (response, "<error code=\"(\\d+)\">");
                if (match.Success) {
                    error = (StationError) Int32.Parse (match.Value);
                    Log.WarningFormat ("Lastfm error {0}", error);
                } else {
                    error = StationError.Unknown;
                }
            }
            if (response_format == ResponseFormat.Json && response.Contains ("\"error\":")) {
                // JSON reply indicates an error
                Deserializer deserializer = new Deserializer (response);
                JsonObject json = deserializer.Deserialize () as JsonObject;
                if (json != null && json.ContainsKey ("error")) {
                    error = (StationError) json["error"];
                    Log.WarningFormat ("Lastfm error {0} : {1}", error, (string)json["message"]);
                }
            }

            return error;
        }

        private string BuildGetUrl ()
        {
            if (request_type == RequestType.AuthenticatedRead) {
                parameters.Add ("sk", LastfmCore.Account.SessionKey);
            }

            StringBuilder url = new StringBuilder (API_ROOT);
            url.AppendFormat ("?method={0}", method);
            url.AppendFormat ("&api_key={0}", LastfmCore.ApiKey);
            foreach (KeyValuePair<string, string> param in parameters) {
                url.AppendFormat ("&{0}={1}", param.Key, Uri.EscapeDataString (param.Value));
            }
            if (request_type == RequestType.AuthenticatedRead || request_type == RequestType.SessionRequest) {
                url.AppendFormat ("&api_sig={0}", GetSignature ());
            }

            return url.ToString ();
        }

        private string BuildPostData ()
        {
            parameters.Add ("sk", LastfmCore.Account.SessionKey);

            StringBuilder data = new StringBuilder ();
            data.AppendFormat ("method={0}", method);
            data.AppendFormat ("&api_key={0}", LastfmCore.ApiKey);
            foreach (KeyValuePair<string, string> param in parameters) {
                data.AppendFormat ("&{0}={1}", param.Key, Uri.EscapeDataString (param.Value));
            }
            data.AppendFormat ("&api_sig={0}", GetSignature ());

            return data.ToString ();
        }

        private string GetSignature ()
        {
            SortedDictionary<string, string> sorted_params = new SortedDictionary<string, string> (parameters);

            if (!sorted_params.ContainsKey ("api_key")) {
                sorted_params.Add ("api_key", LastfmCore.ApiKey);
            }
            if (!sorted_params.ContainsKey ("method")) {
                sorted_params.Add ("method", method);
            }
            StringBuilder signature = new StringBuilder ();
            foreach (KeyValuePair<string, string> parm in sorted_params) {
                if (parm.Key.Equals ("format")) {
                    continue;
                }
                signature.Append (parm.Key);
                signature.Append (parm.Value);
            }
            signature.Append (LastfmCore.ApiSecret);

            return Hyena.CryptoUtil.Md5Encode (signature.ToString (), Encoding.UTF8);
        }

#region HTTP helpers

        private Stream Get (string uri)
        {
            return Get (uri, null);
        }

        private Stream Get (string uri, string accept)
        {
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create (uri);
            if (accept != null) {
                request.Accept = accept;
            }
            request.UserAgent = LastfmCore.UserAgent;
            request.Timeout = 10000;
            request.KeepAlive = false;
            request.AllowAutoRedirect = true;

            HttpWebResponse response = (HttpWebResponse) request.GetResponse ();
            return response.GetResponseStream ();
        }

        private Stream Post (string uri, string data)
        {
            // Do not trust docs : it doesn't work if parameters are in the request body
            HttpWebRequest request = (HttpWebRequest) WebRequest.Create (String.Concat (uri, "?", data));
            request.UserAgent = LastfmCore.UserAgent;
            request.Timeout = 10000;
            request.Method = "POST";
            request.KeepAlive = false;
            request.ContentType = "application/x-www-form-urlencoded";

            HttpWebResponse response = null;
            try {
                response = (HttpWebResponse) request.GetResponse ();
            } catch (WebException e) {
                Log.DebugException (e);
                response = (HttpWebResponse)e.Response;
            }
            return response.GetResponseStream ();
        }

#endregion
    }
}