text:
// Copyright 2014 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.devtools.build.lib.analysis;

import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.Location;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.Package;

/**
 * Tests that check that dependency cycles are reported correctly.
 */
public class CircularDependencyTest extends BuildViewTestCase {
  @Override
  public void setUp() throws Exception {
    super.setUp();
  }

  public void testOneRuleCycle() throws Exception {
    checkError(
        "cycle",
        "foo.g",
        //error message
        selfEdgeMsg("//cycle:foo.g"),
        // Rule
        "genrule(name = 'foo.g',",
        "        outs = ['Foo.java'],",
        "        srcs = ['foo.g'],",
        "        cmd = 'cat $(SRCS) > $<' )");
  }

  public void testDirectPackageGroupCycle() throws Exception {
    checkError(
        "cycle",
        "melon",
        selfEdgeMsg("//cycle:moebius"),
        "package_group(name='moebius', packages=[], includes=['//cycle:moebius'])",
        "sh_library(name='melon', visibility=[':moebius'])");
  }

  public void testThreeLongPackageGroupCycle() throws Exception {
    String expectedEvent =
        "cycle in dependency graph:\n"
            + "    //cycle:superman\n"
            + "  * //cycle:rock\n"
            + "    //cycle:paper\n"
            + "    //cycle:scissors";
    checkError(
        "cycle",
        "superman",
        expectedEvent,
        "# dummy line",
        "package_group(name='paper', includes=['//cycle:scissors'])",
        "package_group(name='rock', includes=['//cycle:paper'])",
        "package_group(name='scissors', includes=['//cycle:rock'])",
        "sh_library(name='superman', visibility=[':rock'])");

    Event foundEvent = null;
    for (Event event : eventCollector) {
      if (event.getMessage().contains(expectedEvent)) {
        foundEvent = event;
        break;
      }
    }

    assertNotNull(foundEvent);
    Location location = foundEvent.getLocation();
    assertEquals(3, location.getStartLineAndColumn().getLine());
    assertEquals("/workspace/cycle/BUILD", location.getPath().toString());
  }

  /**
   * Test to detect implicit input/output file overlap in rules.
   */
  public void testOneRuleImplicitCycleJava() throws Exception {
    Package pkg =
        createScratchPackageForImplicitCycle(
            "cycle", "java_library(name='jcyc',", "      srcs = ['libjcyc.jar', 'foo.java'])");
    try {
      pkg.getTarget("jcyc");
      fail();
    } catch (NoSuchTargetException e) {
      /* ok */
    }
    assertTrue(pkg.containsErrors());
    assertContainsEvent("rule 'jcyc' has file 'libjcyc.jar' as both an" + " input and an output");
  }

  /**
   * Test not to detect implicit input/output file overlap in rules,
   * when coming from a different package.
   */
  public void testInputOutputConflictDifferentPackage() throws Exception {
    Package pkg =
        createScratchPackageForImplicitCycle(
            "googledata/xxx",
            "genrule(name='geo',",
            "    srcs = ['//googledata/geo:geo_info.txt'],",
            "    outs = ['geoinfo.txt'],",
            "    cmd = '$(SRCS) > $@')");
    assertFalse(pkg.containsErrors());
  }

  public void testTwoRuleCycle() throws Exception {
    scratchRule("b", "rule2", "cc_library(name='rule2',", "           deps=['//a:rule1'])");

    checkError(
        "a",
        "rule1",
        "in cc_library rule //a:rule1: cycle in dependency graph:\n"
            + "  * //a:rule1\n"
            + "    //b:rule2",
        "cc_library(name='rule1',",
        "           deps=['//b:rule2'])");
  }

  public void testTwoRuleCycle2() throws Exception {
    reporter.removeHandler(failFastHandler); // expect errors
    scratch.file(
        "x/BUILD", "java_library(name='x', deps=['y'])", "java_library(name='y', deps=['x'])");
    getConfiguredTarget("//x");
    assertContainsEvent("in java_library rule //x:x: cycle in dependency graph");
  }

  public void testIndirectOneRuleCycle() throws Exception {
    scratchRule(
        "cycle",
        "foo.h",
        "genrule(name = 'foo.h',",
        "      outs = ['bar.h'],",
        "      srcs = ['foo.h'],",
        "      cmd = 'cp $< $@')");
    checkError(
        "main",
        "mygenrule",
        //error message
        selfEdgeMsg("//cycle:foo.h"),
        // Rule
        "genrule(name='mygenrule',",
        "      outs = ['baz.h'],",
        "      srcs = ['//cycle:foo.h'],",
        "      cmd = 'cp $< $@')");
  }

  private String selfEdgeMsg(String label) {
    return label + " [self-edge]";
  }

  // Regression test for: "IllegalStateException in
  // AbstractConfiguredTarget.initialize()".
  // Failure to mark all cycle-forming nodes when there are *two* cycles led to
  // an attempt to initialise a node we'd already visited.
  public void testTwoCycles() throws Exception {
    reporter.removeHandler(failFastHandler); // expect errors
    scratch.file(
        "x/BUILD",
        "genrule(name='b', srcs=['c'], tools=['c'], outs=['b.out'], cmd=':')",
        "genrule(name='c', srcs=['b.out'], outs=[], cmd=':')");
    getConfiguredTarget("//x:b"); // doesn't crash!
    assertContainsEvent("in genrule rule //x:b: cycle in dependency graph");
  }
}


text:
function video_source(source = 'default') {
	// Controlled by cmd_data.msg1[4], set to normal video output by default
	const cmd_data = {
		id   : 0x6F1,
		msg0 : [ 0x63, 0x10, 0x0B, 0x31, 0x01, 0xA0, 0x1C, 0x00 ],
		msg1 : [ 0x63, 0x21, 0x00, 0x00, 0x01, 0x00, 0x01, 0xFF ],
	};

	// Support toggling video input
	switch (source) {
		case 'toggle' : {
			log.module('Toggling video input');

			// Pick target video source based on current video source (for toggling)
			switch (status.nbt.video.source) {
				case 'default' : source = 'RFK'; break;
				case 'RFK'     : source = 'default';
			}

			break;
		}
	}

	switch (source) {
		case 'default' : cmd_data.msg1[4] = 0x01; break;
		case 'RFK'     : cmd_data.msg1[4] = 0x04; break;

		default : {
			log.module('Video source ' + source + ' is not valid');
			return;
		}
	}

	log.module('Setting NBT video source to ' + source);

	// Send 1st half of message
	bus.data.send({
		bus  : config.nbt.can_intf,
		id   : cmd_data.id,
		data : Buffer.from(cmd_data.msg0),
	});

	update.status('nbt.video.source', source);

	// 2nd half of message sent 100ms later
	setTimeout(() => {
		bus.data.send({
			bus  : config.nbt.can_intf,
			id   : cmd_data.id,
			data : Buffer.from(cmd_data.msg1),
		});
	}, 100);
} // video_source(source)

function reverse_camera(gear) {
	// Bounce if NBT retrofit is not enabled or NBT reverse camera is not enabled
	if (config.retrofit.nbt               !== true) return;
	if (config.nbt.reverse_camera.enabled !== true) return;

	switch (gear) {
		case 'reverse' : {
			// If now in reverse, and were NOT before,
			// Send message to NBT to switch input to reverse camera
			if (status.egs.gear === 'reverse') return;

			// Wait 250ms, then check if we're still in reverse
			setTimeout(() => {
				if (status.egs.gear !== 'reverse') return;

				video_source(config.nbt.reverse_camera.input);
			}, 250);

			break;
		}

		default : {
			// If now NOT in reverse, and were before
			// Send message to NBT to switch input to default
			if (status.egs.gear !== 'reverse') return;

			setTimeout(() => {
				if (status.egs.gear         === 'reverse')                       return;
				if (status.nbt.video.source !== config.nbt.reverse_camera.input) return;

				video_source();
			}, 250);
		}
	}
} // reverse_camera(gear)

// Used for iDrive knob rotational initialization
function decode_init_con(data) {
	// Bounce if not enabled
	if (config.emulate.nbt !== true && config.retrofit.nbt !== true) return data;

	data.command = 'con';
	data.value   = 'NBT init iDrive knob';

	// log.module('NBT status message ' + Buffer.from(data.msg));

	return data;
} // decode_init_con(data)

// Initialize CON rotation counter
function encode_init_con(action = false) {
	// Bounce if not enabled
	if (config.emulate.nbt !== true && config.retrofit.con !== true) return;

	// Handle setting/unsetting timeout
	switch (action) {
		case false : {
			if (NBT.timeout.encode_init_con !== null) {
				clearTimeout(NBT.timeout.encode_init_con);
				NBT.timeout.encode_init_con = null;

				log.module('Unset CON rotation init timeout');
			}

			// Return here since we're not re-sending again
			return;
		}

		case true : {
			NBT.timeout.encode_init_con = setTimeout(() => {
				encode_init_con(true);
			}, 10000);

			if (NBT.timeout.encode_init_con === null) log.module('Set CON rotation init timeout');
		}
	}

	const msg = {
		bus  : config.nbt.can_intf,
		id   : null,
		data : [ ],
	};

	switch (config.nbt.mode.toLowerCase()) {
		case 'cic' : {
			msg.id   = 0x273;
			msg.data = [ 0x1D, 0xE1, 0x00, 0xF0, 0xFF, 0x7F, 0xDE, 0x04 ];
			break;
		}

		case 'nbt' : {
			msg.id   = 0x563;
			msg.data = [ 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x63 ];
			break;
		}

		default : {
			log.error('config.nbt.mode must be set to one of CIC or NBT');
			return;
		}
	}

	// Convert data array to Buffer
	msg.data = Buffer.from(msg.data);

	// Send message
	bus.data.send(msg);
} //  encode_init_con(action)

function init_listeners() {
	// Bounce if not enabled
	if (config.emulate.nbt !== true && config.retrofit.nbt !== true) return;

	// Perform commands on EGS gear changes
	EGS.on('gear', reverse_camera);

	// Perform commands on power lib active event
	power.on('active', data => {
		encode_init_con(data.new);
	});

	log.module('Initialized listeners');
} // init_listeners()

// Parse data sent to module
function parse_in(data) {
	// Bounce if not enabled
	if (config.emulate.nbt !== true) return data;

	return data;
} // parse_in(data)

// Parse data sent from module
function parse_out(data) {
	// Bounce if not enabled
	if (config.emulate.nbt !== true && config.retrofit.nbt !== true) return data;

	switch (data.src.id) {
		case 0x273 :
		case 0x563 : return decode_init_con(data);

		case 0x277 : { // NBT ACK to rotational initialization message
			data.command = 'rep';
			data.value   = 'CON => NBT : ACK init';
			break;
		}

		case 0x34E : { // NBT navigation information
			data.command = 'bro';
			data.value   = 'Navigation system information';
			break;
		}

		case 0x38D : return;
		case 0x5E3 : {
			data.command = 'bro';
			data.value   = 'Services';
			break;
		}
	}

	return data;
} // parse_out(data)

module.exports = {
	timeout : {
		encode_init_con : null,
	},

	// Functions
	init_listeners,

	video_source,

	parse_in,
	parse_out,
};

redpajama_set_name: RedPajamaGithub


text:
package com.google.gerrit.acceptance.pgm;

import com.google.gerrit.testing.ConfigSuite;
import org.eclipse.jgit.lib.Config;

public class LuceneReindexIT extends AbstractReindexTests {
  @ConfigSuite.Default
  public static Config luceneConfig() {
    Config cfg = new Config();
    cfg.setString("index", null, "type", "lucene");
    return cfg;
  }
}


text:
//
//  SortViewCell.h
//  JuPai
//
//  Created by wangjiayu on 2017/1/13.
//
//

#import <UIKit/UIKit.h>
@class Items;

static NSString * const sortViewCellIdentifier = @"sortViewCellIdentifier";

@interface SortViewCell : UICollectionViewCell
/** 数据模型 */
@property (nonatomic,strong)  Items *items;

@property (weak, nonatomic) IBOutlet UIView *lineView;

@end


text:
package io.cattle.platform.servicediscovery.deployment;

public interface DeploymentUnitInstanceIdGenerator {

    Integer getNextAvailableId();
}


text:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="true"
         stopOnFailure="false"
         syntaxCheck="false"
         verbose="true"
         beStrictAboutTestsThatDoNotTestAnything="true">
    <testsuites>
        <testsuite name="Bencode Test Suites">
            <directory suffix=".php">./tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>


text:
define([
    'jquery',
    'rangy-core',
    'ext/PluginMgr',
    'util/PubSub',
    'util/FocusTracker',
    'ext/PluginContext',
    'hithandler/HitHandler'
], function ($, rangy, PluginMgr, PubSub, FocusTracker, Context, HitHandler) {
    'use strict';

    var InsertCommandHandler = function () {
        PubSub.subscribe('plugin.saved', this.onPluginSave.bind(this));
        PubSub.subscribe('plugin.exited', this.onPluginCancel.bind(this));
        PubSub.subscribe('insert.text', this.onTextInsert.bind(this));
        PubSub.subscribe('insert.html', this.onHtmlInsert.bind(this));
        HitHandler.register(this);
    };

    /**
     * Remove focus from the editable so that the virtiual keyboard will slide out on
     * the iPad.
     */
    InsertCommandHandler.prototype.loadPlugin = function (id) {
        FocusTracker.removeFocus();
        PluginMgr.loadPlugin(id);
    };

    InsertCommandHandler.prototype.insert = function (contentType) {
        this.loadPlugin(contentType);
    };

    /**
     * Only act on double hits even though single are also accepted (which prevents them being
     * passed to the default hit listeners).
     */
    InsertCommandHandler.prototype.handle = function (event) {
        var ctx = PluginMgr.identifyPlugin(event.event),
            handled;
        if (ctx) {
            if (event.hitType === 'double') {
                this.loadPlugin(ctx);
            }
            handled = true;
        }
        return handled;
    };

    /**
     * On the iPad there are cases where there is no saved range (e.g. manually slide the keyboard
     * out). In these cases the best that can be done is to programmatically create a range.
     */
    InsertCommandHandler.prototype.onPluginSave = function (data) {
        var range = FocusTracker.createFocus();
        try {
            Context.commit(data, range);
            rangy.getSelection().setSingleRange(range);
            PubSub.publish('editable.range', range);
        } finally {
            Context.destroy();
        }
    };

    InsertCommandHandler.prototype.onPluginCancel = function () {
        Context.destroy();
        FocusTracker.restoreFocus();
    };

    /**
     * Inserts text into the current editable at the cursor location.
     */
    InsertCommandHandler.prototype.onTextInsert = function (text) {
        var range, node;
        range = FocusTracker.createFocus();
        node = document.createTextNode(text);
        if (!range.collapsed) {
            range.deleteContents();
        }
        range.insertNode(node);
        range.setStartAfter(node);
        range.collapse(false);
        rangy.getSelection().setSingleRange(range);
        PubSub.publish('editable.range', range);
    };

    /**
     * Inserts html into the current editable at the cursor location.
     */
    InsertCommandHandler.prototype.onHtmlInsert = function (html) {
        var range, nodes;
        range = FocusTracker.createFocus();
        if (!range.collapsed) {
            range.deleteContents();
        }
        nodes = $(html);
        nodes.each(function () {
            range.insertNode(this);
            range.setStartAfter(this);
            range.collapse(false);
        });
        rangy.getSelection().setSingleRange(range);
        PubSub.publish('editable.range', range);
    };

    return InsertCommandHandler;
});


text:
//: concurrency/MultiLock.java
package concurrency; /* Added by Eclipse.py */
// One thread can reacquire the same lock.
import static net.mindview.util.Print.*;

public class MultiLock {
  public synchronized void f1(int count) {
    if(count-- > 0) {
      print("f1() calling f2() with count " + count);
      f2(count);
    }
  }
  public synchronized void f2(int count) {
    if(count-- > 0) {
      print("f2() calling f1() with count " + count);
      f1(count);
    }
  }
  public static void main(String[] args) throws Exception {
    final MultiLock multiLock = new MultiLock();
    new Thread() {
      public void run() {
        multiLock.f1(10);
      }
    }.start();
  }
} /* Output:
f1() calling f2() with count 9
f2() calling f1() with count 8
f1() calling f2() with count 7
f2() calling f1() with count 6
f1() calling f2() with count 5
f2() calling f1() with count 4
f1() calling f2() with count 3
f2() calling f1() with count 2
f1() calling f2() with count 1
f2() calling f1() with count 0
*///:~


text:
package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// Switch Ethernet Switch REST API
//
// swagger:model switch
type Switch struct {

	// links
	Links *SelfLink `json:"_links,omitempty"`

	// IP Address.
	Address string `json:"address,omitempty"`

	// Discovered By ONTAP CDP/LLDP
	// Read Only: true
	Discovered *bool `json:"discovered,omitempty"`

	// Model Number.
	Model string `json:"model,omitempty"`

	// monitoring
	Monitoring *SwitchMonitoring `json:"monitoring,omitempty"`

	// Name.
	Name string `json:"name,omitempty"`

	// Switch Network.
	// Enum: [cluster management storage]
	Network string `json:"network,omitempty"`

	// Serial Number.
	// Read Only: true
	SerialNumber string `json:"serial_number,omitempty"`

	// snmp
	Snmp *SwitchSnmp `json:"snmp,omitempty"`

	// Software Version.
	// Read Only: true
	Version string `json:"version,omitempty"`
}

// Validate validates this switch
func (m *Switch) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateLinks(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateMonitoring(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateNetwork(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateSnmp(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Switch) validateLinks(formats strfmt.Registry) error {
	if swag.IsZero(m.Links) { // not required
		return nil
	}

	if m.Links != nil {
		if err := m.Links.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("_links")
			}
			return err
		}
	}

	return nil
}

func (m *Switch) validateMonitoring(formats strfmt.Registry) error {
	if swag.IsZero(m.Monitoring) { // not required
		return nil
	}

	if m.Monitoring != nil {
		if err := m.Monitoring.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("monitoring")
			}
			return err
		}
	}

	return nil
}

var switchTypeNetworkPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["cluster","management","storage"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		switchTypeNetworkPropEnum = append(switchTypeNetworkPropEnum, v)
	}
}

const (

	// BEGIN DEBUGGING
	// switch
	// Switch
	// network
	// Network
	// cluster
	// END DEBUGGING
	// SwitchNetworkCluster captures enum value "cluster"
	SwitchNetworkCluster string = "cluster"

	// BEGIN DEBUGGING
	// switch
	// Switch
	// network
	// Network
	// management
	// END DEBUGGING
	// SwitchNetworkManagement captures enum value "management"
	SwitchNetworkManagement string = "management"

	// BEGIN DEBUGGING
	// switch
	// Switch
	// network
	// Network
	// storage
	// END DEBUGGING
	// SwitchNetworkStorage captures enum value "storage"
	SwitchNetworkStorage string = "storage"
)

// prop value enum
func (m *Switch) validateNetworkEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, switchTypeNetworkPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *Switch) validateNetwork(formats strfmt.Registry) error {
	if swag.IsZero(m.Network) { // not required
		return nil
	}

	// value enum
	if err := m.validateNetworkEnum("network", "body", m.Network); err != nil {
		return err
	}

	return nil
}

func (m *Switch) validateSnmp(formats strfmt.Registry) error {
	if swag.IsZero(m.Snmp) { // not required
		return nil
	}

	if m.Snmp != nil {
		if err := m.Snmp.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("snmp")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this switch based on the context it is used
func (m *Switch) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateLinks(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateDiscovered(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateMonitoring(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateSerialNumber(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateSnmp(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateVersion(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Switch) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error {

	if m.Links != nil {
		if err := m.Links.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("_links")
			}
			return err
		}
	}

	return nil
}

func (m *Switch) contextValidateDiscovered(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "discovered", "body", m.Discovered); err != nil {
		return err
	}

	return nil
}

func (m *Switch) contextValidateMonitoring(ctx context.Context, formats strfmt.Registry) error {

	if m.Monitoring != nil {
		if err := m.Monitoring.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("monitoring")
			}
			return err
		}
	}

	return nil
}

func (m *Switch) contextValidateSerialNumber(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "serial_number", "body", string(m.SerialNumber)); err != nil {
		return err
	}

	return nil
}

func (m *Switch) contextValidateSnmp(ctx context.Context, formats strfmt.Registry) error {

	if m.Snmp != nil {
		if err := m.Snmp.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("snmp")
			}
			return err
		}
	}

	return nil
}

func (m *Switch) contextValidateVersion(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "version", "body", string(m.Version)); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *Switch) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *Switch) UnmarshalBinary(b []byte) error {
	var res Switch
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}

// SwitchMonitoring switch monitoring
//
// swagger:model SwitchMonitoring
type SwitchMonitoring struct {

	// Enable Health Monitoring.
	Enabled bool `json:"enabled,omitempty"`

	// Is Monitored.
	// Read Only: true
	Monitored *bool `json:"monitored,omitempty"`

	// Reason For Not Monitoring.
	// Read Only: true
	// Enum: [none unsupported_model user_deleted bad_ip_address invalid_snmp_settings bad_model invalid_software_version user_disabled unknown]
	Reason string `json:"reason,omitempty"`
}

// Validate validates this switch monitoring
func (m *SwitchMonitoring) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateReason(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

var switchMonitoringTypeReasonPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["none","unsupported_model","user_deleted","bad_ip_address","invalid_snmp_settings","bad_model","invalid_software_version","user_disabled","unknown"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		switchMonitoringTypeReasonPropEnum = append(switchMonitoringTypeReasonPropEnum, v)
	}
}

const (

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// none
	// END DEBUGGING
	// SwitchMonitoringReasonNone captures enum value "none"
	SwitchMonitoringReasonNone string = "none"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// unsupported_model
	// END DEBUGGING
	// SwitchMonitoringReasonUnsupportedModel captures enum value "unsupported_model"
	SwitchMonitoringReasonUnsupportedModel string = "unsupported_model"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// user_deleted
	// END DEBUGGING
	// SwitchMonitoringReasonUserDeleted captures enum value "user_deleted"
	SwitchMonitoringReasonUserDeleted string = "user_deleted"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// bad_ip_address
	// END DEBUGGING
	// SwitchMonitoringReasonBadIPAddress captures enum value "bad_ip_address"
	SwitchMonitoringReasonBadIPAddress string = "bad_ip_address"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// invalid_snmp_settings
	// END DEBUGGING
	// SwitchMonitoringReasonInvalidSnmpSettings captures enum value "invalid_snmp_settings"
	SwitchMonitoringReasonInvalidSnmpSettings string = "invalid_snmp_settings"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// bad_model
	// END DEBUGGING
	// SwitchMonitoringReasonBadModel captures enum value "bad_model"
	SwitchMonitoringReasonBadModel string = "bad_model"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// invalid_software_version
	// END DEBUGGING
	// SwitchMonitoringReasonInvalidSoftwareVersion captures enum value "invalid_software_version"
	SwitchMonitoringReasonInvalidSoftwareVersion string = "invalid_software_version"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// user_disabled
	// END DEBUGGING
	// SwitchMonitoringReasonUserDisabled captures enum value "user_disabled"
	SwitchMonitoringReasonUserDisabled string = "user_disabled"

	// BEGIN DEBUGGING
	// SwitchMonitoring
	// SwitchMonitoring
	// reason
	// Reason
	// unknown
	// END DEBUGGING
	// SwitchMonitoringReasonUnknown captures enum value "unknown"
	SwitchMonitoringReasonUnknown string = "unknown"
)

// prop value enum
func (m *SwitchMonitoring) validateReasonEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, switchMonitoringTypeReasonPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *SwitchMonitoring) validateReason(formats strfmt.Registry) error {
	if swag.IsZero(m.Reason) { // not required
		return nil
	}

	// value enum
	if err := m.validateReasonEnum("monitoring"+"."+"reason", "body", m.Reason); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this switch monitoring based on the context it is used
func (m *SwitchMonitoring) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateMonitored(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateReason(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *SwitchMonitoring) contextValidateMonitored(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "monitoring"+"."+"monitored", "body", m.Monitored); err != nil {
		return err
	}

	return nil
}

func (m *SwitchMonitoring) contextValidateReason(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "monitoring"+"."+"reason", "body", string(m.Reason)); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *SwitchMonitoring) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *SwitchMonitoring) UnmarshalBinary(b []byte) error {
	var res SwitchMonitoring
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}

// SwitchSnmp switch snmp
//
// swagger:model SwitchSnmp
type SwitchSnmp struct {

	// Community String or SNMPv3 Username.
	User string `json:"user,omitempty"`

	// SNMP Version.
	// Enum: [snmpv1 snmpv2c snmpv3]
	Version string `json:"version,omitempty"`
}

// Validate validates this switch snmp
func (m *SwitchSnmp) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateVersion(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

var switchSnmpTypeVersionPropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["snmpv1","snmpv2c","snmpv3"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		switchSnmpTypeVersionPropEnum = append(switchSnmpTypeVersionPropEnum, v)
	}
}

const (

	// BEGIN DEBUGGING
	// SwitchSnmp
	// SwitchSnmp
	// version
	// Version
	// snmpv1
	// END DEBUGGING
	// SwitchSnmpVersionSnmpv1 captures enum value "snmpv1"
	SwitchSnmpVersionSnmpv1 string = "snmpv1"

	// BEGIN DEBUGGING
	// SwitchSnmp
	// SwitchSnmp
	// version
	// Version
	// snmpv2c
	// END DEBUGGING
	// SwitchSnmpVersionSnmpv2c captures enum value "snmpv2c"
	SwitchSnmpVersionSnmpv2c string = "snmpv2c"

	// BEGIN DEBUGGING
	// SwitchSnmp
	// SwitchSnmp
	// version
	// Version
	// snmpv3
	// END DEBUGGING
	// SwitchSnmpVersionSnmpv3 captures enum value "snmpv3"
	SwitchSnmpVersionSnmpv3 string = "snmpv3"
)

// prop value enum
func (m *SwitchSnmp) validateVersionEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, switchSnmpTypeVersionPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *SwitchSnmp) validateVersion(formats strfmt.Registry) error {
	if swag.IsZero(m.Version) { // not required
		return nil
	}

	// value enum
	if err := m.validateVersionEnum("snmp"+"."+"version", "body", m.Version); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this switch snmp based on context it is used
func (m *SwitchSnmp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *SwitchSnmp) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *SwitchSnmp) UnmarshalBinary(b []byte) error {
	var res SwitchSnmp
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}


text:
package com.vtapadia.fifa.dao;

import com.vtapadia.fifa.domain.Match;
import com.vtapadia.fifa.domain.Prediction;
import com.vtapadia.fifa.domain.User;
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.transform.ResultTransformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Repository
public class PredictionDAO extends AbstractDAO<Prediction> {
    Logger log = LoggerFactory.getLogger(PredictionDAO.class);

    public Prediction getById(long id) {
        Query query = getEntityManager().createNativeQuery("select * from ef_prediction where id=?1", Prediction.class);
        query.setParameter(1,id);
        Prediction prediction = (Prediction) query.getSingleResult();
        return prediction;
    }

    public List<Prediction> getForUser(User user) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        List<Prediction> predictions = criteria.list();
        return predictions;
    }

    public List<Prediction> forUpdateForUser(User user) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        criteria.createAlias("match", "match");
        criteria.add(Restrictions.gt("match.matchDate", new Date()));
        criteria.addOrder(Order.asc("match.matchDate"));
        List<Prediction> predictions = criteria.list();
        return predictions;
    }

    public List<Prediction> forViewForUser(User user) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        criteria.createAlias("match", "match");
        Date date = new Date();
        criteria.add(
                Restrictions.or(
                        Restrictions.lt("match.matchDate", date),
                        Restrictions.eq("match.matchDate", date)
                ));
        criteria.addOrder(Order.desc("match.matchDate"));
        List<Prediction> predictions = criteria.list();
        return predictions;
    }

    public List<Prediction> getForMatch(Match match) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("match", match));
        List<Prediction> predictions = criteria.list();
        return predictions;
    }

    public List<Prediction> getForUserMatches(User user, List<Match> matches) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        criteria.createAlias("match", "match");
        criteria.add(Restrictions.in("match", matches));
        criteria.addOrder(Order.asc("match.matchDate")).addOrder(Order.asc("match.id"));
        List<Prediction> predictions = criteria.list();
        return predictions;
    }

    public boolean createSafe(User user, Match match) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        criteria.add(Restrictions.eq("match", match));

        List<Prediction> predictions = criteria.list();
        Prediction prediction = null;
        if (predictions.size() == 0) {
            prediction = new Prediction();
            prediction.setCreated(new Date());
            prediction.setUser(user);
            prediction.setMatch(match);
            prediction.setTeamAScore(0);
            prediction.setTeamBScore(0);
            save(prediction);
        } else {
            log.debug("Ignoring for default prediction " + user.getUser_id() + " match " + match.getId());
        }
        return true;
    }

    public Prediction update(User user, Match match, int teamAScore, int teamBScore) {
        Criteria criteria = getCriteria();
        criteria.add(Restrictions.eq("user", user));
        criteria.add(Restrictions.eq("match", match));

        List<Prediction> predictions = criteria.list();
        Prediction prediction = null;
        if (predictions.size() == 0) {
            prediction = new Prediction();
            prediction.setCreated(new Date());
            prediction.setUser(user);
            prediction.setMatch(match);
            prediction.setTeamAScore(teamAScore);
            prediction.setTeamBScore(teamBScore);
        } else {
            prediction = predictions.get(0);
            prediction.setTeamAScore(teamAScore);
            prediction.setTeamBScore(teamBScore);
        }
        save(prediction);
        return prediction;
    }

    @Override
    protected Class getDomainClass() {
        return Prediction.class;
    }
}


text:
Inherited Events

{% if inheritedEvents.length > 0 %}
{% for event in inheritedEvents %}
{% include "partials/event.html" %}
{% endfor %}
{% else %}
No inherited events
{% endif %}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon" href="../../../docs/favicon.ico">

  <title>宿舍管理系统-管理员主页</title>

  <link href="../../../dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="../../../docs/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
  <link href="../../css/admin/home.css" rel="stylesheet">

        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          Toggle navigation

        </button>
        学生宿舍管理系统

(头像)刘宿管

注销

宿舍入退调申请处理(current)

宿舍报修申请处理

宿舍资源申请处理

社区活动申请处理

共享书屋

宿生信息检索


text:
<!DOCTYPE html>
<html>
  <body>
    <fieldset>
      <legend>
        <textarea style="background-color: green;"></textarea>
      </legend>
    </fieldset>
  </body>
</html>


text:
int comparison_count = 0;
template <typename T>
bool counting_equals ( const T &a, const T &b ) {
    ++comparison_count;
    return a == b;
    }

int main()
{
    {
        const int ia[] = {0};
        const int ib[] = {0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + 0),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0};
        const int ib[] = {1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }

    {
        const int ia[] = {0, 0};
        const int ib[] = {0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0};
        const int ib[] = {0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0};
        const int ib[] = {1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0};
        const int ib[] = {1, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1};
        const int ib[] = {0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1};
        const int ib[] = {0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1};
        const int ib[] = {1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1};
        const int ib[] = {1, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 0};
        const int ib[] = {0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 0};
        const int ib[] = {0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 0};
        const int ib[] = {1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 0};
        const int ib[] = {1, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 1};
        const int ib[] = {0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 1};
        const int ib[] = {0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 1};
        const int ib[] = {1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {1, 1};
        const int ib[] = {1, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }

    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 0, 2};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 1, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 1, 2};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 2, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 2, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 0};
        const int ib[] = {1, 2, 2};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 1};
        const int ib[] = {1, 0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 1};
        const int ib[] = {1, 0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1, 2};
        const int ib[] = {1, 0, 2};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1, 2};
        const int ib[] = {1, 2, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1, 2};
        const int ib[] = {2, 1, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1, 2};
        const int ib[] = {2, 0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 1};
        const int ib[] = {1, 0, 1};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 0, 1};
        const int ib[] = {1, 0, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib + 1),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
#endif
    }
    {
        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == true);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == true);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib + 1),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   std::equal_to<const int>()) == false);
        comparison_count = 0;
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa - 1),
                                   counting_equals<const int>) == false);
        assert ( comparison_count > 0 );
        comparison_count = 0;
        assert(std::is_permutation(random_access_iterator<const int*>(ia),
                                   random_access_iterator<const int*>(ia + sa),
                                   random_access_iterator<const int*>(ib),
                                   random_access_iterator<const int*>(ib + sa - 1),
                                   counting_equals<const int>) == false);
        assert ( comparison_count == 0 );
#endif
    }
    {
        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   std::equal_to<const int>()) == false);
#ifdef HAS_FOUR_ITERATOR_VERSION
        assert(std::is_permutation(forward_iterator<const int*>(ia),
                                   forward_iterator<const int*>(ia + sa),
                                   forward_iterator<const int*>(ib),
                                   forward_iterator<const int*>(ib + sa),
                                   std::equal_to<const int>()) == false);
#endif
    }
}


text:
package id.my.note.todolist;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hilmiat on 16/09/17.
 */

public class TodoDBModel {
    SQLiteDatabase db;

    public TodoDBModel(Context ctx) {
        this.db = new TaskDbHelper(ctx).getWritableDatabase();
    }

    public ArrayList<Todo> getAllTodo(){
        //#1 siapkan penampungan data
        ArrayList<Todo> taskList = new ArrayList<>();
        //#3 query data
        Cursor cur = db.query("table_todo",
                new String[]{"title",
                            "description",
                            "date",
                            "priority",
                            "category",
                            "_id"},
                null,null,null,null,null);
        //#4 looping cursor untuk disimpan dalam penampungan data
        while (cur.moveToNext()){
            Todo todo = new Todo();
            //get title
            int title_index = cur.getColumnIndex("title");
            todo.setTitle(cur.getString(title_index));
            //get description
            todo.setDescription(cur.getString(cur.getColumnIndex("description")));
            //get date
            todo.setDate(cur.getString(cur.getColumnIndex("date")));
            //get priority
            todo.setPriority(cur.getInt(cur.getColumnIndex("priority")));
            //get _id
            todo.set_id(cur.getInt(cur.getColumnIndex("_id")));

            taskList.add(todo);
        }
        return taskList;
    }

    public void deleteTodo(int id){
        db.delete("table_todo","_id=?",new String[]{id+""});
    }
    public Todo getById(int id){
        //#2 Query data
        Cursor cur = db.query("table_todo",
                new String[]{"title",
                        "description",
                        "date",
                        "priority",
                        "_id",
                        "category"},
                "_id = ?",
                new String[]{id+""},
                null,null,null
        );
        //baca data
        cur.moveToFirst();
        Todo todo = new Todo();
        //get title
        int title_index = cur.getColumnIndex("title");
        todo.setTitle(cur.getString(title_index));
        //get description
        todo.setDescription(cur.getString(cur.getColumnIndex("description")));
        //get date
        todo.setDate(cur.getString(cur.getColumnIndex("date")));
        //get priority
        todo.setPriority(cur.getInt(cur.getColumnIndex("priority")));
        //get _id
        todo.set_id(cur.getInt(cur.getColumnIndex("_id")));
        //get category
        todo.setCategory(cur.getInt(cur.getColumnIndex("category")));
        return todo;
    }

    public void insertTodo(Todo todo){
        ContentValues cv = this.todoToCV(todo);
        db.insert("table_todo",null,cv);
    }
    public void updateTodo(Todo todo){
        ContentValues cv = this.todoToCV(todo);
        //update data
        db.update("table_todo",
                cv,
                "_id=?",
                new String[]{todo.get_id()+""});
    }
    public ContentValues todoToCV(Todo todo){
        ContentValues cv = new ContentValues();
        cv.put("title",todo.getTitle());
        cv.put("description",todo.getDescription());
        cv.put("priority",todo.getPriority());
        cv.put("date",todo.getDate());
        cv.put("category",todo.getCategory());
        return cv;
    }
}


text:
require 'optparse'
require_relative  'core/context'

module Bauxite
	# +bauxite+ command-line program.
	#
	# This program executes Bauxite tests and outputs the execution progress
	# and tests results to the terminal.
	#
	# == Synopsis
	#
	#    bauxite [OPTIONS] file1 file2 ...
	#    # => Executes file1, then file2, and so on.
	#
	#    bauxite [OPTIONS] -d
	#    # => Start Bauxite directly in the debug console.
	#
	#    bauxite [OPTIONS]
	#    # => Start Bauxite and read test actions from the standard input.
	#
	# == Options
	# For a detailed list of options for your Bauxite version execute:
	#    bauxite -h
    #
	#
	# [-v, \--verbose]
	#     Show verbose error messages (i.e. print exception names and
	#     backtraces).
	#
	# [-t, \--timeout SECONDS]
	#     Number of seconds to wait before issuing a timeout error. This
	#     timeout applies only to Selectors.
	#
	# [-o, \--open_timeout SECONDS]
	#     Number of seconds to wait before issuing a timeout error. This
	#     timeout applies only to page loading times (i.e. Net::HTTP).
	#
	# [-d, \--debug]
	#     If an error occurs, break into the debug console. This mode is very
	#     useful to try different selector combinations and debug
	#     NoSuchElementError errors.
	#
	# [-p, \--provider DRIVER]
	#     Selenium WebDriver provider. Defaults to +firefox+.
	#
	#     Other options include:
	#     - +remote+
	#     - +ie+
	#     - +chrome+
	#     - +android+
	#     - +iphone+
	#     - +opera+
	#     - +phantomjs+
	#     - +safari+
	#
	#     Driver availability dependes on the system running Bauxite.
	# [-P, \--provider-option OPTION]
	#    A <tt>name=value</tt> pair of options that are directly forwarded to
	#    the Selenium WebDriver provider. This option argument can appear
	#    multiple times in the command line to specify multiple options.
	#
	# [-l, \--logger LOGGER]
	#    Logger instance to use. Defaults to +xterm+ if the +TERM+ environment
	#    variable is set to +xterm+, otherwise it defaults to +terminal+.
	#
	#    To see a complete list of the available loggers execute:
	#        bauxite -h
	#
	#    Note that multiple instances of this option can be specified.
	#
	# [-L, \--logger-option OPTION]
	#    A <tt>name=value</tt> pair of options that are directly forwarded to
	#    the logger. This option argument can appear multiple times in the
	#    command line to specify multiple options.
	#
	# [-r, \--reset]
	#    Issue a Action#reset action between every test specified in
	#    the command line. This option enforces test isolation by resetting
	#    the test context before each test (this removes cookies, sessions,
	#    etc. from the previous test).
	#
	# [-w, \--wait]
	#    Wait for user input when the test completes instead of closing the
	#    browser window.
	#
	# [-s, \--selector SELECTOR]
	#    Default selector strategy. This strategy is applied if the selector
	#    text does not contain an <tt>=</tt> sign.
	#
	#    To see a complete list of the available selectors execute:
	#        bauxite -h
	#
	# [-c, \--capture]
	#    If the test fails, capture a screenshot in the +output+ directory.
	#    See the \--output option below.
	#
	# [\--csv-summary FILE]
	#    Output a single-line CSV summary ideal to feed into the Plot Jenkins
	#    plugin. If +FILE+ is not specified, defaults to +summary.csv+
	#
	# [\--output DIR]
	#    Output directory for generated artifacts. Defaults to the current
	#    working directory.
	#
	# [-u, \--url URL]
	#    This option is an alias of:
	#        -p remote -P url=URL
	#    If +URL+ is not present <tt>http://localhost:4444/wd/hub</tt> will be
	#    assumed.
	#
	# [\--jenkins DIR]
	#    Configures default options for Jenkins integration. This option is an
	#    alias of:
	#         -p remote -P url=http://localhost:4444/wd/hub -l echo -l html
	#         -L html_package=true -c --csv-summary
	#         --output DIR
	#    Note that any of the options above can be overridden by specifying the
	#    option after the <tt>--jenkins</tt> option. For example:
	#         --jenkins -u selenium.my-organization.com:4445
	#
	# [-e, \--extension DIR]
	#    Loads every Ruby file (*.rb) inside +DIR+ (and subdirectories). This
	#    option can be used to load custom Bauxite extensions (e.g. Actions,
	#    Selectors, Loggers, etc.) for a specific test run.
	#
	#    For example:
	#        # === custom/my_selector.rb ======= #
	#        class Bauxite::Selector
	#            def by_attr(value)
	#                attr "by_attr:#{value}"
	#            end
	#        end
	#        # === end custom/my_selector.rb === #
	#
	#        # === custom/my_test.bxt ========== #
	#        # ...
	#        assert "by_attr=attr_value" hello
	#        # ...
	#        # === end custom/my_test.bxt ====== #
	#
	#        bauxite -e custom custom/my_test.bxt
	#
	# [\--version]
	#     Shows the Bauxite version.
	#
	# == Exit Status
	# The +bauxite+ program exits with +zero+ if every action in the test
	# succeeded and +non-zero+ otherwise.
	#
	# If the test run includes multiple Action#test actions, the exit status
	# equals the number of failed test cases (again, +zero+ indicates success).
	#
	class Application
		def self.start #:nodoc:
			options = {
				:logger       => [],
				:verbose      => false,
				:break        => false,
				:driver       => 'firefox',
				:debug        => false,
				:timeout      => 10,
				:open_timeout => 60,
				:reset        => false,
				:selector     => 'sid',
				:driver_opt   => {},
				:logger_opt   => {},
				:extensions   => []
			}

			default_logger = (ENV['TERM'] == 'xterm') ?  'xterm' : 'terminal'

			OptionParser.new do |opts|
				opts.banner = "Usage: bauxite [options] [files...]"

				def opts.o=(o)
					@o = o
				end
				def opts.single(*args)
					on(*args[1..-1]) do |v|
						@o[args[0]] = v
					end
					self
				end
				def opts.hash(*args)
					on(*args[1..-1]) do |v|
						n,v = v.split('=', 2)
						@o[args[0]][n.to_sym] = v || true
					end
					self
				end
				def opts.multi(*args)
					on(*args[1..-1]) do |v|
						@o[args[0]] << v
					end
					self
				end
				opts.o = options

				opts.separator ""
				opts.separator "Options: "
				opts
				.single(:verbose     , "-v",  "--verbose", "Show verbose errors")
				.single(:timeout     , "-t",  "--timeout SECONDS", "Selector timeout (#{options[:timeout]}s)")
				.single(:open_timeout, "-o",  "--open-timeout SECONDS", "Open timeout (#{options[:open_timeout]}s)")
				.single(:debug       , "-d",  "--debug", "Break to debug on error. "+
												"Start the debug console if no input files given.")
				.single(:driver      , "-p",  "--provider PROVIDER"     , "Driver provider")
				.hash(  :driver_opt  , "-P",  "--provider-option OPTION", "Provider options (name=value)")
				.multi( :logger      , "-l",  "--logger LOGGER"         , "Logger type ('#{default_logger}')")
				.hash(  :logger_opt  , "-L",  "--logger-option OPTION"  , "Logger options (name=value)")
				.single(:reset       , "-r",  "--reset"                 , "Reset driver between tests")
				.single(:wait        , "-w",  "--wait"                  , "Wait for ENTER before exiting")
				.single(:selector    , "-s",  "--selector SELECTOR"     , "Default selector ('#{options[:selector]}')")
				.single(:capture     , "-c",  "--capture"               , "If the test fails, capture a screenshot")
				.single(:output      , "--output DIR"                   , "Output directory for generated artifacts")
				.multi( :extensions  , "-e",  "--extension DIR"         , "Load extensions from DIR")

				opts.on("-u", "--url [URL]", "Configure the remote provider listening in the given url") do |v|
					v = 'localhost:4444' unless v
					v = 'http://'+v unless v.match /^https?:\/\//
					v = v + '/wd/hub' unless v.end_with? '/wd/hub'
					options[:driver] = 'remote'
					options[:driver_opt][:url] = v
				end

				opts.on("--csv-summary [FILE]", "Output a single-line CSV summary") { |v| options[:csv] = v || 'summary.csv' }

				opts.on("--jenkins DIR", "Configure default options for Jenkins integration") do |v|
					options[:driver] = 'remote'
					options[:driver_opt][:url] = 'http://localhost:4444/wd/hub'
					options[:logger] = ['echo', 'html']
					options[:output] = v
					options[:logger_opt][:html_package] = true
					options[:capture] = true
					options[:csv] = 'summary.csv'
				end

				opts.on("--version", "Show version") do
					puts "bauxite #{Bauxite::VERSION}"
					exit
				end

				opts.separator ""
				opts.separator "Loggers:"
				Context::loggers.sort.each do |s|
					opts.separator "    #{s}"
				end

				opts.separator ""
				opts.separator "Selectors:".ljust(32)+" Actions:"
				max_action_size = Context::max_action_name_size
				selectors = Context::selectors.sort
				actions   = Context::actions.sort
				[selectors.size, actions.size].max.times.zip(selectors, actions).each do |idx,s,a|
					a = a ? "#{a.ljust(max_action_size)} #{Context.action_args(a).join(' ')}" : ''
					s = '' unless s
					opts.separator "    #{s.ljust(28)}     #{a}"
				end

				opts.separator ""
			end.parse!

			options[:logger] << default_logger unless options[:logger].size > 0

			ctx = nil
			begin
				ctx = Context.new(options)
			rescue StandardError => e
				puts e.message
				if options[:verbose]
					p e
					puts e.backtrace
				end
				exit false
			end

			files = ARGV
			files = ['stdin'] if files.size == 0 and not options[:debug]

			actions = files.map { |f| "load \"#{f.gsub('"', '""')}\"" }

			if options[:reset] and files.size > 1
				actions = actions.map { |a| [a] }.inject do |sum,a|
					sum += ['reset']
					sum + a
				end.flatten
			end

			if options[:debug] and actions.size == 0
				actions = ['debug']
			end

			begin
				ctx.start(actions)
			rescue StandardError => e
				exit false
			ensure
				if ctx.tests.any?

					if (csv_file = options[:csv])
						total  = ctx.tests.size
						ok     = ctx.tests.inject(0) { |s,t| s + (t[:status] == 'OK' ? 1 : 0) }
						failed = total - ok
						time   = ctx.tests.inject(0) { |s,t| s + t[:time] }
						File.open(ctx.output_path(csv_file), 'w') do |f|
							f.write "Total,OK,Failed,Time\n#{total},#{ok},#{failed},#{time}\n"
						end
					end

					failed = 0

					puts
					puts 'Test summary:'
					puts '============='
					puts 'Name'.ljust(40 ) + ' Time'.ljust(7 ) + ' Status'.ljust(7)+' Error'
					puts ''.ljust(40, '-') + ' '.ljust(7, '-') + ' '.ljust(7, '-' )+' '.ljust(5, '-')
					ctx.tests.each do |t|
						error = t[:error]
						error = error ? error.message : ''
						puts t[:name].ljust(40) + ' ' + t[:time].round(2).to_s.rjust(6) + ' ' + t[:status].ljust(6) + ' ' + error
						failed += 1 if t[:status] != 'OK'
					end
					exit failed if failed > 0
				end
			end
		end
	end
end


text:
layout: post
title: Sevdiğim Animeler...
---