text:
package org.apache.geode.management.internal.cli.commands;

import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
import static org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
import static org.assertj.core.api.Java6Assertions.assertThat;

import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.apache.geode.cache.Cache;
import org.apache.geode.cache.PartitionAttributes;
import org.apache.geode.cache.PartitionAttributesFactory;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.distributed.ConfigurationProperties;
import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.internal.AvailablePortHelper;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.management.DistributedRegionMXBean;
import org.apache.geode.management.ManagementService;
import org.apache.geode.management.internal.cli.CliUtil;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.rules.GfshCommandRule;

@SuppressWarnings("serial")
public class RegionMembershipMBeanDUnitTestBase {
  private static final String DATA_REGION_NAME = "GemfireDataCommandsTestRegion";
  private static final String DATA_REGION_NAME_VM1 = "GemfireDataCommandsTestRegion_Vm1";
  private static final String DATA_REGION_NAME_VM2 = "GemfireDataCommandsTestRegion_Vm2";
  private static final String DATA_REGION_NAME_PATH = "/GemfireDataCommandsTestRegion";
  private static final String DATA_REGION_NAME_VM1_PATH = "/GemfireDataCommandsTestRegion_Vm1";
  private static final String DATA_REGION_NAME_VM2_PATH = "/GemfireDataCommandsTestRegion_Vm2";

  private static final String DATA_PAR_REGION_NAME = "GemfireDataCommandsTestParRegion";
  private static final String DATA_PAR_REGION_NAME_VM1 = "GemfireDataCommandsTestParRegion_Vm1";
  private static final String DATA_PAR_REGION_NAME_VM2 = "GemfireDataCommandsTestParRegion_Vm2";
  private static final String DATA_PAR_REGION_NAME_PATH = "/GemfireDataCommandsTestParRegion";
  private static final String DATA_PAR_REGION_NAME_VM1_PATH =
      "/GemfireDataCommandsTestParRegion_Vm1";
  private static final String DATA_PAR_REGION_NAME_VM2_PATH =
      "/GemfireDataCommandsTestParRegion_Vm2";
  private static final String DATA_REGION_NAME_CHILD_1 = "ChildRegionRegion1";
  private static final String DATA_REGION_NAME_CHILD_1_PATH =
      "/GemfireDataCommandsTestRegion/ChildRegionRegion1";
  private static final String DATA_REGION_NAME_CHILD_1_2 = "ChildRegionRegion12";
  private static final String DATA_REGION_NAME_CHILD_1_2_PATH =
      "/GemfireDataCommandsTestRegion/ChildRegionRegion1/ChildRegionRegion12";

  private static final String SERIALIZATION_FILTER =
      "org.apache.geode.management.internal.cli.**";

  @Rule
  public GfshCommandRule gfsh = new GfshCommandRule();

  @Rule
  public ClusterStartupRule cluster = new ClusterStartupRule();

  protected MemberVM locator, server1, server2;

  @Before
  public void before() throws Exception {
    Properties props = locatorProperties();
    props.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
    props.setProperty(NAME, "locator");

    Properties serverProps = new Properties();
    serverProps.setProperty(SERIALIZABLE_OBJECT_FILTER, SERIALIZATION_FILTER);
    locator = cluster.startLocatorVM(0, l -> l.withHttpService().withProperties(props));
    server1 = cluster.startServerVM(1, serverProps, locator.getPort());
    server2 = cluster.startServerVM(2, serverProps, locator.getPort());

    connectToLocator();
  }

  // extracted in order to override in RegionMembershipMBeanOverHttpDUnitTest to use http connection
  public void connectToLocator() throws Exception {
    gfsh.connectAndVerify(locator.getJmxPort(), jmxManager);
  }

  private static void setupDataRegionAndSubregions() {
    InternalCache cache = ClusterStartupRule.getCache();
    RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);

    Region dataRegion = regionFactory.create(DATA_REGION_NAME);
    assertThat(dataRegion).isNotNull();

    Region dataSubRegion = regionFactory.createSubregion(dataRegion, DATA_REGION_NAME_CHILD_1);
    assertThat(dataSubRegion).isNotNull();

    dataSubRegion = regionFactory.createSubregion(dataSubRegion, DATA_REGION_NAME_CHILD_1_2);
    assertThat(dataSubRegion).isNotNull();
    assertThat(dataRegion).isNotNull();
  }

  private static void setupReplicatedRegion(String regionName) {
    InternalCache cache = ClusterStartupRule.getCache();
    RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);

    Region dataRegion = regionFactory.create(regionName);
    assertThat(dataRegion).isNotNull();
    assertThat(dataRegion.getFullPath()).contains(regionName);
  }

  private static void setupPartitionedRegion(String regionName) {
    InternalCache cache = ClusterStartupRule.getCache();
    PartitionAttributes partitionAttrs =
        new PartitionAttributesFactory().setRedundantCopies(2).create();
    RegionFactory<Object, Object> partitionRegionFactory =
        cache.createRegionFactory(RegionShortcut.PARTITION);

    partitionRegionFactory.setPartitionAttributes(partitionAttrs);
    Region dataParRegion = partitionRegionFactory.create(regionName);

    assertThat(dataParRegion).isNotNull();
    assertThat(dataParRegion.getFullPath()).contains(regionName);
  }

  @Test
  public void testReplicatedRegionOnOneMember() {
    server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME));
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 1);

    Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
    Integer memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean).isEqualTo(1);
  }

  @Test
  public void testMultipleReplicatedRegionsAndSubregions() {
    server1.invoke(() -> setupDataRegionAndSubregions());
    server1.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME_VM1));

    server2.invoke(() -> setupDataRegionAndSubregions());
    server2.invoke(() -> setupReplicatedRegion(DATA_REGION_NAME_VM2));

    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM1_PATH, 1);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_VM2_PATH, 1);

    Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
    Integer memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
    memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
    memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_VM1_PATH);
    memSizeFromFunctionCall = distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_VM1_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_VM2_PATH);
    memSizeFromFunctionCall = distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_VM2_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
  }

  @Test
  public void testAddRmNewMemberWithReplicatedRegionsAndSubregions() {
    server1.invoke(() -> setupDataRegionAndSubregions());
    server2.invoke(() -> setupDataRegionAndSubregions());

    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);

    Integer initialMemberSizeFromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
    Integer initialMemberSizeFromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
    assertThat(initialMemberSizeFromFunction).isEqualTo(initialMemberSizeFromMBean);

    Integer initialMemberSizeChild1FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
    Integer initialMemberSizeChild1FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
    assertThat(initialMemberSizeChild1FromFunction).isEqualTo(initialMemberSizeChild1FromMBean);

    Integer initialMemberSizeChild2FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
    Integer initialMemberSizeChild2FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
    assertThat(initialMemberSizeChild2FromFunction).isEqualTo(initialMemberSizeChild2FromMBean);

    MemberVM server3 = cluster.startServerVM(3, locator.getPort());
    server3.invoke(() -> setupDataRegionAndSubregions());

    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 3);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 3);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 3);

    Integer intermediateMemberSizeFromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
    Integer intermediateMemberSizeFromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
    assertThat(intermediateMemberSizeFromFunction).isEqualTo(intermediateMemberSizeFromMBean)
        .isEqualTo(initialMemberSizeFromFunction + 1);

    Integer intermediateMemberSizeChild1FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
    Integer intermediateMemberSizeChild1FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
    assertThat(intermediateMemberSizeChild1FromMBean)
        .isEqualTo(intermediateMemberSizeChild1FromFunction)
        .isEqualTo(initialMemberSizeChild1FromFunction + 1);

    Integer intermediateMemberSizeChild2FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
    Integer intermediateMemberSizeChild2FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
    assertThat(intermediateMemberSizeChild2FromFunction)
        .isEqualTo(intermediateMemberSizeChild2FromMBean)
        .isEqualTo(initialMemberSizeChild2FromMBean + 1);

    server3.stop(Boolean.TRUE);

    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_REGION_NAME_CHILD_1_2_PATH, 2);

    Integer finalMemberSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_PATH);
    Integer finalMemberSizeFromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_PATH);
    assertThat(finalMemberSizeFromFunction).isEqualTo(finalMemberSizeFromMBean)
        .isEqualTo(initialMemberSizeFromFunction);

    Integer finalMemberSizeChild1FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_PATH);
    Integer finalMemberSizeChild1FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_PATH);
    assertThat(finalMemberSizeChild1FromMBean).isEqualTo(finalMemberSizeChild1FromFunction)
        .isEqualTo(initialMemberSizeChild1FromFunction);

    Integer finalMemberSizeChild2FromMBean =
        distributedRegionMembersSizeFromMBean(DATA_REGION_NAME_CHILD_1_2_PATH);
    Integer finalMemberSizeChild2FromFunction =
        distributedRegionMembersSizeFromFunction(DATA_REGION_NAME_CHILD_1_2_PATH);
    assertThat(finalMemberSizeChild2FromFunction).isEqualTo(finalMemberSizeChild2FromMBean)
        .isEqualTo(initialMemberSizeChild2FromMBean);
  }

  @Test
  public void testPartitionedRegionOnOneMember() {
    server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 1);

    Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
    Integer memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean).isEqualTo(1);
  }

  @Test
  public void testMultiplePartitionedRegions() {
    server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    server1.invoke(() -> setupReplicatedRegion(DATA_PAR_REGION_NAME_VM1));

    server2.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    server2.invoke(() -> setupReplicatedRegion(DATA_PAR_REGION_NAME_VM2));

    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 2);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM1_PATH, 1);
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_VM2_PATH, 1);

    Integer memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
    Integer memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_VM1_PATH);
    memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_VM1_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);

    memSizeFromMBean = distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_VM2_PATH);
    memSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_VM2_PATH);
    assertThat(memSizeFromFunctionCall).isEqualTo(memSizeFromMBean);
  }

  @Test
  public void testAddRmNewMemberWithPartitionedRegions() {
    server1.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    server2.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 2);

    Integer initialMemberSizeFromMBean =
        distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
    Integer initialMemberSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
    assertThat(initialMemberSizeFromFunctionCall).isEqualTo(initialMemberSizeFromMBean);

    MemberVM server3 = cluster.startServerVM(3, locator.getPort());
    server3.invoke(() -> setupPartitionedRegion(DATA_PAR_REGION_NAME));
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(DATA_PAR_REGION_NAME_PATH, 3);

    Integer intermediateMemberSizeFromMBean =
        distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
    Integer intermediateMemberSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
    assertThat(intermediateMemberSizeFromFunctionCall).isEqualTo(intermediateMemberSizeFromMBean)
        .isEqualTo(initialMemberSizeFromMBean + 1);

    server3.stop(Boolean.TRUE);

    Integer finalMemberSizeFromMBean =
        distributedRegionMembersSizeFromMBean(DATA_PAR_REGION_NAME_PATH);
    Integer finalMemberSizeFromFunctionCall =
        distributedRegionMembersSizeFromFunction(DATA_PAR_REGION_NAME_PATH);
    assertThat(finalMemberSizeFromFunctionCall).isEqualTo(finalMemberSizeFromMBean)
        .isEqualTo(initialMemberSizeFromFunctionCall);
  }

  private Integer distributedRegionMembersSizeFromFunction(String regionName) {
    return locator.invoke(() -> {
      InternalCache cache = ClusterStartupRule.getCache();
      Set<DistributedMember> distributedMembers =
          CliUtil.getRegionAssociatedMembers(regionName, cache, true);

      return distributedMembers.size();
    });
  }

  private Integer distributedRegionMembersSizeFromMBean(String regionPath) {
    return locator.invoke(() -> {
      Cache cache = ClusterStartupRule.getCache();

      Awaitility.waitAtMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
        DistributedRegionMXBean bean = ManagementService.getManagementService(cache)
            .getDistributedRegionMXBean(regionPath);
        assertThat(bean).isNotNull();
      });

      DistributedRegionMXBean bean = ManagementService.getManagementService(cache)
          .getDistributedRegionMXBean(regionPath);
      String[] membersName = bean.getMembers();
      return membersName.length;
    });
  }

  private Properties locatorProperties() {
    int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOG_LEVEL, "fine");
    props.setProperty(ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS, "localhost");
    props.setProperty(ConfigurationProperties.JMX_MANAGER_PORT, "" + jmxPort);

    return props;
  }
}


text:
[//]: # (title: Custom Language Support Tutorial)

<!-- Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->

<link-summary>Tutorial for creating a .properties-like custom language.</link-summary>

In this tutorial we will add support for a [.properties](https://en.wikipedia.org/wiki/.properties) language and its usages within Java code.

> IntelliJ Platform support for custom languages is discussed in more depth in the [Custom Language Support](custom_language_support.md) section.
> Corresponding parts are linked under **Reference** on top of each page in this tutorial.
>
> All relevant code added or changed on a page is linked in **Code**.
>
> The accompanying [](writing_tests_for_plugins.md) tutorial covers testing the functionality; corresponding parts are linked under **Testing**.
>

> The complete and fully working example plugin used in this tutorial is the [`simple_language_plugin`](%gh-sdk-samples%/simple_language_plugin) code sample.
> See [](code_samples.md) on how to build and run it.
>
{style="note"}

This a step-by-step tutorial, and it requires completing each step, in order:

* [](prerequisites.md)
* [](language_and_filetype.md)
* [](grammar_and_parser.md)
* [](lexer_and_parser_definition.md)
* [](syntax_highlighter_and_color_settings_page.md)
* [](psi_helper_and_utilities.md)
* [](annotator.md)
* [](line_marker_provider.md)
* [](completion_contributor.md)
* [](reference_contributor.md)
* [](find_usages_provider.md)
* [](folding_builder.md)
* [](go_to_symbol_contributor.md)
* [](structure_view_factory.md)
* [](structure_aware_navbar.md)
* [](formatter.md)
* [](code_style_settings.md)
* [](commenter.md)
* [](quick_fix.md)
* [](documentation_provider.md)
* [](spell_checking_strategy.md)

> If a topic you are interested in is not covered in the above sections, let us know via the "**Was this page helpful?**" feedback form below or [other channels](getting_help.md#problems-with-the-guide).
>
> Please be specific about the topics and reasons for adding them, and leave your email in case we need more details.
>
{style="note"}

redpajama_set_name: RedPajamaGithub


text:
'use strict';

// MODULES //

var tape = require( 'tape' );
var validate = require( './../lib/validate.js' );

// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.strictEqual( typeof validate, 'function', 'main export is a function' );
	t.end();
});

tape( 'if provided an `options` argument which is not an `object`, the function returns a type error', function test( t ) {
	var values;
	var opts;
	var err;
	var i;

	values = [
		'5',
		5,
		NaN,
		true,
		false,
		null,
		void 0,
		[],
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		opts = {};
		err = validate( opts, values[i] );
		t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
	}
	t.end();
});

tape( 'if provided a `dev` option which is not a `boolean`, the function returns a type error', function test( t ) {
	var values;
	var opts;
	var err;
	var i;

	values = [
		'abc',
		5,
		NaN,
		null,
		void 0,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		opts = {};
		err = validate( opts, {
			'dev': values[i]
		});
		t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[i] );
	}
	t.end();
});

tape( 'if provided a `level` option which is not a `number`, the function returns a type error', function test( t ) {
	var values;
	var opts;
	var err;
	var i;

	values = [
		'abc',
		true,
		false,
		null,
		void 0,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		opts = {};
		err = validate( opts, {
			'level': values[ i ]
		});
		t.strictEqual( err instanceof TypeError, true, 'returns a type error when provided '+values[ i ] );
	}
	t.end();
});

tape( 'the function returns `null` if all options are valid', function test( t ) {
	var opts;
	var obj;
	var err;

	opts = {
		'dev': false,
		'level': 10
	};
	obj = {};
	err = validate( obj, opts );

	t.strictEqual( err, null, 'returns null' );
	t.strictEqual( obj.level, opts.level, 'sets level option' );
	t.strictEqual( obj.dev, opts.dev, 'sets dev option' );

	t.end();
});

tape( 'the function ignores unsupported/unrecognized options', function test( t ) {
	var opts;
	var obj;
	var err;

	opts = {
		'beep': 'boop',
		'a': 'b',
		'c': [ 1, 2, 3 ]
	};
	obj = {};
	err = validate( obj, opts );

	t.strictEqual( err, null, 'returns null' );
	t.deepEqual( obj, {}, 'does not set any options' );
	t.end();
});


text:
package com.netflix.conductor.sdk.workflow.def;

public class ValidationError extends RuntimeException {

    public ValidationError(String message) {
        super(message);
    }
}


text:
servers do
  hopeful_host do
    ip "192.168.0.25"
    services :mysql, :memcached, :email, :backup
    uptime `uptime`.strip
    config_script "/var/configurations/hopeful.conf"
  end

  squishy_host do
    fwc_comment "my favorite ip address of all time"
    fwc_comment "in fact, it makes me wonder why anyone bothers with other ip addresses, this one is so great"
    fwc_comment "never in my life have I met such an ip address"
    fwc_comment "comments are going to change my life"
    ip "192.168.0.27"
    services :postresql, :couchdb
    uptime `uptime`.strip
    config_script "/var/configurations/squishy.conf"
    deeper do
      salivate( {} )
      cuticle  :rostenfeffer
    end
  end
end

workstations do
  betty do
    ip "192.168.0.14"
    os "Ubuntu Linux 13.04"
  end

  veronica do
    ip "192.168.0.15"
    os "Solaris 10"
  end
end


text:
@interface PodsDummy_BXCityPicker : NSObject
@end
@implementation PodsDummy_BXCityPicker
@end


text:
  Navio

A visualization widget to understand and navigate your data

You can use it to summarize hundreds of thousands of records a dozens of columns, explore and navigate them with three simple interactions:

| Sort | Filter a Range | Filter By Value|
| -----| --- | ---|
| Click on a header to sort
  | Drag to select a range
  | Click on a value to select all instances
   |

## Try it!

You can test Navio right now with your **own CSV or JSON data** (less than 200MB), using:

| Obervable Notebook | Shipyard | Jupyter Notebook |
| ---- | --- | --- |
|   |   |

Other demos:

* [MoMa Collection](https://john-guerra.github.io/momaExplorer/) ([Code](https://github.com/john-guerra/momaExplorer))
* [Navio-only Vast 2017 MiniChallenge1 ](http://john-guerra.github.io/navio/example_vastChallenge2017/index.html) ([Code](https://github.com/john-guerra/navio/tree/master/example_vastChallenge2017))
* [Co-voting patterns of the Colombian senate](http://johnguerra.co/viz/senadoColombia)
* [Simplest example with Networks on SVG](https://john-guerra.github.io/navio/example/) ([Code](https://github.com/john-guerra/navio/tree/master/example))
* [Simple example with Networks on Canvas](https://john-guerra.github.io/navio/exampleSenate/) ([Code](https://github.com/john-guerra/navio/tree/master/exampleSenate))
* [IEEEVIS Publications Data](https://john-guerra.github.io/navio/example_vispubdata/) ([Code](https://github.com/john-guerra/navio/blob/master/example_vispubdata/index.html)) ([Observable Notebook](https://observablehq.com/@john-guerra/navio))

# Comparing

Why using something else for summarizing your data?. Here is how Navio compares with other alternatives:

**Navio vs Parallel Coordinates**

You can use [this Notebook to compare Navio with Parallel Coordinates](https://observablehq.com/@john-guerra/navio-vs-parallel-coordinates), using your own data. Please be aware that the Vegalite implementation of Parallel Coordinates will break with a few thousand rows (on the image below it broke with 500 rows and 86 attributes of the [fifa19 Kaggle Dataset](https://www.kaggle.com/karangadiya/fifa19
))

**Navio vs Scatterplot Matrix**

Use [this Notebook to compare Navio with a Scatterplot Matrix](https://observablehq.com/@john-guerra/navio-vs-scatterplot-matrix), using your own data. Please be aware that the Vegalite implementation of the Scatterplot Matrix only support quantitative attributes and will also break with a dozen attributes and a few hundred rows), therefore the image below only displayed 8 attributes (out of the 28) on the scatterplot matrix.

# Install

```js
npm install navio
```

Or use it from unpkg

```html
  <script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
  <script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
  <script src="https://unpkg.com/popper.js@1.14/dist/umd/popper.min.js"></script>
  <script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>
```

Requires [^popper.js@0.14](https://github.com/FezVrasta/popper.js/), [^d3@4.13](http://d3js.org) and [d3-scale-chromatic](https://github.com/d3/d3-scale-chromatic) (unless you use d3.v5).

# Usage

TLDR

```html
<!DOCTYPE html>
<body>
  <!-- Placeholder for the widget -->
  <div id="navio"></div>

  <!-- NAVIO Step 0: Load the libraries -->
  <script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
  <script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
  <script src="https://unpkg.com/popper.js@1.14/dist/umd/popper.min.js"></script>
  <script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>

<script>
  // NAVIO  Step 1.  Create a Navio passing a d3 selection to place it and an optional height
  var nv = navio(d3.select("#navio"), 600);

  d3.csv(YOUR_DATA, function (err, data) {
    if (err) throw err;

    // NAVIO Step 2. Load your data!
    nv.data(data);

    // NAVIO Step 3. Detect your attributes (or load them manually)
    nv.addAllAttribs();

    // Optional, setup a selection callback
    nv.updateCallback( selected => console.log("selected in Navio: ", selected.length));
  });
</script>
</body>
</html>
```
### Step by step
1. **HTML**. Start with this template
```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Basic Usage</title>
</head>
<body>

  // Your Navio widget goes here
  <div id="Navio"></div>

</body>
</html>

```
2. **Import Navio**. Create and import a new JavaScript file below the scripts (d3 and Navio) or right in the html like in the example below.
```html
<script src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="https://john-guerra.github.io/navio/Navio.js"></script>
<script type="text/javascript">
  //   YOUR_JS_CODE_HERE
</script>
```

3. **Create a Navio Instance**

``` javascript
var nv = navio(d3.select("#Navio"), 600); //height 600
```

4. [Optional] **Configure navio to your liking**

```javascript
// Default parameters
nv.x0 = 0;  //Where to start drawing navio in x
nv.y0 = 100; //Where to start drawing navio in y, useful if your attrib names are too long
nv.maxNumDistictForCategorical = 10; // addAllAttribs uses this for deciding if an attribute is categorical (has less than nv.maxNumDistictForCategorical categories) or ordered
nv.maxNumDistictForOrdered = 90; // addAllAttribs uses this for deciding if an attribute is ordered (has less than nv.maxNumDistictForCategorical categories) or text. Use nv.maxNumDistictForOrdered = Infinity for never choosing Text

nv.howManyItemsShouldSearchForNotNull = 100; // How many rows should addAllAttribs search to decide guess an attribute type
nv.margin = 10; // Margin around navio

nv.levelsSeparation = 40; // Separation between the levels
nv.divisionsColor = "white"; // Border color for the divisions
nv.levelConnectionsColor = "rgba(205, 220, 163, 0.5)"; // Color for the conections between levels
nv.divisionsThreshold = 4; // What's the minimum row height needed to draw divisions
nv.fmtCounts = d3.format(",.0d"); // Format used to display the counts on the bottom
nv.legendFont = "14px sans-serif"; // The font for the header
nv.nestedFilters = true; // Should navio use nested levels?

nv.showAttribTitles = true; // Show headers?
nv.attribWidth = 15; // Width of the columns
nv.attribRotation = -45; // Headers rotation
nv.attribFontSize = 13; // Headers font size
nv.attribFontSizeSelected = 32; // Headers font size when mouse over

nv.filterFontSize = 10; // Font size of the filters explanations on the bottom

nv.tooltipFontSize = 12; // Font size for the tooltip
nv.tooltipBgColor = "#b2ddf1"; // Font color for tooltip background
nv.tooltipMargin = 50; // How much to separate the tooltip from the cursor
nv.tooltipArrowSize = 10; // How big is the arrow on the tooltip

nv.digitsForText = 2; // How many digits to use for text attributes

nv.id("attribName"); // Shows this id on the tooltip, should be unique

nv.addAllAttribsRecursionLevel = Infinity; // How many levels depth do we keep on adding nested attributes
nv.addAllAttribsIncludeObjects = false; // Should addAllAttribs include objects
nv.addAllAttribsIncludeArrays = false; // Should addAllAttribs include arrays

// Default colors for values
nv.nullColor = "#ffedfd"; // Color for null values
nv.defaultColorInterpolator = d3.interpolateBlues;
nv.defaultColorInterpolatorDate = d3.interpolatePurples;
nv.defaultColorInterpolatorDiverging = d3.interpolateBrBG;
nv.defaultColorInterpolatorOrdered = d3.interpolateOranges;
nv.defaultColorInterpolatorText = d3.interpolateGreys;
nv.defaultColorRangeBoolean = ["#a1d76a", "#e9a3c9", "white"]; //true false null
nv.defaultColorRangeSelected = ["white", "#b5cf6b"];
nv.defaultColorCategorical = d3.schemeCategory10;

// // Discouraged: If you want to break perceptual rules to have many more categories use
// // the following "Piñata mode 🎉"
// nv.defaultColorCategorical = d3.schemeCategory10
//   .concat(d3.schemeAccent)
//   .concat(d3.schemePastel1)
//   .concat(d3.schemeSet2)
//   .concat(d3.schemeSet3);
// nv.maxNumDistictForCategorical = nv.defaultColorCategorical.length;

```

4. [Optional] **Add your attributes manually**. Navio supports six types of attributes: categorical, sequential (numerical), diverging (numerical with negative values), text, date and boolean. You can either add them manually or use `nv.addAllAttribs()` to auto detect them (must be called after seting the data with `nv.data(your_data)`)

```javascript
nv.addCategoricalAttrib("attribName", [customScale]);
nv.addSequentialAttrib("attribName", [customScale]);
nv.addDivergingAttrib("attribName", [customScale]);
nv.addTextAttrib("attribName", [customScale]); // Colors by the first nv.digitsForText
nv.addOrderedAttrib("attribName", [customScale]); // Sorts and then colors by rank
nv.addDateAttrib("attribName", [customScale]);
nv.addBooleanAttrib("attribName", [customScale]);
```

If you ommit the [customScale] parameter it will use the defaults. You can also create your own custom made parameters using `nv.addAttrib("attribName", customScale)`. For example, if you already have a scale for setting the colors of a `cluster` property on your visualization, you can tell navio to use the same matching colors. Make sure to set the domain and range of the scale, as navio will not try to do it with this function.

```javascript
var color = d3.scaleOrdinal(d3.schemeSet3)
  .domain["cluster1", "cluster2", "cluster3"];

nv.addAttrib("cluster", color);

```

5. **Set the data**

After loading your data pass it to navio. This will trigger the drawing operation. You can force redrawing using `nv.update();`
``` javascript
nv.data(myData);
```

If your data is a network, or you have some links in the same format of a [d3.forceSimulation](https://github.com/d3/d3-force#links) you can also add them to navio using `nv.links([links])`. This won't trigger a redraw, so make sure to call it before setting your data

``` javascript
nv.links(myLinks);
nv.data(myData);
```

6. **Detect Attributes**. navio also includes a function that detects the attributes automatically, which is slow, redraws the whole thing, and my be buggy. Use it at your own risk. But make sure to call it after setting your data

``` javascript
nv.data(myData);
nv.addAllAttribs();
```

7. **Set a callback**. A function that navio will call when the user filters/sort the data
``` javascript
nv.updateCallback( data => console.log("The filtered data is ", data));
```

## Other methods

# nv.update() [<>](https://github.com/john-guerra/navio/blob/master/src/navio.js#L1443 "Source")

Use it to force a redraw of navio after changing the underlying data without losing the filters. Useful in case you modify the data with some other action in your code, e.g. you recomputed clusters in a network chart.

# nv.hardUpdate([opts]) [<>](https://github.com/john-guerra/navio/blob/master/src/navio.js#L1443 "Source")

Slower update that recomputes brushes and checks for parameters. Use it if you change any parameters or added new attributes after calling .data. opts can be an object that contains any of the following attributes:

* shouldDrawBrushes (defaults true)
* shouldUpdateColorDomains (defaults true)
* recomputeBrushes (defaults true)
* levelsToUpdate (defaults all levels, should be an array of indices)

# nv.getColorScales(attr
) [<>](https://github.com/john-guerra/navio/blob/master/src/navio.js#L1737 "Source")

Returns the color scale for a certain attribute, make sure to pass an attribute that has been already added

# nv.getAttribs(
) [<>](https://github.com/john-guerra/navio/blob/master/src/navio.js#L1742 "Source")

Returns the ordered list of attributes added to navio

## License

Navio.js is licensed under the MIT license. (http://opensource.org/licenses/MIT)


text:
package com.news.fast_news_app.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.news.fast_news_app.R;

/**
 * Created by Administrator on 2016/2/22.
 */
public class Indicator_Viewpager7 extends Fragment{
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View viewpager7 = inflater.inflate(R.layout.indicator_viewpager7,null);
        return viewpager7;
    }
}


text:
{TITLE:Content Management System}

Content Management System

	Account&nbsp|
	Threads&nbsp|
	Logout

	Login&nbsp|&nbsp
	Register

{CONTENT}


text:
from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import AbstractUser
from django.core.validators import RegexValidator, MinLengthValidator

from easy_thumbnails.signals import saved_file
from easy_thumbnails.signal_handlers import generate_aliases_global
from easy_thumbnails import fields

from sanitizer.models import SanitizedCharField, SanitizedTextField

saved_file.connect(generate_aliases_global)

alphanumeric = RegexValidator(r'^[0-9a-zA-Z]*$', 'Only alphanumeric characters are allowed.')
minlength = MinLengthValidator(3, message='Field value must be at least 3 characters long')

class ImageUser(AbstractUser):
    """
    Our custom user.
    """

    added = models.DateTimeField(auto_now_add=True)

class Image(models.Model):
    """
    How we store the image.
    """

    added = models.DateTimeField(auto_now_add=True)

    size = models.IntegerField(default=0)

    # How we track stored images.
    file = models.ImageField()
    thumbnail = fields.ThumbnailerImageField(upload_to='thumbnails',
                                             resize_source=dict(size=(160, 160), sharpen=True),
                                             blank=True)

    # How we connect labels / tags / people
    labels = models.ManyToManyField('Label', related_name='images')

class Label(models.Model):
    """
    These are how we tag images.
    """

    value = SanitizedCharField(max_length=256, unique=True, validators=[alphanumeric, minlength])


text:
namespace quic {

namespace test {
class QuicStreamSequencerBufferPeer;
}  // namespace test

class QUIC_EXPORT_PRIVATE QuicStreamSequencerBuffer {
 public:
  // Size of blocks used by this buffer.
  // Choose 8K to make block large enough to hold multiple frames, each of
  // which could be up to 1.5 KB.
  static const size_t kBlockSizeBytes = 8 * 1024;  // 8KB

  // The basic storage block used by this buffer.
  struct QUIC_EXPORT_PRIVATE BufferBlock {
    char buffer[kBlockSizeBytes];
  };

  explicit QuicStreamSequencerBuffer(size_t max_capacity_bytes);
  QuicStreamSequencerBuffer(const QuicStreamSequencerBuffer&) = delete;
  QuicStreamSequencerBuffer(QuicStreamSequencerBuffer&&) = default;
  QuicStreamSequencerBuffer& operator=(const QuicStreamSequencerBuffer&) =
      delete;
  QuicStreamSequencerBuffer& operator=(QuicStreamSequencerBuffer&&) = default;
  ~QuicStreamSequencerBuffer();

  // Free the space used to buffer data.
  void Clear();

  // Returns true if there is nothing to read in this buffer.
  bool Empty() const;

  // Called to buffer new data received for this stream.  If the data was
  // successfully buffered, returns QUIC_NO_ERROR and stores the number of
  // bytes buffered in |bytes_buffered|. Returns an error otherwise.
  QuicErrorCode OnStreamData(QuicStreamOffset offset, absl::string_view data,
                             size_t* bytes_buffered,
                             std::string* error_details);

  // Reads from this buffer into given iovec array, up to number of iov_len
  // iovec objects and returns the number of bytes read.
  QuicErrorCode Readv(const struct iovec* dest_iov, size_t dest_count,
                      size_t* bytes_read, std::string* error_details);

  // Returns the readable region of valid data in iovec format. The readable
  // region is the buffer region where there is valid data not yet read by
  // client.
  // Returns the number of iovec entries in |iov| which were populated.
  // If the region is empty, one iovec entry with 0 length
  // is returned, and the function returns 0. If there are more readable
  // regions than |iov_size|, the function only processes the first
  // |iov_size| of them.
  int GetReadableRegions(struct iovec* iov, int iov_len) const;

  // Fills in one iovec with data from the next readable region.
  // Returns false if there is no readable region available.
  bool GetReadableRegion(iovec* iov) const;

  // Returns true and sets |*iov| to point to a region starting at |offset|.
  // Returns false if no data can be read at |offset|, which can be because data
  // has not been received yet or it is already consumed.
  // Does not consume data.
  bool PeekRegion(QuicStreamOffset offset, iovec* iov) const;

  // Called after GetReadableRegions() to free up |bytes_consumed| space if
  // these bytes are processed.
  // Pre-requisite: bytes_consumed <= available bytes to read.
  bool MarkConsumed(size_t bytes_consumed);

  // Deletes and records as consumed any buffered data and clear the buffer.
  // (To be called only after sequencer's StopReading has been called.)
  size_t FlushBufferedFrames();

  // Free the memory of buffered data.
  void ReleaseWholeBuffer();

  // Whether there are bytes can be read out.
  bool HasBytesToRead() const;

  // Count how many bytes have been consumed (read out of buffer).
  QuicStreamOffset BytesConsumed() const;

  // Count how many bytes are in buffer at this moment.
  size_t BytesBuffered() const;

  // Returns number of bytes available to be read out.
  size_t ReadableBytes() const;

  // Returns offset of first missing byte.
  QuicStreamOffset FirstMissingByte() const;

  // Returns offset of highest received byte + 1.
  QuicStreamOffset NextExpectedByte() const;

  // Return all received frames as a string.
  std::string ReceivedFramesDebugString() const;

 private:
  friend class test::QuicStreamSequencerBufferPeer;

  // Copies |data| to blocks_, sets |bytes_copy|. Returns true if the copy is
  // successful. Otherwise, sets |error_details| and returns false.
  bool CopyStreamData(QuicStreamOffset offset, absl::string_view data,
                      size_t* bytes_copy, std::string* error_details);

  // Dispose the given buffer block.
  // After calling this method, blocks_[index] is set to nullptr
  // in order to indicate that no memory set is allocated for that block.
  // Returns true on success, false otherwise.
  bool RetireBlock(size_t index);

  // Should only be called after the indexed block is read till the end of the
  // block or missing data has been reached.
  // If the block at |block_index| contains no buffered data, the block
  // should be retired.
  // Returns true on success, or false otherwise.
  bool RetireBlockIfEmpty(size_t block_index);

  // Calculate the capacity of block at specified index.
  // Return value should be either kBlockSizeBytes for non-trailing blocks and
  // max_buffer_capacity % kBlockSizeBytes for trailing block.
  size_t GetBlockCapacity(size_t index) const;

  // Does not check if offset is within reasonable range.
  size_t GetBlockIndex(QuicStreamOffset offset) const;

  // Given an offset in the stream, return the offset from the beginning of the
  // block which contains this data.
  size_t GetInBlockOffset(QuicStreamOffset offset) const;

  // Get offset relative to index 0 in logical 1st block to start next read.
  size_t ReadOffset() const;

  // Get the index of the logical 1st block to start next read.
  size_t NextBlockToRead() const;

  // Resize blocks_ if more blocks are needed to accomodate bytes before
  // next_expected_byte.
  void MaybeAddMoreBlocks(QuicStreamOffset next_expected_byte);

  // The maximum total capacity of this buffer in byte, as constructed.
  size_t max_buffer_capacity_bytes_;

  // Number of blocks this buffer would have when it reaches full capacity,
  // i.e., maximal number of blocks in blocks_.
  size_t max_blocks_count_;

  // Number of blocks this buffer currently has.
  size_t current_blocks_count_;

  // Number of bytes read out of buffer.
  QuicStreamOffset total_bytes_read_;

  // An ordered, variable-length list of blocks, with the length limited
  // such that the number of blocks never exceeds max_blocks_count_.
  // Each list entry can hold up to kBlockSizeBytes bytes.
  std::unique_ptr<BufferBlock*[]> blocks_;

  // Number of bytes in buffer.
  size_t num_bytes_buffered_;

  // Currently received data.
  QuicIntervalSet<QuicStreamOffset> bytes_received_;
};

}  // namespace quic

#endif  // QUICHE_QUIC_CORE_QUIC_STREAM_SEQUENCER_BUFFER_H_


text:
<?php
/**
 * Represents a signed 32 bit integer field.
 *
 * @package sapphire
 * @subpackage model
 */
class Int extends DBField {

	function __construct($name, $defaultVal = 0) {
		$this->defaultVal = is_int($defaultVal) ? $defaultVal : 0;

		parent::__construct($name);
	}

	/**
	 * Returns the number, with commas added as appropriate, eg "1,000".
	 */
	function Formatted() {
		return number_format($this->value);
	}

	function nullValue() {
		return "0";
	}

	function requireField() {
		$parts=Array('datatype'=>'int', 'precision'=>11, 'null'=>'not null', 'default'=>$this->defaultVal, 'arrayValue'=>$this->arrayValue);
		$values=Array('type'=>'int', 'parts'=>$parts);
		DB::requireField($this->tableName, $this->name, $values);
	}

	function Times() {
		$output = new DataObjectSet();
		for( $i = 0; $i < $this->value; $i++ )
			$output->push( new ArrayData( array( 'Number' => $i + 1 ) ) );

		return $output;
	}

	function Nice() {
		return sprintf( '%d', $this->value );
	}

	public function scaffoldFormField($title = null, $params = null) {
		return new NumericField($this->name, $title);
	}

	/**
	 * Return an encoding of the given value suitable for inclusion in a SQL statement.
	 * If necessary, this should include quotes.
	 */
	function prepValueForDB($value) {
		if($value === true) {
			return 1;
		} if(!$value || !is_numeric($value)) {
			if(strpos($value, '[')===false)
				return '0';
			else
				return Convert::raw2sql($value);
		} else {
			return Convert::raw2sql($value);
		}
	}

}

?>


text:
/*
 * FreeRTOS Kernel V10.4.3
 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software. If you wish to use our Amazon
 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * https://www.FreeRTOS.org
 * https://github.com/FreeRTOS
 *
 * 1 tab == 4 spaces!
 */

#ifndef FREERTOS_CONFIG_XTENSA_H
#define FREERTOS_CONFIG_XTENSA_H

#include "sdkconfig.h"

/* enable use of optimized task selection by the scheduler */
#if defined (CONFIG_FREERTOS_OPTIMIZED_SCHEDULER) && !defined(configUSE_PORT_OPTIMISED_TASK_SELECTION)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION         1
#endif

#define XT_USE_THREAD_SAFE_CLIB                         0
#undef XT_USE_SWPRI

#if CONFIG_FREERTOS_CORETIMER_0
#define XT_TIMER_INDEX                                  0
#elif CONFIG_FREERTOS_CORETIMER_1
#define XT_TIMER_INDEX                                  1
#endif

#ifndef __ASSEMBLER__
/**
 * This function is defined to provide a deprecation warning whenever
 * XT_CLOCK_FREQ macro is used.
 * Update the code to use esp_clk_cpu_freq function instead.
 * @return current CPU clock frequency, in Hz
 */
int xt_clock_freq(void) __attribute__((deprecated));

#define XT_CLOCK_FREQ   (xt_clock_freq())

#endif // __ASSEMBLER__

/* Required for configuration-dependent settings */
#include <xtensa_config.h>

/* configASSERT behaviour */
#ifndef __ASSEMBLER__
#include <assert.h>
#include "esp_rom_sys.h"
#if CONFIG_IDF_TARGET_ESP32
#include "esp32/rom/ets_sys.h"  // will be removed in idf v5.0
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/ets_sys.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "esp32s3/rom/ets_sys.h"
#endif
#endif // __ASSEMBLER__

// If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro
// configASSERT_DEFINED remains unset (meaning some warnings are avoided)
#ifdef configASSERT
#undef configASSERT
#if defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE)
#define configASSERT(a) if (unlikely(!(a))) {                           \
        esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__,  \
                   __FUNCTION__);                                           \
    }
#elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
#define configASSERT(a) assert(a)
#endif
#endif

#if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
#define UNTESTED_FUNCTION() { esp_rom_printf("Untested FreeRTOS function %s\r\n", __FUNCTION__); configASSERT(false); } while(0)
#else
#define UNTESTED_FUNCTION()
#endif

#define configXT_BOARD                                  1   /* Board mode */
#define configXT_SIMULATOR                              0

/* The maximum interrupt priority from which FreeRTOS.org API functions can
   be called.  Only API functions that end in ...FromISR() can be used within
   interrupts. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY	XCHAL_EXCM_LEVEL

/* Stack alignment, architecture specifc. Must be a power of two. */
#define configSTACK_ALIGNMENT                           16

/* The Xtensa port uses a separate interrupt stack. Adjust the stack size
 * to suit the needs of your specific application.
 * Size needs to be aligned to the stack increment, since the location of
 * the stack for the 2nd CPU will be calculated using configISR_STACK_SIZE.
 */
#ifndef configISR_STACK_SIZE
#define configISR_STACK_SIZE                            ((CONFIG_FREERTOS_ISR_STACKSIZE + configSTACK_ALIGNMENT - 1) & (~(configSTACK_ALIGNMENT - 1)))
#endif

#ifndef __ASSEMBLER__
#if CONFIG_APPTRACE_SV_ENABLE
extern uint32_t port_switch_flag[];
#define os_task_switch_is_pended(_cpu_) (port_switch_flag[_cpu_])
#else
#define os_task_switch_is_pended(_cpu_) (false)
#endif
#endif

#endif // FREERTOS_CONFIG_XTENSA_H


text:
/**
 * This class is used to display small visual icons in the header of a panel. There are a set of
 * 25 icons that can be specified by using the {@link #type} config. The {@link #handler} config
 * can be used to provide a function that will respond to any click events. In general, this class
 * will not be instantiated directly, rather it will be created by specifying the {@link Ext.panel.Panel#tools}
 * configuration on the Panel itself.
 *
 *     @example
 *     Ext.create('Ext.panel.Panel', {
 *         width: 200,
 *         height: 200,
 *         renderTo: document.body,
 *         title: 'A Panel',
 *         tools: [{
 *             type: 'help',
 *             handler: function(){
 *                 // show help here
 *             }
 *         }, {
 *             itemId: 'refresh',
 *             type: 'refresh',
 *             hidden: true,
 *             handler: function(){
 *                 // do refresh
 *             }
 *         }, {
 *             type: 'search',
 *             handler: function(event, target, owner, tool){
 *                 // do search
 *                 owner.child('#refresh').show();
 *             }
 *         }]
 *     });
 */
Ext.define('Ext.panel.Tool', {
    extend: 'Ext.Component',
    requires: ['Ext.tip.QuickTipManager'],
    alias: 'widget.tool',

    baseCls: Ext.baseCSSPrefix + 'tool',
    disabledCls: Ext.baseCSSPrefix + 'tool-disabled',

    /**
     * @cfg
     * @private
     */
    toolPressedCls: Ext.baseCSSPrefix + 'tool-pressed',
    /**
     * @cfg
     * @private
     */
    toolOverCls: Ext.baseCSSPrefix + 'tool-over',

    ariaRole: 'button',

    childEls: [
        'toolEl'
    ],

    renderTpl: [
        ''
    ],

    /**
     * @cfg {Function} handler
     * A function to execute when the tool is clicked. Arguments passed are:
     *
     * - **event** : Ext.EventObject - The click event.
     * - **toolEl** : Ext.Element - The tool Element.
     * - **owner** : Ext.panel.Header - The host panel header.
     * - **tool** : Ext.panel.Tool - The tool object
     */

    /**
     * @cfg {Object} scope
     * The scope to execute the {@link #handler} function. Defaults to the tool.
     */

    /**
     * @cfg {String} type
     * The type of tool to render. The following types are available:
     *
     * -  close
     * -  minimize
     * -  maximize
     * -  restore
     * -  toggle
     * -  gear
     * -  prev
     * -  next
     * -  pin
     * -  unpin
     * -  right
     * -  left
     * -  down
     * -  up
     * -  refresh
     * -  plus
     * -  minus
     * -  search
     * -  save
     * -  help
     * -  print
     * -  expand
     * -  collapse
     */

    /**
     * @cfg {String/Object} tooltip
     * The tooltip for the tool - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config
     * object
     */

     /**
     * @cfg {String} tooltipType
     * The type of tooltip to use. Either 'qtip' (default) for QuickTips or 'title' for title attribute.
     */
    tooltipType: 'qtip',

    /**
     * @cfg {Boolean} stopEvent
     * Specify as false to allow click event to propagate.
     */
    stopEvent: true,

    height: 15,
    width: 15,

    //<debug>
    _toolTypes: {
        close:1,
        collapse:1,
        down:1,
        expand:1,
        gear:1,
        help:1,
        left:1,
        maximize:1,
        minimize:1,
        minus:1,
        //move:1,
        next:1,
        pin:1,
        plus:1,
        prev:1,
        print:1,
        refresh:1,
        //resize:1,
        restore:1,
        right:1,
        save:1,
        search:1,
        toggle:1,
        unpin:1,
        up:1
    },
    //</debug>

    initComponent: function() {
        var me = this;
        me.addEvents(
            /**
             * @event click
             * Fires when the tool is clicked
             * @param {Ext.panel.Tool} this
             * @param {Ext.EventObject} e The event object
             */
            'click'
        );

        //<debug>
        if (me.id && me._toolTypes[me.id] && Ext.global.console) {
            Ext.global.console.warn('When specifying a tool you should use the type option, the id can conflict now that tool is a Component');
        }
        //</debug>

        me.type = me.type || me.id;

        Ext.applyIf(me.renderData, {
            baseCls: me.baseCls,
            blank: Ext.BLANK_IMAGE_URL,
            type: me.type
        });

        // alias qtip, should use tooltip since it's what we have in the docs
        me.tooltip = me.tooltip || me.qtip;
        me.callParent();
        me.on({
            element: 'toolEl',
            click: me.onClick,
            mousedown: me.onMouseDown,
            mouseover: me.onMouseOver,
            mouseout: me.onMouseOut,
            scope: me
        });
    },

    // inherit docs
    afterRender: function() {
        var me = this,
            attr;

        me.callParent(arguments);
        if (me.tooltip) {
            if (Ext.isObject(me.tooltip)) {
                Ext.tip.QuickTipManager.register(Ext.apply({
                    target: me.id
                }, me.tooltip));
            }
            else {
                attr = me.tooltipType == 'qtip' ? 'data-qtip' : 'title';
                me.toolEl.dom.setAttribute(attr, me.tooltip);
            }
        }
    },

    getFocusEl: function() {
        return this.el;
    },

    /**
     * Sets the type of the tool. Allows the icon to be changed.
     * @param {String} type The new type. See the {@link #type} config.
     * @return {Ext.panel.Tool} this
     */
    setType: function(type) {
        var me = this;

        me.type = type;
        if (me.rendered) {
            me.toolEl.dom.className = me.baseCls + '-' + type;
        }
        return me;
    },

    /**
     * Binds this tool to a component.
     * @private
     * @param {Ext.Component} component The component
     */
    bindTo: function(component) {
        this.owner = component;
    },

    /**
     * Called when the tool element is clicked
     * @private
     * @param {Ext.EventObject} e
     * @param {HTMLElement} target The target element
     */
    onClick: function(e, target) {
        var me = this,
            owner;

        if (me.disabled) {
            return false;
        }
        owner = me.owner || me.ownerCt;

        //remove the pressed + over class
        me.el.removeCls(me.toolPressedCls);
        me.el.removeCls(me.toolOverCls);

        if (me.stopEvent !== false) {
            e.stopEvent();
        }

        Ext.callback(me.handler, me.scope || me, [e, target, owner, me]);
        me.fireEvent('click', me, e);
        return true;
    },

    // inherit docs
    onDestroy: function(){
        if (Ext.isObject(this.tooltip)) {
            Ext.tip.QuickTipManager.unregister(this.id);
        }
        this.callParent();
    },

    /**
     * Called when the user presses their mouse button down on a tool
     * Adds the press class ({@link #toolPressedCls})
     * @private
     */
    onMouseDown: function() {
        if (this.disabled) {
            return false;
        }

        this.el.addCls(this.toolPressedCls);
    },

    /**
     * Called when the user rolls over a tool
     * Adds the over class ({@link #toolOverCls})
     * @private
     */
    onMouseOver: function() {
        if (this.disabled) {
            return false;
        }
        this.el.addCls(this.toolOverCls);
    },

    /**
     * Called when the user rolls out from a tool.
     * Removes the over class ({@link #toolOverCls})
     * @private
     */
    onMouseOut: function() {
        this.el.removeCls(this.toolOverCls);
    }
});


text: <ti-autocomplete-match data="::item"></ti-autocomplete-match>


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

<ScrollView
    android:id="@+id/sv_detail"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="24dp"
        android:background="#ffffff"
        >

        <TextView
            android:id="@+id/tv_number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:text="维修单号 :"
            android:textSize="16dp"
            android:layout_margin="10dp"
            />
        <TextView
            android:id="@+id/number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:text="2333333333"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_depart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="报修部门 :"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/number"
            />
        <TextView
            android:id="@+id/depart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="有关部门"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/number"
            android:maxWidth="180dp"

            />

        <TextView
            android:id="@+id/tv_address"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="报修地点 :"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/depart"
            />
        <TextView
            android:id="@+id/address"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="4号教学楼666"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/depart"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_person"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/address"
            android:text="报修人     :"
            />
        <TextView
            android:id="@+id/person"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/address"
            android:text="小听"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/person"
            android:text="报修时间 :"
            />
        <TextView
            android:id="@+id/time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/person"
            android:text="8/12/1994 8:31:32 PM"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/time"
            android:text="联系电话 :"
            />
        <TextView
            android:id="@+id/phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/time"
            android:text="12580"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/phone"
            android:text="维修内容 :"
            />
        <TextView
            android:id="@+id/content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/phone"
            android:maxWidth="180dp"
            android:text="要求换五星级酒店,顺便看最长不要呼呼呼呼呼俄格哥哥个哥哥哥哥俄格哥哥给个恶搞"
            android:ellipsize="end"
            android:maxLines="3"
            />

        <TextView
            android:id="@+id/tv_describe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/content"
            android:text="完成描述 :"
            />
        <TextView
            android:id="@+id/describe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/content"
            android:text="完成到99.9%"
            android:maxWidth="180dp"
            />

        <TextView
            android:id="@+id/tv_time_finish"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/describe"
            android:text="完成时间 :"
            />
        <TextView
            android:id="@+id/time_finish"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:textSize="16dp"
            android:layout_margin="10dp"
            android:layout_below="@+id/describe"
            android:text="12/12/2222 4:34:33 PM"
            android:maxWidth="180dp"
            />

        <Button
            android:id="@+id/btn_back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="返回"
            android:textSize="20dp"
            android:textColor="#ffffff"
            android:background="@drawable/library_selector"
            android:layout_below="@+id/time_finish"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="24dp"
            android:layout_marginRight="12dp"
            android:layout_marginLeft="12dp"
            android:paddingTop="12dp"
            android:paddingBottom="12dp"
            />
    </RelativeLayout>
</ScrollView>


text:
using System;
using Csla;

namespace MyCsla
{
  /// <summary>
  /// Adds posibbility of Logging/Instrumentation of DataPortal calls on BusinessObjects that does not use the ObjectFactoryAttribute
  ///
  /// Consider f.ex the possiblity of creating PerformanceCounters and logging of Exceptions to EventLog.
  /// </summary>
  [Serializable]
  public class CriteriaBase : Csla.CriteriaBase
  {
    /// <summary>
    /// Indicates that the specified property belongs
    /// to the business object type.
    /// </summary>
    /// <typeparam name="P">Type of property</typeparam>
    /// <param name="objectType">Type of the object.</param>
    /// <param name="propertyName">Name of the property.</param>
    /// <returns>The provided IPropertyInfo object.</returns>
    protected static PropertyInfo<P> RegisterProperty<P>(Type objectType, string propertyName)
    {
      return RegisterProperty(objectType, Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create<P>(objectType, propertyName));
    }

    /// <summary>
    /// Indicates that the specified property belongs
    /// to the business object type.
    /// </summary>
    /// <typeparam name="P">Type of property</typeparam>
    /// <param name="objectType">Type of the object.</param>
    /// <param name="propertyName">Name of the property.</param>
    /// <param name="friendlyName">Name of the friendly.</param>
    /// <returns>The provided IPropertyInfo object.</returns>
    protected static PropertyInfo<P> RegisterProperty<P>(Type objectType, string propertyName, string friendlyName)
    {
      return RegisterProperty(objectType, Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create<P>(objectType, propertyName, friendlyName));
    }

    /// <summary>
    /// Indicates that the specified property belongs
    /// to the business object type.
    /// </summary>
    /// <typeparam name="P">Type of property</typeparam>
    /// <param name="objectType">Type of the object.</param>
    /// <param name="propertyName">Name of the property.</param>
    /// <param name="friendlyName">Name of the friendly.</param>
    /// <param name="defaultValue">The default value.</param>
    /// <returns>The provided IPropertyInfo object.</returns>
    protected static PropertyInfo<P> RegisterProperty<P>(Type objectType, string propertyName, string friendlyName, P defaultValue)
    {
      return RegisterProperty(objectType, Csla.Core.FieldManager.PropertyInfoFactory.Factory.Create<P>(objectType, propertyName, friendlyName, defaultValue));
    }
  }
}