text:
package math.function;

public class AbsoluteValueFunction extends Function{

	public AbsoluteValueFunction(Function arg1) {
		super(arg1, null);
	}

	@Override
	public double f(double[] inputs, String[] variableNames) {
		return Math.abs(getFunction1().f(inputs, variableNames));
	}

	@Override
	public String toString() {
		return "|" + getFunction1().toString() + "|";
	}

}

redpajama_set_name: RedPajamaGithub


text:
package org.elasticsearch.index.mapper;

import org.apache.lucene.document.Field;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.index.mapper.ParseContext.Document;

import java.util.List;

/**
 * The result of parsing a document.
 */
public class ParsedDocument {

    private final Field uid, version;

    private final String id;

    private final String type;

    private final String routing;

    private final long timestamp;

    private final long ttl;

    private final long token;

    private final List<Document> documents;

    private BytesReference source;

    private Mapping dynamicMappingsUpdate;

    private String parent;

    public ParsedDocument(Field uid, Field version, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, BytesReference source, Mapping dynamicMappingsUpdate) {
        this(uid, version, id, type, routing, timestamp, ttl, 0, documents, source, dynamicMappingsUpdate);
    }

    public ParsedDocument(Field uid, Field version, String id, String type, String routing, long timestamp, long ttl, long token, List<Document> documents, BytesReference source, Mapping dynamicMappingsUpdate) {
        this.uid = uid;
        this.version = version;
        this.id = id;
        this.type = type;
        this.routing = routing;
        this.timestamp = timestamp;
        this.ttl = ttl;
        this.token = token;
        this.documents = documents;
        this.source = source;
        this.dynamicMappingsUpdate = dynamicMappingsUpdate;
    }

    public Field uid() {
        return this.uid;
    }

    public Field version() {
        return version;
    }

    public String id() {
        return this.id;
    }

    public String type() {
        return this.type;
    }

    public String routing() {
        return this.routing;
    }

    public long timestamp() {
        return this.timestamp;
    }

    public long ttl() {
        return this.ttl;
    }

    public long token() {
        return this.token;
    }

    public Document rootDoc() {
        return documents.get(documents.size() - 1);
    }

    public List<Document> docs() {
        return this.documents;
    }

    public BytesReference source() {
        return this.source;
    }

    public void setSource(BytesReference source) {
        this.source = source;
    }

    public ParsedDocument parent(String parent) {
        this.parent = parent;
        return this;
    }

    public String parent() {
        return this.parent;
    }

    /**
     * Return dynamic updates to mappings or {@code null} if there were no
     * updates to the mappings.
     */
    public Mapping dynamicMappingsUpdate() {
        return dynamicMappingsUpdate;
    }

    public void addDynamicMappingsUpdate(Mapping update) {
        if (dynamicMappingsUpdate == null) {
            dynamicMappingsUpdate = update;
        } else {
            dynamicMappingsUpdate = dynamicMappingsUpdate.merge(update, false);
        }
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Document ").append("uid[").append(uid).append("] doc [").append(documents).append("]");
        return sb.toString();
    }
}


text:
package com.intellij.history.integration.ui.actions;

import com.intellij.history.core.LocalHistoryFacade;
import com.intellij.history.integration.IdeaGateway;
import com.intellij.history.integration.ui.views.SelectionHistoryDialog;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.openapi.vcs.actions.VcsContextWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsSelection;
import com.intellij.vcsUtil.VcsSelectionUtil;
import javax.annotation.Nullable;

public class ShowSelectionHistoryAction extends ShowHistoryAction {
  @Override
  protected void showDialog(Project p, IdeaGateway gw, VirtualFile f, AnActionEvent e) {
    VcsSelection sel = getSelection(e);

    int from = sel.getSelectionStartLineNumber();
    int to = sel.getSelectionEndLineNumber();

    new SelectionHistoryDialog(p, gw, f, from, to).show();
  }

  @Override
  protected String getText(AnActionEvent e) {
    VcsSelection sel = getSelection(e);
    return sel == null ? super.getText(e) : sel.getActionName();
  }

  @Override
  public void update(AnActionEvent e) {
    if (e.getData(PlatformDataKeys.EDITOR) == null) {
      e.getPresentation().setVisible(false);
    }
    else {
      super.update(e);
    }
  }

  @Override
  protected boolean isEnabled(LocalHistoryFacade vcs, IdeaGateway gw, VirtualFile f, AnActionEvent e) {
    return super.isEnabled(vcs, gw, f, e) && !f.isDirectory() && getSelection(e) != null;
  }

  @Nullable
  private static VcsSelection getSelection(AnActionEvent e) {
    VcsContext c = VcsContextWrapper.createCachedInstanceOn(e);
    return VcsSelectionUtil.getSelection(c);
  }
}


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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".SelectLevelActivity"
                android:background="@drawable/select_level_bg">

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/select_demo_btn"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="200dp"
        android:background="@drawable/button_demo_lvl_selector"/>

</RelativeLayout>


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/alert_container"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#f2f7fa"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/alert_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </FrameLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="#D3D3D3"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="0dp">

        <Button
            android:id="@+id/btn_confirm"
            style="@style/ConfirmBtnPanel"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/default_confirm"/>

        <View
            android:layout_width="1dp"
            android:layout_height="fill_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:background="#D3D3D3"/>

        <Button
            android:id="@+id/btn_cancel"
            style="@style/ConfirmBtnPanel"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/default_cancel"/>
    </LinearLayout>
</LinearLayout>


text:
define([
	"intern!object",
	"intern/chai!assert",
	"requirejs-dplugins/jquery!attributes/classes",
	"delite/register",
	"deliteful/SidePane"
], function (registerSuite, assert, $, register) {
	var container, sp, origBodyStyle;
	var htmlContent = "<d-side-pane id='sp'></d-side-pane>

";

	registerSuite({
		name: "SidePane Show Hide",
		setup: function () {
			origBodyStyle = document.body.style.cssText;
			container = document.createElement("div");
			document.body.appendChild(container);
			container.innerHTML = htmlContent;
			register.deliver();
			sp = document.getElementById("sp");
		},

		"show": function () {
			var shownEvent;
			sp.on("sidepane-after-show", function () {
				shownEvent = true;
			});
			return sp.show("content").then(function (value) {
				assert.strictEqual(value.child.id, "content", "show() promise resolved value is incorrect");
				assert.strictEqual(sp.children[0].id, "content", "SidePane child");
				assert(shownEvent, "fired sidepane-after-show");
			});
		},

		"hide": function () {
			return sp.hide().then(function () {
				assert.strictEqual(sp.children[0].id, "content", "Plain hide() didn't remove child");
			}).then(function () {
				return sp.show();
			}).then(function () {
				return sp.hide("content");
			}).then(function (value) {
				assert.strictEqual(value.child.id, "content", "show() promise resolved value");
				assert.strictEqual(sp.children.length, 1, "# of children");
			});
		},

		"toggle after hide": function () {
			return sp.hide().then(function () {
				return sp.toggle();
			}).then(function () {
				assert.isTrue($(sp).hasClass("-d-side-pane-visible"));
				assert.isFalse($(sp).hasClass("-d-side-pane-hidden"));
			});
		},

		"toggle after show": function () {
			return sp.show().then(function () {
				return sp.toggle();
			}).then(function () {
				assert.isTrue($(sp).hasClass("-d-side-pane-hidden"));
				assert.isFalse($(sp).hasClass("-d-side-pane-visible"));
			});
		},

		teardown: function () {
			container.parentNode.removeChild(container);
			document.body.style.cssText = origBodyStyle;	// so page can scroll again
		}
	});
});


text:
/**
 * Builds a list of the enumerable properties of an object.
 * The function is null-safe, unlike the public one.
 * @private
 * @param {Object} source
 * @returns {String[]}
 */
function _safeEnumerables (source) {
    var result = [];

    for (var key in source) {
        result.push(key);
    }

    return result;
}

export default _safeEnumerables;


text:
using System;

namespace Tests.Framework
{
	public class IntegrationOnly : Attribute { }
}


text:
package io.vitess.jdbc;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;

import io.vitess.proto.Query;
import io.vitess.util.Constants;
import io.vitess.util.charset.CharsetMapping;

/**
 * Created by ashudeep.sharma on 08/02/16.
 */
public class VitessResultSetMetadataTest extends BaseTest {

    private List<FieldWithMetadata> fieldList;

    private List<Query.Field> generateFieldList() {
        List<Query.Field> fieldList = new ArrayList<>();

        fieldList.add(field("col1", "tbl", Query.Type.INT8, 4, CharsetMapping.MYSQL_COLLATION_INDEX_binary)
            .setFlags(Query.MySqlFlag.NOT_NULL_FLAG_VALUE).setOrgName("foo").setOrgTable("foo").build());
        fieldList.add(field("col2", "tbl", Query.Type.UINT8, 3, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.UNSIGNED_FLAG_VALUE).build());
        fieldList.add(field("col3", "tbl", Query.Type.INT16, 6, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col4", "tbl", Query.Type.UINT16, 5, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.UNSIGNED_FLAG_VALUE).build());
        fieldList.add(field("col5", "tbl", Query.Type.INT24, 9, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col6", "tbl", Query.Type.UINT24, 8, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.UNSIGNED_FLAG_VALUE).build());
        fieldList.add(field("col7", "tbl", Query.Type.INT32, 11, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col8", "tbl", Query.Type.UINT32, 10, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.UNSIGNED_FLAG_VALUE).build());
        fieldList.add(field("col9", "tbl", Query.Type.INT64, 20, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col10", "tbl", Query.Type.UINT64, 20, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.UNSIGNED_FLAG_VALUE).build());
        fieldList.add(field("col11", "tbl", Query.Type.FLOAT32, 12, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setDecimals(31).build());
        fieldList.add(field("col12", "tbl", Query.Type.FLOAT64, 22, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setDecimals(31).build());
        fieldList.add(field("col13", "tbl", Query.Type.TIMESTAMP, 10, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col14", "tbl", Query.Type.DATE, 10, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col15", "tbl", Query.Type.TIME, 10, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col16", "tbl", Query.Type.DATETIME, 19, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col17", "tbl", Query.Type.YEAR, 4, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col18", "tbl", Query.Type.DECIMAL, 7, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setDecimals(2).build());
        fieldList.add(field("col19", "tbl", Query.Type.TEXT, 765, /* utf8_bin -- not case insensitive */ 83).build());
        fieldList.add(field("col20", "tbl", Query.Type.BLOB, 65535, CharsetMapping.MYSQL_COLLATION_INDEX_binary)
            .setFlags(Query.MySqlFlag.BINARY_FLAG_VALUE | Query.MySqlFlag.BLOB_FLAG_VALUE)
            .setDecimals(/* this is set to facilitate testing of getScale, since this is non-numeric */2).build());
        fieldList.add(field("col21", "tbl", Query.Type.VARCHAR, 768, CharsetMapping.MYSQL_COLLATION_INDEX_utf8).build());
        fieldList.add(field("col22", "tbl", Query.Type.VARBINARY, 256, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.BINARY_FLAG_VALUE).build());
        fieldList.add(field("col23", "tbl", Query.Type.CHAR, 48, CharsetMapping.MYSQL_COLLATION_INDEX_utf8).build());
        fieldList.add(field("col24", "tbl", Query.Type.BINARY, 4, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.BINARY_FLAG_VALUE).build());
        fieldList.add(field("col25", "tbl", Query.Type.BIT, 8, CharsetMapping.MYSQL_COLLATION_INDEX_binary).build());
        fieldList.add(field("col26", "tbl", Query.Type.ENUM, 3, CharsetMapping.MYSQL_COLLATION_INDEX_utf8).build());
        fieldList.add(field("col27", "tbl", Query.Type.SET, 9, CharsetMapping.MYSQL_COLLATION_INDEX_utf8).build());
        fieldList.add(field("col28", "tbl", Query.Type.TUPLE, 0, CharsetMapping.MYSQL_COLLATION_INDEX_utf8).build());
        fieldList.add(field("col29", "tbl", Query.Type.VARBINARY, 256, CharsetMapping.MYSQL_COLLATION_INDEX_binary).setFlags(Query.MySqlFlag.BINARY_FLAG_VALUE).build());
        fieldList.add(field("col30", "tbl", Query.Type.BLOB, 65535, CharsetMapping.MYSQL_COLLATION_INDEX_utf8)
            .setFlags(Query.MySqlFlag.BLOB_FLAG_VALUE).build());
        return fieldList;
    }

    private Query.Field.Builder field(String name, String table, Query.Type type, int length, int charset) {
        return Query.Field.newBuilder()
            .setName(name)
            .setTable(table)
            .setType(type)
            .setColumnLength(length)
            .setCharset(charset);
    }

    private void initializeFieldList(VitessConnection connection) throws SQLException {
        List<Query.Field> fields = generateFieldList();
        this.fieldList = new ArrayList<>(fields.size());
        for (Query.Field field : fields) {
            this.fieldList.add(new FieldWithMetadata(connection, field));
        }
    }

    public List<FieldWithMetadata> getFieldList() throws SQLException {
        return getFieldList(getVitessConnection());
    }

    public List<FieldWithMetadata> getFieldList(VitessConnection conn) throws SQLException {
        initializeFieldList(conn);
        return this.fieldList;
    }

    @Test public void testgetColumnCount() throws SQLException {

        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals(30, vitessResultSetMetadata.getColumnCount());
    }

    @Test public void testgetColumnName() throws SQLException {

        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        for (int i = 1; i <= vitessResultSetMetadata.getColumnCount(); i++) {
            Assert.assertEquals("col" + i, vitessResultSetMetadata.getColumnName(i));
        }
    }

    @Test public void testgetColumnTypeName() throws SQLException {

        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("TINYINT", vitessResultSetMetadata.getColumnTypeName(1));
        Assert.assertEquals("TINYINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(2));
        Assert.assertEquals("SMALLINT", vitessResultSetMetadata.getColumnTypeName(3));
        Assert.assertEquals("SMALLINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(4));
        Assert.assertEquals("MEDIUMINT", vitessResultSetMetadata.getColumnTypeName(5));
        Assert.assertEquals("MEDIUMINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(6));
        Assert.assertEquals("INT", vitessResultSetMetadata.getColumnTypeName(7));
        Assert.assertEquals("INT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(8));
        Assert.assertEquals("BIGINT", vitessResultSetMetadata.getColumnTypeName(9));
        Assert.assertEquals("BIGINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(10));
        Assert.assertEquals("FLOAT", vitessResultSetMetadata.getColumnTypeName(11));
        Assert.assertEquals("DOUBLE", vitessResultSetMetadata.getColumnTypeName(12));
        Assert.assertEquals("TIMESTAMP", vitessResultSetMetadata.getColumnTypeName(13));
        Assert.assertEquals("DATE", vitessResultSetMetadata.getColumnTypeName(14));
        Assert.assertEquals("TIME", vitessResultSetMetadata.getColumnTypeName(15));
        Assert.assertEquals("DATETIME", vitessResultSetMetadata.getColumnTypeName(16));
        Assert.assertEquals("YEAR", vitessResultSetMetadata.getColumnTypeName(17));
        Assert.assertEquals("DECIMAL", vitessResultSetMetadata.getColumnTypeName(18));
        Assert.assertEquals("TEXT", vitessResultSetMetadata.getColumnTypeName(19));
        Assert.assertEquals("BLOB", vitessResultSetMetadata.getColumnTypeName(20));
        Assert.assertEquals("VARCHAR", vitessResultSetMetadata.getColumnTypeName(21));
        Assert.assertEquals("VARBINARY", vitessResultSetMetadata.getColumnTypeName(22));
        Assert.assertEquals("CHAR", vitessResultSetMetadata.getColumnTypeName(23));
        Assert.assertEquals("BINARY", vitessResultSetMetadata.getColumnTypeName(24));
        Assert.assertEquals("BIT", vitessResultSetMetadata.getColumnTypeName(25));
        Assert.assertEquals("ENUM", vitessResultSetMetadata.getColumnTypeName(26));
        Assert.assertEquals("SET", vitessResultSetMetadata.getColumnTypeName(27));
        Assert.assertEquals("TUPLE", vitessResultSetMetadata.getColumnTypeName(28));
        Assert.assertEquals("VARBINARY", vitessResultSetMetadata.getColumnTypeName(29));
        Assert.assertEquals("BLOB", vitessResultSetMetadata.getColumnTypeName(30));
    }

    @Test public void testgetColumnType() throws SQLException {

        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("TINYINT", Types.TINYINT, vitessResultSetMetadata.getColumnType(1));
        Assert.assertEquals("TINYINT", Types.TINYINT, vitessResultSetMetadata.getColumnType(2));
        Assert.assertEquals("SMALLINT", Types.SMALLINT, vitessResultSetMetadata.getColumnType(3));
        Assert.assertEquals("SMALLINT", Types.SMALLINT, vitessResultSetMetadata.getColumnType(4));
        Assert.assertEquals("INTEGER", Types.INTEGER, vitessResultSetMetadata.getColumnType(5));
        Assert.assertEquals("INTEGER", Types.INTEGER, vitessResultSetMetadata.getColumnType(6));
        Assert.assertEquals("INTEGER", Types.INTEGER, vitessResultSetMetadata.getColumnType(7));
        Assert.assertEquals("INTEGER", Types.INTEGER, vitessResultSetMetadata.getColumnType(8));
        Assert.assertEquals("BIGINT", Types.BIGINT, vitessResultSetMetadata.getColumnType(9));
        Assert.assertEquals("BIGINT", Types.BIGINT, vitessResultSetMetadata.getColumnType(10));
        Assert.assertEquals("FLOAT", Types.FLOAT, vitessResultSetMetadata.getColumnType(11));
        Assert.assertEquals("DOUBLE", Types.DOUBLE, vitessResultSetMetadata.getColumnType(12));
        Assert.assertEquals("TIMESTAMP", Types.TIMESTAMP, vitessResultSetMetadata.getColumnType(13));
        Assert.assertEquals("DATE", Types.DATE, vitessResultSetMetadata.getColumnType(14));
        Assert.assertEquals("TIME", Types.TIME, vitessResultSetMetadata.getColumnType(15));
        Assert.assertEquals("TIMESTAMP", Types.TIMESTAMP, vitessResultSetMetadata.getColumnType(16));
        Assert.assertEquals("SMALLINT", Types.SMALLINT, vitessResultSetMetadata.getColumnType(17));
        Assert.assertEquals("DECIMAL", Types.DECIMAL, vitessResultSetMetadata.getColumnType(18));
        Assert.assertEquals("VARCHAR", Types.VARCHAR, vitessResultSetMetadata.getColumnType(19));
        Assert.assertEquals("LONGVARBINARY", Types.LONGVARBINARY, vitessResultSetMetadata.getColumnType(20));
        Assert.assertEquals("VARCHAR", Types.VARCHAR, vitessResultSetMetadata.getColumnType(21));
        Assert.assertEquals("VARBINARY", Types.VARBINARY, vitessResultSetMetadata.getColumnType(22));
        Assert.assertEquals("CHAR", Types.CHAR, vitessResultSetMetadata.getColumnType(23));
        Assert.assertEquals("BINARY", Types.BINARY, vitessResultSetMetadata.getColumnType(24));
        Assert.assertEquals("BIT", Types.BIT, vitessResultSetMetadata.getColumnType(25));
        Assert.assertEquals("CHAR", Types.CHAR, vitessResultSetMetadata.getColumnType(26));
        Assert.assertEquals("CHAR", Types.CHAR, vitessResultSetMetadata.getColumnType(27));
        Assert.assertEquals("VARBINARY", Types.VARBINARY, vitessResultSetMetadata.getColumnType(29));
        Assert.assertEquals("LONGVARCHAR", Types.LONGVARCHAR, vitessResultSetMetadata.getColumnType(30));
        try {
            int type = vitessResultSetMetadata.getColumnType(28);
        } catch (SQLException ex) {
            Assert
                .assertEquals(Constants.SQLExceptionMessages.INVALID_COLUMN_TYPE, ex.getMessage());
        }

        try {
            int type = vitessResultSetMetadata.getColumnType(0);
        } catch (SQLException ex) {
            Assert.assertEquals(Constants.SQLExceptionMessages.INVALID_COLUMN_INDEX + ": " + 0,
                ex.getMessage());
        }
    }

    @Test public void testgetColumnLabel() throws SQLException {
        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetaData = new VitessResultSetMetaData(fieldList);
        for (int i = 1; i <= vitessResultSetMetaData.getColumnCount(); i++) {
            Assert.assertEquals("col" + i, vitessResultSetMetaData.getColumnLabel(i));
        }
    }

    @Test public void testgetTableName() throws SQLException {
        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        for (int i = 1; i <= vitessResultSetMetadata.getColumnCount(); i++) {
            Assert.assertEquals(vitessResultSetMetadata.getTableName(i), "tbl");
        }
    }

    @Test public void isReadOnlyTest() throws SQLException {
        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals(vitessResultSetMetadata.isReadOnly(1), false);
        Assert.assertEquals(vitessResultSetMetadata.isWritable(1), true);
        Assert.assertEquals(vitessResultSetMetadata.isDefinitelyWritable(1), true);

        for (int i = 2; i <= vitessResultSetMetadata.getColumnCount(); i++) {
            Assert.assertEquals(vitessResultSetMetadata.isReadOnly(i), true);
            Assert.assertEquals(vitessResultSetMetadata.isWritable(i), false);
            Assert.assertEquals(vitessResultSetMetadata.isDefinitelyWritable(i), false);
        }
    }

    @Test public void getColumnTypeNameTest() throws SQLException {
        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetadata = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("TINYINT", vitessResultSetMetadata.getColumnTypeName(1));
        Assert.assertEquals("TINYINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(2));
        Assert.assertEquals("SMALLINT", vitessResultSetMetadata.getColumnTypeName(3));
        Assert.assertEquals("SMALLINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(4));
        Assert.assertEquals("MEDIUMINT", vitessResultSetMetadata.getColumnTypeName(5));
        Assert.assertEquals("MEDIUMINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(6));
        Assert.assertEquals("INT", vitessResultSetMetadata.getColumnTypeName(7));
        Assert.assertEquals("INT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(8));
        Assert.assertEquals("BIGINT", vitessResultSetMetadata.getColumnTypeName(9));
        Assert.assertEquals("BIGINT UNSIGNED", vitessResultSetMetadata.getColumnTypeName(10));
        Assert.assertEquals("FLOAT", vitessResultSetMetadata.getColumnTypeName(11));
        Assert.assertEquals("DOUBLE", vitessResultSetMetadata.getColumnTypeName(12));
        Assert.assertEquals("TIMESTAMP", vitessResultSetMetadata.getColumnTypeName(13));
        Assert.assertEquals("DATE", vitessResultSetMetadata.getColumnTypeName(14));
        Assert.assertEquals("TIME", vitessResultSetMetadata.getColumnTypeName(15));
        Assert.assertEquals("DATETIME", vitessResultSetMetadata.getColumnTypeName(16));
        Assert.assertEquals("YEAR", vitessResultSetMetadata.getColumnTypeName(17));
        Assert.assertEquals("DECIMAL", vitessResultSetMetadata.getColumnTypeName(18));
        Assert.assertEquals("TEXT", vitessResultSetMetadata.getColumnTypeName(19));
        Assert.assertEquals("BLOB", vitessResultSetMetadata.getColumnTypeName(20));
        Assert.assertEquals("VARCHAR", vitessResultSetMetadata.getColumnTypeName(21));
        Assert.assertEquals("VARBINARY", vitessResultSetMetadata.getColumnTypeName(22));
        Assert.assertEquals("CHAR", vitessResultSetMetadata.getColumnTypeName(23));
        Assert.assertEquals("BINARY", vitessResultSetMetadata.getColumnTypeName(24));
        Assert.assertEquals("BIT", vitessResultSetMetadata.getColumnTypeName(25));
        Assert.assertEquals("ENUM", vitessResultSetMetadata.getColumnTypeName(26));
        Assert.assertEquals("SET", vitessResultSetMetadata.getColumnTypeName(27));
        Assert.assertEquals("TUPLE", vitessResultSetMetadata.getColumnTypeName(28));
    }

    @Test public void getSchemaNameTest() throws SQLException {
        List<FieldWithMetadata> fieldList = getFieldList();
        VitessResultSetMetaData vitessResultSetMetaData = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals(vitessResultSetMetaData.getSchemaName(1), "");
        Assert.assertEquals(vitessResultSetMetaData.getCatalogName(1), "");
        Assert.assertEquals(vitessResultSetMetaData.getPrecision(1), 3);
        Assert.assertEquals(vitessResultSetMetaData.getScale(1), 0);
        Assert.assertEquals(vitessResultSetMetaData.getColumnDisplaySize(1), 4);
        Assert.assertEquals(vitessResultSetMetaData.isCurrency(1), false);
    }

    @Test public void testCaseSensitivity() throws SQLException {
        VitessConnection connection = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(connection);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);

        // numeric types and date types are not case sensitive
        Assert.assertEquals("int8 case sensitivity", false, md.isCaseSensitive(1));
        Assert.assertEquals("uint8 case sensitivity", false, md.isCaseSensitive(2));
        Assert.assertEquals("int16 case sensitivity", false, md.isCaseSensitive(3));
        Assert.assertEquals("uint16 case sensitivity", false, md.isCaseSensitive(4));
        Assert.assertEquals("int24 case sensitivity", false, md.isCaseSensitive(5));
        Assert.assertEquals("uint24 case sensitivity", false, md.isCaseSensitive(6));
        Assert.assertEquals("int32 case sensitivity", false, md.isCaseSensitive(7));
        Assert.assertEquals("uint32 case sensitivity", false, md.isCaseSensitive(8));
        Assert.assertEquals("int64 case sensitivity", false, md.isCaseSensitive(9));
        Assert.assertEquals("uint64 case sensitivity", false, md.isCaseSensitive(10));
        Assert.assertEquals("float32 case sensitivity", false, md.isCaseSensitive(11));
        Assert.assertEquals("float64 case sensitivity", false, md.isCaseSensitive(12));
        Assert.assertEquals("timestamp case sensitivity", false, md.isCaseSensitive(13));
        Assert.assertEquals("date case sensitivity", false, md.isCaseSensitive(14));
        Assert.assertEquals("time case sensitivity", false, md.isCaseSensitive(15));
        Assert.assertEquals("datetime case sensitivity", false, md.isCaseSensitive(16));
        Assert.assertEquals("year case sensitivity", false, md.isCaseSensitive(17));
        Assert.assertEquals("decimal case sensitivity", false, md.isCaseSensitive(18));

        // These are handled on a case-by-case basis
        Assert.assertEquals("text cases sensitivity", /* due to binary */true, md.isCaseSensitive(19));
        Assert.assertEquals("blob case sensitivity", /* due to binary */true, md.isCaseSensitive(20));
        Assert.assertEquals("varchar case sensitivity", /* due to utf-8_ci */ false, md.isCaseSensitive(21));
        Assert.assertEquals("varbinary case sensitivity", /* due to binary */true, md.isCaseSensitive(22));
        Assert.assertEquals("char case sensitivity", /* due to utf-8_ci */ false, md.isCaseSensitive(23));
        Assert.assertEquals("binary case sensitivity", /* due to binary */true, md.isCaseSensitive(24));
        Assert.assertEquals("bit case sensitivity", /* due to numeric type */false, md.isCaseSensitive(25));
        Assert.assertEquals("enum case sensitivity", /* due to utf-8_ci */ false, md.isCaseSensitive(26));
        Assert.assertEquals("set case sensitivity", /* due to utf-8_ci, SET == CHAR */ false, md.isCaseSensitive(27));
        Assert.assertEquals("tuple case sensitivity", /* due to default case */ true, md.isCaseSensitive(28));
        Assert.assertEquals("varbinary case sensitivity", /* due to binary */ true, md.isCaseSensitive(29));
        Assert.assertEquals("text cases sensitivity", /* due to utf8_bin (not case insensitive) encoding */false, md.isCaseSensitive(30));

        connection.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        // with limited included fields, we can really only know about numeric types -- those should return false.  the rest should return true
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - non-numeric case insensitive due to lack of included fields", i >= 18 && i != 24, md.isCaseSensitive(i + 1));
        }
    }

    @Test public void testIsNullable() throws SQLException {
        VitessConnection conn = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(conn);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("NOT_NULL flag means columnNoNulls (0) value for isNullable", ResultSetMetaData.columnNoNulls, md.isNullable(1));
        for (int i = 1; i < fieldList.size(); i++) {
            Assert.assertEquals("lack of NOT_NULL flag means columnNullable (1) value for isNullable", ResultSetMetaData.columnNullable, md.isNullable(i + 1));
        }

        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - isNullable is columnNullableUnknown (2) for all when lack of included fields", 2, md.isNullable(i + 1));
        }
    }

    @Test public void testDisplaySize() throws SQLException {
        VitessConnection conn = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(conn);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);

        Assert.assertEquals("int8 display size", 4, md.getColumnDisplaySize(1));
        Assert.assertEquals("uint8 display size", 3, md.getColumnDisplaySize(2));
        Assert.assertEquals("int16 display size", 6, md.getColumnDisplaySize(3));
        Assert.assertEquals("uint16 display size", 5, md.getColumnDisplaySize(4));
        Assert.assertEquals("int24 display size", 9, md.getColumnDisplaySize(5));
        Assert.assertEquals("uint24 display size", 8, md.getColumnDisplaySize(6));
        Assert.assertEquals("int32 display size", 11, md.getColumnDisplaySize(7));
        Assert.assertEquals("uint32 display size", 10, md.getColumnDisplaySize(8));
        Assert.assertEquals("int64 display size", 20, md.getColumnDisplaySize(9));
        // unsigned long gets an extra digit of precision over signed, so display sizes are the same
        Assert.assertEquals("uint64 display size", 20, md.getColumnDisplaySize(10));
        Assert.assertEquals("float32 display size", 12, md.getColumnDisplaySize(11));
        Assert.assertEquals("float64 display size", 22, md.getColumnDisplaySize(12));
        Assert.assertEquals("timestamp display size", 10, md.getColumnDisplaySize(13));
        Assert.assertEquals("date display size", 10, md.getColumnDisplaySize(14));
        Assert.assertEquals("time display size", 10, md.getColumnDisplaySize(15));
        Assert.assertEquals("datetime display size", 19, md.getColumnDisplaySize(16));
        Assert.assertEquals("year display size", 4, md.getColumnDisplaySize(17));
        Assert.assertEquals("decimal display size", 7, md.getColumnDisplaySize(18));
        Assert.assertEquals("text display size", 255, md.getColumnDisplaySize(19));
        Assert.assertEquals("blob display size", 65535, md.getColumnDisplaySize(20));
        Assert.assertEquals("varchar display size", 256, md.getColumnDisplaySize(21));
        Assert.assertEquals("varbinary display size", 256, md.getColumnDisplaySize(22));
        Assert.assertEquals("char display size", 16, md.getColumnDisplaySize(23));
        Assert.assertEquals("binary display size", 4, md.getColumnDisplaySize(24));
        Assert.assertEquals("bit display size", 8, md.getColumnDisplaySize(25));
        Assert.assertEquals("enum display size", 1, md.getColumnDisplaySize(26));
        Assert.assertEquals("set display size", 3, md.getColumnDisplaySize(27));
        Assert.assertEquals("tuple display size", 0, md.getColumnDisplaySize(28));
        Assert.assertEquals("varbinary display size", 256, md.getColumnDisplaySize(29));

        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - getColumnDisplaySize is 0 for all when lack of included fields", 0, md.getColumnDisplaySize(i + 1));
        }
    }

    @Test public void testGetPrecision() throws SQLException {
        VitessConnection conn = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(conn);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);

        Assert.assertEquals("int8 precision", 3, md.getPrecision(1));
        Assert.assertEquals("uint8 precision", 3, md.getPrecision(2));
        Assert.assertEquals("int16 precision", 5, md.getPrecision(3));
        Assert.assertEquals("uint16 precision", 5, md.getPrecision(4));
        Assert.assertEquals("int24 precision", 8, md.getPrecision(5));
        Assert.assertEquals("uint24 precision", 8, md.getPrecision(6));
        Assert.assertEquals("int32 precision", 10, md.getPrecision(7));
        Assert.assertEquals("uint32 precision", 10, md.getPrecision(8));
        Assert.assertEquals("int64 precision", 19, md.getPrecision(9));
        Assert.assertEquals("uint64 precision", 20, md.getPrecision(10));
        Assert.assertEquals("float32 precision", 12, md.getPrecision(11));
        Assert.assertEquals("float64 precision", 22, md.getPrecision(12));
        Assert.assertEquals("timestamp precision", 10, md.getPrecision(13));
        Assert.assertEquals("date precision", 10, md.getPrecision(14));
        Assert.assertEquals("time precision", 10, md.getPrecision(15));
        Assert.assertEquals("datetime precision", 19, md.getPrecision(16));
        Assert.assertEquals("year precision", 4, md.getPrecision(17));
        Assert.assertEquals("decimal precision", 5, md.getPrecision(18)); // 7 - decimal - sign
        Assert.assertEquals("text precision", 255, md.getPrecision(19));
        Assert.assertEquals("blob precision", 65535, md.getPrecision(20));
        Assert.assertEquals("varchar precision", 256, md.getPrecision(21));
        Assert.assertEquals("varbinary precision", 256, md.getPrecision(22));
        Assert.assertEquals("char precision", 16, md.getPrecision(23));
        Assert.assertEquals("binary precision", 4, md.getPrecision(24));
        Assert.assertEquals("bit precision", 8, md.getPrecision(25));
        Assert.assertEquals("enum precision", 1, md.getPrecision(26));
        Assert.assertEquals("set precision", 3, md.getPrecision(27));
        Assert.assertEquals("tuple precision", 0, md.getPrecision(28));
        Assert.assertEquals("varbinary precision", 256, md.getPrecision(29));

        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - getPrecision is 0 for all when lack of included fields", 0, md.getPrecision(i + 1));
        }
    }

    @Test public void testGetScale() throws SQLException {
        VitessConnection conn = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(conn);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("int8 precision", 0, md.getScale(1));
        Assert.assertEquals("uint8 precision", 0, md.getScale(2));
        Assert.assertEquals("int16 precision", 0, md.getScale(3));
        Assert.assertEquals("uint16 precision", 0, md.getScale(4));
        Assert.assertEquals("int24 precision", 0, md.getScale(5));
        Assert.assertEquals("uint24 precision", 0, md.getScale(6));
        Assert.assertEquals("int32 precision", 0, md.getScale(7));
        Assert.assertEquals("uint32 precision", 0, md.getScale(8));
        Assert.assertEquals("int64 precision", 0, md.getScale(9));
        Assert.assertEquals("uint64 precision", 0, md.getScale(10));
        Assert.assertEquals("float32 precision", 31, md.getScale(11));
        Assert.assertEquals("float64 precision", 31, md.getScale(12));
        Assert.assertEquals("timestamp precision", 0, md.getScale(13));
        Assert.assertEquals("date precision", 0, md.getScale(14));
        Assert.assertEquals("time precision", 0, md.getScale(15));
        Assert.assertEquals("datetime precision", 0, md.getScale(16));
        Assert.assertEquals("year precision",  0, md.getScale(17));
        Assert.assertEquals("decimal precision", 2, md.getScale(18));
        Assert.assertEquals("text precision", 0, md.getScale(19));
        Assert.assertEquals("blob precision", 0, md.getScale(20));
        Assert.assertEquals("varchar precision", 0, md.getScale(21));
        Assert.assertEquals("varbinary precision", 0, md.getScale(22));
        Assert.assertEquals("char precision", 0, md.getScale(23));
        Assert.assertEquals("binary precision", 0, md.getScale(24));
        Assert.assertEquals("bit precision", 0, md.getScale(25));
        Assert.assertEquals("enum precision", 0, md.getScale(26));
        Assert.assertEquals("set precision", 0, md.getScale(27));
        Assert.assertEquals("tuple precision", 0, md.getScale(28));
        Assert.assertEquals("varbinary precision", 0, md.getScale(29));

        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - getScale is 0 for all when lack of included fields", 0, md.getScale(i + 1));
        }
    }

    @Test public void testGetColumnClassName() throws SQLException {
        VitessConnection conn = getVitessConnection();
        List<FieldWithMetadata> fieldList = getFieldList(conn);
        VitessResultSetMetaData md = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(1));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(2));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(3));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(4));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(5));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(6));
        Assert.assertEquals("java.lang.Integer", md.getColumnClassName(7));
        Assert.assertEquals("java.lang.Long", md.getColumnClassName(8));
        Assert.assertEquals("java.lang.Long", md.getColumnClassName(9));
        Assert.assertEquals("java.math.BigInteger", md.getColumnClassName(10));
        Assert.assertEquals("java.lang.Double", md.getColumnClassName(11));
        Assert.assertEquals("java.lang.Double", md.getColumnClassName(12));
        Assert.assertEquals("java.sql.Timestamp", md.getColumnClassName(13));
        Assert.assertEquals("java.sql.Date", md.getColumnClassName(14));
        Assert.assertEquals("java.sql.Time", md.getColumnClassName(15));
        Assert.assertEquals("java.sql.Timestamp", md.getColumnClassName(16));
        Assert.assertEquals("java.sql.Date", md.getColumnClassName(17));
        Assert.assertEquals("java.math.BigDecimal", md.getColumnClassName(18));
        Assert.assertEquals("java.lang.String", md.getColumnClassName(19));
        Assert.assertEquals("[B", md.getColumnClassName(20));
        Assert.assertEquals("java.lang.String", md.getColumnClassName(21));
        Assert.assertEquals("[B", md.getColumnClassName(22));
        Assert.assertEquals("java.lang.String", md.getColumnClassName(23));
        Assert.assertEquals("[B", md.getColumnClassName(24));
        Assert.assertEquals("java.lang.Boolean", md.getColumnClassName(25));
        Assert.assertEquals("java.lang.String", md.getColumnClassName(26));
        Assert.assertEquals("java.lang.String", md.getColumnClassName(27));
        Assert.assertEquals("java.lang.Object", md.getColumnClassName(28));
        Assert.assertEquals("[B", md.getColumnClassName(29));

        conn.setYearIsDateType(false);
        md = new VitessResultSetMetaData(fieldList);
        Assert.assertEquals("java.lang.Short", md.getColumnClassName(17));

        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        for (int i = 0; i < fieldList.size(); i++) {
            Assert.assertEquals(fieldList.get(i).getName() + " - class name is null when no included fields", null, md.getColumnClassName(i + 1));
        }
    }

    /**
     * Some of the tests above verify that their particular part honors the IncludedFields.ALL value, but
     * this further verifies that when someone has disabled ALL, the values returned by the driver are basically the same
     * as what they used to be before we supported returning all fields.
     */
    @Test public void testDefaultValuesWithoutIncludedFields() throws SQLException {
        VitessConnection conn = getVitessConnection();
        conn.setIncludedFields(Query.ExecuteOptions.IncludedFields.TYPE_AND_NAME);
        List<FieldWithMetadata> fields = getFieldList(conn);
        VitessResultSetMetaData vitessResultSetMetaData = new VitessResultSetMetaData(fields);
        for (int i = 1; i < fields.size() + 1; i++) {
            FieldWithMetadata field = fields.get(i - 1);
            Assert.assertEquals(false, vitessResultSetMetaData.isAutoIncrement(i));
            boolean shouldBeSensitive = true;
            switch (field.getJavaType()) {
                case Types.BIT:
                case Types.TINYINT:
                case Types.SMALLINT:
                case Types.INTEGER:
                case Types.BIGINT:
                case Types.FLOAT:
                case Types.REAL:
                case Types.DOUBLE:
                case Types.DATE:
                case Types.DECIMAL:
                case Types.NUMERIC:
                case Types.TIME:
                case Types.TIMESTAMP:
                    shouldBeSensitive = false;
                    break;
            }
            Assert.assertEquals(shouldBeSensitive, vitessResultSetMetaData.isCaseSensitive(i));
            Assert.assertEquals(field.getName(), true, vitessResultSetMetaData.isSearchable(i));
            Assert.assertEquals(field.getName(), false, vitessResultSetMetaData.isCurrency(i));
            Assert.assertEquals(field.getName(), ResultSetMetaData.columnNullableUnknown, vitessResultSetMetaData.isNullable(i));
            Assert.assertEquals(field.getName(), false, vitessResultSetMetaData.isSigned(i));
            Assert.assertEquals(field.getName(), 0, vitessResultSetMetaData.getColumnDisplaySize(i));
            Assert.assertEquals(field.getName(), field.getName(), vitessResultSetMetaData.getColumnLabel(i));
            Assert.assertEquals(field.getName(), field.getName(), vitessResultSetMetaData.getColumnName(i));
            Assert.assertEquals(field.getName(), 0, vitessResultSetMetaData.getPrecision(i));
            Assert.assertEquals(field.getName(), 0, vitessResultSetMetaData.getScale(i));
            Assert.assertEquals(field.getName(), null, vitessResultSetMetaData.getTableName(i));
            Assert.assertEquals(field.getName(), null, vitessResultSetMetaData.getCatalogName(i));
            // These two do not depend on IncludedFields and are covered by tests above
            //Assert.assertEquals(field.getName(), null, vitessResultSetMetaData.getColumnType(i));
            //Assert.assertEquals(field.getName(), null, vitessResultSetMetaData.getColumnTypeName(i));
            Assert.assertEquals(field.getName(), false, vitessResultSetMetaData.isReadOnly(i));
            Assert.assertEquals(field.getName(), true, vitessResultSetMetaData.isWritable(i));
            Assert.assertEquals(field.getName(), true, vitessResultSetMetaData.isDefinitelyWritable(i));
            Assert.assertEquals(field.getName(), null, vitessResultSetMetaData.getColumnClassName(i));
        }
    }
}


text:
// weiteng 2015-09-24

(function ($) {
    $.extend({
        getDialogTemplate: function (type) {
            return "
"
            + "
"
                 + "
"
                     + "
"
                         + "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">"
                             + "×"
                         + "</button>"
                         + "

"
                     + "
"
                     + "

"
                     + "
 0\">"
                        + " <button type=\"button\" data-bind=\"text:text, click:click, attr:{class: className == '' ? 'btn btn-default' : className}\">取消</button>"
                     + "
"
                 + "
"
            + "
"
         + "
";
        },
        BtDialogButtonInfo: function (text, className, click) {
            className = className || " btn btn-default ";
            this.text = text;
            this.className = className;

            if (typeof (click) == "function") {
                this.click = click;
            }
            else {
                this.click = function (obj) { };
            }
        },
        btClose: function (delay) {
        	delay=delay||0;
        	window.setTimeout(function(){
            if (typeof (window.frameElement) == "object" && $(window.frameElement).attr("dialogid") && typeof (window.frameElement.parentNode) == "object" && window.frameElement.parentNode.tagName == "DIV") {
                if (window.parent) {
                    if (typeof (window.parent[$(window.frameElement).attr("dialogid")].modal) == "function") {
                        window.parent[$(window.frameElement).attr("dialogid")].modal("hide");
                    }
                }
            }
            }, delay);
        },
        btDialog: function (config) {
            /*
            config= {
             title:title,
             html:html,
             iscenter: true,
             type:modal-xl|modal-lg|modal-sm|modal-md
             buttons:BtDialogButtonInfo[]
            }
            */

            config = config || {};
            config.iscenter = config.iscenter || true;

            // default modal-sm
            if (!config.type) {
                config.type = "modal-sm";
            }

            var btDialogTemplateString = $.getDialogTemplate(config.type);

            var divDialog = $(btDialogTemplateString)[0];

            ko.applyBindings({
                title: config.title || "系统提示",
                html: config.html || "",
                buttons: config.buttons || []
            }, divDialog);

            var dilog = $(divDialog).modal({
                backdrop: "static",
                keyboard: false,
                show: true
            });

            dilog.on('hide.bs.modal', function () {
                window.setTimeout(function () {
                    $(divDialog).remove();
                }, 2000);
                return true;
            });

            if (config.iscenter == true) {
                window.setTimeout(function () {
                    var divDialogHeight = $(divDialog).height();
                    var contentHeight = $($(divDialog).find("div[class*=modal-dialog]")[0]).outerHeight(true);

                    $(divDialog).css({
                        "margin-top": (divDialogHeight - contentHeight) / 2 + "px"
                    });

                }, 10);
            }

            return dilog;
        },
        btAlert: function (msg, callback, title) {
            var dialog = $.btDialog({
                title: title || "系统提示",
                html: "

" + (msg || "") + "

",
                type: "modal-md"
            });

            dialog.on('hidden.bs.modal', function() {
				if (typeof (callback) == "function") {
				    callback();
				}
			});

            return dialog;
        },
        btConfirm: function (msg, callback, title) {
            var dialog = $.btDialog({
                title: title || "系统提示",
                html: "

" + (msg || "") + "

",
                type: "modal-md",
                buttons: [
                    new $.BtDialogButtonInfo("确定",
                        "btn btn-warning",
                        function () {
                            dialog.retrunValue = true;
                            dialog.modal('hide');
                        }),
                    new $.BtDialogButtonInfo("取消",
                        "btn btn-primary",
                        function () {
                            dialog.retrunValue = false;
                            dialog.modal('hide');
                        }),
                ]
            });

            dialog.on('hidden.bs.modal', function() {
				if (typeof (callback) == "function") {
				    callback(dialog.retrunValue);
				}
			});

            return dialog;
        },
        btWarning: function (msg, callback, title) {
            var dialog = $.btDialog({
                title: title || "系统提示",
                html: "

" + (msg || "") + "

",
                type: "modal-md",
                buttons: [
                    new $.BtDialogButtonInfo("确定",
                        "btn btn-danger",
                        function () {
                            dialog.retrunValue = true;
                            dialog.modal('hide');
                        }),
                    new $.BtDialogButtonInfo("取消",
                        "btn btn-primary",
                        function () {
                            dialog.retrunValue = false;
                            dialog.modal('hide');
                        }),
                ]
            });

            dialog.on('hidden.bs.modal', function() {
            	console.log(callback);
				if (typeof (callback) == "function") {
				    callback(dialog.retrunValue);
				}
			});

            return dialog;
        },
        btOpenurl: function (config) {
            /*
            config= {
             url:url,
             height:300px,
             title:title,
             iscenter: true,
             type:modal-lg|modal-sm,
             buttons:BtDialogButtonInfo[]
            }
            */

            config = config || {};
            var dialogid = "dialog_" + Date.parse(new Date()) ;

            config.html = "";

            var dialog = $.btDialog(config);
            window[dialogid] = dialog;

            dialog.on("hidden.bs.modal", function () {
                delete window[dialogid];
            });

            return dialog;
        }

    });
})(jQuery);


text:
<?php

namespace Phython\Exceptions;

class OutputException extends JsonException
{
    //
}


text:
const spawn = require('cross-spawn');
const { resolveBin } = require('../utils/path-resolver');

const upgrade = resolveBin('@talend/upgrade-deps', { executable: 'talend-upgrade-deps' });

module.exports = function upgradeDeps(env, _, options) {
	try {
		return spawn.sync(
			upgrade,
			options,
			{ stdio: 'inherit', env },
		);
	} catch(error) {
		console.error(error);
	}
	return undefined;
};


text:
package com.sequenceiq.freeipa.flow.freeipa.cleanup;

import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.CLEANUP_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.CLEANUP_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.CLEANUP_FAILURE_HANDLED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.CLEANUP_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_DNS_ENTRIES_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_DNS_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_HOSTS_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_HOSTS_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_ROLES_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_ROLES_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_USERS_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_USERS_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_VAULT_ENTRIES_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REMOVE_VAULT_ENTRIES_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REVOKE_CERTS_FAILED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupEvent.REVOKE_CERTS_FINISHED_EVENT;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.CLEANUP_FAILED_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.CLEANUP_FINISHED_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.FINAL_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.INIT_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REMOVE_DNS_ENTRIES_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REMOVE_HOSTS_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REMOVE_ROLES_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REMOVE_USERS_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REMOVE_VAULT_ENTRIES_STATE;
import static com.sequenceiq.freeipa.flow.freeipa.cleanup.FreeIpaCleanupState.REVOKE_CERTS_STATE;

import java.util.List;

import org.springframework.stereotype.Component;

import com.sequenceiq.flow.core.config.AbstractFlowConfiguration;
import com.sequenceiq.flow.core.config.AbstractFlowConfiguration.Transition.Builder;
import com.sequenceiq.flow.core.config.RetryableFlowConfiguration;

@Component
public class FreeIpaCleanupFlowConfig extends AbstractFlowConfiguration<FreeIpaCleanupState, FreeIpaCleanupEvent>
        implements RetryableFlowConfiguration<FreeIpaCleanupEvent> {

    private static final FreeIpaCleanupEvent[] FREEIPA_INIT_EVENTS = {CLEANUP_EVENT};

    private static final FlowEdgeConfig<FreeIpaCleanupState, FreeIpaCleanupEvent> EDGE_CONFIG =
            new FlowEdgeConfig<>(INIT_STATE, FINAL_STATE, CLEANUP_FAILED_STATE, CLEANUP_FAILURE_HANDLED_EVENT);

    private static final List<Transition<FreeIpaCleanupState, FreeIpaCleanupEvent>> TRANSITIONS =
            new Builder<FreeIpaCleanupState, FreeIpaCleanupEvent>().defaultFailureEvent(CLEANUP_FAILED_EVENT)
            .from(INIT_STATE).to(REVOKE_CERTS_STATE).event(CLEANUP_EVENT).defaultFailureEvent()
            .from(REVOKE_CERTS_STATE).to(REMOVE_HOSTS_STATE).event(REVOKE_CERTS_FINISHED_EVENT).failureEvent(REVOKE_CERTS_FAILED_EVENT)
            .from(REMOVE_HOSTS_STATE).to(REMOVE_DNS_ENTRIES_STATE).event(REMOVE_HOSTS_FINISHED_EVENT).failureEvent(REMOVE_HOSTS_FAILED_EVENT)
            .from(REMOVE_DNS_ENTRIES_STATE).to(REMOVE_VAULT_ENTRIES_STATE).event(REMOVE_DNS_ENTRIES_FINISHED_EVENT).failureEvent(REMOVE_DNS_FAILED_EVENT)
            .from(REMOVE_VAULT_ENTRIES_STATE).to(REMOVE_USERS_STATE).event(REMOVE_VAULT_ENTRIES_FINISHED_EVENT).failureEvent(REMOVE_VAULT_ENTRIES_FAILED_EVENT)
            .from(REMOVE_USERS_STATE).to(REMOVE_ROLES_STATE).event(REMOVE_USERS_FINISHED_EVENT).failureEvent(REMOVE_USERS_FAILED_EVENT)
            .from(REMOVE_ROLES_STATE).to(CLEANUP_FINISHED_STATE).event(REMOVE_ROLES_FINISHED_EVENT).failureEvent(REMOVE_ROLES_FAILED_EVENT)
            .from(CLEANUP_FINISHED_STATE).to(FINAL_STATE).event(CLEANUP_FINISHED_EVENT).defaultFailureEvent()
            .build();

    public FreeIpaCleanupFlowConfig() {
        super(FreeIpaCleanupState.class, FreeIpaCleanupEvent.class);
    }

    @Override
    protected List<Transition<FreeIpaCleanupState, FreeIpaCleanupEvent>> getTransitions() {
        return TRANSITIONS;
    }

    @Override
    protected FlowEdgeConfig<FreeIpaCleanupState, FreeIpaCleanupEvent> getEdgeConfig() {
        return EDGE_CONFIG;
    }

    @Override
    public FreeIpaCleanupEvent[] getEvents() {
        return FreeIpaCleanupEvent.values();
    }

    @Override
    public FreeIpaCleanupEvent[] getInitEvents() {
        return FREEIPA_INIT_EVENTS;
    }

    @Override
    public String getDisplayName() {
        return "Cleanup FreeIPA";
    }

    @Override
    public FreeIpaCleanupEvent getRetryableEvent() {
        return EDGE_CONFIG.getFailureHandled();
    }
}


text:
package org.supercsv.benchmark;

import java.io.FileReader;

import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.supercsv.benchmark.cellprocessor.ParseIconColour;
import org.supercsv.benchmark.cellprocessor.ParseStopType;
import org.supercsv.benchmark.cellprocessor.ParseStopTypeAndName;
import org.supercsv.benchmark.model.TransportLocation;
import org.supercsv.benchmark.model.TransportLocationStrings;
import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ParseDouble;
import org.supercsv.cellprocessor.constraint.NotNull;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.prefs.CsvPreference;

import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;

/**
 * Benchmarks each of the Super CSV readers. The CSV file is the first 50,000
 * rows of a file free for download from the Guardian newspaper website
 * (http://www.guardian.co.uk/news/datablog/2010/sep/27/uk-transport-national
 * -public-data-repository#data). The existing header was replaced with a
 * CsvBeanReader-compatible header for convenience. The file contains no
 * embedded newlines.
 *
 * @author James Bassett
 */
@BenchmarkMethodChart(filePrefix = "StandardCsvReadingBenchmark")
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class StandardCsvReadingBenchmarkTest extends AbstractCsvReadingBenchmark {

	private static final CsvPreference PREFS = new CsvPreference.Builder(
			CsvPreference.STANDARD_PREFERENCE).build();

	// CSV file with 50,001 lines (including header)
	private static final String CSV_FILE = "Britain's transport infrastructure.csv";

	public static final CellProcessor[] PROCESSORS = { new NotNull(), // atcoCode
			new NotNull(new ParseDouble()), // easting
			new NotNull(new ParseDouble()), // northing
			new NotNull(new ParseDouble()), // longitude
			new NotNull(new ParseDouble()), // latitude
			new NotNull(), // commonName
			new Optional(), // identifier
			new NotNull(), // direction
			new NotNull(), // street
			new Optional(), // landmark
			new NotNull(), // natGazId
			new Optional(), // natGazLocality
			new NotNull(new ParseStopType()), // stopType
			new NotNull(new ParseStopTypeAndName()), // stopTypeAndName
			new NotNull(new ParseIconColour()), // iconColour
	};

	// the number of data rows to read (max possible is 50,000)
	private static final int ROWS = 50000;

	/**
	 * Times CsvListReader.
	 */
	@Test
	public void testCsvListReader() throws Exception {
		timeCsvListReader(new FileReader(CSV_FILE), PREFS, ROWS);
	}

	/**
	 * Times CsvListReader using processors.
	 */
	@Test
	public void testCsvListReaderUsingProcessors() throws Exception {
		timeCsvListReaderUsingProcessors(new FileReader(CSV_FILE), PREFS,
				PROCESSORS, ROWS);
	}

	/**
	 * Times CsvMapReader.
	 */
	@Test
	public void testCsvMapReader() throws Exception {
		timeCsvMapReader(new FileReader(CSV_FILE), PREFS, ROWS);
	}

	/**
	 * Times CsvMapReader using processors.
	 */
	@Test
	public void testCsvMapReaderUsingProcessors() throws Exception {
		timeCsvMapReaderUsingProcessors(new FileReader(CSV_FILE), PREFS,
				PROCESSORS, ROWS);
	}

	/**
	 * Times CsvBeanReader.
	 */
	@Test
	public void testCsvBeanReader() throws Exception {
		timeCsvBeanReader(new FileReader(CSV_FILE), PREFS,
				TransportLocationStrings.class, ROWS);
	}

	/**
	 * Times CsvBeanReader using processors.
	 */
	@Test
	public void testCsvBeanReaderUsingProcessors() throws Exception {
		timeCsvBeanReaderUsingProcessors(new FileReader(CSV_FILE), PREFS,
				TransportLocation.class, PROCESSORS, ROWS);
	}

	/**
	 * Times CsvDozerBeanReader.
	 */
	@Test
	public void testCsvDozerBeanReader() throws Exception {
		timeCsvDozerBeanReader(new FileReader(CSV_FILE), PREFS,
				TransportLocationStrings.class, ROWS);
	}

	/**
	 * Times CsvDozerBeanReader using processors.
	 */
	@Test
	public void testCsvDozerBeanReaderUsingProcessors() throws Exception {
		timeCsvDozerBeanReaderUsingProcessors(new FileReader(CSV_FILE), PREFS,
				TransportLocation.class, PROCESSORS, ROWS);
	}

}


text:
#region Using directives
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Globalization;

using log4net;
using Sharp3D.Math.Core;

using treeDiM.Basics;
using treeDiM.StackBuilder.Basics;
using treeDiM.StackBuilder.Graphics;
using treeDiM.StackBuilder.Desktop.Properties;
#endregion

namespace treeDiM.StackBuilder.Desktop
{
    public partial class DockContentHAnalysis : DockContentView, IDrawingContainer
    {
        #region Constructors
        public DockContentHAnalysis()
            : base(null)
        {
            InitializeComponent();
        }
        public DockContentHAnalysis(IDocument document, AnalysisHetero analysis)
            : base(document)
        {
            Analysis = analysis;
            Analysis.AddListener(this);
            Solution = Analysis.Solution;

            InitializeComponent();
        }
        #endregion

        #region Form override
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (DesignMode) return;

            // --- window caption
            if (null != Analysis)
                Text = Analysis.Name + " - " + Analysis.ParentDocument.Name;

            // initialize drawing container
            graphCtrlSolution.DrawingContainer = this;
            graphCtrlSolution.Invalidate();

            FillGrid();
            UpdateGrid();
        }
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
            Document.RemoveView(this);
        }
        #endregion

        #region IItemListener implementation
        public override void Update(ItemBase item)
        {
        }
        public override void Kill(ItemBase item)
        {
            Close();
            if (null != Analysis)
                Analysis.RemoveListener(this);
        }
        #endregion

        #region IDrawingContainer
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            ViewerHSolution sv = new ViewerHSolution(Solution, SolItemIndex);
            sv.Draw(graphics, Transform3D.Identity);
        }
        #endregion

        #region Public properties
        public AnalysisHetero Analysis { get; set; } = null;
        public HSolution Solution { get; set; }
        #endregion
        #region Protected properties
        protected int GridFontSize => Settings.Default.GridFontSize;
        protected virtual string GridCaption => Resources.ID_LOAD;
        #endregion
        #region Private properties
        private int SolItemIndex { get; set; } = 0;
        #endregion

        #region Grid methods
        public virtual void FillGrid()
        {
            // clear grid
            gridSolutions.Rows.Clear();
            // border
            gridSolutions.BorderStyle = BorderStyle.FixedSingle;
            gridSolutions.ColumnsCount = 2;
            gridSolutions.Columns[0].Width = 100;
            gridSolutions.FixedColumns = 1;
        }
        public virtual void UpdateGrid()
        {
            try
            {
                // sanity check
                if (gridSolutions.ColumnsCount < 2)
                    return;
                // remove all existing rows
                gridSolutions.Rows.Clear();
                // *** IViews
                // caption header
                DevAge.Drawing.VisualElements.RowHeader veHeaderCaption = new DevAge.Drawing.VisualElements.RowHeader()
                {
                    BackColor = Color.SteelBlue,
                    Border = DevAge.Drawing.RectangleBorder.NoBorder
                };
                SourceGrid.Cells.Views.RowHeader captionHeader = new SourceGrid.Cells.Views.RowHeader
                {
                    Background = veHeaderCaption,
                    ForeColor = Color.Black,
                    Font = new Font("Arial", GridFontSize+2, FontStyle.Bold),
                    TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter
                };
                SourceGrid.Cells.Views.RowHeader captionHeader2 = new SourceGrid.Cells.Views.RowHeader
                {
                    Background = veHeaderCaption,
                    ForeColor = Color.Black,
                    Font = new Font("Arial", GridFontSize, FontStyle.Regular),
                    TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter
                };
                // viewRowHeader
                DevAge.Drawing.VisualElements.RowHeader backHeader = new DevAge.Drawing.VisualElements.RowHeader()
                {
                    BackColor = Color.LightGray,
                    Border = DevAge.Drawing.RectangleBorder.NoBorder
                };
                SourceGrid.Cells.Views.RowHeader viewRowHeader = new SourceGrid.Cells.Views.RowHeader
                {
                    Background = backHeader,
                    ForeColor = Color.Black,
                    Font = new Font("Arial", GridFontSize, FontStyle.Regular)
                };
                // viewNormal
                CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);
                // ***

                int iRow = -1;
                // ### sol items : begin
                int solItemIndex = 0;
                foreach (var solItem in Solution.SolItems)
                {
                    gridSolutions.Rows.Insert(++iRow);
                    var rowHeader = new SourceGrid.Cells.RowHeader(string.Format(Resources.ID_PALLET_NUMBER, solItemIndex))
                    {
                        ColumnSpan = 2,
                        View = captionHeader
                    };
                    gridSolutions[iRow, 0] = rowHeader;

                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_ITEMS)
                    {
                        ColumnSpan = 2,
                        View = captionHeader2
                    };
                    gridSolutions[iRow, 0] = rowHeader;

                    var dictNameCount = solItem.SolutionItems;
                    foreach (int containedItemIndex in dictNameCount.Keys)
                    {
                        // name
                        string name = string.Empty;
                        if (Analysis.ContentTypeByIndex(containedItemIndex) is Packable packable)
                            name = packable.Name;
                        // count
                        int count = dictNameCount[containedItemIndex];

                        if (count > 0)
                        {
                            gridSolutions.Rows.Insert(++iRow);
                            var itemHeader = new SourceGrid.Cells.RowHeader(name)
                            {
                                View = viewRowHeader
                            };
                            gridSolutions[iRow, 0] = itemHeader;
                            gridSolutions[iRow, 1] = new SourceGrid.Cells.Cell($"{count}");
                        }
                    }
                    // pallet data header
                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_PALLETDATA)
                    {
                        ColumnSpan = 2,
                        View = captionHeader2
                    };
                    gridSolutions[iRow, 0] = rowHeader;
                    // ***
                    // outer dimensions
                    BBox3D bboxGlobal = Solution.BBoxGlobal(solItemIndex);
                    // ---
                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(
                        string.Format(Resources.ID_OUTERDIMENSIONS, UnitsManager.LengthUnitString))
                    {
                        View = viewRowHeader
                    };
                    gridSolutions[iRow, 0] = rowHeader;
                    gridSolutions[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture
                        , "{0:0.#} x {1:0.#} x {2:0.#}"
                        , bboxGlobal.Length, bboxGlobal.Width, bboxGlobal.Height));
                    // load dimensions
                    BBox3D bboxLoad = Solution.BBoxLoad(solItemIndex);
                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(
                        string.Format(Resources.ID_LOADDIMENSIONS, UnitsManager.LengthUnitString))
                    {
                        View = viewRowHeader
                    };
                    gridSolutions[iRow, 0] = rowHeader;
                    gridSolutions[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture
                        , "{0:0.#} x {1:0.#} x {2:0.#}"
                        , bboxLoad.Length, bboxLoad.Width, bboxLoad.Height));
                    // ***
                    // ***
                    // load weight
                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(
                        string.Format(Resources.ID_LOADWEIGHT_WU, UnitsManager.MassUnitString))
                    {
                        View = viewRowHeader
                    };
                    gridSolutions[iRow, 0] = rowHeader;
                    gridSolutions[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture, "{0:0.#}", Solution.LoadWeight(solItemIndex)));

                    // total weight
                    gridSolutions.Rows.Insert(++iRow);
                    rowHeader = new SourceGrid.Cells.RowHeader(
                        string.Format(Resources.ID_PALLETWEIGHT_WU, UnitsManager.MassUnitString))
                    {
                        View = viewRowHeader
                    };
                    gridSolutions[iRow, 0] = rowHeader;
                    gridSolutions[iRow, 1] = new SourceGrid.Cells.Cell(
                        string.Format(CultureInfo.InvariantCulture
                        , "{0:0.#}"
                        , Solution.Weight(solItemIndex)));
                    // ***
                    // increment sol item index
                    ++solItemIndex;
                }
                // ### sol items : end
                gridSolutions.AutoSizeCells();
                gridSolutions.AutoStretchColumnsToFitWidth = true;
                gridSolutions.Invalidate();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        #endregion

        #region Event handlers
        private void OnSolItemIndexUp(object sender, EventArgs e)
        {
            try
            {
                if (null == Solution) return;
                if (SolItemIndex < Solution.SolItemCount - 1)
                    SolItemIndex = SolItemIndex + 1;
                graphCtrlSolution.Invalidate();
                UpdateSolItemIndexButtons();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        private void OnSolItemIndexDown(object sender, EventArgs e)
        {
            try
            {
                if (null == Solution) return;
                if (SolItemIndex > 0)
                    SolItemIndex = SolItemIndex - 1;
                graphCtrlSolution.Invalidate();
                UpdateSolItemIndexButtons();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        private void OnBack(object sender, EventArgs e)
        {
            // close this form
            Close();
            // call edit analysis
            if (null != Document && null != Solution)
                Document.EditAnalysis(Solution.Analysis);
            else
                _log.Error("Solution or Document must not be null");

        }
        private void OnGenerateReport(object sender, EventArgs e)
        {
            FormMain.GenerateReport(Analysis);
        }
        private void OnGenerateExport(object sender, EventArgs e)
        {
            ToolStripButton tsb = sender as ToolStripButton;
            string extension = string.Empty;
            switch (tsb.Name)
            {
                case "toolStripButtonExportXML": extension = "xml"; break;
                case "toolStripButtonExportCSV": extension = "csv"; break;
                case "toolStripButtonExportDAE": extension = "dae"; break;
                default: break;
            }
            FormMain.GenerateExport(Analysis, extension);
        }
        #endregion

        #region Helpers
        private void UpdateSolItemIndexButtons()
        {
            bnSolItemIndexDown.Enabled = SolItemIndex > 0;
            bnSolItemIndexUp.Enabled = SolItemIndex < Solution.SolItemCount - 1;
        }
        #endregion

        #region Data members
        private static ILog _log = LogManager.GetLogger(typeof(DockContentHAnalysis));
        #endregion
    }
}


text:
"use strict";

const Expression = require("./expression");
const KIND = "silent";

/**
 * Avoids to show/log warnings & notices from the inner expression
 * @constructor Silent
 * @memberOf module:php-parser
 * @extends {Expression}
 * @property {Expression} expr
 */
module.exports = Expression.extends(
  KIND,
  function Silent(expr, docs, location) {
    Expression.apply(this, [KIND, docs, location]);
    this.expr = expr;
  }
);


text:
.row {
    margin-top: 10px;
    margin-bottom: 10px;
}

.panel-heading button {
    margin-left: 20px;
}

.folder {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


text:
<?php
$username = "username";
$password = "password";
$hostname = "localhost";

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");

//selecting the database
$selected = mysql_select_db("darpan",$dbhandle)
  or die("Could not select darpan");

?>


text:
(function($) {
    "use strict"; // Start of use strict

    var $d = $('header').height() - 160,
        $w = $(window),
        $b = $("body");

    $(".search-form-q").typeahead({
        minLength: 2,
        items: 100,
        autoSelect: false,
        source: function(query, process) {
            $.get($(".search-form-q").data("endpoint"), {
                    "q": query
                })
                .done(function(data) {
                    process(data);
                })
        },
        matcher: function() {
            return true;
        },
        highlighter: function(instance) {
            return instance;
        },
        updater: function(instance) {
            return $(instance).data("sugg_text")
        },
        sorter: function(items) {
            return items
        },
        afterSelect: function(item) {
            var form = $(".search-form-q").closest("form");
            form.find("input[name=is_exact]").val("on");

            form.submit();
        }
    });

    // jQuery for page scrolling feature - requires jQuery Easing plugin
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($anchor.attr('href')).offset().top - 50)
        }, 1250, 'easeInOutExpo');
        event.preventDefault();
    });

    function adjust_margin() {
        $('.homepage .first-after-intro').css('margin-top', $('header').height());
    }

    function toggle_header() {
        $b.toggleClass('fixed-header', $w.scrollTop() >= $d);
        $b.toggleClass('not-fixed-header', $w.scrollTop() < $d);
    }

    function bigMap() {
        $(".bigMapPage #bigMap, .bigMapPage .pre-scrollable").height($(window).height()-360);
    }

    $w.on("scroll", function() {
        toggle_header();
    });

    $w.on("resize", function() {
        toggle_header();
        adjust_margin();
        bigMap();
    });

    $( document ).ready(function() {
        $(".overInfo h3").fitText(
        1.4, {
            minFontSize: '30px',
            maxFontSize: '65px'
        }
    );

        $(".overInfo h4, .overInfo h1").fitText(
            1.4, {
                minFontSize: '18px',
                maxFontSize: '24px'
            }
        );
    });

    adjust_margin();
    bigMap();

    // Closes the Responsive Menu on Menu Item Click
    $('.navbar-collapse ul li a').click(function() {
        $('.navbar-toggle:visible').click();
    });

    $('.btn.mortgage_registered').on('click', function(e) {
            $(this).closest('tr').next('tr').find('.mortgage-cell').toggleClass("show");
        e.preventDefault();
    });

    $('#navbar-collapse-1').on('show.bs.collapse', function () {
       $('#navbar-collapse-1').addClass("show");
    })
    $('#navbar-collapse-1').on('hide.bs.collapse', function () {
       $('#navbar-collapse-1').removeClass("show");
    })

    // Fit Text Plugin for Main Header

    $(window).on('map:init', function (e) {
        var detail = e.originalEvent ?
                     e.originalEvent.detail : e.detail,
            data = $(".geojson-container").data("geojson"),
            markers = new L.MarkerClusterGroup(),
            mapbox = new L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
                maxZoom: 18,
                id: 'mapbox.streets',
                accessToken: 'pk.eyJ1IjoiZGNoYXBsaW5za3kiLCJhIjoiY2p3N3Z0dnozMGUzdDQ2bzdrMm5vZXJmdSJ9.rc9StX2ALGB5TR2e6FGEjA'
            }),

            mapbox_sat = new L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
                maxZoom: 18,
                id: 'mapbox.streets-satellite',
                accessToken: 'pk.eyJ1IjoiZGNoYXBsaW5za3kiLCJhIjoiY2p3N3Z0dnozMGUzdDQ2bzdrMm5vZXJmdSJ9.rc9StX2ALGB5TR2e6FGEjA'
            }),

            cadastre = new L.tileLayer.wms('https://map.land.gov.ua/geowebcache/service/wms', {
                maxZoom: 22,
                layers: 'kadastr',
                format: 'image/png',
                transparent: true,
                hash: "cadastre",
                overlay: true
            });

        for (var i = data.length - 1; i >= 0; i--) {
            markers.addLayer(
                new L.Marker(data[i].coords, {
                    "title": data[i].title
                }
            ).bindPopup([
                    '',
                    data[i].title,
                    '
',
                    data[i].commercial_name,
                    '
',
                    'Посилання'
                ].join("")
            ));
        };

        detail.map.addLayer(markers);
        detail.map.addLayer(mapbox);

        detail.map.layerscontrol.addBaseLayer(mapbox, "Карта");
        detail.map.layerscontrol.addBaseLayer(mapbox_sat, "Супутник");
        detail.map.layerscontrol.addOverlay(cadastre, "Кадастр");

        detail.map.fitBounds(markers)
    });
})(jQuery); // End of use strict


text:
class CFrame
{
public:
	CFrame();
	CFrame(int _x, int _y, int _width, int _height);
	~CFrame();

	void Render();

	CPoint2D Position;

	int Width;
	int Height;
};


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.Text.Operations;

namespace Microsoft.R.Components.Test.Fakes.Undo {
    /// <summary>
    /// Represents an empty <see cref="IMergeTextUndoTransactionPolicy"/> implementation, which disallows merging between transactions.
    /// </summary>
    [ExcludeFromCodeCoverage]
    public sealed class NullMergeUndoTransactionPolicy : IMergeTextUndoTransactionPolicy {
        #region Private Fields

        private static NullMergeUndoTransactionPolicy _instance;

        #endregion

        #region Private Constructor

        private NullMergeUndoTransactionPolicy() {
        }

        #endregion

        /// <summary>
        /// Gets the <see cref="NullMergeUndoTransactionPolicy"/> object.
        /// </summary>
        public static IMergeTextUndoTransactionPolicy Instance => _instance ?? (_instance = new NullMergeUndoTransactionPolicy());

        public bool TestCompatiblePolicy(IMergeTextUndoTransactionPolicy other) {
            return false;
        }

        public bool CanMerge(ITextUndoTransaction newerTransaction, ITextUndoTransaction olderTransaction) {
            return false;
        }

        public void PerformTransactionMerge(ITextUndoTransaction existingTransaction, ITextUndoTransaction newTransaction) {
            throw new InvalidOperationException("Strings.NullMergePolicyCannotMerge");
        }
    }
}


text:
#include "uv.h"
#include "task.h"
#include <stdio.h>
#include <stdlib.h>

static int connect_cb_called;
static int close_cb_called;

static uv_connect_t connect_req;
static uv_timer_t timer;
static uv_tcp_t conn;

static void connect_cb(uv_connect_t* req, int status);
static void timer_cb(uv_timer_t* handle, int status);
static void close_cb(uv_handle_t* handle);

static void connect_cb(uv_connect_t* req, int status) {
  ASSERT(req == &connect_req);
  ASSERT(status == -1);
  connect_cb_called++;
}

static void timer_cb(uv_timer_t* handle, int status) {
  ASSERT(handle == &timer);
  uv_close((uv_handle_t*)&conn, close_cb);
  uv_close((uv_handle_t*)&timer, close_cb);
}

static void close_cb(uv_handle_t* handle) {
  ASSERT(handle == (uv_handle_t*)&conn || handle == (uv_handle_t*)&timer);
  close_cb_called++;
}

/* Verify that connecting to an unreachable address or port doesn't hang
 * the event loop.
 */
TEST_IMPL(tcp_connect_timeout) {
  struct sockaddr_in addr;
  int r;

  addr = uv_ip4_addr("8.8.8.8", 9999);

  r = uv_timer_init(uv_default_loop(), &timer);
  ASSERT(r == 0);

  r = uv_timer_start(&timer, timer_cb, 50, 0);
  ASSERT(r == 0);

  r = uv_tcp_init(uv_default_loop(), &conn);
  ASSERT(r == 0);

  r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb);
  ASSERT(r == 0);

  r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
  ASSERT(r == 0);

  MAKE_VALGRIND_HAPPY();
  return 0;
}


text:
package soyjs

import (
	"errors"
	"io"

	"github.com/robfig/soy/soymsg"
	"github.com/robfig/soy/template"
)

// Options for js source generation.
// When no Formatter is defined, soyjs
// will default to ES5Formatter from exec.go
type Options struct {
	Messages  soymsg.Bundle
	Formatter JSFormatter
}

// Generator provides an interface to a template registry capable of generating
// javascript to execute the embodied templates.
// The generated javascript requires lib/soyutils.js to already have been loaded.
type Generator struct {
	registry *template.Registry
}

// NewGenerator returns a new javascript generator capable of producing
// javascript for the templates contained in the given registry.
func NewGenerator(registry *template.Registry) *Generator {
	return &Generator{registry}
}

var ErrNotFound = errors.New("file not found")

// WriteFile generates javascript corresponding to the Soy file of the given name.
func (gen *Generator) WriteFile(out io.Writer, filename string) error {
	for _, soyfile := range gen.registry.SoyFiles {
		if soyfile.Name == filename {
			return Write(out, soyfile, Options{})
		}
	}
	return ErrNotFound
}


text:
package org.springframework.http.client;

public class NoOutputStreamingStreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {

	@Override
	protected ClientHttpRequestFactory createRequestFactory() {
		SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
		factory.setBufferRequestBody(false);
		factory.setOutputStreaming(false);
		return factory;
	}
}


text:
package org.qi4j.index.rdf.qi66;

import org.qi4j.api.property.Property;

public interface HasName
{
    Property<String> name();
}


text:
package knative

import (
	"bytes"
	"context"
	"fmt"
	"io"
	"sync"
	"time"

	"golang.org/x/sync/errgroup"

	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/watch"
	"knative.dev/func/k8s"
)

// GetKServiceLogs will get logs of Knative service.
//
// It will do so by gathering logs of user-container of all affiliated pods.
// In addition, filtering on image can be done so only logs for given image are logged.
// The image must be the digest format since pods of Knative service use it.
//
// This function runs as long as the passed context is active (i.e. it is required cancel the context to stop log gathering).
func GetKServiceLogs(ctx context.Context, namespace, kServiceName, image string, since *time.Time, out io.Writer) error {
	client, namespace, err := k8s.NewClientAndResolvedNamespace(namespace)
	if err != nil {
		return fmt.Errorf("cannot create k8s client: %w", err)
	}

	pods := client.CoreV1().Pods(namespace)

	podListOpts := metav1.ListOptions{
		Watch:         true,
		LabelSelector: fmt.Sprintf("serving.knative.dev/service=%s", kServiceName),
	}

	w, err := pods.Watch(ctx, podListOpts)
	if err != nil {
		return fmt.Errorf("cannot create watch: %w", err)
	}
	defer w.Stop()

	beingProcessed := make(map[string]bool)
	var beingProcessedMu sync.Mutex

	copyLogs := func(pod corev1.Pod) error {
		defer func() {
			beingProcessedMu.Lock()
			delete(beingProcessed, pod.Name)
			beingProcessedMu.Unlock()
		}()
		podLogOpts := corev1.PodLogOptions{
			Container: "user-container",
			Follow:    true,
		}
		if since != nil {
			sinceTime := metav1.NewTime(*since)
			podLogOpts.SinceTime = &sinceTime
		}
		req := client.CoreV1().Pods(namespace).GetLogs(pod.Name, &podLogOpts)

		r, e := req.Stream(ctx)
		if e != nil {
			return fmt.Errorf("cannot get stream: %w", e)
		}
		defer r.Close()
		_, e = io.Copy(out, r)
		if e != nil {
			return fmt.Errorf("error copying logs: %w", e)
		}
		return nil
	}

	mayReadLogs := func(pod corev1.Pod) bool {
		for _, status := range pod.Status.ContainerStatuses {
			if status.Name == "user-container" {
				return status.State.Running != nil || status.State.Terminated != nil
			}
		}
		return false
	}

	getImage := func(pod corev1.Pod) string {
		for _, ctr := range pod.Spec.Containers {
			if ctr.Name == "user-container" {
				return ctr.Image
			}
		}
		return ""
	}

	var eg errgroup.Group

	for event := range w.ResultChan() {
		if event.Type == watch.Modified || event.Type == watch.Added {
			pod := *event.Object.(*corev1.Pod)

			beingProcessedMu.Lock()
			_, loggingAlready := beingProcessed[pod.Name]
			beingProcessedMu.Unlock()

			if !loggingAlready && (image == "" || image == getImage(pod)) && mayReadLogs(pod) {

				beingProcessedMu.Lock()
				beingProcessed[pod.Name] = true
				beingProcessedMu.Unlock()

				eg.Go(func() error { return copyLogs(pod) })
			}
		}
	}

	err = eg.Wait()
	if err != nil {
		return fmt.Errorf("error while gathering logs: %w", err)
	}
	return nil
}

type SynchronizedBuffer struct {
	b  bytes.Buffer
	mu sync.Mutex
}

func (b *SynchronizedBuffer) String() string {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.b.String()
}

func (b *SynchronizedBuffer) Write(p []byte) (n int, err error) {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.b.Write(p)
}

func (b *SynchronizedBuffer) Read(p []byte) (n int, err error) {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.b.Read(p)
}

func (b *SynchronizedBuffer) Reset() {
	b.mu.Lock()
	defer b.mu.Unlock()
	b.b.Reset()
}


text:
package framework.qrcode;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import framework.observer.Bundle;
import framework.observer.Handler;
import framework.observer.Message;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;

/**
 * 實作 QRCode 圖形產生器
 *
 * require jar
 * https://mvnrepository.com/artifact/com.google.zxing/core
 * https://mvnrepository.com/artifact/com.google.zxing/javase/3.4.1
 *
 * QRCode Image Generator
 */
public class QRCodeService {

    private final String exten = "png"; // use png for transparent background
    private final HashMap<EncodeHintType, Object> hints = new HashMap<>();

    private QRCodeService(String character, ErrorCorrectionLevel level, Integer margin) {
        hints.put(EncodeHintType.CHARACTER_SET, character);
        hints.put(EncodeHintType.ERROR_CORRECTION, level);
        hints.put(EncodeHintType.MARGIN, margin);
    }

    /**
     * QRCode image to base64 string
     * base64 header -> data:image/png;base64,[base64string]
     * 主要用於傳遞到前端藉由 base64 資源路徑圖片呈現
     */
    public String toBase64String(String content, int width, int height) {
        String result = null;
        try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
            BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height);
            BufferedImage bi = MatrixToImageWriter.toBufferedImage(bitMatrix);
            ImageIO.write(bi, exten, baos);
            result = Base64.getEncoder().withoutPadding().encodeToString(baos.toByteArray());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * QRCode image to output stream
     * 使用時要注意 HTTP Response 的 Header 要是 "Content-Type":"image/png;charset=UTF-8"
     */
    public void writeToStream(String content, OutputStream stream, int width, int height, Handler handler) throws WriterException, IOException {
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
        MatrixToImageWriter.writeToStream(bitMatrix, exten, stream);
        {
            if(null != handler) {
                Bundle b = new Bundle();
                b.putString("status", "done");
                Message m = handler.obtainMessage();
                m.setData(b);
                m.sendToTarget();
            }
        }
    }

    /**
     * QRCode image to buffered image
     */
    public BufferedImage toBufferedImage(String content, int width, int height) throws WriterException {
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
        return MatrixToImageWriter.toBufferedImage(bitMatrix);
    }

    /**
     * QRCode image to disk file
     */
    public void createImageFile(String content, String path, int width, int height) throws WriterException, IOException {
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
        // toPath() required jdk 1.7+
        MatrixToImageWriter.writeToPath(bitMatrix, exten, new File(path).toPath());
    }

    public static class Builder {

        private final HashMap<EncodeHintType, Object> hints = new HashMap<>();

        public QRCodeService.Builder setCharacter(String character) {
            if(null != character) hints.put(EncodeHintType.CHARACTER_SET, character);
            return this;
        }

        public QRCodeService.Builder setErrorCorrection(ErrorCorrectionLevel level) {
            if(null != level) hints.put(EncodeHintType.ERROR_CORRECTION, level);
            return this;
        }

        public QRCodeService.Builder setMargin(Integer pixel) {
            if(null != pixel) hints.put(EncodeHintType.MARGIN, pixel);
            return this;
        }

        public QRCodeService build() {
            if(!hints.containsKey(EncodeHintType.CHARACTER_SET)) hints.put(EncodeHintType.CHARACTER_SET, StandardCharsets.UTF_8.name());
            if(!hints.containsKey(EncodeHintType.ERROR_CORRECTION)) hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
            if(!hints.containsKey(EncodeHintType.MARGIN)) hints.put(EncodeHintType.MARGIN, 0);
            return new QRCodeService(
                    (String) hints.get(EncodeHintType.CHARACTER_SET),
                    (ErrorCorrectionLevel) hints.get(EncodeHintType.ERROR_CORRECTION),
                    (Integer) hints.get(EncodeHintType.MARGIN)
            );
        }

    }

}


text:
title: Custom Text Source
page_title: Custom Text Source | RadSpell for ASP.NET AJAX Documentation
description: Custom Text Source
slug: spell/configuration/custom-text-source
tags: custom,text,source
published: True
position: 2
---

# Custom Text Source

**RadSpell** is not limited to spellchecking HTML elements only. You can also define a custom text source to provide text for spellchecking. Using a custom text source allows you to spell check virtually anything on the web page that you can access programmatically. See the [live demo](http://demos.telerik.com/aspnet-ajax/Spell/Examples/TextSource/DefaultCS.aspx) for an example of spell checking a Flash object.

To implement spellchecking for text sources other than HTML, define a JavaScript object with two methods, get_text() and set_text(text), and then use the set_textSource(textSource) method of the RadSpell client-side object.

````JavaScript
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
   <script type="text/javascript">
   function MySpellSource()
   {
	  this.get_text = function()
	  {
		  return "colourful mistakrn texr";
	  }
	  this.set_text = function(text)
	  {
		  alert("The corrected text is: " + text);
	  }
   }

   function spellCheck()
   {
	   var spell = $find('<%= RadSpell1.ClientID %>');
	   spell.set_textSource(new MySpellSource());
   }
   </script>
</telerik:RadCodeBlock>
````

````ASP.NET
<body onload="setTimeout(function() { spellCheck(); }, 100);">
   <form id="form2" runat="server">
	   <asp:ScriptManager ID="ScriptManager1" runat="server" />
	   <div>
		   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
		   <telerik:RadSpell ID="RadSpell1" runat="server" ControlToCheck="TextBox1" />
	   </div>
   </form>
</body>
````

# See Also

 * [Live Demo: Custom Text Source](http://demos.telerik.com/aspnet-ajax/Spell/Examples/TextSource/DefaultCS.aspx)