text:
package com.jayway.android.robotium.solo;

import java.util.ArrayList;

import android.app.Activity;
import android.app.Instrumentation.ActivityMonitor;
import android.content.pm.ActivityInfo;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.CompoundButton;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.SlidingDrawer;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.ToggleButton;

public interface ISolo {

	public final static int LANDSCAPE = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // 0
	public final static int PORTRAIT = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; // 1
	public final static int RIGHT = KeyEvent.KEYCODE_DPAD_RIGHT;
	public final static int LEFT = KeyEvent.KEYCODE_DPAD_LEFT;
	public final static int UP = KeyEvent.KEYCODE_DPAD_UP;
	public final static int DOWN = KeyEvent.KEYCODE_DPAD_DOWN;
	public final static int ENTER = KeyEvent.KEYCODE_ENTER;
	public final static int MENU = KeyEvent.KEYCODE_MENU;
	public final static int DELETE = KeyEvent.KEYCODE_DEL;
	public final static int CLOSED = 0;
	public final static int OPENED = 1;

	/**
	 * Returns the ActivityMonitor used by Robotium.
	 *
	 * @return the ActivityMonitor used by Robotium
	 */

	public abstract ActivityMonitor getActivityMonitor();

	/**
	 * Returns an ArrayList of all the View objects located in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link View} objects located in the focused window
	 *
	 */

	public abstract ArrayList<View> getViews();

	/**
	 * Returns an ArrayList of the View objects contained in the parent View.
	 *
	 * @param parent the parent view from which to return the views
	 * @return an {@code ArrayList} of the {@link View} objects contained in the given {@code View}
	 *
	 */

	public abstract ArrayList<View> getViews(View parent);

	/**
	 * Returns the absolute top parent View for a given View.
	 *
	 * @param view the {@link View} whose top parent is requested
	 * @return the top parent {@link View}
	 *
	 */

	public abstract View getTopParent(View view);

	/**
	 * Clears the value of an EditText.
	 *
	 * @param index the index of the {@link EditText} that should be cleared. 0 if only one is available
	 *
	 */

	public abstract void clearEditText(int index);

	/**
	 * Clears the value of an EditText.
	 *
	 * @param editText the {@link EditText} that should be cleared
	 *
	 */

	public abstract void clearEditText(EditText editText);

	/**
	 * Waits for a text to be shown. Default timeout is 20 seconds.
	 *
	 * @param text the text to wait for
	 * @return {@code true} if text is shown and {@code false} if it is not shown before the timeout
	 *
	 */

	public abstract boolean waitForText(String text);

	/**
	 * Waits for a text to be shown.
	 *
	 * @param text the text to wait for
	 * @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches
	 * @param timeout the the amount of time in milliseconds to wait
	 * @return {@code true} if text is shown and {@code false} if it is not shown before the timeout
	 *
	 */

	public abstract boolean waitForText(String text,
			int minimumNumberOfMatches, long timeout);

	/**
	 * Waits for a text to be shown.
	 *
	 * @param text the text to wait for
	 * @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches
	 * @param timeout the the amount of time in milliseconds to wait
	 * @param scroll {@code true} if scrolling should be performed
	 * @return {@code true} if text is shown and {@code false} if it is not shown before the timeout
	 *
	 */

	public abstract boolean waitForText(String text,
			int minimumNumberOfMatches, long timeout, boolean scroll);

	/**
	 * Waits for a View to be shown. Default timeout is 20 seconds.
	 *
	 * @param viewClass the {@link View} class to wait for
	 */

	public abstract <T extends View> boolean waitForView(
			final Class<T> viewClass);

	/**
	 * Waits for a View to be shown.
	 *
	 * @param viewClass the {@link View} class to wait for
	 * @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches
	 * @param timeout the amount of time in milliseconds to wait
	 * @return {@code true} if view is shown and {@code false} if it is not shown before the timeout
	 */

	public abstract <T extends View> boolean waitForView(
			final Class<T> viewClass, final int minimumNumberOfMatches,
			final int timeout);

	/**
	 * Waits for a View to be shown.
	 *
	 * @param viewClass the {@link View} class to wait for
	 * @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches
	 * @param timeout the amount of time in milliseconds to wait
	 * @param scroll {@code true} if scrolling should be performed
	 * @return {@code true} if the {@link View} is shown and {@code false} if it is not shown before the timeout
	 */

	public abstract <T extends View> boolean waitForView(
			final Class<T> viewClass, final int minimumNumberOfMatches,
			final int timeout, final boolean scroll);

	/**
	 * Searches for a text string in the EditText objects currently shown and returns true if found. Will automatically scroll when needed.
	 *
	 * @param text the text to search for
	 * @return {@code true} if an {@link EditText} with the given text is found or {@code false} if it is not found
	 *
	 */

	public abstract boolean searchEditText(String text);

	/**
	 * Searches for a Button with the given text string and returns true if at least one Button
	 * is found. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @return {@code true} if a {@link Button} with the given text is found and {@code false} if it is not found
	 *
	 */

	public abstract boolean searchButton(String text);

	/**
	 * Searches for a Button with the given text string and returns true if at least one Button
	 * is found. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param onlyVisible {@code true} if only {@link Button} visible on the screen should be searched
	 * @return {@code true} if a {@link Button} with the given text is found and {@code false} if it is not found
	 *
	 */

	public abstract boolean searchButton(String text, boolean onlyVisible);

	/**
	 * Searches for a ToggleButton with the given text string and returns {@code true} if at least one ToggleButton
	 * is found. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @return {@code true} if a {@link ToggleButton} with the given text is found and {@code false} if it is not found
	 *
	 */

	public abstract boolean searchToggleButton(String text);

	/**
	 * Searches for a Button with the given text string and returns {@code true} if the
	 * searched Button is found a given number of times. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @return {@code true} if a {@link Button} with the given text is found a given number of times and {@code false}
	 * if it is not found
	 *
	 */

	public abstract boolean searchButton(String text, int minimumNumberOfMatches);

	/**
	 * Searches for a Button with the given text string and returns {@code true} if the
	 * searched Button is found a given number of times. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @param onlyVisible {@code true} if only {@link Button} visible on the screen should be searched
	 * @return {@code true} if a {@link Button} with the given text is found a given number of times and {@code false}
	 * if it is not found
	 *
	 */

	public abstract boolean searchButton(String text,
			int minimumNumberOfMatches, boolean onlyVisible);

	/**
	 * Searches for a ToggleButton with the given text string and returns {@code true} if the
	 * searched ToggleButton is found a given number of times. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @return {@code true} if a {@link ToggleButton} with the given text is found a given number of times and {@code false}
	 * if it is not found
	 *
	 */

	public abstract boolean searchToggleButton(String text,
			int minimumNumberOfMatches);

	/**
	 * Searches for a text string and returns {@code true} if at least one item
	 * is found with the expected text. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @return {@code true} if the search string is found and {@code false} if it is not found
	 *
	 */

	public abstract boolean searchText(String text);

	/**
	 * Searches for a text string and returns {@code true} if at least one item
	 * is found with the expected text. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param onlyVisible {@code true} if only texts visible on the screen should be searched
	 * @return {@code true} if the search string is found and {@code false} if it is not found
	 *
	 */

	public abstract boolean searchText(String text, boolean onlyVisible);

	/**
	 * Searches for a text string and returns {@code true} if the searched text is found a given
	 * number of times. Will automatically scroll when needed.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @return {@code true} if text string is found a given number of times and {@code false} if the text string
	 * is not found
	 *
	 */

	public abstract boolean searchText(String text, int minimumNumberOfMatches);

	/**
	 * Searches for a text string and returns {@code true} if the searched text is found a given
	 * number of times.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression.
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @param scroll {@code true} if scrolling should be performed
	 * @return {@code true} if text string is found a given number of times and {@code false} if the text string
	 * is not found
	 *
	 */

	public abstract boolean searchText(String text, int minimumNumberOfMatches,
			boolean scroll);

	/**
	 * Searches for a text string and returns {@code true} if the searched text is found a given
	 * number of times.
	 *
	 * @param text the text to search for. The parameter will be interpreted as a regular expression.
	 * @param minimumNumberOfMatches the minimum number of matches expected to be found. {@code 0} matches means that one or more
	 * matches are expected to be found
	 * @param scroll {@code true} if scrolling should be performed
	 * @param onlyVisible {@code true} if only texts visible on the screen should be searched
	 * @return {@code true} if text string is found a given number of times and {@code false} if the text string
	 * is not found
	 *
	 */

	public abstract boolean searchText(String text, int minimumNumberOfMatches,
			boolean scroll, boolean onlyVisible);

	/**
	 * Sets the Orientation (Landscape/Portrait) for the current activity.
	 *
	 * @param orientation the orientation to be set. Solo.{@link #LANDSCAPE} for landscape or
	 * Solo.{@link #PORTRAIT} for portrait.
	 *
	 */

	public abstract void setActivityOrientation(int orientation);

	/**
	 * Returns an ArrayList of all the opened/active activities.
	 *
	 * @return an ArrayList of all the opened/active activities
	 *
	 */

	public abstract ArrayList<Activity> getAllOpenedActivities();

	/**
	 * Returns the current Activity.
	 *
	 * @return the current Activity
	 *
	 */

	public abstract Activity getCurrentActivity();

	/**
	 * Asserts that the expected Activity is the currently active one.
	 *
	 * @param message the message that should be displayed if the assert fails
	 * @param name the name of the {@link Activity} that is expected to be active e.g. {@code "MyActivity"}
	 *
	 */

	public abstract void assertCurrentActivity(String message, String name);

	/**
	 * Asserts that the expected Activity is the currently active one.
	 *
	 * @param message the message that should be displayed if the assert fails
	 * @param expectedClass the {@code Class} object that is expected to be active e.g. {@code MyActivity.class}
	 *
	 */

	@SuppressWarnings("unchecked")
	public abstract void assertCurrentActivity(String message,
			Class expectedClass);

	/**
	 * Asserts that the expected Activity is the currently active one, with the possibility to
	 * verify that the expected Activity is a new instance of the Activity.
	 *
	 * @param message the message that should be displayed if the assert fails
	 * @param name the name of the activity that is expected to be active e.g. {@code "MyActivity"}
	 * @param isNewInstance {@code true} if the expected {@link Activity} is a new instance of the {@link Activity}
	 *
	 */

	public abstract void assertCurrentActivity(String message, String name,
			boolean isNewInstance);

	/**
	 * Asserts that the expected Activity is the currently active one, with the possibility to
	 * verify that the expected Activity is a new instance of the Activity.
	 *
	 * @param message the message that should be displayed if the assert fails
	 * @param expectedClass the {@code Class} object that is expected to be active e.g. {@code MyActivity.class}
	 * @param isNewInstance {@code true} if the expected {@link Activity} is a new instance of the {@link Activity}
	 *
	 */

	@SuppressWarnings("unchecked")
	public abstract void assertCurrentActivity(String message,
			Class expectedClass, boolean isNewInstance);

	/**
	 * Asserts that the available memory in the system is not low.
	 *
	 */

	public abstract void assertMemoryNotLow();

	/**
	 * Waits for a Dialog to close.
	 *
	 * @param timeout the amount of time in milliseconds to wait
	 * @return {@code true} if the {@link android.app.Dialog} is closed before the timeout and {@code false} if it is not closed
	 *
	 */

	public abstract boolean waitForDialogToClose(long timeout);

	/**
	 * Simulates pressing the hardware back key.
	 *
	 */

	public abstract void goBack();

	/**
	 * Clicks on a given coordinate on the screen.
	 *
	 * @param x the x coordinate
	 * @param y the y coordinate
	 *
	 */

	public abstract void clickOnScreen(float x, float y);

	/**
	 * Long clicks a given coordinate on the screen.
	 *
	 * @param x the x coordinate
	 * @param y the y coordinate
	 *
	 */

	public abstract void clickLongOnScreen(float x, float y);

	/**
	 * Long clicks a given coordinate on the screen for a given amount of time.
	 *
	 * @param x the x coordinate
	 * @param y the y coordinate
	 * @param time the amount of time to long click
	 *
	 */

	public abstract void clickLongOnScreen(float x, float y, int time);

	/**
	 * Clicks on a Button with a given text. Will automatically scroll when needed.
	 *
	 * @param name the name of the {@link Button} presented to the user. The parameter will be interpreted as a regular expression
	 *
	 */

	public abstract void clickOnButton(String name);

	/**
	 * Clicks on an ImageButton with a given index.
	 *
	 * @param index the index of the {@link ImageButton} to be clicked. 0 if only one is available
	 *
	 */

	public abstract void clickOnImageButton(int index);

	/**
	 * Clicks on a ToggleButton with a given text.
	 *
	 * @param name the name of the {@link ToggleButton} presented to the user. The parameter will be interpreted as a regular expression
	 *
	 */

	public abstract void clickOnToggleButton(String name);

	/**
	 * Clicks on a MenuItem with a given text.
	 * @param text the menu text that should be clicked on. The parameter will be interpreted as a regular expression
	 *
	 */

	public abstract void clickOnMenuItem(String text);

	/**
	 * Clicks on a MenuItem with a given text.
	 *
	 * @param text the menu text that should be clicked on. The parameter will be interpreted as a regular expression
	 * @param subMenu true if the menu item could be located in a sub menu
	 *
	 */

	public abstract void clickOnMenuItem(String text, boolean subMenu);

	/**
	 * Presses a MenuItem with a given index. Index {@code 0} is the first item in the
	 * first row, Index {@code 3} is the first item in the second row and
	 * index {@code 6} is the first item in the third row.
	 *
	 * @param index the index of the {@link android.view.MenuItem} to be pressed
	 *
	 */

	public abstract void pressMenuItem(int index);

	/**
	 * Presses a MenuItem with a given index. Supports three rows with a given amount
	 * of items. If itemsPerRow equals 5 then index 0 is the first item in the first row,
	 * index 5 is the first item in the second row and index 10 is the first item in the third row.
	 *
	 * @param index the index of the {@link android.view.MenuItem} to be pressed
	 * @param itemsPerRow the amount of menu items there are per row.
	 *
	 */

	public abstract void pressMenuItem(int index, int itemsPerRow);

	/**
	 * Presses on a Spinner (drop-down menu) item.
	 *
	 * @param spinnerIndex the index of the {@link Spinner} menu to be used
	 * @param itemIndex the index of the {@link Spinner} item to be pressed relative to the currently selected item
	 * A Negative number moves up on the {@link Spinner}, positive moves down
	 *
	 */

	public abstract void pressSpinnerItem(int spinnerIndex, int itemIndex);

	/**
	 * Clicks on a given View.
	 *
	 * @param view the {@link View} that should be clicked
	 *
	 */

	public abstract void clickOnView(View view);

	/**
	 * Long clicks on a given View.
	 *
	 * @param view the {@link View} that should be long clicked
	 *
	 */

	public abstract void clickLongOnView(View view);

	/**
	 * Long clicks on a given View for a given amount of time.
	 *
	 * @param view the {@link View} that should be long clicked
	 * @param time the amount of time to long click
	 *
	 */

	public abstract void clickLongOnView(View view, int time);

	/**
	 * Clicks on a View displaying a given
	 * text. Will automatically scroll when needed.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 *
	 */

	public abstract void clickOnText(String text);

	/**
	 * Clicks on a View displaying a given text. Will automatically scroll when needed.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 * @param match the match of the text that should be clicked
	 *
	 */

	public abstract void clickOnText(String text, int match);

	/**
	 * Clicks on a View displaying a given text.
	 *
	 * @param text the text that should be clicked on. The parameter will be interpreted as a regular expression
	 * @param match the match of the text that should be clicked
	 * @param scroll true if scrolling should be performed
	 *
	 */

	public abstract void clickOnText(String text, int match, boolean scroll);

	/**
	 * Long clicks on a given View. Will automatically scroll when needed. {@link #clickOnText(String)} can then be
	 * used to click on the context menu items that appear after the long click.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 *
	 */

	public abstract void clickLongOnText(String text);

	/**
	 * Long clicks on a given View. Will automatically scroll when needed. {@link #clickOnText(String)} can then be
	 * used to click on the context menu items that appear after the long click.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 * @param match the match of the text that should be clicked
	 *
	 */

	public abstract void clickLongOnText(String text, int match);

	/**
	 * Long clicks on a given View. {@link #clickOnText(String)} can then be
	 * used to click on the context menu items that appear after the long click.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 * @param match the match of the text that should be clicked
	 * @param scroll true if scrolling should be performed
	 *
	 */

	public abstract void clickLongOnText(String text, int match, boolean scroll);

	/**
	 * Long clicks on a given View. {@link #clickOnText(String)} can then be
	 * used to click on the context menu items that appear after the long click.
	 *
	 * @param text the text that should be clicked. The parameter will be interpreted as a regular expression
	 * @param match the match of the text that should be clicked
	 * @param time the amount of time to long click
	 */

	public abstract void clickLongOnText(String text, int match, int time);

	/**
	 * Long clicks on a given View and then selects
	 * an item from the context menu that appears. Will automatically scroll when needed.
	 *
	 * @param text the text to be clicked. The parameter will be interpreted as a regular expression
	 * @param index the index of the menu item to be pressed. {@code 0} if only one is available
	 *
	 */

	public abstract void clickLongOnTextAndPress(String text, int index);

	/**
	 * Clicks on a Button with a given index.
	 *
	<<<<<<< HEAD
	<<<<<<< HEAD
	<<<<<<>>>>>> 3958c76a064fa944ce35111acbd0d8392b21f1bb
	=======
	 * @param index the index number of the {@code Button}. {@code 0} if only one is available
	>>>>>>> a866efbb7db928958bd1b93d33650acae03fd6fd
	=======
	 * @param index the index of the {@link Button} to be clicked. {@code 0} if only one is available
	>>>>>>> 6c668e1cec88f7d1927bd6bb1c3e2169ff861ff2
	 *
	 */

	public abstract void clickOnButton(int index);

	/**
	 * Clicks on a RadioButton with a given index.
	 *
	 * @param index the index of the {@link RadioButton} to be clicked. {@code 0} if only one is available
	 *
	 */

	public abstract void clickOnRadioButton(int index);

	/**
	 * Clicks on a CheckBox with a given index.
	 *
	 * @param index the index of the {@link CheckBox} to be clicked. {@code 0} if only one is available
	 *
	 */

	public abstract void clickOnCheckBox(int index);

	/**
	 * Clicks on an EditText with a given index.
	 *
	 * @param index the index of the {@link EditText} to be clicked. {@code 0} if only one is available
	 *
	 */

	public abstract void clickOnEditText(int index);

	/**
	 * Clicks on a given list line and returns an ArrayList of the TextView objects that
	 * the list line is showing. Will use the first list it finds.
	 *
	 * @param line the line that should be clicked
	 * @return an {@code ArrayList} of the {@link TextView} objects located in the list line
	 *
	 */

	public abstract ArrayList<TextView> clickInList(int line);

	/**
	 * Clicks on a given list line on a specified list and
	 * returns an ArrayList of the TextView objects that the list line is showing.
	 *
	 * @param line the line that should be clicked
	 * @param index the index of the list. 1 if two lists are available
	 * @return an {@code ArrayList} of the {@link TextView} objects located in the list line
	 *
	 */

	public abstract ArrayList<TextView> clickInList(int line, int index);

	/**
	 * Long clicks on a given list line and returns an ArrayList of the TextView objects that
	 * the list line is showing. Will use the first list it finds.
	 *
	 * @param line the line that should be clicked
	 * @return an {@code ArrayList} of the {@link TextView} objects located in the list line
	 *
	 */
	public abstract ArrayList<TextView> clickLongInList(int line);

	/**
	 * Long clicks on a given list line on a specified list and
	 * returns an ArrayList of the TextView objects that the list line is showing.
	 *
	 * @param line the line that should be clicked
	 * @param index the index of the list. 1 if two lists are available
	 * @return an {@code ArrayList} of the {@link TextView} objects located in the list line
	 *
	 */
	public abstract ArrayList<TextView> clickLongInList(int line, int index);

	/**
	 * Long clicks on a given list line on a specified list and
	 * returns an ArrayList of the TextView objects that the list line is showing.
	 *
	 * @param line the line that should be clicked
	 * @param index the index of the list. 1 if two lists are available
	 * @param time the amount of time to long click
	 * @return an {@code ArrayList} of the {@link TextView} objects located in the list line
	 *
	 */
	public abstract ArrayList<TextView> clickLongInList(int line, int index,
			int time);

	/**
	 * Simulate touching a given location and dragging it to a new location.
	 *
	 * This method was copied from {@code TouchUtils.java} in the Android Open Source Project, and modified here.
	 *
	 * @param fromX X coordinate of the initial touch, in screen coordinates
	 * @param toX X coordinate of the drag destination, in screen coordinates
	 * @param fromY X coordinate of the initial touch, in screen coordinates
	 * @param toY Y coordinate of the drag destination, in screen coordinates
	 * @param stepCount How many move steps to include in the drag
	 *
	 */

	public abstract void drag(float fromX, float toX, float fromY, float toY,
			int stepCount);

	/**
	 * Scrolls down the screen.
	 *
	 * @return {@code true} if more scrolling can be done and {@code false} if it is at the end of
	 * the screen
	 *
	 */

	public abstract boolean scrollDown();

	/**
	 * Scrolls up the screen.
	 *
	 * @return {@code true} if more scrolling can be done and {@code false} if it is at the top of
	 * the screen
	 *
	 */

	public abstract boolean scrollUp();

	/**
	 * Scrolls down a list with a given index.
	 *
	 * @param index the {@link ListView} to be scrolled. {@code 0} if only one list is available
	 * @return {@code true} if more scrolling can be done
	 *
	 */

	public abstract boolean scrollDownList(int index);

	/**
	 * Scrolls up a list with a given index.
	 *
	 * @param index the {@link ListView} to be scrolled. {@code 0} if only one list is available
	 * @return {@code true} if more scrolling can be done
	 *
	 */

	public abstract boolean scrollUpList(int index);

	/**
	 * Scrolls horizontally.
	 *
	 * @param side the side to which to scroll; {@link #RIGHT} or {@link #LEFT}
	 *
	 */

	public abstract void scrollToSide(int side);

	/**
	 * Sets the date in a DatePicker with a given index.
	 *
	 * @param index the index of the {@link DatePicker}. {@code 0} if only one is available
	 * @param year the year e.g. 2011
	 * @param monthOfYear the month e.g. 03
	 * @param dayOfMonth the day e.g. 10
	 *
	 */

	public abstract void setDatePicker(int index, int year, int monthOfYear,
			int dayOfMonth);

	/**
	 * Sets the date in a given DatePicker.
	 *
	 * @param datePicker the {@link DatePicker} object.
	 * @param year the year e.g. 2011
	 * @param monthOfYear the month e.g. 03
	 * @param dayOfMonth the day e.g. 10
	 *
	 */

	public abstract void setDatePicker(DatePicker datePicker, int year,
			int monthOfYear, int dayOfMonth);

	/**
	 * Sets the time in a TimePicker with a given index.
	 *
	 * @param index the index of the {@link TimePicker}. {@code 0} if only one is available
	 * @param hour the hour e.g. 15
	 * @param minute the minute e.g. 30
	 *
	 */

	public abstract void setTimePicker(int index, int hour, int minute);

	/**
	 * Sets the time in a given TimePicker.
	 *
	 * @param timePicker the {@link TimePicker} object.
	 * @param hour the hour e.g. 15
	 * @param minute the minute e.g. 30
	 *
	 */

	public abstract void setTimePicker(TimePicker timePicker, int hour,
			int minute);

	/**
	 * Sets the progress of a ProgressBar with a given index. Examples are SeekBar and RatingBar.
	 *
	 * @param index the index of the {@link ProgressBar}
	 * @param progress the progress that the {@link ProgressBar} should be set to
	 *
	 */

	public abstract void setProgressBar(int index, int progress);

	/**
	 * Sets the progress of a given ProgressBar. Examples are SeekBar and RatingBar.
	 *
	 * @param progressBar the {@link ProgressBar}
	 * @param progress the progress that the {@link ProgressBar} should be set to
	 *
	 */

	public abstract void setProgressBar(ProgressBar progressBar, int progress);

	/**
	 * Sets the status of a SlidingDrawer with a given index. Examples are Solo.CLOSED and Solo.OPENED.
	 *
	 * @param index the index of the {@link SlidingDrawer}
	 * @param status the status that the {@link SlidingDrawer} should be set to
	 *
	 */

	public abstract void setSlidingDrawer(int index, int status);

	/**
	 * Sets the status of a given SlidingDrawer. Examples are Solo.CLOSED and Solo.OPENED.
	 *
	 * @param slidingDrawer the {@link SlidingDrawer}
	 * @param status the status that the {@link SlidingDrawer} should be set to
	 *
	 */

	public abstract void setSlidingDrawer(SlidingDrawer slidingDrawer,
			int status);

	/**
	 * Enters text into an EditText with a given index.
	 *
	 * @param index the index of the {@link EditText}. {@code 0} if only one is available
	 * @param text the text string to enter into the {@link EditText} field
	 *
	 */

	public abstract void enterText(int index, String text);

	/**
	 * Enters text into a given EditText.
	 *
	 * @param editText the {@link EditText} to enter text into
	 * @param text the text string to enter into the {@link EditText} field
	 *
	 */

	public abstract void enterText(EditText editText, String text);

	/**
	 * Clicks on an ImageView with a given index.
	 *
	 * @param index the index of the {@link ImageView} to be clicked. {@code 0} if only one is available
	 *
	 */

	public abstract void clickOnImage(int index);

	/**
	 * Returns an EditText with a given index.
	 *
	 * @param index the index of the {@link EditText}. {@code 0} if only one is available
	 * @return the {@link EditText} with a specified index or {@code null} if index is invalid
	 *
	 */

	public abstract EditText getEditText(int index);

	/**
	 * Returns a Button with a given index.
	 *
	 * @param index the index of the {@link Button}. {@code 0} if only one is available
	 * @return the {@link Button} with a specified index or {@code null} if index is invalid
	 *
	 */

	public abstract Button getButton(int index);

	/**
	 * Returns a TextView with a given index.
	 *
	 * @param index the index of the {@link TextView}. {@code 0} if only one is available
	 * @return the {@link TextView} with a specified index or {@code null} if index is invalid
	 *
	 */

	public abstract TextView getText(int index);

	/**
	 * Returns an ImageView with a given index.
	 *
	 * @param index the index of the {@link ImageView}. {@code 0} if only one is available
	 * @return the {@link ImageView} with a specified index or {@code null} if index is invalid
	 *
	 */

	public abstract ImageView getImage(int index);

	/**
	 * Returns an ImageButton with a given index.
	 *
	 * @param index the index of the {@link ImageButton}. {@code 0} if only one is available
	 * @return the {@link ImageButton} with a specified index or {@code null} if index is invalid
	 *
	 */

	public abstract ImageButton getImageButton(int index);

	/**
	 * Returns a TextView which shows a given text.
	 *
	 * @param text the text that is shown
	 * @return the {@link TextView} that shows the given text
	 */

	public abstract TextView getText(String text);

	/**
	 * Returns a Button which shows a given text.
	 *
	 * @param text the text that is shown
	 * @return the {@link Button} that shows the given text
	 */

	public abstract Button getButton(String text);

	/**
	 * Returns an EditText which shows a given text.
	 *
	 * @param text the text that is shown
	 * @return the {@link EditText} which shows the given text
	 */

	public abstract EditText getEditText(String text);

	/**
	 * Returns a View with a given id.
	 *
	 * @param id the R.id of the {@link View} to be returned
	 * @return a {@link View} with a given id
	 */

	public abstract View getView(int id);

	/**
	 * Returns an ArrayList of the View objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link View} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<View> getCurrentViews();

	/**
	 * Returns an ArrayList of the ImageView objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ImageView} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ImageView> getCurrentImageViews();

	/**
	 * Returns an ArrayList of the EditText objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link EditText} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<EditText> getCurrentEditTexts();

	/**
	 * Returns an ArrayList of the ListView objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ListView}  objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ListView> getCurrentListViews();

	/**
	 * Returns an ArrayList of the ScrollView objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ScrollView} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ScrollView> getCurrentScrollViews();

	/**
	 * Returns an ArrayList of the Spinner objects (drop-down menus) currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link Spinner} objects (drop-down menus) currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<Spinner> getCurrentSpinners();

	/**
	 * Returns an ArrayList of the TextView objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @param parent the parent {@link View} from which the {@link TextView} objects should be returned. {@code null} if
	 * all TextView objects from the currently focused window e.g. Activity should be returned
	 *
	 * @return an {@code ArrayList} of the {@link TextView} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<TextView> getCurrentTextViews(View parent);

	/**
	 * Returns an ArrayList of the GridView objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link GridView} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<GridView> getCurrentGridViews();

	/**
	 * Returns an ArrayList of the Button objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link Button} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<Button> getCurrentButtons();

	/**
	 * Returns an ArrayList of the ToggleButton objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ToggleButton} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ToggleButton> getCurrentToggleButtons();

	/**
	 * Returns an ArrayList of the RadioButton objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link RadioButton} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<RadioButton> getCurrentRadioButtons();

	/**
	 * Returns an ArrayList of the CheckBox objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link CheckBox} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<CheckBox> getCurrentCheckBoxes();

	/**
	 * Returns an ArrayList of the ImageButton objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ImageButton} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ImageButton> getCurrentImageButtons();

	/**
	 * Returns an ArrayList of the DatePicker objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link DatePicker} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<DatePicker> getCurrentDatePickers();

	/**
	 * Returns an ArrayList of the TimePicker objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link TimePicker} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<TimePicker> getCurrentTimePickers();

	/**
	 * Returns an ArrayList of the SlidingDrawer objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link SlidingDrawer} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<SlidingDrawer> getCurrentSlidingDrawers();

	/**
	 * Returns an ArrayList of the ProgressBar objects currently shown in the focused
	 * Activity or Dialog.
	 *
	 * @return an {@code ArrayList} of the {@link ProgressBar} objects currently shown in the
	 * focused window
	 *
	 */

	public abstract ArrayList<ProgressBar> getCurrentProgressBars();

	/**
	 * Checks if a RadioButton with a given index is checked.
	 *
	 * @param index of the {@link RadioButton} to check. {@code 0} if only one is available
	 * @return {@code true} if {@link RadioButton} is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isRadioButtonChecked(int index);

	/**
	 * Checks if a RadioButton with a given text is checked.
	 *
	 * @param text the text that the {@link RadioButton} shows
	 * @return {@code true} if a {@link RadioButton} with the given text is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isRadioButtonChecked(String text);

	/**
	 * Checks if a CheckBox with a given index is checked.
	 *
	 * @param index of the {@link CheckBox} to check. {@code 0} if only one is available
	 * @return {@code true} if {@link CheckBox} is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isCheckBoxChecked(int index);

	/**
	 * Checks if a ToggleButton with a given text is checked.
	 *
	 * @param text the text that the {@link ToggleButton} shows
	 * @return {@code true} if a {@link ToggleButton} with the given text is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isToggleButtonChecked(String text);

	/**
	 * Checks if a ToggleButton with a given index is checked.
	 *
	 * @param index of the {@link ToggleButton} to check. {@code 0} if only one is available
	 * @return {@code true} if {@link ToggleButton} is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isToggleButtonChecked(int index);

	/**
	 * Checks if a CheckBox with a given text is checked.
	 *
	 * @param text the text that the {@link CheckBox} shows
	 * @return {@code true} if a {@link CheckBox} with the given text is checked and {@code false} if it is not checked
	 *
	 */

	public abstract boolean isCheckBoxChecked(String text);

	/**
	 * Checks if the given text is checked.
	 *
	 * @param text the text that the {@link CheckedTextView} or {@link CompoundButton} objects show
	 * @return {@code true} if the given text is checked and {@code false} if it is not checked
	 */

	public abstract boolean isTextChecked(String text);

	/**
	 * Checks if a given text is selected in any Spinner located in the current screen.
	 *
	 * @param text the text that is expected to be selected
	 * @return {@code true} if the given text is selected in any {@link Spinner} and false if it is not
	 *
	 */

	public abstract boolean isSpinnerTextSelected(String text);

	/**
	 * Checks if a given text is selected in a given Spinner.
	 *
	 * @param index the index of the spinner to check. {@code 0} if only one spinner is available
	 * @param text the text that is expected to be selected
	 * @return true if the given text is selected in the given {@link Spinner} and false if it is not
	 */

	public abstract boolean isSpinnerTextSelected(int index, String text);

	/**
	 * Sends a key: Right, Left, Up, Down, Enter, Menu or Delete.
	 *
	 * @param key the key to be sent. Use {@code Solo.}{@link #RIGHT}, {@link #LEFT}, {@link #UP}, {@link #DOWN},
	 * {@link #ENTER}, {@link #MENU}, {@link #DELETE}
	 *
	 */

	public abstract void sendKey(int key);

	/**
	 * Returns to the given Activity.
	 *
	 * @param name the name of the {@link Activity} to return to, e.g. {@code "MyActivity"}
	 *
	 */

	public abstract void goBackToActivity(String name);

	/**
	 * Waits for the given Activity.
	 *
	 * @param name the name of the {@link Activity} to wait for e.g. {@code "MyActivity"}
	 * @param timeout the amount of time in milliseconds to wait
	 * @return {@code true} if {@link Activity} appears before the timeout and {@code false} if it does not
	 *
	 */

	public abstract boolean waitForActivity(String name, int timeout);

	/**
	 * Returns a localized string.
	 *
	 * @param resId the resource ID for the string
	 * @return the localized string
	 *
	 */

	public abstract String getString(int resId);

	/**
	 * Robotium will sleep for a specified time.
	 *
	 * @param time the time in milliseconds that Robotium should sleep
	 *
	 */

	public abstract void sleep(int time);

	/**
	 *
	 * All activites that have been active are finished.
	 *
	 */

	public abstract void finalize() throws Throwable;

}


text:
import numpy as npy
from matplotlib import pyplot as plt
import cv2
import mxnet as mx

ctx=mx.cpu()
load_net, load_arg_params, load_aux_params = mx.model.load_checkpoint('checkpoint\\matchnet', 13)
all_layers=load_net.get_internals()
net=all_layers["feat1_bottleneck_output"]
new_args = dict({k:load_arg_params[k] for k in load_arg_params
                 if 'fc' not in k})
mod = mx.mod.Module(symbol=net, context=ctx, data_names=['data1'],label_names=None)
mod.bind(for_training=False, data_shapes=[('data1', (1,1,64,64))],
         label_shapes=mod._label_shapes)
mod.set_params(new_args, load_aux_params, allow_missing=True)

redpajama_set_name: RedPajamaGithub


text:
package diff

import (
	"bytes"
	"fmt"
	"html/template"
	"strconv"
	"strings"
)

const (
	divTmpl  = "
{{.Contents}}
\n"
	spanTmpl = "{{.Contents}}"
)

var (
	div  = template.Must(template.New("div").Parse(divTmpl))
	span = template.Must(template.New("span").Parse(spanTmpl))
)

type elem struct {
	Classes  string
	Contents interface{}
}

var svgClasses = map[LineSource]string{
	LineFromA:        "add",
	LineFromB:        "del",
	LineFromBothEdit: "edit",
}

// HTMLLine renders a diff solution into a before and after string.
// Words are added one at a time, and changes are marked with spans.
func HTMLLine(d *DiffSolution) (string, string) {
	a := &bytes.Buffer{}
	b := &bytes.Buffer{}
	for _, word := range d.Lines {
		switch LineSource(word[2]) {
		case LineFromA:
			span.Execute(a, elem{"w-add", word[0]})
			span.Execute(b, elem{"w-del", ""})
		case LineFromB:
			span.Execute(a, elem{"w-del", ""})
			span.Execute(b, elem{"w-add", word[1]})
		case LineFromBothEdit:
			span.Execute(a, elem{"w-edit", word[0]})
			span.Execute(b, elem{"w-edit", word[1]})
		case LineFromBoth:
			a.WriteString(template.HTMLEscapeString(word[0]))
			b.WriteString(template.HTMLEscapeString(word[1]))
		}
	}
	return a.String(), b.String()
}

// HTML builds up a html diff. Here be dragons! This is meant for the delta GUI.
func HTML(d *DiffSolution) string {
	// closest contains the number of lines to the *next* changed lines
	maxContext := 10
	maxContext++ // + 1 for lines to hide
	nextChange := make([]int, len(d.Lines))
	lastChangedLine := len(d.Lines) + 10
	for i := len(d.Lines) - 1; i > -1; i-- {
		switch LineSource(d.Lines[i][2]) {
		case LineFromA, LineFromB, LineFromBothEdit:
			lastChangedLine = i
		case LineFromBoth:
			if d.Lines[i][0] != d.Lines[i][1] {
				lastChangedLine = i
			}
		}
		nextChange[i] = lastChangedLine - i
		if nextChange[i] > maxContext {
			nextChange[i] = maxContext
		}
	}

	li, ri := 0, 0
	lg := bytes.NewBufferString("
\n")
	rg := bytes.NewBufferString("
\n")
	lb := bytes.NewBufferString("

\n")
	rb := bytes.NewBufferString("

\n")
	lastChangedLine = -maxContext

	lastSource := LineFromBoth
	lineHeight := 16
	ll := bytes.NewBufferString(fmt.Sprintf(`<div><svg width="16" height="%d">`, lineHeight*len(d.Lines)))

	for i, l := range d.Lines {
		ls := LineSource(l[2])
		if ls != lastSource {
			lastSource = ls
			if l[0] != l[1] {
				ll.WriteString(
					fmt.Sprintf(`<line x1="%d" x2="%d" y1="%d" y2="%d" stroke-width="1" class="connector-%s" />`,
						0, 16, lineHeight*li, lineHeight*ri, svgClasses[lastSource],
					),
				)
			}
		}

		// closestChange keeps track of how close we are to the *previous* change.
		closestChange := 0
		if ls == LineFromBoth && l[0] == l[1] {
			closestChange = i - lastChangedLine
			if closestChange > nextChange[i] {
				closestChange = nextChange[i]
			}
			if closestChange == maxContext {
				closestChange = -1
			}
		} else {
			lastChangedLine = i
		}
		lc := "lc-" + strconv.Itoa(closestChange) + " line "
		if ls == LineFromA {
			li++
			must(div.Execute(lg, elem{lc + "la", li}))
			must(div.Execute(rg, elem{lc, ""}))
			must(div.Execute(lb, elem{lc + "la", l[0]}))
			must(div.Execute(rb, elem{lc, ""}))
		} else if ls == LineFromB {
			ri++
			must(div.Execute(lg, elem{lc, ""}))
			must(div.Execute(rg, elem{lc + "la", ri}))
			must(div.Execute(lb, elem{lc, ""}))
			must(div.Execute(rb, elem{lc + "la", l[1]}))
		} else if ls == LineFromBothEdit {
			li++
			ri++
			dl, dr := "", ""
			sol := DiffLine(l[0], l[1])
			if sol != nil {
				dl, dr = HTMLLine(sol)
			} else {
				dl = template.HTMLEscapeString(l[0])
				dr = template.HTMLEscapeString(l[1])
			}
			must(div.Execute(lg, elem{lc + "ln", li}))
			must(div.Execute(rg, elem{lc + "ln", ri}))
			must(div.Execute(lb, elem{lc + "ln", template.HTML(dl)}))
			must(div.Execute(rb, elem{lc + "ln", template.HTML(dr)}))
		} else if l[0] != l[1] {
			li++
			ri++
			must(div.Execute(lg, elem{lc + "line-ws", li}))
			must(div.Execute(rg, elem{lc + "line-ws", ri}))
			must(div.Execute(lb, elem{lc + "line-ws", l[0]}))
			must(div.Execute(rb, elem{lc + "line-ws", l[1]}))
		} else if ls == LineFromBoth {
			li++
			ri++
			must(div.Execute(lg, elem{lc + "lm", li}))
			must(div.Execute(rg, elem{lc + "lm", ri}))
			must(div.Execute(lb, elem{lc + "lm", l[0]}))
			must(div.Execute(rb, elem{lc + "lm", l[1]}))
		}
	}

	lg.WriteString("
")
	rg.WriteString("
")
	lb.WriteString("

")
	rb.WriteString("

")
	ll.WriteString("
")
	lbs := strings.Replace(lb.String(), "\t", `<span class="delta-tab"> </span>`, -1)
	rbs := strings.Replace(rb.String(), "\t", `<span class="delta-tab"> </span>`, -1)
	if li == 0 {
		return rg.String() + rbs
	}
	if ri == 0 {
		return lg.String() + lbs
	}
	return lg.String() + lbs + rg.String() + rbs
}

func must(err error) {
	if err != nil {
		panic(err)
	}
}


text:
require 'spec_helper'
require 'cs/end_point/user'

module CS
  module Relation
    describe UserRelation do
      let(:users) {
        {"users" => [{"name" => "user1"}, {"name" => "user2"}, {"name" => "user3"}], "total" => 3}
      }

      let(:relation) {
        relation = UserRelation.new
        relation.stub("check_session!").and_return(true)
        relation.stub("get_data!").and_return(users)
        relation
      }

      describe "get_data!" do
        it "should fetch sensor data from commonSense" do
          session = double('Session')
          option = {page: 100, per_page: 99}
          session.should_receive(:get).with("/users.json", option)

          relation = UserRelation.new(session)
          relation.get_data!(page: 100, per_page: 99)
        end
      end

      describe "each" do
        it "should get all user and yield each" do
          session = double('Session')
          relation = UserRelation.new(session)
          relation.stub("get_data!").and_return(users)

          expect { |b| relation.each(&b) }.to yield_successive_args(EndPoint::User, EndPoint::User, EndPoint::User)
        end

        context "empty result" do
          it "should not yield control" do
            session = double('Session')
            relation = UserRelation.new(session)
            relation.stub("get_data!").and_return({"users" => [], "total" => 0})

            expect { |b| relation.each(&b) }.not_to yield_control
          end
        end

        context "limit specified" do
          it "should yield sensor at most specified by limit" do
            relation.limit(1).to_a.count.should eq(1)
          end
        end
      end

      describe "last" do
        it "should return the last record" do
          relation = SensorRelation.new
          relation.stub("count").and_return(3)
          relation.should_receive("get_data").with(page:2, per_page:1).and_return({"sensors" => [{"name" => "sensor3"}], "total" => 3})

          first = relation.last
          first.should be_kind_of(EndPoint::Sensor)
          first.name.should eq("sensor3")
        end

        context "with parameters given" do
          it "should return the last record with options" do
            relation = SensorRelation.new
            relation.stub("count").and_return(3)
            relation.should_receive("get_data").with(page:2, per_page:1, shared:1, owned:1, physical:1, details:'full').and_return({"sensors" => [{"name" => "sensor3"}], "total" => 3})

            first = relation.where(shared: true, owned: true, physical:true, details: 'full').last
            first.should be_kind_of(EndPoint::Sensor)
            first.name.should eq("sensor3")
          end
        end
      end
    end
  end
end


text:
require 'fileutils'

module Gem

  class DocManager

    include UserInteraction

    # Create a document manager for the given gem spec.
    #
    # spec::      The Gem::Specification object representing the gem.
    # rdoc_args:: Optional arguments for RDoc (template etc.) as a String.
    #
    def initialize(spec, rdoc_args="")
      @spec = spec
      @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
      @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
    end

    # Is the RDoc documentation installed?
    def rdoc_installed?
      return File.exist?(File.join(@doc_dir, "rdoc"))
    end

    # Generate the RI documents for this gem spec.
    #
    # Note that if both RI and RDoc documents are generated from the
    # same process, the RI docs should be done first (a likely bug in
    # RDoc will cause RI docs generation to fail if run after RDoc).
    def generate_ri
      if @spec.has_rdoc then
        load_rdoc
        install_ri # RDoc bug, ri goes first
      end

      FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
    end

    # Generate the RDoc documents for this gem spec.
    #
    # Note that if both RI and RDoc documents are generated from the
    # same process, the RI docs should be done first (a likely bug in
    # RDoc will cause RI docs generation to fail if run after RDoc).
    def generate_rdoc
      if @spec.has_rdoc then
        load_rdoc
        install_rdoc
      end

      FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
    end

    # Load the RDoc documentation generator library.
    def load_rdoc
      if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
        raise Gem::FilePermissionError.new(@doc_dir)
      end

      FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)

      begin
        gem 'rdoc'
      rescue Gem::LoadError
        # use built-in RDoc
      end

      begin
        require 'rdoc/rdoc'
      rescue LoadError => e
        raise Gem::DocumentError,
          "ERROR: RDoc documentation generator not installed!"
      end
    end

    def install_rdoc
      rdoc_dir = File.join @doc_dir, 'rdoc'

      FileUtils.rm_rf rdoc_dir

      say "Installing RDoc documentation for #{@spec.full_name}..."
      run_rdoc '--op', rdoc_dir
    end

    def install_ri
      ri_dir = File.join @doc_dir, 'ri'

      FileUtils.rm_rf ri_dir

      say "Installing ri documentation for #{@spec.full_name}..."
      run_rdoc '--ri', '--op', ri_dir
    end

    def run_rdoc(*args)
      args << @spec.rdoc_options
      args << DocManager.configured_args
      args << '--quiet'
      args << @spec.require_paths.clone
      args << @spec.extra_rdoc_files
      args.flatten!

      r = RDoc::RDoc.new

      old_pwd = Dir.pwd
      Dir.chdir(@spec.full_gem_path)
      begin
        r.document args
      rescue Errno::EACCES => e
        dirname = File.dirname e.message.split("-")[1].strip
        raise Gem::FilePermissionError.new(dirname)
      rescue RuntimeError => ex
        alert_error "While generating documentation for #{@spec.full_name}"
        ui.errs.puts "... MESSAGE:   #{ex}"
        ui.errs.puts "... RDOC args: #{args.join(' ')}"
        ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
          Gem.configuration.backtrace
        ui.errs.puts "(continuing with the rest of the installation)"
      ensure
        Dir.chdir(old_pwd)
      end
    end

    def uninstall_doc
      raise Gem::FilePermissionError.new(@spec.installation_path) unless
        File.writable? @spec.installation_path

      original_name = [
        @spec.name, @spec.version, @spec.original_platform].join '-'

      doc_dir = File.join @spec.installation_path, 'doc', @spec.full_name
      unless File.directory? doc_dir then
        doc_dir = File.join @spec.installation_path, 'doc', original_name
      end

      FileUtils.rm_rf doc_dir

      ri_dir = File.join @spec.installation_path, 'ri', @spec.full_name

      unless File.directory? ri_dir then
        ri_dir = File.join @spec.installation_path, 'ri', original_name
      end

      FileUtils.rm_rf ri_dir
    end

    class << self
      def configured_args
        @configured_args ||= []
      end

      def configured_args=(args)
        case args
        when Array
          @configured_args = args
        when String
          @configured_args = args.split
        end
      end
    end

  end
end


text:
package com.lolay.citygrid.content.places.search;

import java.io.Serializable;

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

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@XmlRootElement(name="region")
@XmlAccessorType(value=XmlAccessType.FIELD)
public class SearchRegion implements Serializable {
	private static final long serialVersionUID = 1L;

	@XmlAttribute(name="type",required=true)
	private String type = null;
	@XmlAttribute(name="name",required=true)
	private String name = null;
	@XmlElement(name="latitude",required=true)
	private Double latitude = null;
	@XmlElement(name="longitude",required=true)
	private Double longitude = null;
	@XmlElement(name="default_radius",required=true)
	private Float defaultRadius = null;

	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Double getLatitude() {
		return latitude;
	}
	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}
	public Double getLongitude() {
		return longitude;
	}
	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}
	public Float getDefaultRadius() {
		return defaultRadius;
	}
	public void setDefaultRadius(Float defaultRadius) {
		this.defaultRadius = defaultRadius;
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
	@Override
	public boolean equals(Object obj) {
	   return EqualsBuilder.reflectionEquals(this, obj);
	}
	@Override
	public String toString() {
	   return ToStringBuilder.reflectionToString(this);
	}
}


text:
<?php

namespace Mailmatics\Api;

use Mailmatics\Client;

/**
 * Transacted
 */
class Transacted extends AbstractApi
{
    /**
     * @var int
     */
    protected $transactionalId;

    /**
     * Transacted constructor.
     *
     * @param Client $client
     * @param int    $transactionalId
     */
    public function __construct(Client $client, $transactionalId)
    {
        parent::__construct($client);

        if (!is_int($transactionalId)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Expected an integer greater than zero. "%s" given instead.',
                    gettype($transactionalId)
                )
            );
        }

        if ($transactionalId <= 0) {
            throw new \InvalidArgumentException('Expected an integer greater than zero.');
        }

        $this->transactionalId = $transactionalId;
    }

    /**
     * @return array
     */
    public function all()
    {
        return $this->client->request('transactional/' . $this->transactionalId . '/transacted');
    }

    /**
     * @param int $id
     * @return array
     */
    public function get($id)
    {
        return $this->client->request('transactional/' . $this->transactionalId . '/transacted/' . $id);
    }
}


text:
package binarytrees;

public class TreeNode<T> {
	private TreeNode<T> left;
	private TreeNode<T> right;
	private T value;

	public TreeNode(T value) {
		setValue(value);
	}

	public TreeNode<T> getLeft() {
		return left;
	}

	public void setLeft(TreeNode<T> left) {
		this.left = left;
	}

	public TreeNode<T> getRight() {
		return right;
	}

	public boolean hasLeft() {
		return getLeft() != null;
	}

	public void setRight(TreeNode<T> right) {
		this.right = right;
	}

	public boolean hasRight() {
		return getRight() != null;
	}

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public boolean hasValue() {
		return getValue() != null;
	}

	@Override
	public String toString() {
		if (getValue() != null) {
			return getValue().toString();
		}

		return "";
	}

}


text:
/**
 * Created by marko on 03.01.17.
 */

var OpenSpeedMonitor = OpenSpeedMonitor || {};
OpenSpeedMonitor.script = OpenSpeedMonitor.script ||{};
OpenSpeedMonitor.script.versionControl = OpenSpeedMonitor.script.versionControl || (function(){
    var _showArchivedScriptById= function (scriptId, url) {
        $("input[name='archivedScriptId']").val(scriptId);
        jQuery.ajax({
            type: 'GET',
            url: url,
            data: {
                scriptId: scriptId
            },
            success: function (jsonResponse) {
                $("#archivedNavigationScriptColumn .CodeMirror").remove();
                $("#archivedNavigationScript").text(jsonResponse.navigationScript);
                createCodeMirror("archivedNavigationScript", true);
            }
        });
        _highlightSelectedRow(scriptId)
    };
    var _highlightSelectedRow= function (scriptId) {
        $(".highlight").removeClass('highlight');
        var rowId = "#archivedNavigationScriptTableRow-" + scriptId;
        $(rowId).toggleClass('highlight');

    };
    var _saveVersionDescription= function (archivedScriptId, updateVersionDescriptionUrl) {
        var versionDescriptionTextAreaId = "#versionDescriptionTextArea-" + archivedScriptId;
        var newVersionDescription = $(versionDescriptionTextAreaId).val();
        jQuery.ajax({
            type: 'GET',
            url: updateVersionDescriptionUrl,
            data: {
                archivedScriptId: archivedScriptId,
                newVersionDescription: newVersionDescription
            },
            success: function (content) {
                _hideSaveButton(archivedScriptId);
                $(versionDescriptionTextAreaId).prop("defaultValue", newVersionDescription);
            }
        });
    };
    var _abortVersionDescription= function (archivedScriptId) {
        var versionDescriptionTextAreaId = "#versionDescriptionTextArea-" + archivedScriptId;
        $(versionDescriptionTextAreaId).val($(versionDescriptionTextAreaId).prop("defaultValue"));
        _hideSaveButton(archivedScriptId);
    };

    var _showSaveButton= function (archivedScriptId) {
        var saveIconId = "#versionDescriptionSaveButton-" + archivedScriptId;
        $(saveIconId).css('visibility', 'visible');
        var abortIconId = "#versionDescriptionAbortButton-" + archivedScriptId;
        $(abortIconId).css('visibility', 'visible');
    };
    var _hideSaveButton = function (archivedScriptId) {
        var saveIconId = "#versionDescriptionSaveButton-" + archivedScriptId;
        $(saveIconId).css('visibility', 'hidden');
        var abortIconId = "#versionDescriptionAbortButton-" + archivedScriptId;
        $(abortIconId).css('visibility', 'hidden');
    };
    var _initAutoResize = function (textAreaObject) {
        if (!textAreaObject.alreadyInitialized) {
            var savedValue = textAreaObject.value;
            textAreaObject.value = '';
            textAreaObject.baseScrollHeight = textAreaObject.scrollHeight;
            textAreaObject.value = savedValue;
            textAreaObject.alreadyInitialized = true;

        }
        _resizeTextArea(textAreaObject)
    };
    var _resizeTextArea = function (textAreaObject) {
            var minRows = textAreaObject.getAttribute('data-min-rows') | 0, rows;
            textAreaObject.rows = minRows;
            rows = Math.ceil((textAreaObject.scrollHeight - textAreaObject.baseScrollHeight) / 17);
            textAreaObject.rows = minRows + rows;
    };

    var initVersionControl = function (archivedScriptIds, getArchivedNavigationScriptUrl, updateVersionDescriptionUrl) {
        archivedScriptIds.forEach(function (archivedScriptId) {
            var rowId = "#archivedNavigationScriptTableRow-" + archivedScriptId;
            $(rowId).on("click", function () {
                _showArchivedScriptById(archivedScriptId, getArchivedNavigationScriptUrl);
            });
            var versionDescriptionTextAreaId = "#versionDescriptionTextArea-" + archivedScriptId;
            $('#versionControlModal').on('shown.bs.modal', function () {
                _initAutoResize($(versionDescriptionTextAreaId)[0]);
            });
            $(versionDescriptionTextAreaId).on('keyup', function () {
                _showSaveButton(archivedScriptId);
                _resizeTextArea(this)
            });
            $(versionDescriptionTextAreaId).on('change', function () {
                _showSaveButton(archivedScriptId);
                _resizeTextArea(this)
            });
            var saveIconId = "#versionDescriptionSaveButton-" + archivedScriptId;
            $(saveIconId).on("click", function () {
                _saveVersionDescription(archivedScriptId, updateVersionDescriptionUrl);
            });
            var abortIconId = "#versionDescriptionAbortButton-" + archivedScriptId;
            $(abortIconId).on("click", function () {
                _abortVersionDescription(archivedScriptId);
                _resizeTextArea($(versionDescriptionTextAreaId)[0])
            });
        });
        $('#versionControlModal').on('shown.bs.modal', function () {
            if (!$('#versionControlModal')[0].alreadyInitialized) {
                $('#archivedNavigationScriptTableBody').children('tr:first').trigger('click');
                $('#versionControlModal')[0].alreadyInitialized = true;
            }
        })
    };
    return {
        initVersionControl:initVersionControl
    }
})();


text:
package cfbackup

import (
	"encoding/json"
	"io"
	"io/ioutil"

	"github.com/xchapter7x/lo"
)

//NewConfigurationParser - constructor for a ConfigurationParser from a json installationsettings file
func NewConfigurationParser(installationFilePath string) *ConfigurationParser {
	is := InstallationSettings{}
	b, _ := ioutil.ReadFile(installationFilePath)
	if err := json.Unmarshal(b, &is); err != nil {
		lo.G.Error("Unmarshal installation settings error", err)
	}
    is.SetPGDumpUtilVersions()
	return &ConfigurationParser{
		InstallationSettings: is,
	}
}

//NewConfigurationParserFromReader - constructor for a ConfigurationParser from a json installationsettings file
func NewConfigurationParserFromReader(settings io.Reader) *ConfigurationParser {
	is := InstallationSettings{}
	b, _ := ioutil.ReadAll(settings)
	if err := json.Unmarshal(b, &is); err != nil {
		lo.G.Error("Unmarshal installation settings error", err)
	}

    is.SetPGDumpUtilVersions()
	return &ConfigurationParser{
		InstallationSettings: is,
	}
}

//GetIaaS - get the iaas elements from the installation settings
func (s *ConfigurationParser) GetIaaS() (config IaaSConfiguration, hasSSHKey bool) {
	config = s.InstallationSettings.Infrastructure.IaaSConfig
	hasSSHKey = false

	if config.SSHPrivateKey != "" {
		hasSSHKey = true
	}
	return
}

// FindJobsByProductID finds all the jobs in an installation by product id
func (s *ConfigurationParser) FindJobsByProductID(id string) (jobs []Jobs) {
	jobs = s.InstallationSettings.FindJobsByProductID(id)
	return
}

// FindByProductID finds a product by product id
func (s *ConfigurationParser) FindByProductID(id string) (productResponse Products, err error) {
	productResponse, err = s.InstallationSettings.FindByProductID(id)
	return
}

// FindCFPostgresJobs finds all the postgres jobs in the cf product
func (s *ConfigurationParser) FindCFPostgresJobs() (jobs []Jobs) {
	jobs = s.InstallationSettings.FindCFPostgresJobs()
	return
}

//GetProducts - get the products array
func (s *ConfigurationParser) GetProducts() (products []Products) {
	return s.InstallationSettings.Products
}


text:
@protocol SlideNavigationControllerDelegate <NSObject>
@optional
- (BOOL)slideNavigationControllerShouldDisplayRightMenu;
- (BOOL)slideNavigationControllerShouldDisplayLeftMenu;
@end

typedef  enum{
	MenuLeft = 1,
	MenuRight = 2
}Menu;

@protocol SlideNavigationContorllerAnimator;
@interface SlideNavigationController : NavigationViewController <UINavigationControllerDelegate>

extern NSString * const SlideNavigationControllerDidOpen;
extern NSString  *const SlideNavigationControllerDidClose;
extern NSString  *const SlideNavigationControllerDidReveal;

@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;// 是否当在菜单栏选择同一个视图控制器是直接回收菜单
@property (nonatomic, assign) BOOL enableSwipeGesture;// 是否可以侧滑打开菜单
@property (nonatomic, assign) BOOL enableShadow;// 是否显示阴影
@property (nonatomic, strong) UIViewController *rightMenu;// 右侧菜单
@property (nonatomic, strong) UIViewController *leftMenu;// 左侧菜单
@property (nonatomic, strong) UIBarButtonItem *leftBarButtonItem;//
@property (nonatomic, strong) UIBarButtonItem *rightBarButtonItem;
@property (nonatomic, assign) CGFloat portraitSlideOffset;// 纵向侧滑时显示的主视图的宽度
@property (nonatomic, assign) CGFloat landscapeSlideOffset;// 横向侧滑时显示的主视图的宽度
@property (nonatomic, assign) CGFloat panGestureSideOffset;// 侧滑手势响应的距屏幕边缘的宽度
@property (nonatomic, assign) CGFloat menuRevealAnimationDuration;// 菜单消失动画的时间
@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption;// 菜单消失
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;

+ (SlideNavigationController *)sharedInstance;
- (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion __deprecated;// 该方法被弃用
// 弹出根视图控制器可以带动画
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion;
//
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;

- (void)popAllAndSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion;
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;
- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion;// 使
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion;// 打开菜单
- (void)closeMenuWithCompletion:(void (^)())completion;// 关闭菜单
- (void)toggleLeftMenu;// 弹出左侧菜单
- (void)toggleRightMenu;// 弹出右侧菜单
- (BOOL)isMenuOpen;// 判断菜单是否打开

@end


text:
<?php

declare(strict_types=1);

namespace PhpSchool\PhpWorkshop\Exception;

use RuntimeException;

/**
 * Represents the situation where a command is called which does not exist in the framework.
 */
class CliRouteNotExistsException extends RuntimeException
{
    /**
     * @param string $routeName The name of the command which was typed.
     */
    public function __construct(string $routeName)
    {
        parent::__construct(sprintf('Command: "%s" does not exist', $routeName));
    }
}


text:
bool unlock_called = false;

struct mutex
{
  void lock()
  {
  }
  void unlock()
  {
    unlock_called = true;
  }
};

mutex m;

int main()
{
  boost::unique_lock<mutex> lk(m);
  lk.unlock();
  BOOST_TEST(unlock_called == true);
  BOOST_TEST(lk.owns_lock() == false);
  try
  {
    lk.unlock();
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }
  lk.release();
  try
  {
    lk.unlock();
    BOOST_TEST(false);
  }
  catch (boost::system::system_error& e)
  {
    BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
  }

  return boost::report_errors();
}


text:
const fs = require('fs');
const debug = require('debug')('awsConfig');

/**
 * Configure Amazon Web Services.
 *
 * @param {Object} AWS
 *   AWS SDK.
 * @returns {void}
 */
module.exports = (AWS) => {
  let config;
  // Custom.
  if (fs.existsSync(`${process.cwd()}/.dashingreporter.json`)) {
    debug('Using custom config.');
    config = JSON.parse(fs.readFileSync(`${process.cwd()}/.dashingreporter.json`, 'utf8'));
  }
  // Default.
  else {
    debug('Using default config.');
    config = JSON.parse(fs.readFileSync(`${__dirname}/../.dashingreporter.default.json`, 'utf8'));
  }
  AWS.config.update(config);

  // Set endpoint for localhost.
  if (AWS.config.region === 'localhost') {
    debug('Setting localhost endpoint.');
    AWS.config.update({
      endpoint: 'http://localhost:8000',
    });
  }
};


text:
package com.techshroom.unplanned.blitter.textures.loader;

import com.techshroom.unplanned.blitter.textures.TextureData;

public interface TextureLoader<T, E extends Exception> {

    TextureData load(T source) throws E;

}


text:
<?php

namespace Wbi\ForumBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class TypeType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('type')
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Wbi\ForumBundle\Entity\Type'
        ));
    }

    public function getName()
    {
        return 'wbi_forumbundle_typetype';
    }
}