text:
package no.nordicsemi.android.dfu;

import android.content.Context;
import android.net.Uri;
import android.os.ParcelUuid;
import android.os.Parcelable;

import java.security.InvalidParameterException;
import java.util.UUID;

/**
 * Starting the DfuService service requires a knowledge of some EXTRA_* constants used to pass parameters to the service.
 * The DfuServiceInitiator class may be used to make this process easier. It provides simple API that covers all low lever operations.
 */
public class DfuServiceInitiator {
	public static final int DEFAULT_PRN_VALUE = 12;

	private final String deviceAddress;
	private String deviceName;

	private boolean disableNotification;

	private Uri fileUri;
	private String filePath;
	private int fileResId;

	private Uri initFileUri;
	private String initFilePath;
	private int initFileResId;

	private String mimeType;
	private int fileType = -1;

	private boolean keepBond;
	private boolean forceDfu = false;
	private boolean enableUnsafeExperimentalButtonlessDfu = false;

	private Boolean packetReceiptNotificationsEnabled;
	private int numberOfPackets = 12;

	private Parcelable[] legacyDfuUuids;
	private Parcelable[] secureDfuUuids;
	private Parcelable[] experimentalButtonlessDfuUuids;
	private Parcelable[] buttonlessDfuWithoutBondSharingUuids;
	private Parcelable[] buttonlessDfuWithBondSharingUuids;

	/**
	 * Creates the builder. Use setZip(...), or setBinOrHex(...) methods to specify the file you want to upload.
	 * In the latter case an init file may also be set using the setInitFile(...) method. Init files are required by DFU Bootloader version 0.5 or newer (SDK 7.0.0+).
	 * @param deviceAddress the target device device address
	 */
	public DfuServiceInitiator(final String deviceAddress) {
		this.deviceAddress = deviceAddress;
	}

	/**
	 * Sets the device name. The device name is not required. It's written in the notification during the DFU process.
	 * If not set the {@link no.nordicsemi.android.dfu.R.string#dfu_unknown_name R.string.dfu_unknown_name} value will be used.
	 * @param name the device name (optional)
	 * @return the builder
	 */
	public DfuServiceInitiator setDeviceName(final String name) {
		this.deviceName = name;
		return this;
	}

	/**
	 * Sets whether the progress notification in the status bar should be disabled.
	 * Defaults to false.
	 * @param disableNotification whether to disable the notification
	 * @return the builder
	 */
	public DfuServiceInitiator setDisableNotification(final boolean disableNotification) {
		this.disableNotification = disableNotification;
		return this;
	}

	/**
	 * Sets whether the bond information should be preserver after flashing new application. This feature requires DFU Bootloader version 0.6 or newer (SDK 8.0.0+).
	 * Please see the {@link DfuBaseThread#EXTRA_KEEP_BOND} for more information regarding requirements. Remember that currently updating the Soft Device will remove the bond information.
	 * @param keepBond whether the bond information should be preserved in the new application.
	 * @return the builder
	 */
	public DfuServiceInitiator setKeepBond(final boolean keepBond) {
		this.keepBond = keepBond;
		return this;
	}

	/**
	 * Enables or disables the Packet Receipt Notification (PRN) procedure.
	 *
By default the PRNs are disabled on devices with Android Marshmallow or newer and enabled on older ones.

	 * @param enabled true to enabled PRNs, false to disable
	 * @return the builder
	 * @see DfuSettingsConstants#SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED
	 */
	public DfuServiceInitiator setPacketsReceiptNotificationsEnabled(final boolean enabled) {
		this.packetReceiptNotificationsEnabled = enabled;
		return this;
	}

	/**
	 * If Packet Receipt Notification procedure is enabled, this method sets number of packets to be sent before
	 * receiving a PRN. A PRN is used to synchronize the transmitter and receiver.
	 * @param number number of packets to be sent before receiving a PRN. Defaulted when set to 0.
	 * @return the builder
	 * @see #setPacketsReceiptNotificationsEnabled(boolean)
	 * @see DfuSettingsConstants#SETTINGS_NUMBER_OF_PACKETS
	 */
	public DfuServiceInitiator setPacketsReceiptNotificationsValue(final int number) {
		this.numberOfPackets = number > 0 ? number : DEFAULT_PRN_VALUE;
		return this;
	}

	/**
	 * Setting force DFU to true will prevent from jumping to the DFU Bootloader
	 * mode in case there is no DFU Version characteristic (Legacy DFU only!). Use it if the DFU operation can be handled by your
	 * device running in the application mode.
	 *
	 *
If the DFU Version characteristic exists, the
	 * information whether to begin DFU operation, or jump to bootloader, is taken from that
	 * characteristic's value. The value returned equal to 0x0100 (read as: minor=1, major=0, or version 0.1)
	 * means that the device is in the application mode and buttonless jump to DFU Bootloader is supported.

	 *
	 *
However, if there is no DFU Version characteristic, a device
	 * may support only Application update (version from SDK 4.3.0), may support Soft Device, Bootloader
	 * and Application update but without buttonless jump to bootloader (SDK 6.0.0) or with
	 * buttonless jump (SDK 6.1.0).

	 *
	 *
In the last case, the DFU Library determines whether the device is in application mode or in DFU Bootloader mode
	 * by counting number of services: if no DFU Service found - device is in app mode and does not support
	 * buttonless jump, if the DFU Service is the only service found (except General Access and General Attribute
	 * services) - it assumes it is in DFU Bootloader mode and may start DFU immediately, if there is
	 * at least one service except DFU Service - the device is in application mode and supports buttonless
	 * jump. In the last case, if you want to perform DFU operation without jumping - call the {@link #setForceDfu(boolean)}
	 * method with parameter equal to true.

	 *
	 *
This method is ignored in Secure DFU.

	 * @param force true to ensure the DFU will start if there is no DFU Version characteristic (Legacy DFU only)
	 * @return the builder
	 * @see DfuSettingsConstants#SETTINGS_ASSUME_DFU_NODE
	 */
	public DfuServiceInitiator setForceDfu(final boolean force) {
		this.forceDfu = force;
		return this;
	}

	/**
	 * Set this flag to true to enable experimental buttonless feature in Secure DFU. When the
	 * experimental Buttonless DFU Service is found on a device, the service will use it to
	 * switch the device to the bootloader mode, connect to it in that mode and proceed with DFU.
	 *

	 * Please, read the information below before setting it to true.
	 *

	 * In the SDK 12.x the Buttonless DFU feature for Secure DFU was experimental.
	 * It is NOT recommended to use it: it was not properly tested, had implementation bugs
	 * (e.g. link) and
	 * does not required encryption and therefore may lead to DOS attack (anyone can use it to switch the device
	 * to bootloader mode). However, as there is no other way to trigger bootloader mode on devices
	 * without a button, this DFU Library supports this service, but the feature must be explicitly enabled here.
	 * Be aware, that setting this flag to false will no protect your devices from this kind of attacks, as
	 * an attacker may use another app for that purpose. To be sure your device is secure remove this
	 * experimental service from your device.
	 *

	 * Spec:

	 * Buttonless DFU Service UUID: 8E400001-F315-4F60-9FB8-838830DAEA50

	 * Buttonless DFU characteristic UUID: 8E400001-F315-4F60-9FB8-838830DAEA50 (the same)

	 * Enter Bootloader Op Code: 0x01

	 * Correct return value: 0x20-01-01 , where:

	 * 0x20 - Response Op Code

	 * 0x01 - Request Code

	 * 0x01 - Success

	 * The device should disconnect and restart in DFU mode after sending the notification.
	 *

	 * In SDK 13 this issue will be fixed by a proper implementation (bonding required,
	 * passing bond information to the bootloader, encryption, well tested). It is recommended to use this
	 * new service when SDK 13 (or later) is out. TODO fix the docs when SDK 13 is out.
	 */
	public DfuServiceInitiator setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(final boolean enable) {
		this.enableUnsafeExperimentalButtonlessDfu = enable;
		return this;
	}

	/**
	 * Sets custom UUIDs for Legacy DFU and Legacy Buttonless DFU. Use this method if your DFU implementation uses different UUID for at least one of the given UUIDs.
	 * Parameter set to null will reset the UUID to the default value.
	 * @param dfuServiceUuid custom Legacy DFU service UUID or null, if default is to be used
	 * @param dfuControlPointUuid custom Legacy DFU Control Point characteristic UUID or null, if default is to be used
	 * @param dfuPacketUuid custom Legacy DFU Packet characteristic UUID or null, if default is to be used
	 * @param dfuVersionUuid custom Legacy DFU Version characteristic UUID or null, if default is to be used (SDK 7.0 - 11.0 only, set null for earlier SDKs)
	 * @return the builder
	 */
	public DfuServiceInitiator setCustomUuidsForLegacyDfu(final UUID dfuServiceUuid, final UUID dfuControlPointUuid, final UUID dfuPacketUuid, final UUID dfuVersionUuid) {
		final ParcelUuid[] uuids = new ParcelUuid[4];
		uuids[0] = dfuServiceUuid      != null ? new ParcelUuid(dfuServiceUuid)      : null;
		uuids[1] = dfuControlPointUuid != null ? new ParcelUuid(dfuControlPointUuid) : null;
		uuids[2] = dfuPacketUuid       != null ? new ParcelUuid(dfuPacketUuid)       : null;
		uuids[3] = dfuVersionUuid      != null ? new ParcelUuid(dfuVersionUuid)      : null;
		legacyDfuUuids = uuids;
		return this;
	}

	/**
	 * Sets custom UUIDs for Secure DFU. Use this method if your DFU implementation uses different UUID for at least one of the given UUIDs.
	 * Parameter set to null will reset the UUID to the default value.
	 * @param dfuServiceUuid custom Secure DFU service UUID or null, if default is to be used
	 * @param dfuControlPointUuid custom Secure DFU Control Point characteristic UUID or null, if default is to be used
	 * @param dfuPacketUuid custom Secure DFU Packet characteristic UUID or null, if default is to be used
	 * @return the builder
	 */
	public DfuServiceInitiator setCustomUuidsForSecureDfu(final UUID dfuServiceUuid, final UUID dfuControlPointUuid, final UUID dfuPacketUuid) {
		final ParcelUuid[] uuids = new ParcelUuid[3];
		uuids[0] = dfuServiceUuid      != null ? new ParcelUuid(dfuServiceUuid)      : null;
		uuids[1] = dfuControlPointUuid != null ? new ParcelUuid(dfuControlPointUuid) : null;
		uuids[2] = dfuPacketUuid       != null ? new ParcelUuid(dfuPacketUuid)       : null;
		secureDfuUuids = uuids;
		return this;
	}

	/**
	 * Sets custom UUIDs for the experimental Buttonless DFU Service from SDK 12.x. Use this method if your DFU implementation uses different UUID for at least one of the given UUIDs.
	 * Parameter set to null will reset the UUID to the default value.
	 *
Remember to call {@link #setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(boolean)} with parameter true if you intent to use this service.

	 * @param buttonlessDfuServiceUuid custom Buttonless DFU service UUID or null, if default is to be used
	 * @param buttonlessDfuControlPointUuid custom Buttonless DFU characteristic UUID or null, if default is to be used
	 * @return the builder
	 */
	public DfuServiceInitiator setCustomUuidsForExperimentalButtonlessDfu(final UUID buttonlessDfuServiceUuid, final UUID buttonlessDfuControlPointUuid) {
		final ParcelUuid[] uuids = new ParcelUuid[2];
		uuids[0] = buttonlessDfuServiceUuid      != null ? new ParcelUuid(buttonlessDfuServiceUuid)      : null;
		uuids[1] = buttonlessDfuControlPointUuid != null ? new ParcelUuid(buttonlessDfuControlPointUuid) : null;
		experimentalButtonlessDfuUuids = uuids;
		return this;
	}

	/**
	 * Sets custom UUIDs for the Buttonless DFU Service from SDK 14 (or later). Use this method if your DFU implementation uses different UUID for at least one of the given UUIDs.
	 * Parameter set to null will reset the UUID to the default value.
	 * @param buttonlessDfuServiceUuid custom Buttonless DFU service UUID or null, if default is to be used
	 * @param buttonlessDfuControlPointUuid custom Buttonless DFU characteristic UUID or null, if default is to be used
	 * @return the builder
	 */
	public DfuServiceInitiator setCustomUuidsForButtonlessDfuWithBondSharing(final UUID buttonlessDfuServiceUuid, final UUID buttonlessDfuControlPointUuid) {
		final ParcelUuid[] uuids = new ParcelUuid[2];
		uuids[0] = buttonlessDfuServiceUuid      != null ? new ParcelUuid(buttonlessDfuServiceUuid)      : null;
		uuids[1] = buttonlessDfuControlPointUuid != null ? new ParcelUuid(buttonlessDfuControlPointUuid) : null;
		buttonlessDfuWithBondSharingUuids = uuids;
		return this;
	}

	/**
	 * Sets custom UUIDs for the Buttonless DFU Service from SDK 13. Use this method if your DFU implementation uses different UUID for at least one of the given UUIDs.
	 * Parameter set to null will reset the UUID to the default value.
	 * @param buttonlessDfuServiceUuid custom Buttonless DFU service UUID or null, if default is to be used
	 * @param buttonlessDfuControlPointUuid custom Buttonless DFU characteristic UUID or null, if default is to be used
	 * @return the builder
	 */
	public DfuServiceInitiator setCustomUuidsForButtonlessDfuWithoutBondSharing(final UUID buttonlessDfuServiceUuid, final UUID buttonlessDfuControlPointUuid) {
		final ParcelUuid[] uuids = new ParcelUuid[2];
		uuids[0] = buttonlessDfuServiceUuid      != null ? new ParcelUuid(buttonlessDfuServiceUuid)      : null;
		uuids[1] = buttonlessDfuControlPointUuid != null ? new ParcelUuid(buttonlessDfuControlPointUuid) : null;
		buttonlessDfuWithoutBondSharingUuids = uuids;
		return this;
	}

	/**
	 * Sets the URI to the Distribution packet (ZIP) or to a ZIP file matching the deprecated naming convention.
	 * @param uri the URI of the file
	 * @return the builder
	 * @see #setZip(String)
	 * @see #setZip(int)
	 */
	public DfuServiceInitiator setZip(final Uri uri) {
		return init(uri, null, 0, DfuBaseThread.TYPE_AUTO, DfuBaseThread.MIME_TYPE_ZIP);
	}

	/**
	 * Sets the path to the Distribution packet (ZIP) or the a ZIP file matching the deprecated naming convention.
	 * @param path path to the file
	 * @return the builder
	 * @see #setZip(Uri)
	 * @see #setZip(int)
	 */
	public DfuServiceInitiator setZip(final String path) {
		return init(null, path, 0, DfuBaseThread.TYPE_AUTO, DfuBaseThread.MIME_TYPE_ZIP);
	}

	/**
	 * Sets the resource ID of the Distribution packet (ZIP) or the a ZIP file matching the deprecated naming convention. The file should be in the /res/raw folder.
	 * @param rawResId file's resource ID
	 * @return the builder
	 * @see #setZip(Uri)
	 * @see #setZip(String)
	 */
	public DfuServiceInitiator setZip(final int rawResId) {
		return init(null, null, rawResId, DfuBaseThread.TYPE_AUTO, DfuBaseThread.MIME_TYPE_ZIP);
	}

	/**
	 * Sets the URI or path of the ZIP file. If the URI and path are not null the URI will be used.
	 * @param uri the URI of the file
	 * @param path the path of the file
	 * @return the builder
	 */
	public DfuServiceInitiator setZip(final Uri uri, final String path) {
		return init(uri, path, 0, DfuBaseThread.TYPE_AUTO, DfuBaseThread.MIME_TYPE_ZIP);
	}

	/**
	 * Sets the URI of the BIN or HEX file containing the new firmware.
	 * For DFU Bootloader version 0.5 or newer the init file must be specified using one of {@link #setInitFile(Uri)} methods.
	 * @param fileType the file type, a bit field created from:
	 *

	 *
{@link DfuBaseThread#TYPE_APPLICATION} - the Application will be sent

	 *
{@link DfuBaseThread#TYPE_SOFT_DEVICE} - he Soft Device will be sent

	 *
{@link DfuBaseThread#TYPE_BOOTLOADER} - the Bootloader will be sent

	 *

	 * @param uri the URI of the file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setBinOrHex(final int fileType, final Uri uri) {
		if (fileType == DfuBaseThread.TYPE_AUTO)
			throw new UnsupportedOperationException("You must specify the file type");
		return init(uri, null, 0, fileType, DfuBaseThread.MIME_TYPE_OCTET_STREAM);
	}

	/**
	 * Sets the URI of the BIN or HEX file containing the new firmware.
	 * For DFU Bootloader version 0.5 or newer the init file must be specified using one of {@link #setInitFile(String)} methods.
	 * @param fileType see {@link #setBinOrHex(int, Uri)} for details
	 * @param path path to the file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setBinOrHex(final int fileType, final String path) {
		if (fileType == DfuBaseThread.TYPE_AUTO)
			throw new UnsupportedOperationException("You must specify the file type");
		return init(null, path, 0, fileType, DfuBaseThread.MIME_TYPE_OCTET_STREAM);
	}

	/**
	 * Sets the URI or path to the BIN or HEX file containing the new firmware.
	 * For DFU Bootloader version 0.5 or newer the init file must be specified using one of {@link #setInitFile(String)} methods.
	 * @param fileType see {@link #setBinOrHex(int, Uri)} for details
	 * @param uri the URI of the file
	 * @param path path to the file
	 * @return the builder
	 * @deprecated The Distribution packet (ZIP) should be used for DFU Bootloader version 0.5 or newer
	 */
	@Deprecated
	public DfuServiceInitiator setBinOrHex(final int fileType, final Uri uri, final String path) {
		if (fileType == DfuBaseThread.TYPE_AUTO)
			throw new UnsupportedOperationException("You must specify the file type");
		return init(uri, path, 0, fileType, DfuBaseThread.MIME_TYPE_OCTET_STREAM);
	}

	/**
	 * Sets the resource ID pointing the BIN or HEX file containing the new firmware. The file should be in the /res/raw folder.
	 * For DFU Bootloader version 0.5 or newer the init file must be specified using one of {@link #setInitFile(int)} methods.
	 * @param fileType see {@link #setBinOrHex(int, Uri)} for details
	 * @param rawResId resource ID
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setBinOrHex(final int fileType, final int rawResId) {
		if (fileType == DfuBaseThread.TYPE_AUTO)
			throw new UnsupportedOperationException("You must specify the file type");
		return init(null, null, rawResId, fileType, DfuBaseThread.MIME_TYPE_OCTET_STREAM);
	}

	/**
	 * Sets the URI of the Init file. The init file for DFU Bootloader version pre-0.5 (SDK 4.3, 6.0, 6.1) contains only the CRC-16 of the firmware.
	 * Bootloader version 0.5 or newer requires the Extended Init Packet.
	 * @param initFileUri the URI of the init file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setInitFile(final Uri initFileUri) {
		return init(initFileUri, null, 0);
	}

	/**
	 * Sets the path to the Init file. The init file for DFU Bootloader version pre-0.5 (SDK 4.3, 6.0, 6.1) contains only the CRC-16 of the firmware.
	 * Bootloader version 0.5 or newer requires the Extended Init Packet.
	 * @param initFilePath the path to the init file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setInitFile(final String initFilePath) {
		return init(null, initFilePath, 0);
	}

	/**
	 * Sets the resource ID of the Init file. The init file for DFU Bootloader version pre-0.5 (SDK 4.3, 6.0, 6.1) contains only the CRC-16 of the firmware.
	 * Bootloader version 0.5 or newer requires the Extended Init Packet.
	 * @param initFileResId the resource ID of the init file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setInitFile(final int initFileResId) {
		return init(null, null, initFileResId);
	}

	/**
	 * Sets the URI or path to the Init file. The init file for DFU Bootloader version pre-0.5 (SDK 4.3, 6.0, 6.1) contains only the CRC-16 of the firmware.
	 * Bootloader version 0.5 or newer requires the Extended Init Packet. If the URI and path are not null the URI will be used.
	 * @param initFileUri the URI of the init file
	 * @param initFilePath the path of the init file
	 * @return the builder
	 */
	@Deprecated
	public DfuServiceInitiator setInitFile(final Uri initFileUri, final String initFilePath) {
		return init(initFileUri, initFilePath, 0);
	}

	/**
	 * Starts the DFU service.
	 * @param context the application context
	 * @param thread the class derived from the BaseDfuService
	 */
	public DfuServiceController start(final Context context, final DfuBaseThread thread) {
		if (fileType == -1)
			throw new UnsupportedOperationException("You must specify the firmware file before starting the service");

//		final Intent intent = new Intent(context, thread);
//		SPManager.put(context,(DfuBaseThread.EXTRA_DEVICE_ADDRESS, deviceAddress);
//		SPManager.put(context,(DfuBaseThread.EXTRA_DEVICE_NAME, deviceName);
//		SPManager.put(context,(DfuBaseThread.EXTRA_DISABLE_NOTIFICATION, disableNotification);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FILE_MIME_TYPE, mimeType);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FILE_TYPE, fileType);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FILE_URI, fileUri);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FILE_PATH, filePath);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FILE_RES_ID, fileResId);
//		SPManager.put(context,(DfuBaseThread.EXTRA_INIT_FILE_URI, initFileUri);
//		SPManager.put(context,(DfuBaseThread.EXTRA_INIT_FILE_PATH, initFilePath);
//		SPManager.put(context,(DfuBaseThread.EXTRA_INIT_FILE_RES_ID, initFileResId);
//		SPManager.put(context,(DfuBaseThread.EXTRA_KEEP_BOND, keepBond);
//		SPManager.put(context,(DfuBaseThread.EXTRA_FORCE_DFU, forceDfu);
//		SPManager.put(context,(DfuBaseThread.EXTRA_UNSAFE_EXPERIMENTAL_BUTTONLESS_DFU, enableUnsafeExperimentalButtonlessDfu);
//		if (packetReceiptNotificationsEnabled != null) {
//			SPManager.put(context,(DfuBaseThread.EXTRA_PACKET_RECEIPT_NOTIFICATIONS_ENABLED, packetReceiptNotificationsEnabled);
//			SPManager.put(context,(DfuBaseThread.EXTRA_PACKET_RECEIPT_NOTIFICATIONS_VALUE, numberOfPackets);
//		} else {
//			// For backwards compatibility:
//			// If the setPacketsReceiptNotificationsEnabled(boolean) has not been called, the PRN state and value are taken from
//			// SharedPreferences the way they were read in DFU Library in 1.0.3 and before, or set to default values.
//			// Default values: PRNs enabled on Android 4.3 - 5.1 and disabled starting from Android 6.0. Default PRN value is 12.
//		}
//		if (legacyDfuUuids != null)
//			SPManager.put(context,(DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_LEGACY_DFU, legacyDfuUuids);
//		if (secureDfuUuids != null)
//			SPManager.put(context,(DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_SECURE_DFU, secureDfuUuids);
//		if (experimentalButtonlessDfuUuids != null)
//			SPManager.put(context,(DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_EXPERIMENTAL_BUTTONLESS_DFU, experimentalButtonlessDfuUuids);
//		if (buttonlessDfuWithoutBondSharingUuids != null)
//			SPManager.put(context,(DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_BUTTONLESS_DFU_WITHOUT_BOND_SHARING, buttonlessDfuWithoutBondSharingUuids);
//		if (buttonlessDfuWithBondSharingUuids != null)
//			SPManager.put(context,(DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_BUTTONLESS_DFU_WITH_BOND_SHARING, buttonlessDfuWithBondSharingUuids);
//		context.startService(intent);

		SPManager.put(context,DfuBaseThread.EXTRA_DEVICE_ADDRESS, deviceAddress);
		SPManager.put(context,DfuBaseThread.EXTRA_DEVICE_NAME, deviceName);
		SPManager.put(context,DfuBaseThread.EXTRA_DISABLE_NOTIFICATION, disableNotification);
		SPManager.put(context,DfuBaseThread.EXTRA_FILE_MIME_TYPE, mimeType);
		SPManager.put(context,DfuBaseThread.EXTRA_FILE_TYPE, fileType);
//		SPManager.put(context,DfuBaseThread.EXTRA_FILE_URI, fileUri);
//		SPManager.put(context,DfuBaseThread.EXTRA_FILE_PATH, filePath);
		SPManager.put(context,DfuBaseThread.EXTRA_FILE_RES_ID, fileResId);
//		SPManager.put(context,DfuBaseThread.EXTRA_INIT_FILE_URI, initFileUri);
//		SPManager.put(context,DfuBaseThread.EXTRA_INIT_FILE_PATH, initFilePath);
//		SPManager.put(context,DfuBaseThread.EXTRA_INIT_FILE_RES_ID, initFileResId);
		SPManager.put(context,DfuBaseThread.EXTRA_KEEP_BOND, keepBond);
		SPManager.put(context,DfuBaseThread.EXTRA_FORCE_DFU, forceDfu);
		SPManager.put(context,DfuBaseThread.EXTRA_UNSAFE_EXPERIMENTAL_BUTTONLESS_DFU, enableUnsafeExperimentalButtonlessDfu);
		if (packetReceiptNotificationsEnabled != null) {
			SPManager.put(context,DfuBaseThread.EXTRA_PACKET_RECEIPT_NOTIFICATIONS_ENABLED, packetReceiptNotificationsEnabled);
			SPManager.put(context,DfuBaseThread.EXTRA_PACKET_RECEIPT_NOTIFICATIONS_VALUE, numberOfPackets);
		} else {
			// For backwards compatibility:
			// If the setPacketsReceiptNotificationsEnabled(boolean) has not been called, the PRN state and value are taken from
			// SharedPreferences the way they were read in DFU Library in 1.0.3 and before, or set to default values.
			// Default values: PRNs enabled on Android 4.3 - 5.1 and disabled starting from Android 6.0. Default PRN value is 12.
		}
		if (legacyDfuUuids != null)
			SPManager.put(context,DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_LEGACY_DFU, legacyDfuUuids);
		if (secureDfuUuids != null)
			SPManager.put(context,DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_SECURE_DFU, secureDfuUuids);
		if (experimentalButtonlessDfuUuids != null)
			SPManager.put(context,DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_EXPERIMENTAL_BUTTONLESS_DFU, experimentalButtonlessDfuUuids);
		if (buttonlessDfuWithoutBondSharingUuids != null)
			SPManager.put(context,DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_BUTTONLESS_DFU_WITHOUT_BOND_SHARING, buttonlessDfuWithoutBondSharingUuids);
		if (buttonlessDfuWithBondSharingUuids != null)
			SPManager.put(context,DfuBaseThread.EXTRA_CUSTOM_UUIDS_FOR_BUTTONLESS_DFU_WITH_BOND_SHARING, buttonlessDfuWithBondSharingUuids);
		thread.start();
		return new DfuServiceController(context);
	}

	private DfuServiceInitiator init(final Uri initFileUri, final String initFilePath, final int initFileResId) {
		if (DfuBaseThread.MIME_TYPE_ZIP.equals(mimeType))
			throw new InvalidParameterException("Init file must be located inside the ZIP");

		this.initFileUri = initFileUri;
		this.initFilePath = initFilePath;
		this.initFileResId = initFileResId;
		return this;
	}

	private DfuServiceInitiator init(final Uri fileUri, final String filePath, final int fileResId, final int fileType, final String mimeType) {
		this.fileUri = fileUri;
		this.filePath = filePath;
		this.fileResId = fileResId;
		this.fileType = fileType;
		this.mimeType = mimeType;

		// If the MIME TYPE implies it's a ZIP file then the init file must be included in the file.
		if (DfuBaseThread.MIME_TYPE_ZIP.equals(mimeType)) {
			this.initFileUri = null;
			this.initFilePath = null;
			this.initFileResId = 0;
		}
		return this;
	}
}


text:
import socket
import cPickle
import cStringIO
import marshal

class Myexception(Exception):
    def __init__(self, faultCode, faultString):
        self.faultCode = faultCode
        self.faultString = faultString
        self.args = (faultCode, faultString)

class mysocket:
    def __init__(self, sock=None):
        if sock is None:
            self.sock = socket.socket(
            socket.AF_INET, socket.SOCK_STREAM)
        else:
            self.sock = sock
        self.sock.settimeout(120)
    def connect(self, host, port=False):
        if not port:
            protocol, buf = host.split('//')
            host, port = buf.split(':')
        self.sock.connect((host, int(port)))
    def disconnect(self):
        self.sock.shutdown(socket.SHUT_RDWR)
        self.sock.close()
    def mysend(self, msg, exception=False, traceback=None):

        msg = cPickle.dumps([msg,traceback])
        size = len(msg)
        self.sock.send('%8d' % size)
        self.sock.send(exception and "1" or "0")
        totalsent = 0
        while totalsent < size:
            sent = self.sock.send(msg[totalsent:])
            if sent == 0:
                raise RuntimeError, "Socket connection broken."
            totalsent = totalsent + sent
    def myreceive(self):
        buf=''
        while len(buf) < 8:
            chunk = self.sock.recv(8 - len(buf))
            if chunk == '':
                raise RuntimeError, "Socket connection broken."
            buf += chunk
        size = int(buf)
        buf = self.sock.recv(1)
        if buf != "0":
            exception = buf
        else:
            exception = False
        msg = ''
        while len(msg) < size:
            chunk = self.sock.recv(size-len(msg))
            if chunk == '':
                raise RuntimeError, "Socket connection broken."
            msg = msg + chunk
        msgio = cStringIO.StringIO(msg)
        unpickler = cPickle.Unpickler(msgio)
        unpickler.find_global = None
        res = unpickler.load()

        if isinstance(res[0],Exception):
            if exception:
                raise Myexception(str(res[0]), str(res[1]))
            raise res[0]
        else:
            return res[0]

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

redpajama_set_name: RedPajamaGithub


text:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using iSukces.Code.VsSolutions;
using ISukces.SolutionDoctor.Logic.Problems;

namespace ISukces.SolutionDoctor.Logic.Checkers
{
    internal class NugetRepositoryDependencies
    {
        public static IEnumerable<Problem> Check(Dictionary<string, Dictionary<string, Nuspec>> localNugetRepositiories,
            List<SolutionProject> uniqueProjects)
        {
            var instance = new NugetRepositoryDependencies
            {
                _localNugetRepositiories = localNugetRepositiories,
                _uniqueProjects          = uniqueProjects
            };
            return instance.CheckInternal().ToList();
        }

        private IEnumerable<Problem> CheckInternal()
        {
            var packagesRelations = (from pair in _localNugetRepositiories
                from specPair in pair.Value
                from nugetDependency in specPair.Value.Dependencies
                select new Data
                {
                    CheckedPackageLocation              = specPair.Value.Location,
                    CheckedPackageId                    = specPair.Value.FullId,
                    ReferencedPackageName               = nugetDependency.Id,
                    ReferencedPackageAcceptableVersions = nugetDependency.Versions
                }).ToArray();

            var nugetVersionsForProjects = _uniqueProjects
                .SelectMany(project => project.NugetPackages)
                .GroupBy(nugetPackage => nugetPackage.Id)
                .Select(grouping => new
                {
                    grouping.Key,
                    Items = grouping.OrderByDescending(b => b.Version).First()
                })
                .ToDictionary(a => a.Key, a => a.Items);

            foreach (var packageRelation in packagesRelations)
            {
                if (packageRelation.ReferencedPackageName == null)
                    continue;
                if (!nugetVersionsForProjects.TryGetValue(packageRelation.ReferencedPackageName,
                    out var packageReferencedByProject)) continue;
                var result =
                    packageRelation.ReferencedPackageAcceptableVersions.CheckVersion(packageReferencedByProject
                        .Version);
                if (result == VersionCheckResult.Ok) continue;
                yield return new NugetRepositoryDependencyProblem
                {
                    ProjectFilename =
                        new FileName(new FileInfo(packageRelation.CheckedPackageLocation.FullName)),
                    ReferencedPackageAcceptableVersions = packageRelation.ReferencedPackageAcceptableVersions,
                    CheckedPackageId                    = packageRelation.CheckedPackageId,
                    CheckedPackageLocation              = packageRelation.CheckedPackageLocation,
                    PackageReferencedByProject          = packageReferencedByProject
                };
            }
        }

        private Dictionary<string, Dictionary<string, Nuspec>> _localNugetRepositiories;
        private List<SolutionProject> _uniqueProjects;
    }

    internal class Data
    {
        public override string ToString()
        {
            return string.Format("{2} => {0} {1}", ReferencedPackageName, ReferencedPackageAcceptableVersions,
                CheckedPackageLocation);
        }

        public string            CheckedPackageId                    { get; set; }
        public string            ReferencedPackageName               { get; set; }
        public NugetVersionRange ReferencedPackageAcceptableVersions { get; set; }
        public DirectoryInfo     CheckedPackageLocation              { get; set; }
    }
}


text:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @(#) Client.java
 */

public class Client extends Person
{
	private List<MealOrder> mealOrders = new ArrayList<>();

	public void addMealOrder(MealOrder order) {
		mealOrders.add(order);
	}

	public Integer getAvgDishCalorieCount() {
		Long totalDishCalorieCount = 0L;
		for (MealOrder mo: mealOrders) {
			totalDishCalorieCount += mo.getFoodorder().getCalorieCount();
		}

		return ((Long)(totalDishCalorieCount/ mealOrders.size())).intValue();
	}

	public List<MealOrder> peekMealOrders() {
		return Collections.unmodifiableList(mealOrders);
	}

	public Integer getAvgBeverageVolume() {
		Long totalVolume = 0L;
		for (MealOrder mo: mealOrders) {
			totalVolume += mo.getDrinkorder().getVolume();
		}

		return ((Long)(totalVolume/ mealOrders.size())).intValue();
	}

	public Integer getTotalMoneySpent() {
		Integer total = 0;
		for (MealOrder mo: mealOrders) {
			total += (mo.getDrinkorder().getPrice() + mo.getFoodorder().getPrice());
		}
		return total;
	}

	@Override
	public String toString() {
		return getName() + " " + getSurname();
	}
}


text:
<?xml version="1.0"?>
<Document>

	<Sentence>
		<value>Although it is not common, some infants may have some hearing loss at birth.</value>
		<pattern_crowdsource> Although it is not common, some [[infants|C0021270]] may have some [[hearing loss|C1384666]] at birth.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>not</surface-form>
				<RDF-ID>C1518422</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>common</surface-form>
				<RDF-ID>C0205214</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infants</surface-form>
				<RDF-ID>C0021270</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>birth</surface-form>
				<RDF-ID>C0005615</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C1384666 PROCESS_OF C0021270</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Hearing loss can also develop in children who had normal hearing as infants.</value>
		<pattern_crowdsource> [[Hearing loss|C1384666]] can also develop in [[children|C0008059]] who had [[normal hearing|C0234725]] as infants.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>children</surface-form>
				<RDF-ID>C0008059</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>normal hearing</surface-form>
				<RDF-ID>C0234725</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infants</surface-form>
				<RDF-ID>C0021270</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C1384666 PROCESS_OF C0008059</triple>
			<triple>C0234725 PROCESS_OF C0008059</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Profound hearing loss is what most people call deafness.</value>
		<pattern_crowdsource> Profound [[hearing loss|C1384666]] is what most people call [[deafness|C0011053]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Profound</surface-form>
				<RDF-ID>C0439808</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>people</surface-form>
				<RDF-ID>C0027361</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>deafness</surface-form>
				<RDF-ID>C0011053</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0011053 ISA C1384666</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>They include:  - Birth defects that cause changes in the structure of the ear canal or middle ear  - Buildup of ear wax  - Buildup of fluid behind the eardrum  - Injury to or rupture of the eardrum  - Objects stuck in the ear canal  - Scar on the eardrum from many infections    Another type of hearing loss is due to a problem with the inner ear.</value>
		<pattern_crowdsource> They include:  - Birth defects that cause changes in the structure of the [[ear canal|C0013444]] or middle ear  - Buildup of ear wax  - Buildup of fluid behind the eardrum  - Injury to or rupture of the eardrum  - Objects stuck in the ear canal  - [[Scar|C0008767]] on the [[eardrum|C0041445]] from many infections    Another type of hearing loss is due to a problem with the [[inner ear|C0022889]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Birth defects</surface-form>
				<RDF-ID>C0000768</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>changes</surface-form>
				<RDF-ID>C0392747</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>structure</surface-form>
				<RDF-ID>C0678594</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>ear canal</surface-form>
				<RDF-ID>C0013444</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>middle ear</surface-form>
				<RDF-ID>C0013455</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>ear wax</surface-form>
				<RDF-ID>C0740486</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>fluid</surface-form>
				<RDF-ID>C0302908</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>eardrum</surface-form>
				<RDF-ID>C0041445</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Injury</surface-form>
				<RDF-ID>C0175677</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>eardrum</surface-form>
				<RDF-ID>C0041445</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Objects</surface-form>
				<RDF-ID>C0347997</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>ear canal</surface-form>
				<RDF-ID>C0013444</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Scar</surface-form>
				<RDF-ID>C0008767</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>eardrum</surface-form>
				<RDF-ID>C0041445</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>type</surface-form>
				<RDF-ID>C1547052</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>inner ear</surface-form>
				<RDF-ID>C0022889</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0041445 LOCATION_OF C0008767</triple>
			<triple>C0022889 PART_OF C0013444</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>This type of hearing loss can be caused by:  - Exposure to certain toxic chemicals or medicines while in the womb or after birth  - Genetic disorders  - Infections the mother passes to her baby in the womb (such as toxoplasmosis, measles, or herpes)  - Infections that can damage the brain after birth, such as meningitis or measles  - Problems with the structure of the inner ear  - Tumors    Central hearing loss results from damage to the auditory nerve itself, or the brain pathways that lead to the nerve.</value>
		<pattern_crowdsource> This type of [[hearing loss|C1384666]] can be caused by:  - Exposure to certain [[toxic chemicals|C0032346]] or medicines while in the [[womb|C0042149]] or after birth  - Genetic disorders  - Infections the mother passes to her baby in the [[womb|C0042149]] (such as toxoplasmosis, measles, or herpes)  - Infections that can damage the brain after birth, such as meningitis or measles  - Problems with the structure of the inner ear  - Tumors    Central hearing loss results from damage to the auditory nerve itself, or the brain pathways that lead to the nerve.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>type</surface-form>
				<RDF-ID>C1547052</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>certain</surface-form>
				<RDF-ID>C0205423</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>toxic chemicals</surface-form>
				<RDF-ID>C0032346</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>medicines</surface-form>
				<RDF-ID>C0013227</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>womb</surface-form>
				<RDF-ID>C0042149</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>birth  - Genetic disorders</surface-form>
				<RDF-ID>C0242354</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>mother</surface-form>
				<RDF-ID>C0026591</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>baby</surface-form>
				<RDF-ID>C0021270</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>womb</surface-form>
				<RDF-ID>C0042149</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>toxoplasmosis</surface-form>
				<RDF-ID>C0040558</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>measles</surface-form>
				<RDF-ID>C0025007</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>herpes</surface-form>
				<RDF-ID>C0019340</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>brain</surface-form>
				<RDF-ID>C0006104</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>birth</surface-form>
				<RDF-ID>C0005615</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>meningitis</surface-form>
				<RDF-ID>C0025289</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>measles</surface-form>
				<RDF-ID>C0025007</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Problems</surface-form>
				<RDF-ID>C1546466</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>structure</surface-form>
				<RDF-ID>C0678594</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Tumors</surface-form>
				<RDF-ID>C0027651</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Central</surface-form>
				<RDF-ID>C0205099</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>inner ear  - Tumors    Central hearing loss</surface-form>
				<RDF-ID>C0018784</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>auditory nerve</surface-form>
				<RDF-ID>C0001162</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>brain pathways</surface-form>
				<RDF-ID>C0815011</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>nerve</surface-form>
				<RDF-ID>C1280541</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0042149 LOCATION_OF C0032346</triple>
			<triple>C0042149 LOCATION_OF C1384666</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Central hearing loss is rare in infants and children.</value>
		<pattern_crowdsource> [[Central hearing loss|C0018776]] is rare in [[infants|C0021270]] and [[children|C0008059]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Central hearing loss</surface-form>
				<RDF-ID>C0018776</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>rare</surface-form>
				<RDF-ID>C0522498</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infants</surface-form>
				<RDF-ID>C0021270</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>children</surface-form>
				<RDF-ID>C0008059</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0018776 PROCESS_OF C0021270</triple>
			<triple>C0018776 PROCESS_OF C0008059</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Some children may not be diagnosed with hearing loss until they are in school.</value>
		<pattern_crowdsource> Some [[children|C0008059]] may not be diagnosed with [[hearing loss|C1384666]] until they are in school.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>children</surface-form>
				<RDF-ID>C0008059</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>not</surface-form>
				<RDF-ID>C1518422</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hearing loss</surface-form>
				<RDF-ID>C1384666</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C1384666 PROCESS_OF C0008059</triple>
		</triples>
	</Sentence>

</Document>


text:
<module xmlns="urn:jboss:module:1.0" name="org.camunda.bpm.camunda-engine-plugin-spin">
  <resources>
    <resource-root path="camunda-engine-plugin-spin-@project.version@.jar" />
  </resources>

  <dependencies>

    <module name="javax.api" />
    <module name="org.joda.time" slot="2.1" />

    <module name="org.camunda.commons.camunda-commons-typed-values" />
    <module name="org.camunda.bpm.camunda-engine" />

    <module name="org.camunda.spin.camunda-spin-core" />
    <module name="org.camunda.spin.camunda-spin-dataformat-json-jackson" services="import" />
    <module name="org.camunda.spin.camunda-spin-dataformat-xml-dom" services="import" />

  </dependencies>
</module>


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

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico"/>

    <title>DataTables example</title>

    DataTables new API function plug-in example

Preamble

DataTables presents a number of useful API functions to the calling code which can be used to manipulate the table
    data as required. But there are times when DataTables doesn't provide the API function that you want - so for this
    DataTables allows a method by which custom API functions can be defined (effectively a plug-in). This is done by
    adding functions the $.fn.dataTableExt.oApi object, which will be registered by DataTables. Each function is
    passed a single parameter, the settings object for the table in question.

In the example below, I present an API function which is used to obtain all of the TR rows which are currently not on
    display (useful for building a form from the table).

Live example

Click to get hidden rows

    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade

    Trident
    Internet
        Explorer 4.0

    Win 95+
    4
    X

    Trident
    Internet
        Explorer 5.0

    Win 95+
    5
    C

    Trident
    Internet
        Explorer 5.5

    Win 95+
    5.5
    A

    Trident
    Internet
        Explorer 6

    Win 98+
    6
    A

    Trident
    Internet Explorer 7
    Win XP SP2+
    7
    A

    Trident
    AOL browser (AOL desktop)
    Win XP
    6
    A

    Gecko
    Firefox 1.0
    Win 98+ / OSX.2+
    1.7
    A

    Gecko
    Firefox 1.5
    Win 98+ / OSX.2+
    1.8
    A

    Gecko
    Firefox 2.0
    Win 98+ / OSX.2+
    1.8
    A

    Gecko
    Firefox 3.0
    Win 2k+ / OSX.3+
    1.9
    A

    Gecko
    Camino 1.0
    OSX.2+
    1.8
    A

    Gecko
    Camino 1.5
    OSX.3+
    1.8
    A

    Gecko
    Netscape 7.2
    Win 95+ / Mac OS 8.6-9.2
    1.7
    A

    Gecko
    Netscape Browser 8
    Win 98SE+
    1.7
    A

    Gecko
    Netscape Navigator 9
    Win 98+ / OSX.2+
    1.8
    A

    Gecko
    Mozilla 1.0
    Win 95+ / OSX.1+
    1
    A

    Gecko
    Mozilla 1.1
    Win 95+ / OSX.1+
    1.1
    A

    Gecko
    Mozilla 1.2
    Win 95+ / OSX.1+
    1.2
    A

    Gecko
    Mozilla 1.3
    Win 95+ / OSX.1+
    1.3
    A

    Gecko
    Mozilla 1.4
    Win 95+ / OSX.1+
    1.4
    A

    Gecko
    Mozilla 1.5
    Win 95+ / OSX.1+
    1.5
    A

    Gecko
    Mozilla 1.6
    Win 95+ / OSX.1+
    1.6
    A

    Gecko
    Mozilla 1.7
    Win 98+ / OSX.1+
    1.7
    A

    Gecko
    Mozilla 1.8
    Win 98+ / OSX.1+
    1.8
    A

    Gecko
    Seamonkey 1.1
    Win 98+ / OSX.2+
    1.8
    A

    Gecko
    Epiphany 2.20
    Gnome
    1.8
    A

    Webkit
    Safari 1.2
    OSX.3
    125.5
    A

    Webkit
    Safari 1.3
    OSX.3
    312.8
    A

    Webkit
    Safari 2.0
    OSX.4+
    419.3
    A

    Webkit
    Safari 3.0
    OSX.4+
    522.1
    A

    Webkit
    OmniWeb 5.5
    OSX.4+
    420
    A

    Webkit
    iPod Touch / iPhone
    iPod
    420.1
    A

    Webkit
    S60
    S60
    413
    A

    Presto
    Opera 7.0
    Win 95+ / OSX.1+
    -
    A

    Presto
    Opera 7.5
    Win 95+ / OSX.2+
    -
    A

    Presto
    Opera 8.0
    Win 95+ / OSX.2+
    -
    A

    Presto
    Opera 8.5
    Win 95+ / OSX.2+
    -
    A

    Presto
    Opera 9.0
    Win 95+ / OSX.3+
    -
    A

    Presto
    Opera 9.2
    Win 88+ / OSX.3+
    -
    A

    Presto
    Opera 9.5
    Win 88+ / OSX.3+
    -
    A

    Presto
    Opera for Wii
    Wii
    -
    A

    Presto
    Nokia N800
    N800
    -
    A

    Presto
    Nintendo DS browser
    Nintendo DS
    8.5
    C/A1

    KHTML
    Konqureror 3.1
    KDE 3.1
    3.1
    C

    KHTML
    Konqureror 3.3
    KDE 3.3
    3.3
    A

    KHTML
    Konqureror 3.5
    KDE 3.5
    3.5
    A

    Tasman
    Internet Explorer 4.5
    Mac OS 8-9
    -
    X

    Tasman
    Internet Explorer 5.1
    Mac OS 7.6-9
    1
    C

    Tasman
    Internet Explorer 5.2
    Mac OS 8-X
    1
    C

    Misc
    NetFront 3.1
    Embedded devices
    -
    C

    Misc
    NetFront 3.4
    Embedded devices
    -
    A

    Misc
    Dillo 0.8
    Embedded devices
    -
    X

    Misc
    Links
    Text only
    -
    X

    Misc
    Lynx
    Text only
    -
    X

    Misc
    IE Mobile
    Windows Mobile 6
    -
    C

    Misc
    PSP browser
    PSP
    -
    C

    Other browsers
    All others
    -
    -
    U

    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade

Initialisation code

/*
 * Function: fnGetHiddenTrNodes
 * Purpose:  Get all of the hidden TR nodes (i.e. the ones which aren't on display)
 * Returns:  array:
 * Inputs:   object:oSettings - DataTables settings object
 */
$.fn.dataTableExt.oApi.fnGetHiddenTrNodes = function ( oSettings )
{
	/* Note the use of a DataTables 'private' function thought the 'oApi' object */
	var anNodes = this.oApi._fnGetTrNodes( oSettings );
	var anDisplay = $('tbody tr', oSettings.nTable);

	/* Remove nodes which are being displayed */
	for ( var i=0 ; i<anDisplay.length ; i++ )
	{
		var iIndex = jQuery.inArray( anDisplay[i], anNodes );
		if ( iIndex != -1 )
		{
			anNodes.splice( iIndex, 1 );
		}
	}

	/* Fire back the array to the caller */
	return anNodes;
}

/* Init the table and fire off a call to get the hidden nodes. */
var oTable;
$(document).ready(function() {
	var oTable = $('#example').dataTable();

	$('#button').click( function () {
		var nHidden = oTable.fnGetHiddenTrNodes();
		alert( nHidden.length +' nodes were returned' );
	} );
} );

Other examples

Basic initialisation

Zero configuration

Feature enablement

Sorting data

Multi-column sorting

Multiple tables

Hidden columns

Complex headers - grouping with colspan

DOM positioning

Flexible table width

State saving

Alternative pagination styles

Scrolling:

            Horizontal /
            Vertical /
            Both /
            Themed /
            Infinite

Change language information (internationalisation)

ThemeRoller themes (Smoothness)

Advanced initialisation

Events:

            Live events /
            Pre-init /
            Post-init

Column rendering

Sorting without HTML tags

Multiple table controls (sDom)

Defining length menu options

Complex headers and hidden columns

Custom toolbar (element) around table

Row highlighting with CSS

Row grouping

Row callback

Footer callback

Control sorting direction of columns

Change language information from a file
            (internationalisation)

Setting defaults

State saving with localStorage

Custom events

API

Dynamically add a new row

Individual column filtering (using "input" elements)

Individual column filtering (using "select" elements)

Highlight rows and columns

Show and hide details about a particular record

User selectable rows (multiple rows)

User selectable rows (single row) and delete rows

Editable rows (with jEditable)

Submit form with elements in table

Index column (static number column)

Show and hide columns dynamically

API function use in initialisation object (callback)

DataTables scrolling and tabs

Regular expression filtering

Data sources

DOM

Javascript array

Ajax source

Server side processing

Server-side processing

Obtain server-side data

Add extra HTTP variables

Use HTTP POST

Automatic addition of IDs and classes to rows

Reading table data from objects

Show and hide details about a particular record

User selectable rows (multiple rows)

JSONP for a cross domain data source

jEditable integration with DataTables

Deferred loading of Ajax data

Pipelining data (reduce Ajax calls for paging)

Ajax data source

Ajax sourced data (array of arrays)

Ajax sourced data (array of objects)

Deferred DOM creation for extra speed

Empty data source columns

Use a data source other than aaData (the default)

Read column data from sub-arrays

Read column data from deeply nested properties

Plug-ins

Add custom API functions

Sorting and automatic type detection

Sorting without automatic type detection

Custom pagination controls

Range filtering / custom filtering

Live DOM sorting

Automatic HTML type detection

        Please refer to the DataTables documentation for full information
        about its API properties and methods.

        Additionally, there are a wide range of extras and plug-ins which extend the capabilities of DataTables.

					DataTables designed and created by Allan Jardine ©
                    2007-2011

					DataTables is dual licensed under the GPL v2
                    license or a BSD (3-point) license.


text:
#import "NSObject.h"

@class NSMutableArray;

// Not exported
@interface TSUDateFormatCategory : NSObject
{
    struct __CFDateFormatter *mInitialFormatter;
    NSMutableArray *mEntries;
}

- (struct __CFDate *)newDateFromString:(struct __CFString *)arg1 forceAllowAMPM:(_Bool)arg2 succesTSUlFormatString:(const struct __CFString **)arg3;
- (id)entryForSeparator:(unsigned short)arg1;
- (void)addSeparator:(unsigned short)arg1 format:(id)arg2 locale:(struct __CFLocale *)arg3;
- (void)dealloc;
- (id)initWithInitialPattern:(id)arg1 locale:(struct __CFLocale *)arg2;

@end


text:
package com.github.highcharts4gwt.generator.common.field;

import javax.annotation.CheckForNull;

public enum FieldType
{
    Number
    {

        @CheckForNull
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitNumber(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }

    },
    Boolean
    {

        @CheckForNull
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitBoolean(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }

    },
    String
    {

        @CheckForNull
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitString(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }

    },
    Object
    {
        @Override
        @CheckForNull
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitObject(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    },
    ArrayString
    {

        @CheckForNull
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitArrayString(in);
        }

        @Override
        public boolean isArray()
        {
            return true;
        }

    },
    ArrayNumber
    {
        @Override
        @CheckForNull
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitArrayNumber(in);
        }

        @Override
        public boolean isArray()
        {
            return true;
        }
    },
    ArrayObject
    {
        @Override
        @CheckForNull
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitArrayObject(in);
        }

        @Override
        public boolean isArray()
        {
            return true;
        }
    },
    JsonObject
    {
        @Override
        @CheckForNull
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitJsonObject(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    },
    DoNotTreat
    {
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return null;
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    },
    ArrayJsonObject
    {
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitArrayJsonObject(in);
        }

        @Override
        public boolean isArray()
        {
            return true;
        }
    },
    Function
    {
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitFunction(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    },
    Event
    {
        @Override
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitEvent(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    },
    Element
    {
        @Override
        @CheckForNull
        public <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in)
        {
            return visitor.visitElement(in);
        }

        @Override
        public boolean isArray()
        {
            return false;
        }
    };

    @CheckForNull
    public abstract <IN, OUT> OUT accept(FieldTypeVisitor<IN, OUT> visitor, IN in);

    public abstract boolean isArray();

}


text:
begin
  require 'rspec'
rescue LoadError
  require 'rubygems' unless ENV['NO_RUBYGEMS']
  gem 'rspec'
  require 'rspec'
end

$:.unshift(File.dirname(__FILE__) + '/../lib')

require "rubygems"
require "./lib/blendris"

include Blendris

module TestFixtures

  class Food < Model

    key "food", :name

    string  :name
    string  :description, :default => "a tasty food"
    integer :calories, :default => 0
    set     :qualities
    list    :sales
    ref     :category, :class => "TestFixtures::Category", :reverse => :foods
    ref     :sibling, :class => Food, :reverse => :sibling
    refs    :friends, :class => Food, :reverse => :friends
    ref     :something

    on_change :description do
      self.calories += 1
    end

  end

  class Category < Model

    key "category", :name

    string :name
    refs   :foods, :class => "TestFixtures::Food", :reverse => :category

  end

  class FavoriteFood < Model

    key "person", :person, :food

    string :person
    ref    :food, :class => Food

  end

  class Website < Blendris::Model
    key "website", :title

    string :title
    string :url
    set    :paths
    refs   :sister_sites, :class => Website, :reverse => :sister_sites
  end

  class OnChangeTestModel < Blendris::Model
    key "fixed"

    string :string
    integer :integer
    set :set
    list :list
    ref :ref
    refs :refs

    on_change { raise TestEx.new }
  end

  class WeirdKeyModel < Blendris::Model
    key "setkey", :myset, "listkey", :mylist

    set :myset
    list :mylist
  end

  class TestEx < Exception; end

end

RSpec.configure do |config|
  include TestFixtures

  config.before(:each) do
    Blendris.database = 11
    Blendris.flushdb

    @vegetable = Category.create("vegetable")
    @onion = Food.create("onion")
    @beans = Food.create("beans")

    @fruit = Category.create("fruit")
    @apple = Food.create("apple")
    @lemon = Food.create("lemon")

    @meat = Category.create("meat")
    @steak = Food.create("steak")
  end

  config.after(:each) do
    Blendris.database = 11
    Blendris.flushdb
  end
end


text:
package com.app.qunadai;

/**
 * Created by wayne on 2017/5/2.
 */

public class QNDFactory {
    /**
     * debug开关
     */
    public static boolean isDebug = true;

    public static int COMMENT_MIN = 1;

    //征信查询授权书
    public static final String ZHENGXIN_URL = "https://hft.qunadai.com/resources/yinsiquan.html";

}


text:
package info.naiv.lab.java.jmt.net.http;

import org.hamcrest.Matchers;
import static org.hamcrest.Matchers.is;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author enlo
 */
public class HttpHeaderElementTest {

    public HttpHeaderElementTest() {
    }

    /**
     * Test of parse method, of class HttpHeaderElement.
     */
    @Test
    public void testParse01() {

        String source = "Content-Disposition: attachment";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.anEmptyMap()));
    }

    @Test
    public void testParse02() {

        String source = "Content-Disposition: attachment; filename=AAA.txt";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.hasEntry("filename", "AAA.txt")));
    }

    @Test
    public void testParse03() {

        String source = "Content-Disposition: attachment; filename=\"ABCD.doc\"";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.hasEntry("filename", "ABCD.doc")));
    }

    @Test
    public void testParse04() {

        String source = "Content-Disposition: attachment;"
                + " filename*=UTF-8''%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D.doc;"
                + " filename=\"ABCD.doc\"";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.hasEntry("filename", "ファイル名.doc")));
    }

    @Test
    public void testParse05() {

        String source = "Content-Disposition: attachment;"
                + " filename*=UTF-8'ja_JP'%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D.doc;"
                + " filename=\"ABCD.doc\"";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.hasEntry("filename", "ファイル名.doc")));
    }

    @Test
    public void testParse06() {

        String source = "Content-Disposition: attachment;"
                + " filename*0*=UTF-8'ja_JP';"
                + " filename*1*=%E3;"
                + " filename*2*=%83;"
                + " filename*3*=%95;"
                + " filename*4*=%E3;"
                + " filename*5*=%82;"
                + " filename*6*=%A1;"
                + " filename*12*=.doc;"
                + " filename*7*=%E3;"
                + " filename*8*=%82;"
                + " filename*9*=%A4;"
                + " filename*10*=%E3%83;"
                + " filename*11*=%AB%E5%90%8D;"
                + " filename=\"ABCD.doc\"";
        HttpHeaderElement actual = HttpHeaderElement.parse(source);
        assertThat(actual.getHeaderName(), is("Content-Disposition"));
        assertThat(actual.getHeaderValue(), is("attachment"));
        assertThat(actual.getParameters(), is(Matchers.hasEntry("filename", "ファイル名.doc")));
    }

}


text:
namespace xwalk {

namespace keys = application_widget_keys;

namespace application {

namespace {
// Below key names are readable from Javascript widget interface.
const char kWidgetAuthor[] = "author";
const char kWidgetDecription[] = "description";
const char kWidgetName[] = "name";
const char kWidgetShortName[] = "shortName";
const char kWidgetVersion[] = "version";
const char kWidgetID[] = "id";
const char kWidgetAuthorEmail[] = "authorEmail";
const char kWidgetAuthorHref[] = "authorHref";
const char kWidgetHeight[] = "height";
const char kWidgetWidth[] = "width";
const char kWidgetPreferences[] = "preferences";

// Child keys inside 'preferences' key.
const char kWidgetPreferencesName[] = "name";
const char kWidgetPreferencesValue[] = "value";
const char kWidgetPreferencesReadonly[] = "readonly";

// Value to test
const char author[] = "Some one";
const char decription[] = "This is a test";
const char name[] = "widget handler unittest";
const char shortName[] = "whu";
const char version[] = "0.0.0.1";
const char ID[] = "iiiiiiiiiid";
const char authorEmail[] = "aaa@bbb.com";
const char authorHref[] = "http://www.ssss.com";
const char height[] = "800";
const char width[] = "480";

const char* preferencesName[] = {"pname0", "pname1", "pname2"};
const char* preferencesValue[] = {"pvalue0", "pvalue1", "pvalue2"};
const char* preferencesReadonly[] = {"true", "false", "false"};
}  // namespace

class WidgetHandlerTest: public testing::Test {
 public:
  scoped_refptr<ApplicationData> CreateApplication(
    const base::DictionaryValue& manifest) {
    std::string error;
    scoped_refptr<ApplicationData> application = ApplicationData::Create(
        base::FilePath(), std::string(), ApplicationData::LOCAL_DIRECTORY,
        make_scoped_ptr(new Manifest(make_scoped_ptr(manifest.DeepCopy()),
                                     Manifest::TYPE_WIDGET)),
        &error);
    return application;
  }

  WidgetInfo* GetWidgetInfo(scoped_refptr<ApplicationData> application) {
    WidgetInfo* info = static_cast<WidgetInfo*>(
      application->GetManifestData(keys::kWidgetKey));
    return info;
  }

  base::DictionaryValue* GetPreferencesItem(int id,
                                            bool is_parsed_manifest_key) {
    base::DictionaryValue* preferences = new base::DictionaryValue;
    if (is_parsed_manifest_key) {
      preferences->SetString(keys::kPreferencesNameKey,
                             preferencesName[id]);
      preferences->SetString(keys::kPreferencesValueKey,
                             preferencesValue[id]);
      // PreferencesReadonly is string on manifest and bool on widgetInfo
      preferences->SetString(keys::kPreferencesReadonlyKey,
                             preferencesReadonly[id]);
    } else {
      preferences->SetString(kWidgetPreferencesName,
                             preferencesName[id]);
      preferences->SetString(kWidgetPreferencesValue,
                             preferencesValue[id]);
      preferences->SetBoolean(kWidgetPreferencesReadonly,
                              strncmp(preferencesReadonly[id], "true", 4) == 0);
    }
    return preferences;
  }

  // No Preferences and full other information
  void SetAllInfoToManifest(base::DictionaryValue* manifest) {
    // Insert some key-value pairs into manifest use full key
    manifest->SetString(keys::kAuthorKey,      author);
    manifest->SetString(keys::kDescriptionKey, decription);
    manifest->SetString(keys::kNameKey,        name);
    manifest->SetString(keys::kShortNameKey,   shortName);
    manifest->SetString(keys::kVersionKey,     version);
    manifest->SetString(keys::kIDKey,          ID);
    manifest->SetString(keys::kAuthorEmailKey, authorEmail);
    manifest->SetString(keys::kAuthorHrefKey,  authorHref);
    manifest->SetString(keys::kHeightKey,      height);
    manifest->SetString(keys::kWidthKey,       width);
  }

  // No Preferences and full other information
  void SetAllInfoToWidget(base::DictionaryValue* widget) {
    // Insert some key-value pairs into widget use widget key;
    widget->SetString(kWidgetAuthor,      author);
    widget->SetString(kWidgetDecription,  decription);
    widget->SetString(kWidgetName,        name);
    widget->SetString(kWidgetShortName,   shortName);
    widget->SetString(kWidgetVersion,     version);
    widget->SetString(kWidgetID,          ID);
    widget->SetString(kWidgetAuthorEmail, authorEmail);
    widget->SetString(kWidgetAuthorHref,  authorHref);
    widget->SetString(kWidgetHeight,      height);
    widget->SetString(kWidgetWidth,       width);
  }
};

TEST_F(WidgetHandlerTest, ParseManifestWithOnlyNameAndVersion) {
  base::DictionaryValue manifest;
  manifest.SetString(keys::kNameKey, "no name");
  manifest.SetString(keys::kVersionKey, "0");

  scoped_refptr<ApplicationData> application = CreateApplication(manifest);
  EXPECT_TRUE(application.get());

  WidgetInfo* info = GetWidgetInfo(application);
  int size = info->GetWidgetInfo()->size();

  // Only name and version ,others are empty string "",but exist.
  // And widget have 10 items.
  EXPECT_EQ(size, 10);

  base::DictionaryValue* widget = info->GetWidgetInfo();
  base::DictionaryValue::Iterator it(*widget);

  std::string tmpStr;
  // Check value
  while (!it.IsAtEnd()) {
    it.value().GetAsString(&tmpStr);
    if (it.key() == kWidgetName) {
      EXPECT_EQ(tmpStr, "no name");
    } else if (it.key() == kWidgetVersion) {
      EXPECT_EQ(tmpStr, "0");
    } else {
      EXPECT_EQ(tmpStr, "");
    }
    it.Advance();
  }
}

TEST_F(WidgetHandlerTest,
       ParseManifestWithAllOfOtherItemsAndOnePreferenceItem) {
  // Create a manifest with one preference item.
  scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue);
  SetAllInfoToManifest(manifest.get());
  manifest->Set(keys::kPreferencesKey, GetPreferencesItem(0, true));
  // Create an application use this manifest.
  scoped_refptr<ApplicationData> application;
  application = CreateApplication(*(manifest.get()));
  EXPECT_TRUE(application.get());
  EXPECT_EQ(application->manifest_type(), Manifest::TYPE_WIDGET);
  // Get widget info from this application.
  WidgetInfo* info = GetWidgetInfo(application);
  EXPECT_TRUE(info);
  scoped_ptr<base::DictionaryValue> Copy(info->GetWidgetInfo()->DeepCopy());
  base::DictionaryValue* widget_parsed_from_manifest;
  Copy->GetAsDictionary(&widget_parsed_from_manifest);
  EXPECT_TRUE(widget_parsed_from_manifest);

  // Create a widget with one preference item manually.
  scoped_ptr<base::DictionaryValue> widget(new base::DictionaryValue);
  SetAllInfoToWidget(widget.get());
  widget->Set(kWidgetPreferences, GetPreferencesItem(0, false));

  // Compare the widget parsed from manifest with
  // the widget create manually.
  EXPECT_TRUE(widget->Equals(widget_parsed_from_manifest));
}

TEST_F(WidgetHandlerTest,
       ParseManifestWithAllOfOtherItemsAndThreePreferenceItemsList) {
  // Create a manifest with three preference items.
  scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue);
  SetAllInfoToManifest(manifest.get());
  base::ListValue* manifestPreferences = new base::ListValue;
  for (int i = 0; i < 3; i++) {
    manifestPreferences->Append(GetPreferencesItem(i, true));
  }
  // Create an application use this manifest,
  scoped_refptr<ApplicationData> application;
  application = CreateApplication(*(manifest.get()));
  EXPECT_TRUE(application.get());
  EXPECT_EQ(application->manifest_type(), Manifest::TYPE_WIDGET);
  // Get widget info from this application.
  WidgetInfo* info = GetWidgetInfo(application);
  EXPECT_TRUE(info);
  scoped_ptr<base::DictionaryValue> Copy(info->GetWidgetInfo()->DeepCopy());
  base::DictionaryValue* widget_parsed_from_manifest;
  Copy->GetAsDictionary(&widget_parsed_from_manifest);
  EXPECT_TRUE(widget_parsed_from_manifest);

  // Create a widget with three preference items manually.
  scoped_ptr<base::DictionaryValue> widget(new base::DictionaryValue);
  SetAllInfoToWidget(widget.get());
  base::ListValue* widgetPreferences   = new base::ListValue;
  for (int i = 0; i < 3; i++) {
    widgetPreferences->Append(GetPreferencesItem(i, false));
  }

  // Compare the widget parsed from manifest with
  // the widget create manually.
  EXPECT_TRUE(widget->Equals(widget_parsed_from_manifest));
}

}  // namespace application
}  // namespace xwalk


text:
// This file was automatically generated by informer-gen with arguments: --input-dirs=[k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/apis/apiregistration,k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/apis/apiregistration/v1alpha1] --internal-clientset-package=k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/clientset_generated/internalclientset --listers-package=k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/listers --output-package=k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/informers --versioned-clientset-package=k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/clientset_generated/release_1_5

package informers

import (
	internalclientset "k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/clientset_generated/internalclientset"
	release_1_5 "k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/clientset_generated/release_1_5"
	apiregistration "k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/informers/apiregistration"
	internalinterfaces "k8s.io/kubernetes/cmd/kubernetes-discovery/pkg/client/informers/internalinterfaces"
	cache "k8s.io/kubernetes/pkg/client/cache"
	runtime "k8s.io/kubernetes/pkg/runtime"
	reflect "reflect"
	sync "sync"
	time "time"
)

type sharedInformerFactory struct {
	internalClient  internalclientset.Interface
	versionedClient release_1_5.Interface
	lock            sync.Mutex
	defaultResync   time.Duration

	informers map[reflect.Type]cache.SharedIndexInformer
	// startedInformers is used for tracking which informers have been started.
	// This allows Start() to be called multiple times safely.
	startedInformers map[reflect.Type]bool
}

// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
func NewSharedInformerFactory(internalClient internalclientset.Interface, versionedClient release_1_5.Interface, defaultResync time.Duration) SharedInformerFactory {
	return &sharedInformerFactory{
		internalClient:   internalClient,
		versionedClient:  versionedClient,
		defaultResync:    defaultResync,
		informers:        make(map[reflect.Type]cache.SharedIndexInformer),
		startedInformers: make(map[reflect.Type]bool),
	}
}

// Start initializes all requested informers.
func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) {
	f.lock.Lock()
	defer f.lock.Unlock()

	for informerType, informer := range f.informers {
		if !f.startedInformers[informerType] {
			go informer.Run(stopCh)
			f.startedInformers[informerType] = true
		}
	}
}

// InternalInformerFor returns the SharedIndexInformer for obj using an internal
// client.
func (f *sharedInformerFactory) InternalInformerFor(obj runtime.Object, newFunc internalinterfaces.NewInternalInformerFunc) cache.SharedIndexInformer {
	f.lock.Lock()
	defer f.lock.Unlock()

	informerType := reflect.TypeOf(obj)
	informer, exists := f.informers[informerType]
	if exists {
		return informer
	}
	informer = newFunc(f.internalClient, f.defaultResync)
	f.informers[informerType] = informer

	return informer
}

// VersionedInformerFor returns the SharedIndexInformer for obj using a
// versioned client.
func (f *sharedInformerFactory) VersionedInformerFor(obj runtime.Object, newFunc internalinterfaces.NewVersionedInformerFunc) cache.SharedIndexInformer {
	f.lock.Lock()
	defer f.lock.Unlock()

	informerType := reflect.TypeOf(obj)
	informer, exists := f.informers[informerType]
	if exists {
		return informer
	}
	informer = newFunc(f.versionedClient, f.defaultResync)
	f.informers[informerType] = informer

	return informer
}

// SharedInformerFactory provides shared informers for resources in all known
// API group versions.
type SharedInformerFactory interface {
	internalinterfaces.SharedInformerFactory

	Apiregistration() apiregistration.Interface
}

func (f *sharedInformerFactory) Apiregistration() apiregistration.Interface {
	return apiregistration.New(f)
}


text:
<!DOCTYPE html>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
    <title>

            A Full and Comprehensive Style Test (HTML) | Shekhar Singh

    </title>
    <meta name="author" content="Shekhar Singh" />
    <link rel="shortcut icon" type="image/png" href="static/img/favicon.ico"/>
    <link rel="shortcut icon" type="image/png" href="https://shekharsingh.com/static/img/favicon.ico"/>

    <meta name="keywords" content="News, Tags, Blog, Post | Shekhar Singh - Tech, Data, Fitness, Books - rootcss">

    <link rel="canonical" href="http://localhost:3000/help/2013-06-05-post1">
    <meta property="og:title" content="A Full and Comprehensive Style Test (HTML)" >
    <meta property="og:url" content="http://localhost:3000/help/2013-06-05-post1" >

    <meta property="og:site_name" content="Shekhar Singh" >

    <meta property="og:description" content="A Full and Comprehensive Style Test (HTML) - Shekhar Singh">

    <meta property="og:type" content="website">
    <meta property="og:url" content="http://localhost:3000">
    <meta property="og:locale" content="en_IN">
    <meta name="twitter:card" content="summary">
    <meta property="twitter:title" content="A Full and Comprehensive Style Test (HTML)">
    <meta name="twitter:site" content="@rootcss">
    <meta name="twitter:creator" content="@rootcss">

    <meta name="twitter:description" content="">

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ=="
        crossorigin="anonymous">

    <link rel="stylesheet" type="text/css" href="http://localhost:3000/static/css/main.css" />
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400,200bold,400old" />
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="http://localhost:3000/static/css/syntax.css" />

                Shekhar Singh

BLOG

BOOKS

OUTDOORS

ABOUT

		  A Full and Comprehensive Style Test (HTML)

This is Markdown Cheatsheet Demo for Sustain, this Jekyll theme. Please check the raw content of this file for the markdown usage.

This is just an ipsis verbis copy of the first example running on the Ghost Demo. This shows how you can use html styling to achieve your hopes.

Below is just about everything you'll need to style in the theme. Check the source code to see the many embedded elements within paragraphs.

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5

Heading 6

Lorem ipsum dolor sit amet, test link adipiscing elit. This is strong. Nullam dignissim convallis est. Quisque aliquam. This is emphasized. Donec faucibus. Nunc iaculis suscipit dui. 53 = 125. Water is H2O. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. The New York Times (That's a citation). Underline. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.

HTML and CSS are our tools. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.  Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. To copy a file type COPY <var>filename</var>. Dinner's at 5:00. Let's make that 7. This text has been struck.

Media

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore.

Big Image

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Small Image

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore.

Labore et dolore.

List Types

Definition List

Definition List Title

This is a definition list division.

Definition

An exact statement or description of the nature, scope, or meaning of something: our definition of what constitutes poetry.

Ordered List

List Item 1

List Item 2

Nested list item A

Nested list item B

List Item 3

Unordered List

List Item 1

List Item 2

Nested list item A

Nested list item B

List Item 3

Table

Table Header 1
Table Header 2
Table Header 3

Division 1
Division 2
Division 3

Division 1
Division 2
Division 3

Division 1
Division 2
Division 3

Preformatted Text

Typographically, preformatted text is not the same thing as code. Sometimes, a faithful execution of the text requires preformatted text that may not have anything to do with code. Most browsers use Courier and that's a good default — with one slight adjustment, Courier 10 Pitch over regular Courier for Linux users.

Code

Code can be presented inline, like <?php bloginfo('stylesheet_url'); ?>, or within a <pre> block. Because we have more specific typographic needs for code, we'll specify Consolas and Monaco ahead of the browser-defined monospace font.

#container {
    float: left;
    margin: 0 -240px 0 0;
    width: 100%;
}

Blockquotes

Let's keep it simple. Italics are good to help set it off from the body text. Be sure to style the citation.

Good afternoon, gentlemen. I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992. My instructor was Mr. Langley, and he taught me to sing a song. If you'd like to hear it I can sing it for you. — HAL 9000

And here's a bit of trailing text.

Text-level semantics

The a element example

The abbr element and abbr element with title examples

The b element example

The cite element example

The code element example

The del element example

The <dfn>dfn element</dfn> and <dfn title="Title text">dfn element with title</dfn> examples

The em element example

The i element example

The ins element example

The kbd element example

The mark element example

The <q>q element <q>inside</q> a q element</q> example

The <s>s element</s> example

The <samp>samp element</samp> example

The small element example

The span element example

The strong element example

The sub element example

The sup element example

The <var>var element</var> example

The u element example

Forms

<form>
<fieldset>
<legend>Inputs as descendents of labels (form legend)</legend>

Text input
<input type="text" value="default value" />

Email input
<input type="email" />

Search input
<input type="search" />

Tel input
<input type="tel" />

URL input
<input type="url" placeholder="http://" />

Password input
<input type="password" value="password" />

File input
<input type="file" />

Radio input
<input type="radio" name="rad" />

Checkbox input
<input type="checkbox" />

<input type="radio" name="rad" /> Radio input

<input type="checkbox" /> Checkbox input

Select field
<select>
<option>Option 01</option>
<option>Option 02</option>
</select>

Textarea
<textarea cols="30" rows="5">Textarea text</textarea>

</fieldset>

<fieldset>
<legend>Clickable inputs and buttons</legend>
<input type="image" src="http://placekitten.com/90/24" alt="Image (input)" />
<input type="reset" value="Reset (input)" />
<input type="button" value="Button (input)" />
<input type="submit" value="Submit (input)" />
<button type="reset">Reset (button)</button>
<button type="button">Button (button)</button>
<button type="submit">Submit (button)</button>
</fieldset>

<fieldset id="boxsize">
<legend>box-sizing tests</legend>

<input type="text" value="text" />

<input type="email" value="email" />

<input type="search" value="search" />

<input type="url" value="http://example.com" />

<input type="password" value="password" />

<input type="color" value="#000000" />

<input type="number" value="5" />

<input type="range" value="10" />

<input type="date" value="1970-01-01" />

<input type="month" value="1970-01" />

<input type="week" value="1970-W01" />

<input type="time" value="18:23" />

<input type="datetime" value="1970-01-01T00:00:00Z" />

<input type="datetime-local" value="1970-01-01T00:00" />

<input type="radio" />

<input type="checkbox" />

<select><option>Option 01</option><option>Option 02</option></select>

<textarea cols="30" rows="5">Textarea text</textarea>

<input type="image" src="http://placekitten.com/90/24" alt="Image (input)" />

<input type="reset" value="Reset (input)" />

<input type="button" value="Button (input)" />

<input type="submit" value="Submit (input)" />

<button type="reset">Reset (button)</button>

<button type="button">Button (button)</button>

<button type="submit">Submit (button)</button>

</fieldset>
</form>

Embeds

Sometimes all you want to do is embed a little love from another location and set your post alive.

Video

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Culpa qui officia deserunt mollit anim id est laborum.

Slides

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Culpa qui officia deserunt mollit anim id est laborum.

Audio

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Culpa qui officia deserunt mollit anim id est laborum.

Code

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.

</p>

var c = new Sketch.create({autoclear: false}),
    bigCircle = 50,
    littleCircle = 5,
    // The velocity value determines how much to move the spinner head (in radians).
    velocity = 0.105,
    hue = 0,
    // The alpha value below determines the length of the spinner's tail.
    bg = 'rgba(40,40,40,.075)';
    Spinner = function() {};

Spinner.prototype.setup = function() {
  this.x = c.width / 2;
  this.y = c.height / 2 - bigCircle;
  this.rotation = 0;
}
Spinner.prototype.update = function() {
  this.rotation += velocity;
  this.rotation = this.rotation % TWO_PI;
  this.x = c.width /2 + cos(this.rotation) * bigCircle;
  this.y = c.height / 2 + sin(this.rotation) * bigCircle;
}
Spinner.prototype.draw = function() {
  c.fillStyle = 'hsl('+hue+',50%,50%)';
  c.beginPath();
  c.arc(this.x, this.y, littleCircle, 0, TWO_PI);
  c.fill();
  c.closePath();
}
c.setup = function() {
  spinner = new Spinner();
  spinner.setup();
}
c.update = function() {
  spinner.update();
  hue = ++hue % 360;
}
c.draw = function() {
  spinner.draw();
  c.fillStyle = bg;
  c.fillRect(0,0,c.width,c.height);
}

See the Pen Simple Rotating Spinner by Rob Glazebrook (@rglazebrook) on CodePen.

</div>

Isn't it beautiful.

				Tags:

						News

						Tags

						Blog

						Post

				Tweet

Related Posts

    Please enable JavaScript to view the comments powered by Disqus.
    blog comments powered by Disqus

©
                 Copyright. All rights reserved | Disclaimer


text:
({
    formatValue: function(component) {
        var value = component.get("v.value");
        var inputElement = component.find("inputDateHtml").getElement();

        if (value && inputElement) {
            // v.value could be in UTC format like "2015-08-10T04:00:00.000Z",
            // we DON'T need the time portion
            var dateValue = value.split("T", 1)[0] || value;
            var parsedDate = $A.localizationService.parseDateTimeUTC(dateValue, "YYYY-MM-DD");
            if (parsedDate) {
                // HTML5 date input requires a full date format equal to YYYY-MM-DD.
                inputElement.value = $A.localizationService.formatDateUTC(parsedDate, "YYYY-MM-DD");
            }
        }
    }
});


text:
package fabhttp

import (
	"crypto/tls"
	"crypto/x509"
	"io/ioutil"

	"github.com/hyperledger/fabric/internal/pkg/comm"
)

type TLS struct {
	Enabled            bool
	CertFile           string
	KeyFile            string
	ClientCertRequired bool
	ClientCACertFiles  []string
}

func (t TLS) Config() (*tls.Config, error) {
	var tlsConfig *tls.Config

	if t.Enabled {
		cert, err := tls.LoadX509KeyPair(t.CertFile, t.KeyFile)
		if err != nil {
			return nil, err
		}
		caCertPool := x509.NewCertPool()
		for _, caPath := range t.ClientCACertFiles {
			caPem, err := ioutil.ReadFile(caPath)
			if err != nil {
				return nil, err
			}
			caCertPool.AppendCertsFromPEM(caPem)
		}
		tlsConfig = &tls.Config{
			MinVersion:   tls.VersionTLS12,
			Certificates: []tls.Certificate{cert},
			CipherSuites: comm.DefaultTLSCipherSuites,
			ClientCAs:    caCertPool,
		}
		if t.ClientCertRequired {
			tlsConfig.ClientAuth = tls.RequireAndVerifyClientCert
		} else {
			tlsConfig.ClientAuth = tls.VerifyClientCertIfGiven
		}
	}

	return tlsConfig, nil
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>success</status>
  <result>
    <project>
      <id>3743</id>
      <name>PCRE</name>
      <url>https://www.openhub.net/p/pcre.xml</url>
      <html_url>https://www.openhub.net/p/pcre</html_url>
      <created_at>2006-12-06T00:00:01Z</created_at>
      <updated_at>2015-01-15T21:50:19Z</updated_at>
      <description>The PCRE (Perl Compatible Regular Expressions) library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5. PCRE has its own native API, as well as a set of wrapper functions that correspond to the POSIX regular expression API. The PCRE library is free, even for building commercial software.</description>
      <homepage_url>http://www.pcre.org/</homepage_url>
      <download_url></download_url>
      <url_name>pcre</url_name>
      <user_count>272</user_count>
      <average_rating>4.43636</average_rating>
      <rating_count>55</rating_count>
      <review_count>2</review_count>
      <analysis_id>23780977</analysis_id>
      <tags>
        <tag>perl</tag>
        <tag>pcre</tag>
        <tag>regexp</tag>
        <tag>regular_expressions</tag>
        <tag>library</tag>
      </tags>
      <analysis>
        <id>23780977</id>
        <url>https://www.openhub.net/analyses/23780977.xml</url>
        <project_id>3743</project_id>
        <updated_at>2015-02-01T02:09:13Z</updated_at>
        <logged_at>2015-02-01T02:09:10Z</logged_at>
        <min_month>2007-02-01T00:00:00Z</min_month>
        <max_month>2014-11-01T00:00:00Z</max_month>
        <twelve_month_contributor_count>3</twelve_month_contributor_count>
        <total_contributor_count>4</total_contributor_count>
        <twelve_month_commit_count>95</twelve_month_commit_count>
        <total_commit_count>1383</total_commit_count>
        <total_code_lines>96416</total_code_lines>
        <factoids>
          <factoid type="FactoidAgeVeryOld">
Mature, well-established codebase          </factoid>
          <factoid type="FactoidCommentsAverage">
Average number of code comments          </factoid>
          <factoid type="FactoidTeamSizeSmall">
Small development team          </factoid>
          <factoid type="FactoidActivityDecreasing">
Decreasing Y-O-Y development activity          </factoid>
        </factoids>
        <languages graph_url="https://www.openhub.net/p/pcre/analyses/23780977/languages.png">
          <language percentage="75" color="FF8F00" id="42">
C          </language>
          <language percentage="13" color="47A400" id="1">
HTML          </language>
          <language percentage="6" color="F35F1F" id="44">
C++          </language>
          <language percentage="6" color="000000" id="">
9 Other          </language>
        </languages>
        <main_language_id>42</main_language_id>
        <main_language_name>C</main_language_name>
      </analysis>
      <licenses>
        <license>
          <name>BSD-3-Clause</name>
          <nice_name>BSD 3-clause "New" or "Revised" License</nice_name>
        </license>
      </licenses>
      <project_activity_index>
        <value>40</value>
        <description>Low</description>
      </project_activity_index>
    </project>
  </result>
</response>


text:
<!DOCTYPE>

    <link href="/stylesheet/bootstrap.min.css" rel="stylesheet">
    <link href="/stylesheet/style.css" rel="stylesheet">
    <link href="/stylesheet/stylePost.css" rel="stylesheet">

    <link href="/stylesheet/styleMensajes.css" rel="stylesheet">

Hot

Trending

Random

                        Tags

Funny

Animals

Anime and manga

Movies and TV

WTF

Savage

                <form class="navbar-form navbar-left" role="search" action="/search" method="POST">

                        <input type="text" class="form-control" placeholder="Type to search" name="searchedPost">

                    <button type="submit" class="btn btn-default">  </button>
                </form>

Add post

                        {{#currentUser}}
                        {{username}}
                        {{/currentUser}}

Profile

Tools

Log out

E-mail {{numEmail}}

LA FILA DE ATRAS

                    <legend class="">Mis Mensajes</legend>

RECIBIDOS

ELIMINADOS

                        {{#send-msg}}

                        <form action="/mensajes/{{username}}/enviado" method="POST">

                                        Mensaje:
                                        <textarea class="form-control" id="textarea-message" name="message-content" rows="10"></textarea>

                                    <input type="submit" class="btn btn-default navbar-right"></input>

�
                            </form>

                            {{/send-msg}}

                                {{#sinMensajes}}

No hay mensajes

                                {{/sinMensajes}}
                                {{#messages}}

  {{messageSender.username}}

                                            	{{#conversation}}
                                            	<form action="/mensajes/eliminados/movido/{{id}}" method="POST">
                                                	<button type="submit" class="btn btn-xs navbar-right"></button>
                                            	</form>
                                            	{{/conversation}}
                                                {{^conversation}}
                                                <form action="/mensajes/eliminado/{{id}}" method="POST">
                                                	<button type="submit" class="btn btn-xs navbar-right"></button>
                                            	</form>
                                            	{{/conversation}}

{{messageContent}}

                             {{/messages}}

                    Siguenos en


text:
package io.reneses.tela.modules.instagram.api;

import io.reneses.tela.core.history.History;
import io.reneses.tela.core.history.HistoryFactory;

/**
 * Factory in charge of creating a Instagram API Wrapper
 */
public class InstagramApiWrapperFactory {

    private static AbstractInstagramApiWrapper nonCachedSingleton, cachedSingleton;
    private static final boolean DEFAULT_CACHED = true;

    /**
     * Get an instance of an Instagram API Wrapper
     *
     * @param cached If a cached-enable instance should be created or not
     * @return Instagram API Wrapper
     */
    public static AbstractInstagramApiWrapper create(boolean cached) {
        if (!cached && nonCachedSingleton == null || cached && cachedSingleton == null) {
            InstagramApi instagramApi = new InstagramApiImpl();
            History history = HistoryFactory.create();
            if (cached)
                cachedSingleton = new CachedInstagramApiWrapper(instagramApi, history);
            else
                nonCachedSingleton = new InstagramApiWrapper(instagramApi, history);
        }
        return cached? cachedSingleton : nonCachedSingleton;
    }

    /**
     * Get an instance of an Instagram API Wrapper with the default configuration regarding caching
     *
     * @return Instagram API Wrapper
     */
    public static AbstractInstagramApiWrapper create() {
        return create(DEFAULT_CACHED);
    }

}