text:
package afc.ant.modular;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;

/**
 *
Resolves dependencies between {@link Module modules}, that is it defines an order
 * in which a given set of modules is to be processed so that each module is processed
 * after all modules it depends upon are processed. The order of processing of independent
 * modules is undefined.

 *
 *
The lifecycle of a {@code ParallelDependencyResolver} instance is the following:

 *

 *
{@link #init(Collection)} is invoked with a collection of root modules
 *      passed it. All direct and indirect dependee modules of these root modules
 *      are involved into the dependency resolution process

 *
the caller invokes {@link #getFreeModule()} to acquire the next module which
 *      does not have its dependee modules unprocessed

 *
the caller executes the module processing routine on the module acquired

 *
when the processing is finished the caller invokes {@link #moduleProcessed(Module)}
 *      to report to this {@code ParallelDependencyResolver} that this module is processed so that
 *      the modules that depend upon this module have one less unprocessed dependency

 *
the steps <tt>2-4</tt> are repeated until there are no modules unprocessed, that is
 *      until {@link #getFreeModule()} returns {@code null}

 *

 *
If there are cyclic dependencies between modules (so that the order of module processing
 * is undefined) then a {@link CyclicDependenciesDetectedException} is thrown at the
 * step <tt>1</tt>.

 *
 *
This dependency resolver supports multi-threaded {@link Module module} processing.
 * That is, at the moment multiple modules could be acquired for processing
 * (by different threads). An attempt to acquire a module if there are no modules with
 * no unprocessed dependencies will block the thread until such a module appears (other
 * threads must mark at least a single module as processed for this) or this
 * {@code ParallelDependencyResolver} is {@link #abort() aborted}.

 *
 *
As against {@link SerialDependencyResolver}, {@code ParallelDependencyResolver} is
 * much less efficient with respect to both processor and memory footprint which is
 * compensated by allowing for parallel processing or independent modules.

 *
 *
 *
{@code ParallelDependencyResolver} is thread-safe.

 *
 * @see SerialDependencyResolver
 * @see CallTargetForModules
 *
 * @author Dźmitry Laŭčuk
 */
public class ParallelDependencyResolver
{
    private ArrayList<Node> shortlist;
    private IdentityHashMap<Module, Node> modulesAcquired;
    private int remainingModuleCount;

    /**
     *
Initialises this {@code ParallelDependencyResolver} with a set of {@link Module modules}
     * to process. The resulting set includes these root modules and all their direct and indirect
     * {@link Module#getDependencies() dependee modules}. If this {@code ParallelDependencyResolver}
     * is already initialised with another set of modules then its state is reset so that the new
     * set of modules is being used.

     *
     * @param rootModules the modules that constitute with their direct and indirect dependee
     *      modules a set of modules. The order of processing of modules in this set is to be
     *      resolved by this {@code ParallelDependencyResolver}. This collection and all of
     *      its elements must be non-{@code null}.
     *
     * @throws CyclicDependenciesDetectedException if there are cyclic dependencies between
     *      the modules.
     * @throws NullPointerException if either rootModules or any of its elements
     *      is {@code null}.
     */
    public void init(final Collection<Module> rootModules) throws CyclicDependenciesDetectedException
    {
        if (rootModules == null) {
            throw new NullPointerException("rootModules");
        }
        for (final Module module : rootModules) {
            if (module == null) {
                throw new NullPointerException("rootModules contains null element.");
            }
        }
        synchronized (this) {
            final ArrayList<Node> newShortlist = new ArrayList<Node>();
            /* If buildNodeGraph() throws an exception then the state is not changed
               so that this ParallelDependencyResolver instance could be used as if
               this init() were not invoked. */
            remainingModuleCount = buildNodeGraph(rootModules, newShortlist);
            shortlist = newShortlist;
            modulesAcquired = new IdentityHashMap<Module, Node>();
        }
    }

    /**
     *
Returns a {@link Module module} that does not have {@link Module#getDependencies()
     * dependencies} unprocessed. If all modules are already processed then {@code null} is returned.
     * This {@code ParallelDependencyResolver} must be initialised before this function can be used.
     * Each module that is successfully processed must be released by invoking
     * {@link #moduleProcessed(Module)} with this module passed as a parameter. If this rule is not
     * followed then module processing could get stuck.

     *
     *
If this function is invoked when there are no modules with no unprocessed dependencies then
     * it blocks this thread waiting for a free module to appear. A different thread must report some
     * module previously acquired as processed for this function to return. Another way for this
     * function to return control is to invoke {@link #abort()}. In this case {@code null} is
     * returned.

     *
     * @return a module which has no unprocessed dependee modules, or {@code null} if all modules
     *      are already processed or this {@code ParallelDependencyResolver} is aborted.
     *
     * @throws IllegalStateException if this {@code ParallelDependencyResolver} is not initialised.
     * @throws IllegalStateException if this function is waiting for a free module and the current
     *      thread is interrupted. The interrupted status of this thread is not reset in
     *      this case.
     */
    public synchronized Module getFreeModule()
    {
        ensureInitialised();

        try {
            while (shortlist.isEmpty()) {
                if (remainingModuleCount <= 0) {
                    // Either all modules are processed or #abort() has been called.
                    return null;
                }
                wait();
            }
            final Node node = shortlist.remove(shortlist.size()-1);
            final Module module = node.module;
            modulesAcquired.put(module, node);
            --remainingModuleCount;

            return module;
        }
        catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
            throw new IllegalStateException();
        }
    }

    /**
     *
Marks a given {@link Module module} as processed, so that the modules that depend upon
     * this module have one less unprocessed dependency. The modules for which this module is
     * the last unprocessed dependency become available for processing and can be acquired by
     * invoking {@link #getFreeModule()}. All threads waiting for a free module are notified
     * by this function.

     *
     * @param module the module to be marked as processed. It must belong to the set of modules
     *      this {@code ParallelDependencyResolver} is initialised with. It must be acquired for
     *      processing by invoking {@code getFreeModule()} before it is released by this function.
     *      It must be non-{@code null}.
     *
     * @throws NullPointerException if module is {@code null}.
     * @throws IllegalArgumentException if the given module does not belong to the modules this
     *      {@code ParallelDependencyResolver} is initialised with or if this module is not
     *      acquired for processing by {@code getFreeModule()}. This does not happen if this
     *      {@code ParallelDependencyResolver} is aborted.
     * @throws IllegalStateException if this {@code ParallelDependencyResolver} is not initialised.
     */
    public synchronized void moduleProcessed(final Module module)
    {
        ensureInitialised();
        if (module == null) {
            throw new NullPointerException("module");
        }
        if (remainingModuleCount < 0) {
            // #abort() has been called.
            return;
        }
        final Node node = modulesAcquired.remove(module);
        if (node == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "The module ''{0}'' is not being processed.", module.getPath()));
        }
        for (int i = 0, n = node.dependencyOf.size(); i < n; ++i) {
            final Node depOf = node.dependencyOf.get(i);
            if (--depOf.dependencyCount == 0) {
                // all modules with no dependencies go to the shortlist
                shortlist.add(depOf);
            }
        }
        /* Notifying all threads after the module is removed and its dependencies are processed
           so that each thread waiting can either get a free module or finish execution. */
        notifyAll();
    }

    /**
     *
Aborts the module processing routine associated with this
     * {@code ParallelDependencyResolver} so that:

     *

     *
all threads waiting for a free module within {@link #getFreeModule()} are
     *      notified and {@code null} is returned by them to indicate that there are no
     *      more modules to process

     *
any subsequent invocation of {@code getFreeModule()} returns {@code null}

     *
any subsequent invocation of {@link #moduleProcessed(Module)} accepts any
     *      non-{@code null} module and just returns

     *

     *
It is supposed that all threads that perform parallel module processing
     * will finish it rapidly after {@code abort()} is invoked.

     *
     *
It is safe to invoke {@code abort()} for an already aborted
     * {@code ParallelDependencyResolver}. Successful {@link #init(Collection)
     * re-initialisation} of a {@code ParallelDependencyResolver} resets its
     * aborted status.
     */
    public synchronized void abort()
    {
        ensureInitialised();
        shortlist.clear();
        modulesAcquired.clear(); // Tracking the acquired modules does not make sense anymore.
        remainingModuleCount = -1; // Indicates that #abort() has been called.
        notifyAll();
    }

    private void ensureInitialised()
    {
        if (shortlist == null) {
            throw new IllegalStateException("Resolver is not initialised.");
        }
    }

    private static class Node
    {
        Node(final Module module)
        {
            this.module = module;
            dependencyCount = module.getDependencies().size();
            dependencyOf = new ArrayList<Node>();
        }

        final Module module;
        /* Knowing just dependency count is enough to detect the moment
           when this node has no dependencies remaining. */
        int dependencyCount;
        final ArrayList<Node> dependencyOf;
    }

    /*
     * Builds a DAG which nodes hold modules and arcs that represent inverted module dependencies.
     * The list of nodes returned via shortlist contains the starting vertices of the graph.
     * The modules that are bound to these vertices do not have dependencies on other modules
     * and are used as modules to start unwinding dependencies from.
     *
     * @returns the total number of modules.
     */
    private static int buildNodeGraph(final Collection<Module> rootModules, ArrayList<Node> shortlist)
            throws CyclicDependenciesDetectedException
    {
        final IdentityHashMap<Module, Node> registry = new IdentityHashMap<Module, Node>();
        final LinkedHashSet<Module> path = new LinkedHashSet<Module>();
        for (final Module module : rootModules) {
            addNodeDeep(module, shortlist, registry, path);
        }
        // the number of nodes in the graph
        return registry.size();
    }

    // TODO reduce the number of parameters in this function (see SerialDependencyResolver#addModuleDeep).
    private static Node addNodeDeep(final Module module, final ArrayList<Node> shortlist,
            final IdentityHashMap<Module, Node> registry, final LinkedHashSet<Module> path)
            throws CyclicDependenciesDetectedException
    {
        Node node = registry.get(module);
        if (node != null) {
            return node; // the module is already processed
        }

        if (path.add(module)) {
            node = new Node(module);

            final Module[] deps = module.dependencies;
            if (deps.length == 0) {
                shortlist.add(node);
            } else {
                // inverted dependencies are assigned
                for (int i = 0, n = deps.length; i < n; ++i) {
                    final Module dep = deps[i];
                    final Node depNode = addNodeDeep(dep, shortlist, registry, path);
                    depNode.dependencyOf.add(node);
                }
            }

            registry.put(module, node);
            path.remove(module);
            return node;
        }

        /* A loop is detected. It does not necessarily end with the starting node,
         * some leading path elements could be truncated.
         *
         * it.remove() has non-optional performance: just skipping to the module's
         * position and then copy the remaining modules to a list works faster.
         * However, this implementation is simpler and for an error case
         * the minor difference in performance does not matter.
         */
        final Iterator<Module> it = path.iterator();
        while (it.next() != module) {
            // skipping all leading modules that are outside the loop
            it.remove();
        }
        throw new CyclicDependenciesDetectedException(new ArrayList<Module>(path));
    }
}


text:
require 'jquery-rails'
require 'jquery-ui-rails'

module CtlBaseUi
  class Engine < ::Rails::Engine
    isolate_namespace CtlBaseUi
  end
end

redpajama_set_name: RedPajamaGithub


text:
package ru.atom.lecture07.server.dao;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;

import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

public class Database {
    private static final Logger log = LogManager.getLogger(Database.class);
    /**
     * SessionFactory abstracts
     */
    private static SessionFactory sessionFactory;

    public static Session session() {
        return sessionFactory.openSession();
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

    private Database() {
    }

    /**
     * This is preferred way to initialize SessionFactory
     */
    public static void setUp() throws Exception {
        // A SessionFactory is set up once for an application!
        final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
                .configure() // configures settings from hibernate.cfg.xml
                .build();
        try {
            sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
        } catch (Exception e) {
            // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
            // so destroy it manually.
            StandardServiceRegistryBuilder.destroy(registry);
            throw e;
        }
    }

    /**
     * HINT: You can use this method to execute function within transaction
     */
    public static void execTransactionalFunction(Function<Session, ?> f) {
        Transaction txn = null;
        try (Session session = Database.session()) {
            txn = session.beginTransaction();
            f.apply(session);
            txn.commit();
        } catch (RuntimeException e) {
            log.error("Transaction failed.", e);
            if (txn != null && txn.isActive()) {
                txn.rollback();
            }
        }
    }

    /**
     * HINT: You can use this method to execute consumer within transaction
     */
    public static void execTransactionalConsumer(Consumer<Session> c) {
        Transaction txn = null;
        try (Session session = Database.session()) {
            txn = session.beginTransaction();
            c.accept(session);
            txn.commit();
        } catch (RuntimeException e) {
            log.error("Transaction failed.", e);
            if (txn != null && txn.isActive()) {
                txn.rollback();
            }
        }
    }

    /**
     * HINT: You can use this method to make select within transaction
     */
    static <T> List<T> selectTransactional(Function<Session, List<T>> selectAction) {
        Transaction txn = null;
        List<T> ts = Collections.emptyList();
        try (Session session = Database.session()) {
            txn = session.beginTransaction();
            ts = selectAction.apply(session);
            txn.commit();
        } catch (RuntimeException e) {
            log.error("Transaction failed.", e);
            if (txn != null && txn.isActive()) {
                txn.rollback();
            }
        }

        return ts;
    }
}


text:
package com.connexta.arbitro.cond.cluster;

import com.connexta.arbitro.cond.ConditionSetFunction;
import com.connexta.arbitro.cond.Function;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Clusters all the functions supported by ConditionSetFunction.
 *
 * @since 1.2
 * @author Seth Proctor
 */
public class ConditionSetFunctionCluster implements FunctionCluster {

    public Set<Function> getSupportedFunctions() {
        Set<Function> set = new HashSet<Function>();
        Iterator it = ConditionSetFunction.getSupportedIdentifiers().iterator();

        while (it.hasNext())
            set.add(new ConditionSetFunction((String) (it.next())));

        return set;
    }

}


text:
package biweekly;

import static biweekly.ICalVersion.V2_0;
import static biweekly.util.StringUtils.NEWLINE;
import static biweekly.util.TestUtils.assertIntEquals;
import static biweekly.util.TestUtils.assertParseWarnings;
import static biweekly.util.TestUtils.assertRegex;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import biweekly.component.ICalComponent;
import biweekly.io.CannotParseException;
import biweekly.io.ParseContext;
import biweekly.io.ParseWarning;
import biweekly.io.WriteContext;
import biweekly.io.scribe.component.ICalComponentScribe;
import biweekly.io.scribe.property.ICalPropertyScribe;
import biweekly.io.xml.XCalElement;
import biweekly.parameter.ICalParameters;
import biweekly.property.ICalProperty;
import biweekly.property.ProductId;
import biweekly.util.XmlUtils;

/**
 * @author Michael Angstadt
 */
public class BiweeklyTest {
	@Rule
	public TemporaryFolder folder = new TemporaryFolder();

	@Test
	public void parse_first() {
		//@formatter:off
		String icalStr =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"PRODID:prodid\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();

		ICalendar ical = Biweekly.parse(icalStr).warnings(warnings).first();

		assertEquals(V2_0, ical.getVersion());
		assertEquals("prodid", ical.getProductId().getValue());

		assertEquals(1, warnings.size());
		assertParseWarnings(warnings.get(0));
	}

	@Test
	public void parse_all() {
		//@formatter:off
		String icalStr =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"PRODID:one\r\n" +
		"END:VCALENDAR\r\n" +
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"PRODID:two\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();

		List<ICalendar> icals = Biweekly.parse(icalStr).warnings(warnings).all();
		Iterator<ICalendar> it = icals.iterator();

		ICalendar ical = it.next();
		assertEquals(V2_0, ical.getVersion());
		assertEquals("one", ical.getProductId().getValue());

		ical = it.next();
		assertEquals(V2_0, ical.getVersion());
		assertEquals("two", ical.getProductId().getValue());

		assertEquals(2, warnings.size());
		assertParseWarnings(warnings.get(0));
		assertParseWarnings(warnings.get(1));

		assertFalse(it.hasNext());
	}

	@Test
	public void parse_register() {
		//@formatter:off
		String icalStr =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"PRODID:prodid\r\n" +
		"X-TEST:one\r\n" +
		"BEGIN:X-VPARTY\r\n" +
		"END:X-VPARTY\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on

		ICalendar ical = Biweekly.parse(icalStr).register(new TestPropertyMarshaller()).register(new PartyMarshaller()).first();

		assertIntEquals(1, ical.getProperty(TestProperty.class).getNumber());
		assertEquals(0, ical.getExperimentalProperties().size());
		assertNotNull(ical.getComponent(Party.class));
		assertEquals(0, ical.getExperimentalComponents().size());
	}

	@Test
	public void parse_caretDecoding() {
		//@formatter:off
		String icalStr =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"PRODID;X-TEST=the ^'best^' app:prodid\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on

		//defaults to true
		ICalendar ical = Biweekly.parse(icalStr).first();
		assertEquals("the \"best\" app", ical.getProductId().getParameter("X-TEST"));

		ical = Biweekly.parse(icalStr).caretDecoding(true).first();
		assertEquals("the \"best\" app", ical.getProductId().getParameter("X-TEST"));

		ical = Biweekly.parse(icalStr).caretDecoding(false).first();
		assertEquals("the ^'best^' app", ical.getProductId().getParameter("X-TEST"));
	}

	@Test
	public void parseXml_first() throws Throwable {
		//@formatter:off
		String xml =
		"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
		"<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<prodid><text>one</text></prodid>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<prodid><text>two</text></prodid>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		"</icalendar>";
		//@formatter:on
		List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();

		ICalendar ical = Biweekly.parseXml(xml).warnings(warnings).first();

		assertEquals(V2_0, ical.getVersion());
		assertEquals("one", ical.getProductId().getValue());

		assertEquals(1, warnings.size());
		assertParseWarnings(warnings.get(0));
	}

	@Test
	public void parseXml_all() throws Throwable {
		//@formatter:off
		String xml =
		"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
		"<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<prodid><text>one</text></prodid>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<prodid><text>two</text></prodid>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		"</icalendar>";
		//@formatter:on
		List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();

		List<ICalendar> icals = Biweekly.parseXml(xml).warnings(warnings).all();
		Iterator<ICalendar> it = icals.iterator();

		ICalendar ical = it.next();
		assertEquals(V2_0, ical.getVersion());
		assertEquals("one", ical.getProductId().getValue());

		ical = it.next();
		assertEquals(V2_0, ical.getVersion());
		assertEquals("two", ical.getProductId().getValue());

		assertEquals(2, warnings.size());
		assertParseWarnings(warnings.get(0));
		assertParseWarnings(warnings.get(1));

		assertFalse(it.hasNext());
	}

	@Test
	public void parseXml_register() throws SAXException {
		//@formatter:off
		String xml =
		"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
		"<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<prodid><text>prodid</text></prodid>" +
		      "<version><text>2.0</text></version>" +
		      "<x-test><text>one</text></x-test>" +
		    "</properties>" +
		    "<components>" +
			    "<x-vparty>" +
			    "</x-vparty>" +
		    "</components>" +
		  "</vcalendar>" +
		"</icalendar>";
		//@formatter:on

		ICalendar ical = Biweekly.parseXml(xml).register(new TestPropertyMarshaller()).register(new PartyMarshaller()).first();

		assertIntEquals(1, ical.getProperty(TestProperty.class).getNumber());
		assertEquals(0, ical.getExperimentalProperties().size());
		assertNotNull(ical.getComponent(Party.class));
		assertEquals(0, ical.getExperimentalComponents().size());
	}

	@Test(expected = RuntimeException.class)
	public void parseXml_invalid() throws Throwable {
		String xml = "invalid-xml";
		Biweekly.parseXml(xml).first();
	}

	@Test
	public void write_one() {
		ICalendar ical = new ICalendar();

		//@formatter:off
		String expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID:.*?\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on

		String actual = Biweekly.write(ical).go();

		assertRegex(expected, actual);
	}

	@Test
	public void write_multiple() {
		ICalendar ical1 = new ICalendar();

		ICalendar ical2 = new ICalendar();
		ical2.addExperimentalProperty("X-TEST1", "value1");

		ICalendar ical3 = new ICalendar();
		ical3.addExperimentalProperty("X-TEST2", "value2");

		//@formatter:off
		String expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID:.*?\r\n" +
		"END:VCALENDAR\r\n" +
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID:.*?\r\n" +
		"X-TEST1:value1\r\n" +
		"END:VCALENDAR\r\n" +
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID:.*?\r\n" +
		"X-TEST2:value2\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on

		String actual = Biweekly.write(ical1, ical2, ical3).go();

		assertRegex(expected, actual);
	}

	@Test
	public void write_caretEncoding() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.setProductId("prodid");
		ical.getProductId().addParameter("X-TEST", "the \"best\" app");

		//default is "false"
		//@formatter:off
		String expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID;X-TEST=the 'best' app:prodid\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		try {
			Biweekly.write(ical).go();
			fail("IllegalArgumentException expected");
		} catch (IllegalArgumentException e) {
			//expected
		}

		//@formatter:off
		expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID;X-TEST=the \\^'best\\^' app:prodid\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		String actual = Biweekly.write(ical).caretEncoding(true).go();
		assertRegex(expected, actual);

		//@formatter:off
		expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID;X-TEST=the 'best' app:prodid\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		try {
			Biweekly.write(ical).go();
			fail("IllegalArgumentException expected");
		} catch (IllegalArgumentException e) {
			//expected
		}
	}

	@Test
	public void write_foldLines() throws Exception {
		ICalendar ical = new ICalendar();
		ical.setProductId((String) null);
		ical.setUid((String) null);
		ical.setDescription("In the beginning God created the heavens and the earth. Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters.");

		//default should be "true"
		//@formatter:off
		String expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"DESCRIPTION:In the beginning God created the heavens and the earth. Now the \r\n earth was formless and empty\\, darkness was over the surface of the deep\\, \r\n and the Spirit of God was hovering over the waters.\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		String actual = Biweekly.write(ical).go();
		assertEquals(expected, actual);

		//@formatter:off
		expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"DESCRIPTION:In the beginning God created the heavens and the earth. Now the earth was formless and empty\\, darkness was over the surface of the deep\\, and the Spirit of God was hovering over the waters.\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		actual = Biweekly.write(ical).foldLines(false).go();
		assertEquals(expected, actual);

		//@formatter:off
		expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2.0\r\n" +
		"DESCRIPTION:In the beginning God created the heavens and the earth. Now the \r\n earth was formless and empty\\, darkness was over the surface of the deep\\, \r\n and the Spirit of God was hovering over the waters.\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on
		actual = Biweekly.write(ical).foldLines(true).go();
		assertEquals(expected, actual);
	}

	@Test
	public void write_register() {
		ICalendar ical = new ICalendar();
		ical.addProperty(new TestProperty(1));
		ical.addComponent(new Party());

		//@formatter:off
		String expected =
		"BEGIN:VCALENDAR\r\n" +
		"VERSION:2\\.0\r\n" +
		"PRODID:.*?\r\n" +
		"X-TEST:one\r\n" +
		"BEGIN:X-VPARTY\r\n" +
		"END:X-VPARTY\r\n" +
		"END:VCALENDAR\r\n";
		//@formatter:on

		String actual = Biweekly.write(ical).register(new TestPropertyMarshaller()).register(new PartyMarshaller()).go();

		assertRegex(expected, actual);
	}

	@Test
	public void write_file() throws Exception {
		ICalendar ical = new ICalendar();
		File file = folder.newFile();
		Biweekly.write(ical).go(file);
		assertTrue(file.length() > 0);
	}

	@Test
	public void writeXml() throws Throwable {
		ICalendar ical1 = new ICalendar();
		ical1.setProductId((String) null);

		ICalendar ical2 = new ICalendar();
		ical2.setProductId((String) null);
		ical2.addExperimentalProperty("X-TEST1", "value1");

		ICalendar ical3 = new ICalendar();
		ical3.setProductId((String) null);
		ical3.addExperimentalProperty("X-TEST2", "value2");

		//@formatter:off
		Document expected = XmlUtils.toDocument(
		"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
		"<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<version><text>2.0</text></version>" +
		      "<x-test1><unknown>value1</unknown></x-test1>" +
		    "</properties>" +
		  "</vcalendar>" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<version><text>2.0</text></version>" +
		      "<x-test2><unknown>value2</unknown></x-test2>" +
		    "</properties>" +
		  "</vcalendar>" +
		"</icalendar>"
		);
		//@formatter:on

		Document actual = Biweekly.writeXml(ical1, ical2, ical3).dom();

		assertXMLEqual(expected, actual);
	}

	@Test
	public void writeXml_version() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.getProperties().clear();

		//@formatter:off
		String expected =
		"<?xml version=\"1.1\" encoding=\"UTF-8\"?>" +
		"<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		  "<vcalendar>" +
		    "<properties>" +
		      "<version><text>2.0</text></version>" +
		    "</properties>" +
		  "</vcalendar>" +
		"</icalendar>";
		//@formatter:on

		String actual = Biweekly.writeXml(ical).xmlVersion("1.1").go();

		assertEquals(expected, actual);
	}

	@Test
	public void writeXml_indent() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.getProperties().clear();

		//@formatter:off
		String expected =
		"<?xml version=\"1.0\" encoding=\"UTF-8\"?><icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" + NEWLINE +
		"  <vcalendar>" + NEWLINE +
		"    <properties>" + NEWLINE +
		"      <version>" + NEWLINE +
		"        <text>2.0</text>" + NEWLINE +
		"      </version>" + NEWLINE +
		"    </properties>" + NEWLINE +
		"  </vcalendar>" + NEWLINE +
		"</icalendar>" + NEWLINE;
		//@formatter:on

		String actual = Biweekly.writeXml(ical).indent(2).go();

		assertEquals(expected, actual);
	}

	@Test
	public void writeXml_register() throws Throwable {
		ICalendar ical = new ICalendar();

		ProductId prodId = new ProductId("value");
		prodId.setParameter("X-TEST1", "value1");
		prodId.setParameter("X-TEST2", "value2");
		ical.setProductId(prodId);

		ical.addProperty(new TestProperty(1));
		ical.addComponent(new Party());

		//@formatter:off
		Document expected = XmlUtils.toDocument(
		 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
		 "<icalendar xmlns=\"urn:ietf:params:xml:ns:icalendar-2.0\">" +
		   "<vcalendar>" +
		     "<properties>" +
		     	"<version><text>2.0</text></version>" +
		     	"<prodid>" +
		     		"<parameters>" +
		     			"<x-test1><unknown>value1</unknown></x-test1>" +
		     			"<x-test2><text>value2</text></x-test2>" +
		     		"</parameters>" +
		     		"<text>value</text>" +
		     	"</prodid>" +
		     	"<x-test><unknown>one</unknown></x-test>" +
		     "</properties>" +
		     "<components>" +
		     	"<x-vparty/>" +
		     "</components>" +
		   "</vcalendar>" +
		 "</icalendar>"
		);
		//@formatter:on

		Document actual = Biweekly.writeXml(ical).register(new TestPropertyMarshaller()).register(new PartyMarshaller()).register("X-TEST2", ICalDataType.TEXT).dom();

		assertXMLEqual(expected, actual);
	}

	@Test
	public void writeJson_single() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.setProductId((String) null);

		//@formatter:off
		String expected =
		"[\"vcalendar\"," +
			"[" +
				"[\"version\",{},\"text\",\"2.0\"]" +
			"]," +
			"[" +
			"]" +
		"]";
		//@formatter:on

		String actual = Biweekly.writeJson(ical).go();

		assertEquals(expected, actual);
	}

	@Test
	public void writeJson_multiple() throws Throwable {
		ICalendar ical1 = new ICalendar();
		ical1.setProductId((String) null);

		ICalendar ical2 = new ICalendar();
		ical2.setProductId((String) null);
		ical2.addExperimentalProperty("X-TEST1", "value1");

		ICalendar ical3 = new ICalendar();
		ical3.setProductId((String) null);
		ical3.addExperimentalProperty("X-TEST2", "value2");

		//@formatter:off
		String expected =
		"[" +
			"[\"vcalendar\"," +
				"[" +
					"[\"version\",{},\"text\",\"2.0\"]" +
				"]," +
				"[" +
				"]" +
			"]," +
			"[\"vcalendar\"," +
				"[" +
					"[\"version\",{},\"text\",\"2.0\"]," +
					"[\"x-test1\",{},\"unknown\",\"value1\"]" +
				"]," +
				"[" +
				"]" +
			"]," +
			"[\"vcalendar\"," +
				"[" +
					"[\"version\",{},\"text\",\"2.0\"]," +
					"[\"x-test2\",{},\"unknown\",\"value2\"]" +
				"]," +
				"[" +
				"]" +
			"]" +
		"]";
		//@formatter:on

		String actual = Biweekly.writeJson(ical1, ical2, ical3).go();

		assertEquals(expected, actual);
	}

	@Test
	public void writeJson_indent() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.setProductId((String) null);

		//@formatter:off
		String expected =
		"[" + NEWLINE +
		"  \"vcalendar\"," + NEWLINE +
		"  [" + NEWLINE +
		"    [ \"version\", { }, \"text\", \"2.0\" ]" + NEWLINE +
		"  ]," + NEWLINE +
		"  [ ]" + NEWLINE +
		"]";
		//@formatter:on

		String actual = Biweekly.writeJson(ical).prettyPrint(true).go();

		assertEquals(expected, actual);
	}

	@Test
	public void writeJson_register() throws Throwable {
		ICalendar ical = new ICalendar();
		ical.setProductId((String) null);
		ical.addProperty(new TestProperty(1));
		ical.addComponent(new Party());

		//@formatter:off
		String expected =
		"[\"vcalendar\"," +
			"[" +
				"[\"version\",{},\"text\",\"2.0\"]," +
				"[\"x-test\",{},\"unknown\",\"one\"]" +
			"]," +
			"[" +
				"[\"x-vparty\"," +
					"[" +
					"]," +
					"[" +
					"]" +
				"]" +
			"]" +
		"]";
		//@formatter:on

		String actual = Biweekly.writeJson(ical).register(new TestPropertyMarshaller()).register(new PartyMarshaller()).go();

		assertEquals(expected, actual);
	}

	private class TestProperty extends ICalProperty {
		private Integer number;

		public TestProperty(Integer number) {
			this.number = number;
		}

		private Integer getNumber() {
			return number;
		}
	}

	private class TestPropertyMarshaller extends ICalPropertyScribe<TestProperty> {
		private TestPropertyMarshaller() {
			super(TestProperty.class, "X-TEST", null);
		}

		@Override
		protected String _writeText(TestProperty property, WriteContext context) {
			Integer value = property.getNumber();
			return (value == 1) ? "one" : value.toString();
		}

		@Override
		protected TestProperty _parseText(String value, ICalDataType dataType, ICalParameters parameters, ParseContext context) {
			Integer number;
			if (value.equals("one")) {
				number = 1;
			} else {
				throw new CannotParseException("wat");
			}

			TestProperty prop = new TestProperty(number);
			return prop;
		}

		@Override
		protected TestProperty _parseXml(XCalElement element, ICalParameters parameters, ParseContext context) {
			return _parseText(element.first(ICalDataType.TEXT), null, parameters, null);
		}
	}

	private class PartyMarshaller extends ICalComponentScribe<Party> {
		private PartyMarshaller() {
			super(Party.class, "X-VPARTY");
		}

		@Override
		protected Party _newInstance() {
			return new Party();
		}
	}

	private class Party extends ICalComponent {
		//empty
	}
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Uses of Class com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault</title>
<meta name="date" content="2014-09-23">
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Class
com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault

Packages that use WeatherClientDefault

Package
Description

com.survivingwithandroid.weather.lib.client.volley

Uses of WeatherClientDefault in com.survivingwithandroid.weather.lib.client.volley

Methods in com.survivingwithandroid.weather.lib.client.volley that return WeatherClientDefault

Modifier and Type
Method and Description

static WeatherClientDefault
WeatherClientDefault.getInstance()

Deprecated.

Release 1.4 repleaced by WeatherClient.ClientBuilder

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes


text:
package com.ecspringcloud.easycloud.common.utils;

/**
 * @author sunping
 * @create 2017/8/17
 */
public class Const {
    public static final String GATEWAY_HEAD_KEY="X_EC_GATEWAY";
    public static final String GATEWAY_HEAD_VALUE="X_EC_GATEWAY";
    public static final String CLIENT_HEADER_TOKEN_KEY="X_EC_TOKEN";
    public static final String GATEWAY_JWT_KEY="X_EC_JWT";
    public static final String CLIENT_TOKEN_KEY="token";
}


text:
* [Keywords](cx-keywords.html)
* [Operators](cx-operators.html)
* [Primitive Types](cx-ptypes.html)
* [Expressions](cx-expr.html)


text:
package com.bamboo.nova.constants;

/**
 * This interface contains constants for the nova project.
 *
 * @author ablackbu
 *
 */
public interface NovaConstants {

	String PDF_MIME_TYPE = "application/pdf";
	String PDF_EXTENSION = ".pdf";
	String CV = "CV";
	String PROPERTY_OF = "Sources are property of ";

	/**
	 * Config constants
	 */
	String UNABLE_TO_READ_CONFIG = "Unable to read the configuration file specified.";
	//String PATH_TO_CONFIG = "src/main/java/resources/user.properties";
	String PATH_TO_CONFIG = "user.properties";

	String FIRST_NAME_CONFIG = "user.firstName";
	String MIDDLE_NAME_CONFIG = "user.middleName";
	String LAST_NAME_CONFIG = "user.lastName";
	String INITIALS_CONFIG = "user.initials";
	String EMAIL_CONFIG = "user.email";
	String PHONE_CONFIG = "user.phone";

	String REFERENCE_FIRST_NAME_CONFIG = "reference.firstName";
	String REFERENCE_MIDDLE_NAME_CONFIG = "reference.middleName";
	String REFERENCE_LAST_NAME_CONFIG = "reference.lastName";
	String REFERENCE_INITIALS_CONFIG = "reference.initials";
	String REFERENCE_EMAIL_CONFIG = "reference.email";
	String REFERENCE_PHONE_CONFIG = "reference.phone";

	String EDU_INSTITUTION_NAME_CONFIG = "education.institutionName";
	String EDU_INSTITUTION_START_DATE_CONFIG = "education.startDate";
	String EDU_INSTITUTION_END_DATE_CONFIG = "education.endDate";
	String EDU_INSTITUTION_DESCRIPTION_CONFIG = "education.description";

	String WORK_INSTITUTION_NAME_CONFIG = "work.institutionName";
	String WORK_INSTITUTION_START_DATE_CONFIG = "work.startDate";
	String WORK_INSTITUTION_END_DATE_CONFIG = "work.endDate";
	String WORK_INSTITUTION_DESCRIPTION_CONFIG = "work.description";

	String SKILL_TITLE_CONFIG = "skill.title";
	String SKILL_DESCRIPTION_CONFIG = "skill.description";
	String SKILL_VERSION_CONFIG = "skill.version";

}


text:
/*
Theme Name:        gamesage
Theme URI: www.safetycat.org
Description: Sage is a WordPress starter theme. Contribute on GitHub
Version:            8.2.1
Author:             Elvina@safetycat
Author URI:         http://www.safetycat.co.uk;

License:            MIT License
License URI:        http://opensource.org/licenses/MIT
*/

table.widefat td.column-thumbnail{width: 120px;}
/*.gameloop {display:flex; flex-wrap:flex;}
.gameloop article{height:100%;}*/

.theloop{background: red;}
.theloop {display:flex; flex-wrap:flex;}
.theloop .card {height:100%;}


text:
//
//  PPViewController.m
//  PPToolkit
//
//  Created by Joachim Kret on 03.03.2013.
//  Copyright (c) 2013 Joachim Kret. All rights reserved.
//

#import "PPViewController.h"

#import <objc/runtime.h>
#import "PPAutorotation.h"

/**
 * Initially, I intended to make the iOS 6 autorotation methods for UIViewController globally, not just for the
 * the PPViewController subhierarchy. The obvious way to achieve this result is to swizzle the deprecated
 * -shouldAutorotateToInterfaceOrientation: at the UIViewController level. This cannot work, though: When a
 * view controller is displayed modally or as the root of an application on iOS 4 and 5, the UIViewController
 * -shouldAutorotateToInterfaceOrientation: method is not called if the view controller subclass which is
 * being rotated does not actually override the -shouldAutorotateToInterfaceOrientation: method. We therefore
 * cannot rely on swizzling since there is no way for the swizzling implementation to be called in those two cases.
 *
 * This is confirmed when disassembling one of the UIViewController methods which gets called when rotation
 * occurs for a modal or root view controller: -_isSupportedInterfaceOrientation. This method internally
 * calls -_doesOverrideLegacyShouldAutorotateMethod, which inhibits the call to -shouldAutorotateToInterfaceOrientation:
 * if the displayed view controller subclass does not override it.
 *
 * After thinking a little bit more, making iOS 6 autorotation methods available for PPViewController and not
 * for all of UIViewController class hierarchy is the right thing to do, though:
 *  - if the -shoudlAutorotateToInterfaceOrientation: is swizzled at the UIViewController level, we have no
 *    guarantee that it will get actually be called. Users namely often forget to call the super method
 *    somewhere in the class hierarchy. For PPViewController, failing to do so is documented to lead to
 *    undefined behavior. There is sadly no simple way to enforce this constraint, but at least this is
 *    documented
 *  - swizzling at the UIViewController level would alter the behavior of view controller subclasses which you
 *    do not control the implementation of (e.g. view controller classes stemming from a static library). In
 *    such cases, we would require a parameter to be available so that the trick making iOS 6 methods available
 *    on iOS 4 and 5 can be disabled
 */
@interface PPViewController ()
@end

#pragma mark -

@implementation PPViewController

@dynamic appearsFirstTime;

#pragma mark Object creation and destruction

- (id)init {
    NSString *nibName = nil;
    if ([[NSBundle mainBundle] pathForResource:NSStringFromClass([self class]) ofType:@"nib"]) {
        nibName = NSStringFromClass([self class]);
    }

    return [self initWithNibName:nibName bundle:nil];
}

- (id)initWithBundle:(NSBundle *)nibBundleOrNil {
    NSString *nibName = nil;
    if ([[NSBundle mainBundle] pathForResource:NSStringFromClass([self class]) ofType:@"nib"]) {
        nibName = NSStringFromClass([self class]);
    }

    return [self initWithNibName:nibName bundle:nibBundleOrNil];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        _PPViewControllerFlags.appearsFirstTime = YES;
    }
    return self;
}

- (void)dealloc {
    [self releaseViews];
}

- (void)releaseViews {
}

#pragma mark View

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    //reset flags
    _PPViewControllerFlags.appearsFirstTime = NO;
}

#pragma mark Accessors

- (void)setView:(UIView *)view {
    [super setView:view];

    if (! view) {
        [self releaseViews];
    }
}

- (BOOL)appearsFirstTime {
    return _PPViewControllerFlags.appearsFirstTime;
}

#pragma mark Orientation Management

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    // Implement the old deprecated method in terms of the iOS 6 autorotation methods
    return [self shouldAutorotate] && ([self supportedInterfaceOrientations] & (1 << toInterfaceOrientation));
}

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

@end


text:
import {
  AfterViewInit,
  Component, ElementRef, forwardRef, HostBinding, HostListener, Input, OnChanges, Renderer2,
  SimpleChanges
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

const ENTITIES_SELECT_VALUE_ACCESSOR = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => EntitiesSelectComponent),
  multi: true,
};

@Component({
  selector: 'ng-entities-select',
  templateUrl: './entities-select.component.html',
  styleUrls: ['./entities-select.component.css'],
  providers: [ENTITIES_SELECT_VALUE_ACCESSOR],
})
export class EntitiesSelectComponent implements ControlValueAccessor, AfterViewInit, OnChanges {
  @Input() placeholder: string;
  @Input() items: any[] = [];
  @Input() idProp: string;
  @Input() valueProp: string;
  @Input() textProp = 'name';
  @Input() adapter = (entity: any) => (entity && entity[this.textProp]);
  @HostBinding('attr.aria-disabled') @HostBinding('class.disabled') disabled = false;
  @HostBinding('class.dropdown') dropdownClass = true;
  @HostBinding('class.has-selected-value') hasSelectedValue = false;
  isOpened = false;
  adaptedItems: any[] = [];

  private selectedItem: any;
  private innerValue: any;
  private onChange = (_: any) => {};
  private onTouched = () => {};

  constructor(private renderer: Renderer2, private ref: ElementRef) {}

  ngOnChanges(changes: SimpleChanges) {
    if (changes.items && this.items) {
      this.adaptedItems = this.adaptItems(this.items);
      this.selectedItem = this.findItemByValue(this.value);
      this.hasSelectedValue = !!this.selectedItem;
    }
  }

  ngAfterViewInit() {
    this.renderer.setAttribute(this.ref.nativeElement, 'role', 'listbox');
    this.renderer.setAttribute(this.ref.nativeElement, 'tabindex', '0');
    if (this.placeholder) {
      this.renderer.setAttribute(this.ref.nativeElement, 'aria-label', this.placeholder);
    }
    this.renderer.setAttribute(this.ref.nativeElement, 'aria-multiselectable', 'false');
  }

  get selectedText() {
    return this.selectedItem ? this.selectedItem.label : '';
  }

  @HostListener('document:click', ['$event'])
  onDocumentClick(event: MouseEvent) {
    const ref = this.ref.nativeElement;
    const clickedRef = event.target;

    if (clickedRef !== ref && !ref.contains(clickedRef)) {
      this.close();
    }
  }

  close() {
    this.isOpened = false;
  }

  onSelectedValueClick() {
    if (this.disabled) {
      return;
    }
    this.isOpened = !this.isOpened;
  }

  onItemClick(value: any) {
    this.value = value;
    this.isOpened = false;
  }

  protected adaptItems(items: any[]): any[] {
    return items.map(item => ({
      label: this.adapter(item),
      value: this.valueProp ? item[this.valueProp] : item,
    }));
  }

  private findItemByValue(value: any) {
    for (const item of this.adaptedItems) {
      if (
        (value || value === 0)
        && (item.value || item.value === 0)
        && this.compareValues(value, item.value)
      ) {
        return item;
      }
    }
    return null;
  }

  private compareValues(aVal: any, bVal: any) {
    if (!this.idProp) {
      return (aVal === bVal);
    }
    return (aVal[this.idProp] === bVal[this.idProp]);
  }

  // --------------------- NgModel --------------------- //
  get value(): any {
    return this.innerValue;
  }

  set value(value: any) {
    if (this.innerValue !== value) {
      this.selectedItem = this.findItemByValue(value);
      this.hasSelectedValue = !!this.selectedItem;
      this.innerValue = value;
      this.onChange(value);
    }
  }

  writeValue(value: any) {
    if (this.innerValue !== value) {
      this.selectedItem = this.findItemByValue(value);
      this.hasSelectedValue = !!this.selectedItem;
      this.innerValue = value;
    }
  }

  registerOnChange(fn: (value: any) => void) {
    this.onChange = fn;
  }

  registerOnTouched(fn: () => void) {
    this.onTouched = fn;
  }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"

    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.xht.android.serverhelp.view.ClearEditText
        android:id="@+id/mClientEdit"
        android:layout_marginTop="5dip"
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:background="@drawable/green_stroke"
        android:drawableLeft="@drawable/sorlistview_search_bar_icon_normal"
        android:hint="请输入关键字"
        android:singleLine="true"
        android:textSize="15.0dip" />

    <ListView
        android:id="@+id/mClientList"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>
</LinearLayout>


text:
if [ -f "/usr/bin/yum" ]; then
    yum -y update
else
    apt-get update
    apt-get upgrade -y
fi

mkdir -pv /vagrant/dist
rm -rfv /var/cache/omnibus
cp -rfv /vagrant /var/cache/omnibus
cd /var/cache/omnibus

source /etc/profile.d/rvm.sh
rvm use --install 2.5.1
bundle config timeout 30
bundle install --verbose --binstubs --jobs `nproc --ignore=1` --retry=3

if [ -f "/var/cache/omnibus/local.sh" ]; then
    source /var/cache/omnibus/local.sh
    echo "populating cache..."
    bin/omnibus cache populate
fi

bin/omnibus build netuitive-agent --log-level=debug

cp -fv /var/cache/omnibus/pkg/* /vagrant/dist
cp -fv /var/cache/omnibus/pkg/* /vagrant/testing/dist


text:
//---------------------------------------------------------------------
// <copyright file="ServiceOperationDescriptorVerifier.cs" company="Microsoft">
//      Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
// </copyright>
//---------------------------------------------------------------------

namespace Microsoft.Test.Taupo.Astoria.ResponseVerification
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using Microsoft.Test.Taupo.Astoria.Contracts;
    using Microsoft.Test.Taupo.Astoria.Contracts.EntityModel;
    using Microsoft.Test.Taupo.Astoria.Contracts.Http;
    using Microsoft.Test.Taupo.Astoria.Contracts.OData;
    using Microsoft.Test.Taupo.Astoria.Contracts.ResponseVerification;
    using Microsoft.Test.Taupo.Common;
    using Microsoft.Test.Taupo.Contracts.EntityModel;
    using Microsoft.Test.Taupo.Contracts.Types;

    /// <summary>
    /// A class for response action/function verification.
    /// </summary>
    public class ServiceOperationDescriptorVerifier : ResponseVerifierBase, ISelectiveResponseVerifier
    {
        private EntityModelSchema model;

        /// <summary>
        /// Initializes a new instance of the ServiceOperationDescriptorVerifier class.
        /// </summary>
        /// <param name="model">The conceptual model of the service</param>
        public ServiceOperationDescriptorVerifier(EntityModelSchema model)
            : base()
        {
            ExceptionUtilities.CheckArgumentNotNull(model, "model");
            this.model = model;
        }

        /// <summary>
        /// Returns true if this verifier applies to responses for this kind of request
        /// </summary>
        /// <param name="request">The request that was issued</param>
        /// <returns>Whether or not this verifier applies to responses for this kind of request</returns>
        public bool Applies(ODataRequest request)
        {
            // Do not need to verify action/function links in metadata response.
            return !request.Uri.IsMetadata();
        }

        /// <summary>
        /// Return true if this verifier applies to the response
        /// </summary>
        /// <param name="response">The response that might need to be verified</param>
        /// <returns>Whether or not this verifier applies to the response</returns>
        public bool Applies(ODataResponse response)
        {
            return response.StatusCode != HttpStatusCode.NoContent;
        }

        /// <summary>
        /// Verifies that the actions/functions in the response are correct.
        /// </summary>
        /// <param name="request">The request that was sent</param>
        /// <param name="response">The response to verify</param>
        public override void Verify(ODataRequest request, ODataResponse response)
        {
            base.Verify(request, response);
            this.VerifyPayloadElementOperations(response.RootElement, request, response, true);
        }

        /// <summary>
        /// Checks for a name collision between an action's name and a property's name
        /// </summary>
        /// <param name="function">The function to check for name property collision</param>
        /// <param name="bindingEntityDataType">The bindingEntityDataType is the entity to check against</param>
        /// <param name="actualInstanceEntityType">the entity type of the instance of the entity</param>
        /// <returns>a string representing the entity container's name</returns>
        public string BuildExpectedContainerName(Function function, EntityDataType bindingEntityDataType, EntityType actualInstanceEntityType)
        {
            string containerName = string.Empty;

            // check for open entity type on the function definition or on the actual entity itself
            if (bindingEntityDataType.Definition.IsOpen || actualInstanceEntityType.IsOpen)
            {
                containerName = string.Concat(function.Model.GetDefaultEntityContainer().Name, ".");
            }

            var foundNameCollision = bindingEntityDataType.Definition.AllProperties.Where(a => a.Name.Equals(function.Name)).FirstOrDefault();
            if (foundNameCollision != null && !bindingEntityDataType.Definition.IsOpen)
            {
                containerName = string.Concat(function.Model.GetDefaultEntityContainer().Name, ".");
            }

            return containerName;
        }

        /// <summary>
        /// Checks if the expected action descriptor in the case where the entity type is open and the property is open
        /// </summary>
        /// <param name="function">The function to check for name property collision</param>
        /// <param name="bindingEntityDataType">The bindingEntityDataType is the entity to check against</param>
        /// <param name="expectActionDescriptor">current value of the expected behavior</param>
        /// <returns>true is the action descriptor is expected in response payload</returns>
        public bool VerifyIfOpenType(Function function, EntityDataType bindingEntityDataType, bool expectActionDescriptor)
        {
            if ((expectActionDescriptor == false) && bindingEntityDataType.Definition.IsOpen)
            {
                // in open types, an action with a name collision will be returned in metadata
                var possibleNameCollision = bindingEntityDataType.Definition.AllProperties.Where(a => a.Name.Equals(function.Name)).FirstOrDefault();
                if (possibleNameCollision != null)
                {
                    // if property is not declared, then action descriptor will be present
                    expectActionDescriptor = !possibleNameCollision.IsMetadataDeclaredProperty();
                }
            }

            return expectActionDescriptor;
        }

        private static string ExtractSimpleActionName(string fullName)
        {
            string actionName = string.Empty;
            foreach (var actionChar in fullName)
            {
                if (actionChar == '.')
                {
                    actionName = string.Empty;
                }
                else
                {
                    actionName = actionName + actionChar;
                }
            }

            return actionName;
        }

        private static bool IsJsonLightResponse(string acceptHeaderValue)
        {
            return acceptHeaderValue.Contains(MimeTypes.ApplicationJson) && !acceptHeaderValue.Contains("verbose");
        }

        /// <summary>
        /// Verifies that any action/function in the payload element are correct.
        /// </summary>
        /// <param name="payloadElement">The payload element to verify</param>
        /// <param name="request">The request that was sent</param>
        /// <param name="response">The response to verify</param>
        /// <param name="isTopLevelElement">Whether the payloadElement is the top level of response</param>
        private void VerifyPayloadElementOperations(ODataPayloadElement payloadElement, ODataRequest request, ODataResponse response, bool isTopLevelElement)
        {
            // find all the entities and verify action/functions for the entities.
            List<EntityInstance> entities = new List<EntityInstance>();
            if (payloadElement.ElementType == ODataPayloadElementType.EntityInstance)
            {
                entities.Add(payloadElement as EntityInstance);
            }
            else if (payloadElement.ElementType == ODataPayloadElementType.EntitySetInstance)
            {
                foreach (EntityInstance ei in payloadElement as EntitySetInstance)
                {
                    entities.Add(ei as EntityInstance);
                }
            }

            this.VerifyEntityOperations(request, response, entities, isTopLevelElement);
        }

        /// <summary>
        /// Verifies that any action/function in the entities are correct.
        /// </summary>
        /// <param name="request">The request that was sent</param>
        /// <param name="response">The response to verify</param>
        /// <param name="entities">List of entities to verify actions/functions</param>
        /// <param name="isTopLevelElement">Whether the payloadElement is the top level of response</param>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Temporarily suppressing this message. Have opened bug against the test owner to fix this.")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Temporarily suppressing this message.")]
        private void VerifyEntityOperations(ODataRequest request, ODataResponse response, List<EntityInstance> entities, bool isTopLevelElement)
        {
            foreach (var entity in entities.Where(et => !et.IsNull))
            {
                var instanceEntityType = this.model.EntityTypes.Single(et => et.FullName == entity.FullTypeName);

                // look at each action/function bound to the same type as entity, ensure it is advertised correctly
                int numberOfDescriptorsVerified = 0;
                var functionsWithBindings = this.model.Functions.Where(f => f.Annotations.OfType<ServiceOperationAnnotation>().Any(s => s.BindingKind.IsBound())).ToArray();
                foreach (Function function in functionsWithBindings)
                {
                    ServiceOperationAnnotation serviceOperationAnnotation = function.Annotations.OfType<ServiceOperationAnnotation>().SingleOrDefault();
                    if (serviceOperationAnnotation != null)
                    {
                        DataType bindingParameterDataType = function.Parameters[0].DataType;
                        EntityDataType bindingEntityDataType = bindingParameterDataType as EntityDataType;
                        if (bindingEntityDataType == null)
                        {
                            ExceptionUtilities.Assert(bindingParameterDataType is CollectionDataType, "Unsupported binding parameter data type.");
                            ExceptionUtilities.Assert(entity.ServiceOperationDescriptors.SingleOrDefault(d => d.Title == function.Name) == null, "Unexpected feed-bound action advertised in entry.");
                            continue;
                        }

                        // Check the base type as well as derived types
                        bool beginServiceOpMatchMatching = bindingEntityDataType.Definition.Model.EntityTypes.Where(t => t.IsKindOf(bindingEntityDataType.Definition)).Where(a => a.FullName.Equals(entity.FullTypeName)).Any();

                        if (beginServiceOpMatchMatching)
                        {
                            // find ServiceOperationDescriptor that matches the function
                            ServiceOperationDescriptor descriptor = entity.ServiceOperationDescriptors.SingleOrDefault(d => ExtractSimpleActionName(d.Title) == function.Name);
                            bool expectActionDescriptor = true;
                            if (request.Uri.SelectSegments.Count > 0)
                            {
                                expectActionDescriptor = this.ExpectActionWithProjection(request.Uri, function, isTopLevelElement);
                            }

                            if (descriptor == null)
                            {
                                ExceptionUtilities.Assert(!expectActionDescriptor, "Missing service operation descriptor for " + function.Name);
                            }
                            else
                            {
                                expectActionDescriptor = this.VerifyIfOpenType(function, bindingEntityDataType, expectActionDescriptor);

                                ExceptionUtilities.Assert(expectActionDescriptor, "Unexpected service operation descriptor for " + function.Name);

                                // JSONLight will always add the type segment if its a derived type now
                                string derivedTypeFullName = string.Empty;
                                var acceptHeaderValue = response.Headers[HttpHeaders.ContentType];
                                if (bindingEntityDataType.Definition.BaseType != null)
                                {
                                    derivedTypeFullName = string.Concat(bindingEntityDataType.Definition.FullName, "/");
                                }

                                if (bindingEntityDataType.Definition.FullName != instanceEntityType.FullName)
                                {
                                    derivedTypeFullName = string.Concat(instanceEntityType.FullName, "/");
                                }

                                // check if there is a possible name collision between a property and an action, if so add the Entity Container name to the expected result
                                string containerName = this.BuildExpectedContainerName(function, bindingEntityDataType, instanceEntityType);
                                string expectedMetadataContainerName = string.Concat(function.Model.GetDefaultEntityContainer().Name, ".");

                                // When running in JSONLight descriptor returns full name, not partial
                                if (IsJsonLightResponse(acceptHeaderValue))
                                {
                                    containerName = string.Concat(function.Model.GetDefaultEntityContainer().Name, ".");

                                    expectedMetadataContainerName = containerName;
                                }

                                string expectedTarget = string.Concat(entity.Id.TrimEnd('/'), "/", derivedTypeFullName, containerName, function.Name);
                                string expectedMetadata = string.Concat(((ServiceRootSegment)request.Uri.RootSegment).Uri.AbsoluteUri.TrimEnd('/'), "/", Endpoints.Metadata, "#", expectedMetadataContainerName, function.Name);

                                this.Assert(descriptor.Target == expectedTarget, "Expected target " + expectedTarget + " Actual " + descriptor.Target, request, response);
                                this.Assert(descriptor.Metadata == expectedMetadata, "Expected Metadata " + expectedMetadata + " Actual " + descriptor.Metadata, request, response);

                                // verify IsAction flag
                                this.Assert(serviceOperationAnnotation.IsAction == descriptor.IsAction, "Expected action " + serviceOperationAnnotation.IsAction + " Actual " + descriptor.IsAction, request, response);
                                numberOfDescriptorsVerified++;
                            }
                        }
                    }
                }

                this.Assert(numberOfDescriptorsVerified == entity.ServiceOperationDescriptors.Count, "Wrong number of action/function.", request, response);
                this.VerifyExpandedEntityOperations(entity, request, response);
            }
        }

        /// <summary>
        /// Verifies actions/functions in the expanded entity.
        /// </summary>
        /// <param name="entity">The entity to expand</param>
        /// <param name="request">The request that was sent</param>
        /// <param name="response">The response to verify</param>
        private void VerifyExpandedEntityOperations(EntityInstance entity, ODataRequest request, ODataResponse response)
        {
            foreach (var navigation in entity.Properties.OfType<NavigationPropertyInstance>())
            {
                // verify expanded entities
                if (navigation.Value.ElementType == ODataPayloadElementType.ExpandedLink)
                {
                    ODataPayloadElement expandedElement = ((ExpandedLink)navigation.Value).ExpandedElement;
                    if (expandedElement != null)
                    {
                        this.VerifyPayloadElementOperations(expandedElement, request, response, false);
                    }
                }
            }
        }

        /// <summary>
        /// Find out whether to expect action descriptor with projection in request uri
        /// </summary>
        /// <param name="requestUri">The request uri</param>
        /// <param name="action">The action</param>
        /// <param name="isTopLevelElement">Whether the entity being verified is top level payload element</param>
        /// <returns>Whether to expect action descriptor</returns>
        private bool ExpectActionWithProjection(ODataUri requestUri, Function action, bool isTopLevelElement)
        {
            ODataUriSegmentPathCollection selectSegments = requestUri.SelectSegments;
            ODataUriSegmentPathCollection expandSegments = requestUri.ExpandSegments;

            // handle single level $select path, expect action descriptor if $select=ActionName or $select=Container.*
            foreach (var selectSegmentPath in selectSegments.Where(ss => ss.Count == 1))
            {
                ODataUriSegment selectSegment = selectSegmentPath.Single();

                if (isTopLevelElement && this.FuctionMatchWithSelectFunctionSegment(action, selectSegment))
                {
                    return true;
                }

                if (this.IsSelectAllFunctionSegment(selectSegment))
                {
                    return true;
                }
            }

            // handle multiple level $select path, expect action descriptor for $expand=Rating if: $select=Rating or $select=Rating/ActionName or $Select=Rating/Container.*
            foreach (var expandSegmentPath in expandSegments)
            {
                List<ODataUriSegment> expandSegmentList = expandSegmentPath.ToList();
                foreach (var selectSegmentPath in selectSegments.Where(ss => ss.Count == expandSegmentPath.Count || ss.Count == expandSegmentPath.Count + 1))
                {
                    List<ODataUriSegment> selectSegmentList = selectSegmentPath.ToList();
                    if (this.FunctionMatchWithExpandSegmentList(selectSegmentList, expandSegmentList, action))
                    {
                        return true;
                    }
                }
            }

            return false;
        }

        /// <summary>
        /// Find out whether to expect action descriptor given expand and select segments.
        /// </summary>
        /// <param name="selectSegmentList">The select segments</param>
        /// <param name="expandSegmentList">The expand segments</param>
        /// <param name="action">The action</param>
        /// <returns>Whether to expect action descriptor</returns>
        private bool FunctionMatchWithExpandSegmentList(List<ODataUriSegment> selectSegmentList, List<ODataUriSegment> expandSegmentList, Function action)
        {
            // check if $select path and $expand path matchs
            int index = 0;
            NavigationSegment expandNavSegment = null;
            foreach (var expandSegment in expandSegmentList)
            {
                expandNavSegment = expandSegment as NavigationSegment;
                ExceptionUtilities.CheckArgumentNotNull(expandNavSegment, "Unexpected expand segment.");
                NavigationSegment selectNavSegment = selectSegmentList[index] as NavigationSegment;
                if (selectNavSegment == null || !expandNavSegment.NavigationProperty.Equals(selectNavSegment.NavigationProperty))
                {
                    return false;
                }

                index++;
            }

            // check if the action binding type matches with last segment of $expand path
            EntityDataType bindingEntityDataType = action.Parameters.First().DataType as EntityDataType;
            ExceptionUtilities.CheckArgumentNotNull(bindingEntityDataType, "Unexpected feed-bound action.");
            EntityType bindingEntityType = bindingEntityDataType.Definition;
            if (bindingEntityType != expandNavSegment.NavigationProperty.ToAssociationEnd.EntityType)
            {
                return false;
            }

            // expect action descriptor (return true) for $expand=Rating if: $select=Rating, $select=Rating/ActionName, $Select=Rating/Container.*
            if (selectSegmentList.Count == expandSegmentList.Count + 1)
            {
                ODataUriSegment lastSelectSegment = selectSegmentList.Last();
                return this.FuctionMatchWithSelectFunctionSegment(action, lastSelectSegment) || this.IsSelectAllFunctionSegment(lastSelectSegment);
            }

            return true;
        }

        /// <summary>
        /// Find out whether action matches with the ODataUri select function segment
        /// </summary>
        /// <param name="action">The action</param>
        /// <param name="selectSegment">The segment</param>
        /// <returns>Whether action matches with the function segment</returns>
        private bool FuctionMatchWithSelectFunctionSegment(Function action, ODataUriSegment selectSegment)
        {
            FunctionSegment selectFunctionSegment = selectSegment as FunctionSegment;
            if (selectFunctionSegment != null && selectFunctionSegment.Function == action)
            {
                return true;
            }

            // Sometimes the $select segment is an UnrecognizedSegment
            UnrecognizedSegment otherTypeOfSelectSegment = selectSegment as UnrecognizedSegment;
            if (otherTypeOfSelectSegment != null && selectFunctionSegment == null)
            {
                string actionName = action.Name;

                // Determine the if selction segment was <Action Name> or <EntityContainer>.<Action Name>
                if (otherTypeOfSelectSegment.Value.Contains('.'))
                {
                    actionName = string.Concat(action.Model.GetDefaultEntityContainer().Name, ".", actionName);
                }

                if (otherTypeOfSelectSegment.Value.Equals(actionName, System.StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }

        /// <summary>
        /// Find out whehter the given segment is select-all-function-segment (ContainerName.*)
        /// </summary>
        /// <param name="selectSegment">The segment</param>
        /// <returns>Whether segment is select-all-function-segment</returns>
        private bool IsSelectAllFunctionSegment(ODataUriSegment selectSegment)
        {
            UnrecognizedSegment selectAllFunctionSegment = selectSegment as UnrecognizedSegment;
            if (selectAllFunctionSegment != null && selectAllFunctionSegment.Value == this.model.GetDefaultEntityContainer().Name + ".*")
            {
                return true;
            }

            return false;
        }
    }
}