blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
af93a9734a7560602ba10279a12d064f640e141d | 0bbf0904d118db2b9365544e728fdbc3540dd278 | /src/main/java/jhaturanga/commons/Pair.java | 6031c196f3015a8db400d46d71777f3c68addbb9 | [
"MIT"
] | permissive | apaz4/Jhaturanga | e6b627c5bef1e473da37a226c051c7198680e44f | 0e10592651c6ca7526af15ac81e4c24993c677c2 | refs/heads/master | 2023-08-16T16:53:46.634670 | 2021-10-01T08:34:26 | 2021-10-01T08:34:26 | 412,389,851 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,712 | java | package jhaturanga.commons;
/*
* A standard generic Pair<X,Y>, with getters, hashCode, equals, and toString well implemented.
*/
public final class Pair<X, Y> {
private final X x;
private final Y y;
public Pair(final X x, final Y y) {
super();
this.x = x;
this.y = y;
}
/**
* Get the first value of the pair.
*
* @return the X value of the pair
*/
public X getX() {
return x;
}
/**
* Get the second value of the pair.
*
* @return the Y value of the pair
*/
public Y getY() {
return y;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((x == null) ? 0 : x.hashCode());
result = prime * result + ((y == null) ? 0 : y.hashCode());
return result;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pair other = (Pair) obj;
if (x == null) {
if (other.x != null) {
return false;
}
} else if (!x.equals(other.x)) {
return false;
}
if (y == null) {
if (other.y != null) {
return false;
}
} else if (!y.equals(other.y)) {
return false;
}
return true;
}
@Override
public String toString() {
return "Pair [x=" + x + ", y=" + y + "]";
}
}
| [
"[email protected]"
] | |
3adf5bf653fc03689bcd29492b764d2c046ec963 | 400a926f706d2e754dea1235dd34eac782653a52 | /atishay-workspace-Dec-9-0300hrs/target/robocode-1.7.2.2-Beta-src/robocode-1.7.2.2-Beta/robocode.samples/src/main/java/sampleex/Slave.java | e29bf25c1b61b8f7fa81a9e3c4f304cbcda3c008 | [] | no_license | atishayjain25/Virtual-Combat | bfe42cc8a2ddac634ad17512f9376c53ab45752f | 634ac7216426bf0aa8fa855a517c3b7253bc6fef | refs/heads/master | 2016-09-09T20:19:47.549261 | 2010-12-13T15:25:23 | 2010-12-13T15:25:23 | 1,131,494 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,226 | java | /*******************************************************************************
* Copyright (c) 2001, 2008 Mathew A. Nelson and Robocode contributors
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://robocode.sourceforge.net/license/cpl-v10.html
*
* Contributors:
* Pavel Savara
* - Initial implementation
*******************************************************************************/
package sampleex;
import robocode.AdvancedRobot;
import robocode.HitByBulletEvent;
import robocode.ScannedRobotEvent;
/**
* This is robot derived from AdvancedRobot.
* Only reason to use this inheritance and this class is that external robots are unable to call RobotPeer directly
*/
class Slave extends AdvancedRobot {
final MasterBase parent;
public Slave(MasterBase parent) {
this.parent = parent;
}
public void run() {
parent.run();
}
public void onScannedRobot(ScannedRobotEvent e) {
parent.onScannedRobot(e);
}
public void onHitByBullet(HitByBulletEvent e) {
parent.onHitByBullet(e);
}
}
| [
"[email protected]"
] | |
81423650b6f31c5ea7041c7a443f95c146760cae | 12bbc5f851b94ff93663e623b8e2727058dd7cd8 | /src/main/java/vn/homtech/dtls/config/LoggingConfiguration.java | 8595cfdcc8f55684329280eefbf43dbb399ba007 | [] | no_license | tkmd123/DTLS | 3678e80b548c0b615037d47f4b2f4cff3e4fadaf | b23c967ea3883cfb2c9cf8c5b3027560b10ba6ca | refs/heads/master | 2021-07-01T11:22:16.132273 | 2018-11-16T10:58:32 | 2018-11-16T10:58:32 | 157,855,134 | 0 | 1 | null | 2020-09-18T12:19:13 | 2018-11-16T10:58:23 | Java | UTF-8 | Java | false | false | 6,578 | java | package vn.homtech.dtls.config;
import java.net.InetSocketAddress;
import java.util.Iterator;
import io.github.jhipster.config.JHipsterProperties;
import ch.qos.logback.classic.AsyncAppender;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.boolex.OnMarkerEvaluator;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggerContextListener;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.filter.EvaluatorFilter;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.spi.FilterReply;
import net.logstash.logback.appender.LogstashTcpSocketAppender;
import net.logstash.logback.encoder.LogstashEncoder;
import net.logstash.logback.stacktrace.ShortenedThrowableConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
public class LoggingConfiguration {
private static final String LOGSTASH_APPENDER_NAME = "LOGSTASH";
private static final String ASYNC_LOGSTASH_APPENDER_NAME = "ASYNC_LOGSTASH";
private final Logger log = LoggerFactory.getLogger(LoggingConfiguration.class);
private LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
private final String appName;
private final String serverPort;
private final JHipsterProperties jHipsterProperties;
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
JHipsterProperties jHipsterProperties) {
this.appName = appName;
this.serverPort = serverPort;
this.jHipsterProperties = jHipsterProperties;
if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
addLogstashAppender(context);
addContextListener(context);
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
setMetricsMarkerLogbackFilter(context);
}
}
private void addContextListener(LoggerContext context) {
LogbackLoggerContextListener loggerContextListener = new LogbackLoggerContextListener();
loggerContextListener.setContext(context);
context.addListener(loggerContextListener);
}
private void addLogstashAppender(LoggerContext context) {
log.info("Initializing Logstash logging");
LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
logstashAppender.setName(LOGSTASH_APPENDER_NAME);
logstashAppender.setContext(context);
String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";
// More documentation is available at: https://github.com/logstash/logstash-logback-encoder
LogstashEncoder logstashEncoder = new LogstashEncoder();
// Set the Logstash appender config from JHipster properties
logstashEncoder.setCustomFields(customFields);
// Set the Logstash appender config from JHipster properties
logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));
ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
throwableConverter.setRootCauseFirst(true);
logstashEncoder.setThrowableConverter(throwableConverter);
logstashEncoder.setCustomFields(customFields);
logstashAppender.setEncoder(logstashEncoder);
logstashAppender.start();
// Wrap the appender in an Async appender for performance
AsyncAppender asyncLogstashAppender = new AsyncAppender();
asyncLogstashAppender.setContext(context);
asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME);
asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
asyncLogstashAppender.addAppender(logstashAppender);
asyncLogstashAppender.start();
context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
onMarkerMetricsEvaluator.setContext(context);
onMarkerMetricsEvaluator.addMarker("metrics");
onMarkerMetricsEvaluator.start();
EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
metricsFilter.setContext(context);
metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
metricsFilter.setOnMatch(FilterReply.DENY);
metricsFilter.start();
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) {
Appender<ILoggingEvent> appender = it.next();
if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
log.debug("Filter metrics logs from the {} appender", appender.getName());
appender.setContext(context);
appender.addFilter(metricsFilter);
appender.start();
}
}
}
}
/**
* Logback configuration is achieved by configuration file and API.
* When configuration file change is detected, the configuration is reset.
* This listener ensures that the programmatic configuration is also re-applied after reset.
*/
class LogbackLoggerContextListener extends ContextAwareBase implements LoggerContextListener {
@Override
public boolean isResetResistant() {
return true;
}
@Override
public void onStart(LoggerContext context) {
addLogstashAppender(context);
}
@Override
public void onReset(LoggerContext context) {
addLogstashAppender(context);
}
@Override
public void onStop(LoggerContext context) {
// Nothing to do.
}
@Override
public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) {
// Nothing to do.
}
}
}
| [
"[email protected]"
] | |
14a7b07d8d1f72798c3ed3d9b501bf73dd0cf9d6 | 329307375d5308bed2311c178b5c245233ac6ff1 | /src/com/tencent/mm/protocal/b/jy.java | 80e1c0b84e0d9922f1791860d551f4b22f950753 | [] | no_license | ZoneMo/com.tencent.mm | 6529ac4c31b14efa84c2877824fa3a1f72185c20 | dc4f28aadc4afc27be8b099e08a7a06cee1960fe | refs/heads/master | 2021-01-18T12:12:12.843406 | 2015-07-05T03:21:46 | 2015-07-05T03:21:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,785 | java | package com.tencent.mm.protocal.b;
import java.util.LinkedList;
public final class jy
extends com.tencent.mm.al.a
{
public LinkedList bDC = new LinkedList();
protected final int a(int paramInt, Object... paramVarArgs)
{
if (paramInt == 0)
{
((a.a.a.c.a)paramVarArgs[0]).d(1, 8, bDC);
return 0;
}
if (paramInt == 1) {
return a.a.a.a.c(1, 8, bDC) + 0;
}
if (paramInt == 2)
{
paramVarArgs = (byte[])paramVarArgs[0];
bDC.clear();
paramVarArgs = new a.a.a.a.a(paramVarArgs, hfZ);
for (paramInt = com.tencent.mm.al.a.a(paramVarArgs); paramInt > 0; paramInt = com.tencent.mm.al.a.a(paramVarArgs)) {
if (!super.a(paramVarArgs, this, paramInt)) {
paramVarArgs.aVo();
}
}
return 0;
}
if (paramInt == 3)
{
Object localObject1 = (a.a.a.a.a)paramVarArgs[0];
jy localjy = (jy)paramVarArgs[1];
paramInt = ((Integer)paramVarArgs[2]).intValue();
switch (paramInt)
{
default:
return -1;
}
paramVarArgs = ((a.a.a.a.a)localObject1).pL(paramInt);
int i = paramVarArgs.size();
paramInt = 0;
while (paramInt < i)
{
Object localObject2 = (byte[])paramVarArgs.get(paramInt);
localObject1 = new kc();
localObject2 = new a.a.a.a.a((byte[])localObject2, hfZ);
for (boolean bool = true; bool; bool = ((kc)localObject1).a((a.a.a.a.a)localObject2, (com.tencent.mm.al.a)localObject1, com.tencent.mm.al.a.a((a.a.a.a.a)localObject2))) {}
bDC.add(localObject1);
paramInt += 1;
}
return 0;
}
return -1;
}
}
/* Location:
* Qualified Name: com.tencent.mm.protocal.b.jy
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
8a0fc1dce8869062fb2017a0b197232f26682cdb | fde82278bf3fe393ae9610be8d4b33a73074dc68 | /app/src/main/java/com/lzh/volleywrapdemo/model/WeatherModel.java | 496983f3b3bccaea46b45e0b551d933a0e8d6e2a | [] | no_license | jason0539/VolleyWrapDemo | ef97d7c501d954282a8fa2742a868a17ba7ad0fb | 7798fae507d3dec29506d1a3fb4fce969d9411d7 | refs/heads/master | 2021-01-10T10:36:49.549397 | 2016-04-15T12:28:33 | 2016-04-15T12:28:33 | 52,347,421 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,182 | java | package com.lzh.volleywrapdemo.model;
import org.json.JSONObject;
import com.lzh.volleywrap.baseframe.http.HttpResponseListener;
import com.lzh.volleywrap.middleframe.HttpClientWrapper;
import com.lzh.volleywrapdemo.utils.DemoConstant;
import android.text.TextUtils;
/**
* liuzhenhui 16/2/22.下午8:59
*/
public class WeatherModel {
private static final String TAG = WeatherModel.class.getSimpleName();
public void getWeather(final WeatherCallback callback) {
HttpResponseListener<JSONObject> listener = new HttpResponseListener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
if (response != null) {
callback.success(response.toString());
}
}
@Override
public void onError(String msg) {
if (!TextUtils.isEmpty(msg)) {
callback.fail(msg);
}
}
};
HttpClientWrapper.getInstance().getWeather(DemoConstant.API_KEY, listener);
}
public interface WeatherCallback {
void fail(String msg);
void success(String msg);
}
}
| [
"[email protected]"
] | |
2dbba66a1ae3e667b4e17df45812e3509fd3f63b | d7c4e9eb15d40fe62b02394520a8eba4725674f2 | /src/best/dafu.java | 292a732e3b948e5a4e19edce955aabe45cd753d3 | [] | no_license | wangkunProject/javaweb | 32ef68773d2a62d82346dda34bc33c37f22e1a5c | 5db1cb11d120df65d21eebc95ab5a4dd667897e0 | refs/heads/master | 2022-12-09T00:26:23.404591 | 2020-09-09T11:42:47 | 2020-09-09T11:42:47 | 294,088,838 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 60 | java | package best;
public class dafu {
int sdf=23563434;
}
| [
"[email protected]"
] | |
979b69785d1d4283238357d8b8833279a836b378 | 5e67d7d5bf36ca31bdf45cfb73afe1e82a5730f2 | /src/homeWork/P4/Exe.java | 430e9c62b967b131a770c5634cd115026b3fa7c3 | [] | no_license | matasstoskus/Java | 3415ea7c85d754968d04af82c71fa616259d9209 | 9718b9f46b8c6c1c78e61659de485b9aba0a932b | refs/heads/master | 2022-12-26T06:10:38.386118 | 2020-10-06T07:13:42 | 2020-10-06T07:13:42 | 292,279,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,421 | java | package homeWork.P4;
public class Exe {
public static void main(String args[]) {
int a[] = {1, 2, 5, 6, 3, 2};
int b[] = {44, 66, 99, 77, 33, 22, 55};
System.out.println("Smallest: " + getSmallest(a, 6));
System.out.println("Smallest: " + getSmallest(b, 7));
System.out.println("Largest: " + getLargest(a, 6));
System.out.println("Largest: " + getLargest(b, 7));
System.out.println("Sum: " + getSum(a));
System.out.println("Sum: " + getSum(b));
}
public static int getSmallest(int[] a, int total) {
int temp;
for (int i = 0; i < total; i++) {
for (int j = i + 1; j < total; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
return a[0];
}
public static int getLargest(int[] a, int total) {
int temp;
for (int i = 0; i < total; i++) {
for (int j = i + 1; j < total; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
return a[total - 1];
}
public static int getSum(int[] a) {
int sum = 0;
for (int value : a) {
sum += value;
}
return sum;
}
} | [
"[email protected]"
] | |
e58b975a55544b785b98917a4a566f302a228014 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipseswt_cluster/7640/src_0.java | 63005d1c52e5679ab7b844b44a2d97dcdc26d36b | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133,584 | java | /*******************************************************************************
* Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;
import org.eclipse.swt.internal.gtk.*;
/**
* Instances of this class implement a selectable user interface
* object that displays a list of images and strings and issues
* notification when selected.
* <p>
* The item children that may be added to instances of this class
* must be of type <code>TableItem</code>.
* </p><p>
* Style <code>VIRTUAL</code> is used to create a <code>Table</code> whose
* <code>TableItem</code>s are to be populated by the client on an on-demand basis
* instead of up-front. This can provide significant performance improvements for
* tables that are very large or for which <code>TableItem</code> population is
* expensive (for example, retrieving values from an external source).
* </p><p>
* Here is an example of using a <code>Table</code> with style <code>VIRTUAL</code>:
* <code><pre>
* final Table table = new Table (parent, SWT.VIRTUAL | SWT.BORDER);
* table.setItemCount (1000000);
* table.addListener (SWT.SetData, new Listener () {
* public void handleEvent (Event event) {
* TableItem item = (TableItem) event.item;
* int index = table.indexOf (item);
* item.setText ("Item " + index);
* System.out.println (item.getText ());
* }
* });
* </pre></code>
* </p><p>
* Note that although this class is a subclass of <code>Composite</code>,
* it does not normally make sense to add <code>Control</code> children to
* it, or set a layout on it, unless implementing something like a cell
* editor.
* </p><p>
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL, NO_SCROLL</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem</dd>
* </dl>
* </p><p>
* Note: Only one of the styles SINGLE, and MULTI may be specified.
* </p><p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*
* @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a>
* @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
* @noextend This class is not intended to be subclassed by clients.
*/
public class Table extends Composite {
long /*int*/ modelHandle, checkRenderer;
int itemCount, columnCount, lastIndexOf, sortDirection;
long /*int*/ ignoreCell;
TableItem [] items;
TableColumn [] columns;
TableItem currentItem;
TableColumn sortColumn;
ImageList imageList, headerImageList;
boolean firstCustomDraw;
int drawState, drawFlags;
GdkColor drawForeground;
boolean ownerDraw, ignoreSize, ignoreAccessibility;
static final int CHECKED_COLUMN = 0;
static final int GRAYED_COLUMN = 1;
static final int FOREGROUND_COLUMN = 2;
static final int BACKGROUND_COLUMN = 3;
static final int FONT_COLUMN = 4;
static final int FIRST_COLUMN = FONT_COLUMN + 1;
static final int CELL_PIXBUF = 0;
static final int CELL_TEXT = 1;
static final int CELL_FOREGROUND = 2;
static final int CELL_BACKGROUND = 3;
static final int CELL_FONT = 4;
static final int CELL_TYPES = CELL_FONT + 1;
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
* <p>
* The style value is either one of the style constants defined in
* class <code>SWT</code> which is applicable to instances of this
* class, or must be built by <em>bitwise OR</em>'ing together
* (that is, using the <code>int</code> "|" operator) two or more
* of those <code>SWT</code> style constants. The class description
* lists the style constants that are applicable to the class.
* Style bits are also inherited from superclasses.
* </p>
*
* @param parent a composite control which will be the parent of the new instance (cannot be null)
* @param style the style of control to construct
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*
* @see SWT#SINGLE
* @see SWT#MULTI
* @see SWT#CHECK
* @see SWT#FULL_SELECTION
* @see SWT#HIDE_SELECTION
* @see SWT#VIRTUAL
* @see SWT#NO_SCROLL
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
public Table (Composite parent, int style) {
super (parent, checkStyle (style));
// A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=457196
if (OS.GTK3) {
addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
layout();
removeListener(SWT.MeasureItem, this);
}
});
}
}
@Override
void _addListener (int eventType, Listener listener) {
super._addListener (eventType, listener);
if (!ownerDraw) {
switch (eventType) {
case SWT.MeasureItem:
case SWT.EraseItem:
case SWT.PaintItem:
ownerDraw = true;
recreateRenderers ();
break;
}
}
}
TableItem _getItem (int index) {
if ((style & SWT.VIRTUAL) == 0) return items [index];
if (items [index] != null) return items [index];
return items [index] = new TableItem (this, SWT.NONE, index, false);
}
static int checkStyle (int style) {
/*
* Feature in Windows. Even when WS_HSCROLL or
* WS_VSCROLL is not specified, Windows creates
* trees and tables with scroll bars. The fix
* is to set H_SCROLL and V_SCROLL.
*
* NOTE: This code appears on all platforms so that
* applications have consistent scroll bar behavior.
*/
if ((style & SWT.NO_SCROLL) == 0) {
style |= SWT.H_SCROLL | SWT.V_SCROLL;
}
/* GTK is always FULL_SELECTION */
style |= SWT.FULL_SELECTION;
return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}
@Override
long /*int*/ cellDataProc (long /*int*/ tree_column, long /*int*/ cell, long /*int*/ tree_model, long /*int*/ iter, long /*int*/ data) {
if (cell == ignoreCell) return 0;
long /*int*/ path = OS.gtk_tree_model_get_path (tree_model, iter);
int [] index = new int [1];
OS.memmove (index, OS.gtk_tree_path_get_indices (path), 4);
TableItem item = _getItem (index[0]);
OS.gtk_tree_path_free (path);
if (item != null) OS.g_object_set_qdata (cell, Display.SWT_OBJECT_INDEX2, item.handle);
boolean isPixbuf = OS.GTK_IS_CELL_RENDERER_PIXBUF (cell);
boolean isText = OS.GTK_IS_CELL_RENDERER_TEXT (cell);
if (isText && OS.GTK3) {
OS.gtk_cell_renderer_set_fixed_size (cell, -1, -1);
}
if (!(isPixbuf || isText)) return 0;
int modelIndex = -1;
boolean customDraw = false;
if (columnCount == 0) {
modelIndex = Table.FIRST_COLUMN;
customDraw = firstCustomDraw;
} else {
TableColumn column = (TableColumn) display.getWidget (tree_column);
if (column != null) {
modelIndex = column.modelIndex;
customDraw = column.customDraw;
}
}
if (modelIndex == -1) return 0;
boolean setData = false;
if ((style & SWT.VIRTUAL) != 0) {
if (!item.cached) {
lastIndexOf = index[0];
setData = checkData (item);
}
}
long /*int*/ [] ptr = new long /*int*/ [1];
if (setData) {
ptr [0] = 0;
if (isPixbuf) {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
OS.g_object_set (cell, OS.GTK3 ? OS.gicon : OS.pixbuf, ptr [0], 0);
if (ptr [0] != 0) OS.g_object_unref (ptr [0]);
} else {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.text, ptr [0], 0);
OS.g_free (ptr [0]);
}
}
}
if (customDraw) {
if (!ownerDraw) {
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.cell_background_gdk, ptr [0], 0);
OS.gdk_color_free (ptr [0]);
}
}
if (!isPixbuf) {
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.foreground_gdk, ptr [0], 0);
OS.gdk_color_free (ptr [0]);
}
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.font_desc, ptr [0], 0);
OS.pango_font_description_free (ptr [0]);
}
}
}
if (setData) {
ignoreCell = cell;
setScrollWidth (tree_column, item);
ignoreCell = 0;
}
return 0;
}
boolean checkData (TableItem item) {
if (item.cached) return true;
if ((style & SWT.VIRTUAL) != 0) {
item.cached = true;
Event event = new Event ();
event.item = item;
event.index = indexOf (item);
int mask = OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
int signal_id = OS.g_signal_lookup (OS.row_changed, OS.gtk_tree_model_get_type ());
OS.g_signal_handlers_block_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
currentItem = item;
sendEvent (SWT.SetData, event);
//widget could be disposed at this point
currentItem = null;
if (isDisposed ()) return false;
OS.g_signal_handlers_unblock_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
if (item.isDisposed ()) return false;
}
return true;
}
@Override
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the user changes the receiver's selection, by sending
* it one of the messages defined in the <code>SelectionListener</code>
* interface.
* <p>
* When <code>widgetSelected</code> is called, the item field of the event object is valid.
* If the receiver has the <code>SWT.CHECK</code> style and the check selection changes,
* the event object detail field contains the value <code>SWT.CHECK</code>.
* <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
* The item field of the event object is valid for default selection, but the detail field is not used.
* </p>
*
* @param listener the listener which should be notified when the user changes the receiver's selection
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SelectionListener
* @see #removeSelectionListener
* @see SelectionEvent
*/
public void addSelectionListener (SelectionListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection, typedListener);
addListener (SWT.DefaultSelection, typedListener);
}
int calculateWidth (long /*int*/ column, long /*int*/ iter) {
OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
/*
* Bug in GTK. The width calculated by gtk_tree_view_column_cell_get_size()
* always grows in size regardless of the text or images in the table.
* The fix is to determine the column width from the cell renderers.
*/
//This workaround is causing the problem Bug 459834 in GTK3. So reverting the workaround for GTK3
if (OS.GTK3) {
int [] width = new int [1];
OS.gtk_tree_view_column_cell_get_size (column, null, null, null, width, null);
return width [0];
} else {
int width = 0;
int [] w = new int [1];
OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0);
width += 2 * w [0];
long /*int*/ list = OS.gtk_cell_layout_get_cells(column);
if (list == 0) return 0;
long /*int*/ temp = list;
while (temp != 0) {
long /*int*/ renderer = OS.g_list_data (temp);
if (renderer != 0) {
gtk_cell_renderer_get_preferred_size (renderer, handle, w, null);
width += w [0];
}
temp = OS.g_list_next (temp);
}
OS.g_list_free (list);
if (OS.gtk_tree_view_get_grid_lines(handle) > OS.GTK_TREE_VIEW_GRID_LINES_NONE) {
OS.gtk_widget_style_get (handle, OS.grid_line_width, w, 0) ;
width += 2 * w [0];
}
return width;
}
}
/**
* Clears the item at the given zero-relative index in the receiver.
* The text, icon and other attributes of the item are set to the default
* value. If the table was created with the <code>SWT.VIRTUAL</code> style,
* these attributes are requested again as needed.
*
* @param index the index of the item to clear
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SWT#VIRTUAL
* @see SWT#SetData
*
* @since 3.0
*/
public void clear (int index) {
checkWidget ();
if (!(0 <= index && index < itemCount)) {
error(SWT.ERROR_INVALID_RANGE);
}
TableItem item = items [index];
if (item != null) item.clear ();
}
/**
* Removes the items from the receiver which are between the given
* zero-relative start and end indices (inclusive). The text, icon
* and other attributes of the items are set to their default values.
* If the table was created with the <code>SWT.VIRTUAL</code> style,
* these attributes are requested again as needed.
*
* @param start the start index of the item to clear
* @param end the end index of the item to clear
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SWT#VIRTUAL
* @see SWT#SetData
*
* @since 3.0
*/
public void clear (int start, int end) {
checkWidget ();
if (start > end) return;
if (!(0 <= start && start <= end && end < itemCount)) {
error (SWT.ERROR_INVALID_RANGE);
}
if (start == 0 && end == itemCount - 1) {
clearAll();
} else {
for (int i=start; i<=end; i++) {
TableItem item = items [i];
if (item != null) item.clear();
}
}
}
/**
* Clears the items at the given zero-relative indices in the receiver.
* The text, icon and other attributes of the items are set to their default
* values. If the table was created with the <code>SWT.VIRTUAL</code> style,
* these attributes are requested again as needed.
*
* @param indices the array of indices of the items
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SWT#VIRTUAL
* @see SWT#SetData
*
* @since 3.0
*/
public void clear (int [] indices) {
checkWidget ();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
for (int i=0; i<indices.length; i++) {
if (!(0 <= indices [i] && indices [i] < itemCount)) {
error (SWT.ERROR_INVALID_RANGE);
}
}
for (int i=0; i<indices.length; i++) {
TableItem item = items [indices [i]];
if (item != null) item.clear();
}
}
/**
* Clears all the items in the receiver. The text, icon and other
* attributes of the items are set to their default values. If the
* table was created with the <code>SWT.VIRTUAL</code> style, these
* attributes are requested again as needed.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SWT#VIRTUAL
* @see SWT#SetData
*
* @since 3.0
*/
public void clearAll () {
checkWidget ();
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (item != null) item.clear();
}
}
@Override
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
Point size = computeNativeSize (handle, wHint, hHint, changed);
if (size.x == 0 && wHint == SWT.DEFAULT) size.x = DEFAULT_WIDTH;
/*
* in GTK 3.8 computeNativeSize returning 0 for height.
* So if the height is returned as zero calculate the table height
* based on the number of items in the table
*/
if (OS.GTK3 && size.y == 0 && hHint == SWT.DEFAULT) {
size.y = getItemCount() * getItemHeight();
}
/*
* In case the table doesn't contain any elements,
* getItemCount returns 0 and size.y will be 0
* so need to assign default height
*/
if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT;
Rectangle trim = computeTrim (0, 0, size.x, size.y);
size.x = trim.width;
size.y = trim.height;
return size;
}
void createColumn (TableColumn column, int index) {
int modelIndex = FIRST_COLUMN;
if (columnCount != 0) {
int modelLength = OS.gtk_tree_model_get_n_columns (modelHandle);
boolean [] usedColumns = new boolean [modelLength];
for (int i=0; i<columnCount; i++) {
int columnIndex = columns [i].modelIndex;
for (int j = 0; j < CELL_TYPES; j++) {
usedColumns [columnIndex + j] = true;
}
}
while (modelIndex < modelLength) {
if (!usedColumns [modelIndex]) break;
modelIndex++;
}
if (modelIndex == modelLength) {
long /*int*/ oldModel = modelHandle;
long /*int*/[] types = getColumnTypes (columnCount + 4); // grow by 4 rows at a time
long /*int*/ newModel = OS.gtk_list_store_newv (types.length, types);
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ [] ptr = new long /*int*/ [1];
int [] ptr1 = new int [1];
for (int i=0; i<itemCount; i++) {
long /*int*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (newItem == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_list_store_append (newModel, newItem);
TableItem item = items [i];
if (item != null) {
long /*int*/ oldItem = item.handle;
/* the columns before FOREGROUND_COLUMN contain int values, subsequent columns contain pointers */
for (int j=0; j<FOREGROUND_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr1, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr1 [0], -1);
}
for (int j=FOREGROUND_COLUMN; j<modelLength; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
if (ptr [0] != 0) {
if (types [j] == OS.G_TYPE_STRING ()) {
OS.g_free ((ptr [0]));
} else if (types [j] == OS.GDK_TYPE_COLOR()) {
OS.gdk_color_free (ptr [0]);
} else if (types [j] == OS.GDK_TYPE_PIXBUF()) {
OS.g_object_unref (ptr [0]);
} else if (types [j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
OS.pango_font_description_free (ptr [0]);
}
}
}
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
item.handle = newItem;
} else {
OS.g_free (newItem);
}
}
OS.gtk_tree_view_set_model (handle, newModel);
setModel (newModel);
}
}
long /*int*/ columnHandle = OS.gtk_tree_view_column_new ();
if (columnHandle == 0) error (SWT.ERROR_NO_HANDLES);
if (index == 0 && columnCount > 0) {
TableColumn checkColumn = columns [0];
createRenderers (checkColumn.handle, checkColumn.modelIndex, false, checkColumn.style);
}
createRenderers (columnHandle, modelIndex, index == 0, column == null ? 0 : column.style);
if ((style & SWT.VIRTUAL) == 0 && columnCount == 0) {
OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_GROW_ONLY);
} else {
OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
}
OS.gtk_tree_view_column_set_resizable (columnHandle, true);
OS.gtk_tree_view_column_set_clickable (columnHandle, true);
OS.gtk_tree_view_column_set_min_width (columnHandle, 0);
OS.gtk_tree_view_insert_column (handle, columnHandle, index);
/*
* Bug in GTK3. The column header has the wrong CSS styling if it is hidden
* when inserting to the tree widget. The fix is to hide the column only
* after it is inserted.
*/
if (columnCount != 0) OS.gtk_tree_view_column_set_visible (columnHandle, false);
if (column != null) {
column.handle = columnHandle;
column.modelIndex = modelIndex;
}
if (!searchEnabled ()) {
OS.gtk_tree_view_set_search_column (handle, -1);
} else {
/* Set the search column whenever the model changes */
int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
}
}
@Override
void createHandle (int index) {
state |= HANDLE;
fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_widget_set_has_window (fixedHandle, true);
scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ [] types = getColumnTypes (1);
modelHandle = OS.gtk_list_store_newv (types.length, types);
if (modelHandle == 0) error (SWT.ERROR_NO_HANDLES);
handle = OS.gtk_tree_view_new_with_model (modelHandle);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
if ((style & SWT.CHECK) != 0) {
checkRenderer = OS.gtk_cell_renderer_toggle_new ();
if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
OS.g_object_ref (checkRenderer);
}
createColumn (null, 0);
OS.gtk_container_add (fixedHandle, scrolledHandle);
OS.gtk_container_add (scrolledHandle, handle);
int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_MULTIPLE : OS.GTK_SELECTION_BROWSE;
long /*int*/ selectionHandle = OS.gtk_tree_view_get_selection (handle);
OS.gtk_tree_selection_set_mode (selectionHandle, mode);
OS.gtk_tree_view_set_headers_visible (handle, false);
int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
if ((style & SWT.VIRTUAL) != 0) {
OS.g_object_set (handle, OS.fixed_height_mode, true, 0);
}
if (!searchEnabled ()) {
OS.gtk_tree_view_set_search_column (handle, -1);
}
}
void createItem (TableColumn column, int index) {
if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE);
if (columnCount == 0) {
column.handle = OS.gtk_tree_view_get_column (handle, 0);
OS.gtk_tree_view_column_set_sizing (column.handle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
OS.gtk_tree_view_column_set_visible (column.handle, false);
column.modelIndex = FIRST_COLUMN;
createRenderers (column.handle, column.modelIndex, true, column.style);
column.customDraw = firstCustomDraw;
firstCustomDraw = false;
} else {
createColumn (column, index);
}
long /*int*/ boxHandle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 3);
if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ labelHandle = OS.gtk_label_new_with_mnemonic (null);
if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ imageHandle = OS.gtk_image_new ();
if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_container_add (boxHandle, imageHandle);
OS.gtk_container_add (boxHandle, labelHandle);
OS.gtk_widget_show (boxHandle);
OS.gtk_widget_show (labelHandle);
column.labelHandle = labelHandle;
column.imageHandle = imageHandle;
OS.gtk_tree_view_column_set_widget (column.handle, boxHandle);
if (OS.GTK3) {
column.buttonHandle = OS.gtk_tree_view_column_get_button(column.handle);
} else {
long /*int*/ widget = OS.gtk_widget_get_parent (boxHandle);
while (widget != handle) {
if (OS.GTK_IS_BUTTON (widget)) {
column.buttonHandle = widget;
break;
}
widget = OS.gtk_widget_get_parent (widget);
}
}
if (columnCount == columns.length) {
TableColumn [] newColumns = new TableColumn [columns.length + 4];
System.arraycopy (columns, 0, newColumns, 0, columns.length);
columns = newColumns;
}
System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
columns [index] = column;
if ((state & FONT) != 0) {
column.setFontDescription (getFontDescription ());
}
if (columnCount >= 1) {
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (item != null) {
Font [] cellFont = item.cellFont;
if (cellFont != null) {
Font [] temp = new Font [columnCount];
System.arraycopy (cellFont, 0, temp, 0, index);
System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1);
item.cellFont = temp;
}
}
}
}
/*
* Feature in GTK. The tree view does not resize immediately if a table
* column is created when the table is not visible. If the width of the
* new column is queried, GTK returns an incorrect value. The fix is to
* ensure that the columns are resized before any queries.
*/
if(!isVisible ()) {
forceResize();
}
}
void createItem (TableItem item, int index) {
if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
if (itemCount == items.length) {
int length = drawCount <= 0 ? items.length + 4 : Math.max (4, items.length * 3 / 2);
TableItem [] newItems = new TableItem [length];
System.arraycopy (items, 0, newItems, 0, items.length);
items = newItems;
}
item.handle = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (item.handle == 0) error (SWT.ERROR_NO_HANDLES);
/*
* Feature in GTK. It is much faster to append to a list store
* than to insert at the end using gtk_list_store_insert().
*/
if (index == itemCount) {
OS.gtk_list_store_append (modelHandle, item.handle);
} else {
OS.gtk_list_store_insert (modelHandle, item.handle, index);
}
System.arraycopy (items, index, items, index + 1, itemCount++ - index);
items [index] = item;
}
void createRenderers (long /*int*/ columnHandle, int modelIndex, boolean check, int columnStyle) {
OS.gtk_tree_view_column_clear (columnHandle);
if ((style & SWT.CHECK) != 0 && check) {
OS.gtk_tree_view_column_pack_start (columnHandle, checkRenderer, false);
OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.active, CHECKED_COLUMN);
OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN);
if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
if (ownerDraw) {
OS.gtk_tree_view_column_set_cell_data_func (columnHandle, checkRenderer, display.cellDataProc, handle, 0);
OS.g_object_set_qdata (checkRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
}
}
long /*int*/ pixbufRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_pixbuf_get_type (), 0) : OS.gtk_cell_renderer_pixbuf_new ();
if (pixbufRenderer == 0) {
error (SWT.ERROR_NO_HANDLES);
} else {
// set default size this size is used for calculating the icon and text positions in a table
if ((!ownerDraw) && (OS.GTK3)) {
OS.gtk_cell_renderer_set_fixed_size(pixbufRenderer, 16, 16);
}
}
long /*int*/ textRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_text_get_type (), 0) : OS.gtk_cell_renderer_text_new ();
if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
if (ownerDraw) {
OS.g_object_set_qdata (pixbufRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
OS.g_object_set_qdata (textRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
}
/*
* Feature in GTK. When a tree view column contains only one activatable
* cell renderer such as a toggle renderer, mouse clicks anywhere in a cell
* activate that renderer. The workaround is to set a second cell renderer
* to be activatable.
*/
if ((style & SWT.CHECK) != 0 && check) {
OS.g_object_set (pixbufRenderer, OS.mode, OS.GTK_CELL_RENDERER_MODE_ACTIVATABLE, 0);
}
/* Set alignment */
if ((columnStyle & SWT.RIGHT) != 0) {
OS.g_object_set(textRenderer, OS.xalign, 1f, 0);
OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
OS.gtk_tree_view_column_pack_end (columnHandle, pixbufRenderer, false);
OS.gtk_tree_view_column_set_alignment (columnHandle, 1f);
} else if ((columnStyle & SWT.CENTER) != 0) {
OS.g_object_set(textRenderer, OS.xalign, 0.5f, 0);
OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
OS.gtk_tree_view_column_set_alignment (columnHandle, 0.5f);
} else {
OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
OS.gtk_tree_view_column_pack_start (columnHandle, textRenderer, true);
OS.gtk_tree_view_column_set_alignment (columnHandle, 0f);
}
/* Add attributes */
OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.GTK3 ? OS.gicon : OS.pixbuf, modelIndex + CELL_PIXBUF);
if (!ownerDraw) {
OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
}
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, modelIndex + CELL_TEXT);
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.foreground_gdk, FOREGROUND_COLUMN);
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.font_desc, FONT_COLUMN);
boolean customDraw = firstCustomDraw;
if (columnCount != 0) {
for (int i=0; i<columnCount; i++) {
if (columns [i].handle == columnHandle) {
customDraw = columns [i].customDraw;
break;
}
}
}
if ((style & SWT.VIRTUAL) != 0 || customDraw || ownerDraw) {
OS.gtk_tree_view_column_set_cell_data_func (columnHandle, textRenderer, display.cellDataProc, handle, 0);
OS.gtk_tree_view_column_set_cell_data_func (columnHandle, pixbufRenderer, display.cellDataProc, handle, 0);
}
}
@Override
void createWidget (int index) {
super.createWidget (index);
items = new TableItem [4];
columns = new TableColumn [4];
itemCount = columnCount = 0;
// In GTK 3 font description is inherited from parent widget which is not how SWT has always worked,
// reset to default font to get the usual behavior
if (OS.GTK3) {
setFontDescription(defaultFont().handle);
}
}
@Override
int applyThemeBackground () {
return -1; /* No Change */
}
GdkColor defaultBackground () {
return display.COLOR_LIST_BACKGROUND;
}
GdkColor defaultForeground () {
return display.COLOR_LIST_FOREGROUND;
}
@Override
void deregister () {
super.deregister ();
display.removeWidget (OS.gtk_tree_view_get_selection (handle));
if (checkRenderer != 0) display.removeWidget (checkRenderer);
display.removeWidget (modelHandle);
}
/**
* Deselects the item at the given zero-relative index in the receiver.
* If the item at the index was already deselected, it remains
* deselected. Indices that are out of range are ignored.
*
* @param index the index of the item to deselect
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void deselect (int index) {
checkWidget();
if (index < 0 || index >= itemCount) return;
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
* is selected, it is deselected. If the item at the index
* was not selected, it remains deselected. The range of the
* indices is inclusive. Indices that are out of range are ignored.
*
* @param start the start index of the items to deselect
* @param end the end index of the items to deselect
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void deselect (int start, int end) {
checkWidget();
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
for (int index=start; index<=end; index++) {
if (index < 0 || index >= itemCount) continue;
OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
* is selected, it is deselected. If the item at the index
* was not selected, it remains deselected. Indices that are out
* of range and duplicate indices are ignored.
*
* @param indices the array of indices for the items to deselect
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void deselect (int [] indices) {
checkWidget();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
for (int i=0; i<indices.length; i++) {
int index = indices[i];
if (index < 0 || index >= itemCount) continue;
OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Deselects all selected items in the receiver.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void deselectAll () {
checkWidget();
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_selection_unselect_all (selection);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
void destroyItem (TableColumn column) {
int index = 0;
while (index < columnCount) {
if (columns [index] == column) break;
index++;
}
if (index == columnCount) return;
long /*int*/ columnHandle = column.handle;
if (columnCount == 1) {
firstCustomDraw = column.customDraw;
}
System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
columns [columnCount] = null;
OS.gtk_tree_view_remove_column (handle, columnHandle);
if (columnCount == 0) {
long /*int*/ oldModel = modelHandle;
long /*int*/[] types = getColumnTypes (1);
long /*int*/ newModel = OS.gtk_list_store_newv (types.length, types);
if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
long /*int*/ [] ptr = new long /*int*/ [1];
int [] ptr1 = new int [1];
for (int i=0; i<itemCount; i++) {
long /*int*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (newItem == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_list_store_append (newModel, newItem);
TableItem item = items [i];
if (item != null) {
long /*int*/ oldItem = item.handle;
/* the columns before FOREGROUND_COLUMN contain int values, subsequent columns contain pointers */
for (int j=0; j<FOREGROUND_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr1, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr1 [0], -1);
}
for (int j=FOREGROUND_COLUMN; j<FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
if (ptr [0] != 0) {
if (j == FOREGROUND_COLUMN || j == BACKGROUND_COLUMN) {
OS.gdk_color_free (ptr [0]);
} else if (j == FONT_COLUMN) {
OS.pango_font_description_free (ptr [0]);
}
}
}
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_PIXBUF, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_PIXBUF, ptr [0], -1);
if (ptr [0] != 0) OS.g_object_unref (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_TEXT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_TEXT, ptr [0], -1);
OS.g_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FOREGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FOREGROUND, ptr [0], -1);
if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_BACKGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_BACKGROUND, ptr [0], -1);
if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FONT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FONT, ptr [0], -1);
if (ptr [0] != 0) OS.pango_font_description_free (ptr [0]);
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
item.handle = newItem;
} else {
OS.g_free (newItem);
}
}
OS.gtk_tree_view_set_model (handle, newModel);
setModel (newModel);
createColumn (null, 0);
} else {
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (item != null) {
long /*int*/ iter = item.handle;
int modelIndex = column.modelIndex;
OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_PIXBUF, (long /*int*/)0, -1);
OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_TEXT, (long /*int*/)0, -1);
OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FOREGROUND, (long /*int*/)0, -1);
OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_BACKGROUND, (long /*int*/)0, -1);
OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FONT, (long /*int*/)0, -1);
Font [] cellFont = item.cellFont;
if (cellFont != null) {
if (columnCount == 0) {
item.cellFont = null;
} else {
Font [] temp = new Font [columnCount];
System.arraycopy (cellFont, 0, temp, 0, index);
System.arraycopy (cellFont, index + 1, temp, index, columnCount - index);
item.cellFont = temp;
}
}
}
}
if (index == 0) {
TableColumn checkColumn = columns [0];
createRenderers (checkColumn.handle, checkColumn.modelIndex, true, checkColumn.style);
}
}
if (!searchEnabled ()) {
OS.gtk_tree_view_set_search_column (handle, -1);
} else {
/* Set the search column whenever the model changes */
int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
}
}
void destroyItem (TableItem item) {
int index = 0;
while (index < itemCount) {
if (items [index] == item) break;
index++;
}
if (index == itemCount) return;
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_list_store_remove (modelHandle, item.handle);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
if (itemCount == 0) resetCustomDraw ();
}
@Override
boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
boolean selected = false;
if (filter) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
if (path [0] != 0) {
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) selected = true;
OS.gtk_tree_path_free (path [0]);
}
} else {
return false;
}
}
boolean dragDetect = super.dragDetect (x, y, filter, false, consume);
if (dragDetect && selected && consume != null) consume [0] = true;
return dragDetect;
}
@Override
long /*int*/ eventWindow () {
return paintWindow ();
}
boolean fixAccessibility () {
/*
* Bug in GTK. With GTK 2.12, when assistive technologies is on, the time
* it takes to add or remove several rows to the model is very long. This
* happens because the accessible object asks each row for its data, including
* the rows that are not visible. The the fix is to block the accessible object
* from receiving row_added and row_removed signals and, at the end, send only
* a notify signal with the "model" detail.
*
* Note: The test bellow has to be updated when the real problem is fixed in
* the accessible object.
*/
return true;
}
@Override
void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
for (int i=0; i<columnCount; i++) {
TableColumn column = columns [i];
if (column.toolTipText != null) {
column.setToolTipText(oldShell, null);
column.setToolTipText(newShell, column.toolTipText);
}
}
}
@Override
GdkColor getBackgroundColor () {
return getBaseColor ();
}
@Override
public Rectangle getClientArea () {
checkWidget ();
forceResize ();
OS.gtk_widget_realize (handle);
long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
long /*int*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
int [] binX = new int [1], binY = new int [1];
OS.gdk_window_get_origin (binWindow, binX, binY);
int [] fixedX = new int [1], fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
long /*int*/ clientHandle = clientHandle ();
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (clientHandle, allocation);
int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
rect.y += getHeaderHeight();
}
return rect;
}
@Override
int getClientWidth () {
int [] w = new int [1], h = new int [1];
OS.gtk_widget_realize (handle);
gdk_window_get_size(OS.gtk_tree_view_get_bin_window(handle), w, h);
return w[0];
}
/**
* Returns the column at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
* Columns are returned in the order that they were created.
* If no <code>TableColumn</code>s were created by the programmer,
* this method will throw <code>ERROR_INVALID_RANGE</code> despite
* the fact that a single column of data may be visible in the table.
* This occurs when the programmer uses the table like a list, adding
* items but never creating a column.
*
* @param index the index of the column to return
* @return the column at the given index
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#getColumnOrder()
* @see Table#setColumnOrder(int[])
* @see TableColumn#getMoveable()
* @see TableColumn#setMoveable(boolean)
* @see SWT#Move
*/
public TableColumn getColumn (int index) {
checkWidget();
if (!(0 <= index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE);
return columns [index];
}
/**
* Returns the number of columns contained in the receiver.
* If no <code>TableColumn</code>s were created by the programmer,
* this value is zero, despite the fact that visually, one column
* of items may be visible. This occurs when the programmer uses
* the table like a list, adding items but never creating a column.
*
* @return the number of columns
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getColumnCount () {
checkWidget();
return columnCount;
}
long /*int*/[] getColumnTypes (int columnCount) {
long /*int*/[] types = new long /*int*/ [FIRST_COLUMN + (columnCount * CELL_TYPES)];
// per row data
types [CHECKED_COLUMN] = OS.G_TYPE_BOOLEAN ();
types [GRAYED_COLUMN] = OS.G_TYPE_BOOLEAN ();
types [FOREGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
types [BACKGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
types [FONT_COLUMN] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
// per cell data
for (int i=FIRST_COLUMN; i<types.length; i+=CELL_TYPES) {
types [i + CELL_PIXBUF] = OS.GDK_TYPE_PIXBUF ();
types [i + CELL_TEXT] = OS.G_TYPE_STRING ();
types [i + CELL_FOREGROUND] = OS.GDK_TYPE_COLOR ();
types [i + CELL_BACKGROUND] = OS.GDK_TYPE_COLOR ();
types [i + CELL_FONT] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
}
return types;
}
/**
* Returns an array of zero-relative integers that map
* the creation order of the receiver's items to the
* order in which they are currently being displayed.
* <p>
* Specifically, the indices of the returned array represent
* the current visual order of the items, and the contents
* of the array represent the creation order of the items.
* </p><p>
* Note: This is not the actual structure used by the receiver
* to maintain its list of items, so modifying the array will
* not affect the receiver.
* </p>
*
* @return the current visual order of the receiver's items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#setColumnOrder(int[])
* @see TableColumn#getMoveable()
* @see TableColumn#setMoveable(boolean)
* @see SWT#Move
*
* @since 3.1
*/
public int [] getColumnOrder () {
checkWidget ();
if (columnCount == 0) return new int [0];
long /*int*/ list = OS.gtk_tree_view_get_columns (handle);
if (list == 0) return new int [0];
int i = 0, count = OS.g_list_length (list);
int [] order = new int [count];
long /*int*/ temp = list;
while (temp != 0) {
long /*int*/ column = OS.g_list_data (temp);
if (column != 0) {
for (int j=0; j<columnCount; j++) {
if (columns [j].handle == column) {
order [i++] = j;
break;
}
}
}
temp = OS.g_list_next (temp);
}
OS.g_list_free (list);
return order;
}
/**
* Returns an array of <code>TableColumn</code>s which are the
* columns in the receiver. Columns are returned in the order
* that they were created. If no <code>TableColumn</code>s were
* created by the programmer, the array is empty, despite the fact
* that visually, one column of items may be visible. This occurs
* when the programmer uses the table like a list, adding items but
* never creating a column.
* <p>
* Note: This is not the actual structure used by the receiver
* to maintain its list of items, so modifying the array will
* not affect the receiver.
* </p>
*
* @return the items in the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#getColumnOrder()
* @see Table#setColumnOrder(int[])
* @see TableColumn#getMoveable()
* @see TableColumn#setMoveable(boolean)
* @see SWT#Move
*/
public TableColumn [] getColumns () {
checkWidget();
TableColumn [] result = new TableColumn [columnCount];
System.arraycopy (columns, 0, result, 0, columnCount);
return result;
}
TableItem getFocusItem () {
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_tree_view_get_cursor (handle, path, null);
if (path [0] == 0) return null;
TableItem item = null;
long /*int*/ indices = OS.gtk_tree_path_get_indices (path [0]);
if (indices != 0) {
int [] index = new int []{-1};
OS.memmove (index, indices, 4);
item = _getItem (index [0]);
}
OS.gtk_tree_path_free (path [0]);
return item;
}
@Override
GdkColor getForegroundColor () {
return getTextColor ();
}
/**
* Returns the width in pixels of a grid line.
*
* @return the width of a grid line in pixels
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getGridLineWidth () {
checkWidget();
return 0;
}
/**
* Returns the height of the receiver's header
*
* @return the height of the header or zero if the header is not visible
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 2.0
*/
public int getHeaderHeight () {
checkWidget ();
if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
if (columnCount > 0) {
GtkRequisition requisition = new GtkRequisition ();
int height = 0;
for (int i=0; i<columnCount; i++) {
long /*int*/ buttonHandle = columns [i].buttonHandle;
if (buttonHandle != 0) {
gtk_widget_get_preferred_size (buttonHandle, requisition);
height = Math.max (height, requisition.height);
}
}
return height;
}
OS.gtk_widget_realize (handle);
long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle);
long /*int*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
int [] binY = new int [1];
OS.gdk_window_get_origin (binWindow, null, binY);
int [] fixedY = new int [1];
OS.gdk_window_get_origin (fixedWindow, null, fixedY);
return binY [0] - fixedY [0];
}
/**
* Returns <code>true</code> if the receiver's header is visible,
* and <code>false</code> otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, this method
* may still indicate that it is considered visible even though
* it may not actually be showing.
* </p>
*
* @return the receiver's header's visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean getHeaderVisible () {
checkWidget();
return OS.gtk_tree_view_get_headers_visible (handle);
}
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
*
* @param index the index of the item to return
* @return the item at the given index
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public TableItem getItem (int index) {
checkWidget();
if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
return _getItem (index);
}
/**
* Returns the item at the given point in the receiver
* or null if no such item exists. The point is in the
* coordinate system of the receiver.
* <p>
* The item that is returned represents an item that could be selected by the user.
* For example, if selection only occurs in items in the first column, then null is
* returned if the point is outside of the item.
* Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy,
* determines the extent of the selection.
* </p>
*
* @param point the point used to locate the item
* @return the item at the given point, or null if the point is not in a selectable item
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public TableItem getItem (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
int y = point.y;
if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
y -= getHeaderHeight();
}
if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, y, path, null, null, null)) return null;
if (path [0] == 0) return null;
long /*int*/ indices = OS.gtk_tree_path_get_indices (path [0]);
TableItem item = null;
if (indices != 0) {
int [] index = new int [1];
OS.memmove (index, indices, 4);
item = _getItem (index [0]);
}
OS.gtk_tree_path_free (path [0]);
return item;
}
/**
* Returns the number of items contained in the receiver.
*
* @return the number of items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getItemCount () {
checkWidget ();
return itemCount;
}
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the receiver.
*
* @return the height of one item
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getItemHeight () {
checkWidget();
if (itemCount == 0) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0);
int [] w = new int [1], h = new int [1];
ignoreSize = true;
OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
int height = h [0];
if (OS.GTK3) {
long /*int*/ textRenderer = getTextRenderer (column);
OS.gtk_cell_renderer_get_preferred_height_for_width (textRenderer, handle, 0, h, null);
height += h [0];
}
ignoreSize = false;
return height;
} else {
int height = 0;
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
OS.gtk_tree_model_get_iter_first (modelHandle, iter);
int columnCount = Math.max (1, this.columnCount);
for (int i=0; i<columnCount; i++) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, i);
OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
int [] w = new int [1], h = new int [1];
OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
height = Math.max (height, h [0]);
}
OS.g_free (iter);
return height;
}
}
/**
* Returns a (possibly empty) array of <code>TableItem</code>s which
* are the items in the receiver.
* <p>
* Note: This is not the actual structure used by the receiver
* to maintain its list of items, so modifying the array will
* not affect the receiver.
* </p>
*
* @return the items in the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public TableItem [] getItems () {
checkWidget();
TableItem [] result = new TableItem [itemCount];
if ((style & SWT.VIRTUAL) != 0) {
for (int i=0; i<itemCount; i++) {
result [i] = _getItem (i);
}
} else {
System.arraycopy (items, 0, result, 0, itemCount);
}
return result;
}
/**
* Returns <code>true</code> if the receiver's lines are visible,
* and <code>false</code> otherwise. Note that some platforms draw
* grid lines while others may draw alternating row colors.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, this method
* may still indicate that it is considered visible even though
* it may not actually be showing.
* </p>
*
* @return the visibility state of the lines
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean getLinesVisible() {
checkWidget();
if (OS.GTK3) {
return OS.gtk_tree_view_get_grid_lines(handle) > OS.GTK_TREE_VIEW_GRID_LINES_NONE;
} else {
return OS.gtk_tree_view_get_rules_hint (handle);
}
}
long /*int*/ getPixbufRenderer (long /*int*/ column) {
long /*int*/ list = OS.gtk_cell_layout_get_cells(column);
if (list == 0) return 0;
long /*int*/ originalList = list;
long /*int*/ pixbufRenderer = 0;
while (list != 0) {
long /*int*/ renderer = OS.g_list_data (list);
if (OS.GTK_IS_CELL_RENDERER_PIXBUF (renderer)) {
pixbufRenderer = renderer;
break;
}
list = OS.g_list_next (list);
}
OS.g_list_free (originalList);
return pixbufRenderer;
}
/**
* Returns an array of <code>TableItem</code>s that are currently
* selected in the receiver. The order of the items is unspecified.
* An empty array indicates that no items are selected.
* <p>
* Note: This is not the actual structure used by the receiver
* to maintain its selection, so modifying the array will
* not affect the receiver.
* </p>
* @return an array representing the selection
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public TableItem [] getSelection () {
checkWidget();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null);
long /*int*/ originalList = list;
if (list != 0) {
int count = OS.g_list_length (list);
int [] treeSelection = new int [count];
int length = 0;
for (int i=0; i<count; i++) {
long /*int*/ data = OS.g_list_data (list);
long /*int*/ indices = OS.gtk_tree_path_get_indices (data);
if (indices != 0) {
int [] index = new int [1];
OS.memmove (index, indices, 4);
treeSelection [length] = index [0];
length++;
}
OS.gtk_tree_path_free (data);
list = OS.g_list_next (list);
}
OS.g_list_free (originalList);
TableItem [] result = new TableItem [length];
for (int i=0; i<result.length; i++) result [i] = _getItem (treeSelection [i]);
return result;
}
return new TableItem [0];
}
/**
* Returns the number of selected items contained in the receiver.
*
* @return the number of selected items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getSelectionCount () {
checkWidget();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
return OS.gtk_tree_selection_count_selected_rows (selection);
}
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
*
* @return the index of the selected item
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getSelectionIndex () {
checkWidget();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null);
long /*int*/ originalList = list;
if (list != 0) {
int [] index = new int [1];
boolean foundIndex = false;
while (list != 0) {
long /*int*/ data = OS.g_list_data (list);
if (foundIndex == false) {
long /*int*/ indices = OS.gtk_tree_path_get_indices (data);
if (indices != 0) {
OS.memmove (index, indices, 4);
foundIndex = true;
}
}
list = OS.g_list_next (list);
OS.gtk_tree_path_free (data);
}
OS.g_list_free (originalList);
return index [0];
}
return -1;
}
/**
* Returns the zero-relative indices of the items which are currently
* selected in the receiver. The order of the indices is unspecified.
* The array is empty if no items are selected.
* <p>
* Note: This is not the actual structure used by the receiver
* to maintain its selection, so modifying the array will
* not affect the receiver.
* </p>
* @return the array of indices of the selected items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int [] getSelectionIndices () {
checkWidget();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null);
long /*int*/ originalList = list;
if (list != 0) {
int count = OS.g_list_length (list);
int [] treeSelection = new int [count];
int length = 0;
for (int i=0; i<count; i++) {
long /*int*/ data = OS.g_list_data (list);
long /*int*/ indices = OS.gtk_tree_path_get_indices (data);
if (indices != 0) {
int [] index = new int [1];
OS.memmove (index, indices, 4);
treeSelection [length] = index [0];
length++;
}
list = OS.g_list_next (list);
OS.gtk_tree_path_free (data);
}
OS.g_list_free (originalList);
int [] result = new int [length];
System.arraycopy (treeSelection, 0, result, 0, length);
return result;
}
return new int [0];
}
/**
* Returns the column which shows the sort indicator for
* the receiver. The value may be null if no column shows
* the sort indicator.
*
* @return the sort indicator
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #setSortColumn(TableColumn)
*
* @since 3.2
*/
public TableColumn getSortColumn () {
checkWidget ();
return sortColumn;
}
/**
* Returns the direction of the sort indicator for the receiver.
* The value will be one of <code>UP</code>, <code>DOWN</code>
* or <code>NONE</code>.
*
* @return the sort direction
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #setSortDirection(int)
*
* @since 3.2
*/
public int getSortDirection () {
checkWidget ();
return sortDirection;
}
long /*int*/ getTextRenderer (long /*int*/ column) {
long /*int*/ list = OS.gtk_cell_layout_get_cells(column);
if (list == 0) return 0;
long /*int*/ originalList = list;
long /*int*/ textRenderer = 0;
while (list != 0) {
long /*int*/ renderer = OS.g_list_data (list);
if (OS.GTK_IS_CELL_RENDERER_TEXT (renderer)) {
textRenderer = renderer;
break;
}
list = OS.g_list_next (list);
}
OS.g_list_free (originalList);
return textRenderer;
}
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
* scrolled or new items are added or removed.
*
* @return the index of the top item
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getTopIndex () {
checkWidget();
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_widget_realize (handle);
if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return 0;
if (path [0] == 0) return 0;
long /*int*/ indices = OS.gtk_tree_path_get_indices (path[0]);
int[] index = new int [1];
if (indices != 0) OS.memmove (index, indices, 4);
OS.gtk_tree_path_free (path [0]);
return index [0];
}
@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
if (gdkEvent.window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
long /*int*/ result = super.gtk_button_press_event (widget, event);
if (result != 0) return result;
/*
* Feature in GTK. In a multi-select table view, when multiple items are already
* selected, the selection state of the item is toggled and the previous selection
* is cleared. This is not the desired behaviour when bringing up a popup menu.
* Also, when an item is reselected with the right button, the tree view issues
* an unwanted selection event. The workaround is to detect that case and not
* run the default handler when the item is already part of the current selection.
*/
int button = gdkEvent.button;
if (button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
if (path [0] != 0) {
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) result = 1;
OS.gtk_tree_path_free (path [0]);
}
}
}
/*
* Feature in GTK. When the user clicks in a single selection GtkTreeView
* and there are no selected items, the first item is selected automatically
* before the click is processed, causing two selection events. The is fix
* is the set the cursor item to be same as the clicked item to stop the
* widget from automatically selecting the first item.
*/
if ((style & SWT.SINGLE) != 0 && getSelectionCount () == 0) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
if (path [0] != 0) {
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_view_set_cursor (handle, path [0], 0, false);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_path_free (path [0]);
}
}
}
//If Mouse double-click pressed, manually send a DefaultSelection. See Bug 312568.
if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) {
sendTreeDefaultSelection ();
}
return result;
}
@Override
long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) {
GdkEventKey keyEvent = new GdkEventKey ();
OS.memmove (keyEvent, event, GdkEventKey.sizeof);
int key = keyEvent.keyval;
keyPressDefaultSelectionHandler (event, key);
return super.gtk_key_press_event (widget, event);
}
/**
* Used to emulate DefaultSelection event. See Bug 312568.
* @param event the gtk key press event that was fired.
*/
void keyPressDefaultSelectionHandler (long /*int*/ event, int key) {
int keymask = gdk_event_get_state (event);
switch (key) {
case OS.GDK_Return:
//Send Default selection return only when no other modifier is pressed.
if ((keymask & (OS.GDK_MOD1_MASK | OS.GDK_SHIFT_MASK | OS.GDK_CONTROL_MASK
| OS.GDK_SUPER_MASK | OS.GDK_META_MASK | OS.GDK_HYPER_MASK)) == 0) {
sendTreeDefaultSelection ();
}
break;
case OS.GDK_space:
//Shift + Space is a legal DefaultSelection event. (as per row-activation signal documentation).
//But do not send if another modifier is pressed.
if ((keymask & (OS.GDK_MOD1_MASK | OS.GDK_CONTROL_MASK
| OS.GDK_SUPER_MASK | OS.GDK_META_MASK | OS.GDK_HYPER_MASK)) == 0) {
sendTreeDefaultSelection ();
}
break;
}
}
//Used to emulate DefaultSelection event. See Bug 312568.
//Feature in GTK. 'row-activation' event comes before DoubleClick event.
//This is causing the editor not to get focus after doubleclick.
//The solution is to manually send the DefaultSelection event after a doubleclick,
//and to emulate it for Space/Return.
void sendTreeDefaultSelection() {
//Note, similar DefaultSelectionHandling in SWT List/Table/Tree
TableItem tableItem = getFocusItem ();
if (tableItem == null)
return;
Event event = new Event ();
event.item = tableItem;
sendSelectionEvent (SWT.DefaultSelection, event, false);
}
@Override
long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event) {
long /*int*/ window = OS.GDK_EVENT_WINDOW (event);
if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
return super.gtk_button_release_event (widget, event);
}
@Override
long /*int*/ gtk_changed (long /*int*/ widget) {
TableItem item = getFocusItem ();
if (item != null) {
Event event = new Event ();
event.item = item;
sendSelectionEvent (SWT.Selection, event, false);
}
return 0;
}
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
switch (OS.GDK_EVENT_TYPE (gdkEvent)) {
case OS.GDK_EXPOSE: {
/*
* Bug in GTK. SWT connects the expose-event 'after' the default
* handler of the signal. If the tree has no children, then GTK
* sends expose signal only 'before' the default signal handler.
* The fix is to detect this case in 'event_after' and send the
* expose event.
*/
if (OS.gtk_tree_model_iter_n_children (modelHandle, 0) == 0) {
gtk_expose_event (widget, gdkEvent);
}
break;
}
}
return super.gtk_event_after (widget, gdkEvent);
}
void drawInheritedBackground (long /*int*/ eventPtr, long /*int*/ cairo) {
if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) {
Control control = findBackgroundControl ();
if (control != null) {
long /*int*/ window = OS.gtk_tree_view_get_bin_window (handle);
long /*int*/ rgn = 0;
if (eventPtr != 0) {
GdkEventExpose gdkEvent = new GdkEventExpose ();
OS.memmove (gdkEvent, eventPtr, GdkEventExpose.sizeof);
if (window != gdkEvent.window) return;
rgn = gdkEvent.region;
}
int [] width = new int [1], height = new int [1];
gdk_window_get_size (window, width, height);
int bottom = 0;
if (itemCount != 0) {
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, itemCount - 1);
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
GdkRectangle rect = new GdkRectangle ();
OS.gtk_tree_view_get_cell_area (handle, path, 0, rect);
bottom = rect.y + rect.height;
OS.gtk_tree_path_free (path);
OS.g_free (iter);
}
if (height [0] > bottom) {
drawBackground (control, window, cairo, rgn, 0, bottom, width [0], height [0] - bottom);
}
}
}
}
@Override
long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
if ((state & OBSCURED) != 0) return 0;
drawInheritedBackground (0, cairo);
return super.gtk_draw (widget, cairo);
}
@Override
long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) {
if ((state & OBSCURED) != 0) return 0;
drawInheritedBackground (eventPtr, 0);
return super.gtk_expose_event (widget, eventPtr);
}
@Override
long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
long /*int*/ window = OS.GDK_EVENT_WINDOW (event);
if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
return super.gtk_motion_notify_event (widget, event);
}
@Override
long /*int*/ gtk_row_deleted (long /*int*/ model, long /*int*/ path) {
if (ignoreAccessibility) {
OS.g_signal_stop_emission_by_name (model, OS.row_deleted);
}
return 0;
}
@Override
long /*int*/ gtk_row_inserted (long /*int*/ model, long /*int*/ path, long /*int*/ iter) {
if (ignoreAccessibility) {
OS.g_signal_stop_emission_by_name (model, OS.row_inserted);
}
return 0;
}
@Override
long /*int*/ gtk_start_interactive_search(long /*int*/ widget) {
if (!searchEnabled()) {
OS.g_signal_stop_emission_by_name(widget, OS.start_interactive_search);
return 1;
}
return 0;
}
@Override
long /*int*/ gtk_toggled (long /*int*/ renderer, long /*int*/ pathStr) {
long /*int*/ path = OS.gtk_tree_path_new_from_string (pathStr);
if (path == 0) return 0;
long /*int*/ indices = OS.gtk_tree_path_get_indices (path);
if (indices != 0) {
int [] index = new int [1];
OS.memmove (index, indices, 4);
TableItem item = _getItem (index [0]);
item.setChecked (!item.getChecked ());
Event event = new Event ();
event.detail = SWT.CHECK;
event.item = item;
sendSelectionEvent (SWT.Selection, event, false);
}
OS.gtk_tree_path_free (path);
return 0;
}
@Override
void gtk_widget_size_request (long /*int*/ widget, GtkRequisition requisition) {
/*
* Bug in GTK. For some reason, gtk_widget_size_request() fails
* to include the height of the tree view items when there are
* no columns visible. The fix is to temporarily make one column
* visible.
*/
if (columnCount == 0) {
super.gtk_widget_size_request (widget, requisition);
return;
}
long /*int*/ columns = OS.gtk_tree_view_get_columns (handle), list = columns;
boolean fixVisible = columns != 0;
while (list != 0) {
long /*int*/ column = OS.g_list_data (list);
if (OS.gtk_tree_view_column_get_visible (column)) {
fixVisible = false;
break;
}
list = OS.g_list_next (list);
}
long /*int*/ columnHandle = 0;
if (fixVisible) {
columnHandle = OS.g_list_data (columns);
OS.gtk_tree_view_column_set_visible (columnHandle, true);
}
super.gtk_widget_size_request (widget, requisition);
if (fixVisible) {
OS.gtk_tree_view_column_set_visible (columnHandle, false);
}
if (columns != 0) OS.g_list_free (columns);
}
void hideFirstColumn () {
long /*int*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
OS.gtk_tree_view_column_set_visible (firstColumn, false);
}
@Override
void hookEvents () {
super.hookEvents ();
long /*int*/ selection = OS.gtk_tree_view_get_selection(handle);
OS.g_signal_connect_closure (selection, OS.changed, display.getClosure (CHANGED), false);
OS.g_signal_connect_closure (handle, OS.row_activated, display.getClosure (ROW_ACTIVATED), false);
if (checkRenderer != 0) {
OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.getClosure (TOGGLED), false);
}
OS.g_signal_connect_closure (handle, OS.start_interactive_search, display.getClosure (START_INTERACTIVE_SEARCH), false);
if (fixAccessibility ()) {
OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.getClosure (ROW_INSERTED), true);
OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.getClosure (ROW_DELETED), true);
}
}
/**
* Searches the receiver's list starting at the first column
* (index 0) until a column is found that is equal to the
* argument, and returns the index of that column. If no column
* is found, returns -1.
*
* @param column the search column
* @return the index of the column
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the column is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int indexOf (TableColumn column) {
checkWidget();
if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
for (int i=0; i<columnCount; i++) {
if (columns [i] == column) return i;
}
return -1;
}
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
* argument, and returns the index of that item. If no item
* is found, returns -1.
*
* @param item the search item
* @return the index of the item
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the item is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int indexOf (TableItem item) {
checkWidget();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) {
if (items [lastIndexOf] == item) return lastIndexOf;
if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
if (items [lastIndexOf - 1] == item) return --lastIndexOf;
}
if (lastIndexOf < itemCount / 2) {
for (int i=0; i<itemCount; i++) {
if (items [i] == item) return lastIndexOf = i;
}
} else {
for (int i=itemCount - 1; i>=0; --i) {
if (items [i] == item) return lastIndexOf = i;
}
}
return -1;
}
/**
* Returns <code>true</code> if the item is selected,
* and <code>false</code> otherwise. Indices out of
* range are ignored.
*
* @param index the index of the item
* @return the selection state of the item at the index
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean isSelected (int index) {
checkWidget();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
byte [] buffer = Converter.wcsToMbcs (null, Integer.toString (index), true);
long /*int*/ path = OS.gtk_tree_path_new_from_string (buffer);
boolean answer = OS.gtk_tree_selection_path_is_selected (selection, path);
OS.gtk_tree_path_free (path);
return answer;
}
@Override
boolean mnemonicHit (char key) {
for (int i=0; i<columnCount; i++) {
long /*int*/ labelHandle = columns [i].labelHandle;
if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
}
return false;
}
@Override
boolean mnemonicMatch (char key) {
for (int i=0; i<columnCount; i++) {
long /*int*/ labelHandle = columns [i].labelHandle;
if (labelHandle != 0 && mnemonicMatch (labelHandle, key)) return true;
}
return false;
}
@Override
long /*int*/ paintWindow () {
OS.gtk_widget_realize (handle);
if (fixedHandle != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) {
OS.gtk_widget_realize (fixedHandle);
return OS.gtk_widget_get_window(fixedHandle);
}
return OS.gtk_tree_view_get_bin_window (handle);
}
void recreateRenderers () {
if (checkRenderer != 0) {
display.removeWidget (checkRenderer);
OS.g_object_unref (checkRenderer);
checkRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_toggle_get_type(), 0) : OS.gtk_cell_renderer_toggle_new ();
if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
OS.g_object_ref (checkRenderer);
display.addWidget (checkRenderer, this);
OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.getClosure (TOGGLED), false);
}
if (columnCount == 0) {
createRenderers (OS.gtk_tree_view_get_column (handle, 0), Table.FIRST_COLUMN, true, 0);
} else {
for (int i = 0; i < columnCount; i++) {
TableColumn column = columns [i];
createRenderers (column.handle, column.modelIndex, i == 0, column.style);
}
}
}
@Override
void redrawBackgroundImage () {
Control control = findBackgroundControl ();
if (control != null && control.backgroundImage != null) {
redrawWidget (0, 0, 0, 0, true, false, false);
}
}
@Override
void register () {
super.register ();
display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
if (checkRenderer != 0) display.addWidget (checkRenderer, this);
display.addWidget (modelHandle, this);
}
@Override
void releaseChildren (boolean destroy) {
if (items != null) {
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (item != null && !item.isDisposed ()) {
item.release (false);
}
}
items = null;
}
if (columns != null) {
for (int i=0; i<columnCount; i++) {
TableColumn column = columns [i];
if (column != null && !column.isDisposed ()) {
column.release (false);
}
}
columns = null;
}
super.releaseChildren (destroy);
}
@Override
void releaseWidget () {
super.releaseWidget ();
if (modelHandle != 0) OS.g_object_unref (modelHandle);
modelHandle = 0;
if (checkRenderer != 0) OS.g_object_unref (checkRenderer);
checkRenderer = 0;
if (imageList != null) imageList.dispose ();
if (headerImageList != null) headerImageList.dispose ();
imageList = headerImageList = null;
currentItem = null;
}
/**
* Removes the item from the receiver at the given
* zero-relative index.
*
* @param index the index for the item
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void remove (int index) {
checkWidget();
if (!(0 <= index && index < itemCount)) error (SWT.ERROR_ITEM_NOT_REMOVED);
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
TableItem item = items [index];
boolean disposed = false;
if (item != null) {
disposed = item.isDisposed ();
if (!disposed) {
OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ());
item.release (false);
}
} else {
OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
}
if (!disposed) {
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_list_store_remove (modelHandle, iter);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
}
OS.g_free (iter);
}
/**
* Removes the items from the receiver which are
* between the given zero-relative start and end
* indices (inclusive).
*
* @param start the start of the range
* @param end the end of the range
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void remove (int start, int end) {
checkWidget();
if (start > end) return;
if (!(0 <= start && start <= end && end < itemCount)) {
error (SWT.ERROR_INVALID_RANGE);
}
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (iter == 0) error (SWT.ERROR_NO_HANDLES);
if (fixAccessibility ()) {
ignoreAccessibility = true;
}
int index = end;
while (index >= start) {
OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
TableItem item = items [index];
if (item != null && !item.isDisposed ()) item.release (false);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_list_store_remove (modelHandle, iter);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
index--;
}
if (fixAccessibility ()) {
ignoreAccessibility = false;
OS.g_object_notify (handle, OS.model);
}
OS.g_free (iter);
index = end + 1;
System.arraycopy (items, index, items, start, itemCount - index);
for (int i=itemCount-(index-start); i<itemCount; i++) items [i] = null;
itemCount = itemCount - (index - start);
}
/**
* Removes the items from the receiver's list at the given
* zero-relative indices.
*
* @param indices the array of indices of the items
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
* <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void remove (int [] indices) {
checkWidget();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
if (indices.length == 0) return;
int [] newIndices = new int [indices.length];
System.arraycopy (indices, 0, newIndices, 0, indices.length);
sort (newIndices);
int start = newIndices [newIndices.length - 1], end = newIndices [0];
if (!(0 <= start && start <= end && end < itemCount)) {
error (SWT.ERROR_INVALID_RANGE);
}
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
int last = -1;
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (iter == 0) error (SWT.ERROR_NO_HANDLES);
if (fixAccessibility ()) {
ignoreAccessibility = true;
}
for (int i=0; i<newIndices.length; i++) {
int index = newIndices [i];
if (index != last) {
TableItem item = items [index];
boolean disposed = false;
if (item != null) {
disposed = item.isDisposed ();
if (!disposed) {
OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ());
item.release (false);
}
} else {
OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
}
if (!disposed) {
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_list_store_remove (modelHandle, iter);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
System.arraycopy (items, index + 1, items, index, --itemCount - index);
items [itemCount] = null;
}
last = index;
}
}
if (fixAccessibility ()) {
ignoreAccessibility = false;
OS.g_object_notify (handle, OS.model);
}
OS.g_free (iter);
}
/**
* Removes all of the items from the receiver.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void removeAll () {
checkWidget();
int index = itemCount - 1;
while (index >= 0) {
TableItem item = items [index];
if (item != null && !item.isDisposed ()) item.release (false);
--index;
}
items = new TableItem [4];
itemCount = 0;
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixAccessibility ()) {
ignoreAccessibility = true;
}
OS.gtk_list_store_clear (modelHandle);
if (fixAccessibility ()) {
ignoreAccessibility = false;
OS.g_object_notify (handle, OS.model);
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
resetCustomDraw ();
if (!searchEnabled ()) {
OS.gtk_tree_view_set_search_column (handle, -1);
} else {
/* Set the search column whenever the model changes */
int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
}
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the user changes the receiver's selection.
*
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see SelectionListener
* @see #addSelectionListener(SelectionListener)
*/
public void removeSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
eventTable.unhook (SWT.DefaultSelection,listener);
}
void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ height) {
if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell) && hooks (SWT.MeasureItem)) {
long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
TableItem item = null;
boolean isSelected = false;
if (iter != 0) {
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
int [] buffer = new int [1];
OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4);
int index = buffer [0];
item = _getItem (index);
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
isSelected = OS.gtk_tree_selection_path_is_selected (selection, path);
OS.gtk_tree_path_free (path);
}
if (item != null) {
int columnIndex = 0;
if (columnCount > 0) {
long /*int*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
for (int i = 0; i < columnCount; i++) {
if (columns [i].handle == columnHandle) {
columnIndex = i;
break;
}
}
}
int [] contentWidth = new int [1], contentHeight = new int [1];
if (width != 0) OS.memmove (contentWidth, width, 4);
if (height != 0) OS.memmove (contentHeight, height, 4);
if (OS.GTK3) {
OS.gtk_cell_renderer_get_preferred_height_for_width (cell, handle, contentWidth[0], contentHeight, null);
}
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
Rectangle bounds = image.getBounds ();
imageWidth = bounds.width;
}
contentWidth [0] += imageWidth;
GC gc = new GC (this);
gc.setFont (item.getFont (columnIndex));
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
event.width = contentWidth [0];
event.height = contentHeight [0];
if (isSelected) event.detail = SWT.SELECTED;
sendEvent (SWT.MeasureItem, event);
gc.dispose ();
contentWidth [0] = event.width - imageWidth;
if (contentHeight [0] < event.height) contentHeight [0] = event.height;
if (width != 0) OS.memmove (width, contentWidth, 4);
if (height != 0) OS.memmove (height, contentHeight, 4);
if (OS.GTK3) {
OS.gtk_cell_renderer_set_fixed_size (cell, contentWidth [0], contentHeight [0]);
}
}
}
}
@Override
long /*int*/ rendererGetPreferredWidthProc (long /*int*/ cell, long /*int*/ handle, long /*int*/ minimun_size, long /*int*/ natural_size) {
long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
GtkCellRendererClass klass = new GtkCellRendererClass ();
OS.memmove (klass, g_class);
OS.call (klass.get_preferred_width, cell, handle, minimun_size, natural_size);
sendMeasureEvent (cell, minimun_size, 0);
return 0;
}
@Override
long /*int*/ rendererGetSizeProc (long /*int*/ cell, long /*int*/ widget, long /*int*/ cell_area, long /*int*/ x_offset, long /*int*/ y_offset, long /*int*/ width, long /*int*/ height) {
long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
GtkCellRendererClass klass = new GtkCellRendererClass ();
OS.memmove (klass, g_class);
OS.call_get_size (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height);
sendMeasureEvent (cell, width, height);
return 0;
}
@Override
long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ cr, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ flags) {
rendererRender (cell, cr, 0, widget, background_area, cell_area, 0, flags);
return 0;
}
@Override
long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) {
rendererRender (cell, 0, window, widget, background_area, cell_area, expose_area, flags);
return 0;
}
void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) {
TableItem item = null;
long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
if (iter != 0) {
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
int [] buffer = new int [1];
OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4);
int index = buffer [0];
item = _getItem (index);
OS.gtk_tree_path_free (path);
}
long /*int*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
int columnIndex = 0;
if (columnCount > 0) {
for (int i = 0; i < columnCount; i++) {
if (columns [i].handle == columnHandle) {
columnIndex = i;
break;
}
}
}
if (item != null) {
if (OS.GTK_IS_CELL_RENDERER_TOGGLE (cell) ||
( (OS.GTK_IS_CELL_RENDERER_PIXBUF (cell) || OS.GTK_VERSION > OS.VERSION(3, 13, 0)) && (columnIndex != 0 || (style & SWT.CHECK) == 0))) {
drawFlags = (int)/*64*/flags;
drawState = SWT.FOREGROUND;
long /*int*/ [] ptr = new long /*int*/ [1];
OS.gtk_tree_model_get (modelHandle, item.handle, Table.BACKGROUND_COLUMN, ptr, -1);
if (ptr [0] == 0) {
int modelIndex = columnCount == 0 ? Table.FIRST_COLUMN : columns [columnIndex].modelIndex;
OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1);
}
if (ptr [0] != 0) {
drawState |= SWT.BACKGROUND;
OS.gdk_color_free (ptr [0]);
}
if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
if (!OS.GTK3 || (flags & OS.GTK_CELL_RENDERER_SELECTED) == 0) {
if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;
}
GdkRectangle rect = new GdkRectangle ();
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
OS.gtk_tree_path_free (path);
// A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=459117
if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
GdkRectangle r2 = new GdkRectangle ();
OS.gdk_cairo_get_clip_rectangle (cr, r2);
rect.x = r2.x;
rect.width = r2.width;
}
if ((drawState & SWT.SELECTED) == 0) {
if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) {
Control control = findBackgroundControl ();
if (control != null) {
if (cr != 0) {
Cairo.cairo_save (cr);
if (!OS.GTK3){
Cairo.cairo_reset_clip (cr);
}
}
drawBackground (control, window, cr, 0, rect.x, rect.y, rect.width, rect.height);
if (cr != 0) {
Cairo.cairo_restore (cr);
}
}
}
}
//send out measure before erase
long /*int*/ textRenderer = getTextRenderer (columnHandle);
if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null);
if (hooks (SWT.EraseItem)) {
boolean wasSelected = (drawState & SWT.SELECTED) != 0;
if (wasSelected) {
Control control = findBackgroundControl ();
if (control == null) control = this;
if (!OS.GTK3){
if (cr != 0) {
Cairo.cairo_save (cr);
Cairo.cairo_reset_clip (cr);
}
drawBackground (control, window, cr, 0, rect.x, rect.y, rect.width, rect.height);
if (cr != 0) {
Cairo.cairo_restore (cr);
}
}
}
GC gc = getGC(cr);
if ((drawState & SWT.SELECTED) != 0) {
gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
} else {
gc.setBackground (item.getBackground (columnIndex));
gc.setForeground (item.getForeground (columnIndex));
}
gc.setFont (item.getFont (columnIndex));
if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) {
GdkRectangle r = new GdkRectangle();
OS.gdk_cairo_get_clip_rectangle(cr, r);
gc.setClipping(rect.x, r.y, r.width, r.height);
if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.width = r.width;
}
} else {
gc.setClipping (rect.x, rect.y, rect.width, rect.height);
}
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
event.x = rect.x;
event.y = rect.y;
event.width = rect.width;
event.height = rect.height;
event.detail = drawState;
sendEvent (SWT.EraseItem, event);
drawForeground = null;
drawState = event.doit ? event.detail : 0;
if (OS.GTK3) {
drawState |= SWT.BACKGROUND;
}
drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED);
if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED;
if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
if ((drawState & SWT.SELECTED) != 0) {
if (OS.GTK3) {
Cairo.cairo_save (cr);
Cairo.cairo_reset_clip (cr);
long /*int*/ context = OS.gtk_widget_get_style_context (widget);
OS.gtk_style_context_save (context);
OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_CELL);
OS.gtk_style_context_set_state (context, OS.GTK_STATE_FLAG_SELECTED);
OS.gtk_render_background(context, cr, rect.x, rect.y, rect.width, rect.height);
OS.gtk_style_context_restore (context);
Cairo.cairo_restore (cr);
} else {
long /*int*/ style = OS.gtk_widget_get_style (widget);
//TODO - parity and sorted
byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
}
} else {
if (wasSelected) drawForeground = gc.getForeground ().handle;
}
gc.dispose();
}
}
}
if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) {
GC gc = getGC(cr);
gc.setBackground (item.getBackground (columnIndex));
GdkRectangle rect = new GdkRectangle ();
OS.memmove (rect, background_area, GdkRectangle.sizeof);
gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
gc.dispose ();
}
if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
GtkCellRendererClass klass = new GtkCellRendererClass ();
OS.memmove (klass, g_class);
if (drawForeground != null && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
OS.g_object_set (cell, OS.foreground_gdk, drawForeground, 0);
}
if (OS.GTK3) {
OS.call (klass.render, cell, cr, widget, background_area, cell_area, drawFlags);
} else {
OS.call (klass.render, cell, window, widget, background_area, cell_area, expose_area, drawFlags);
}
}
if (item != null) {
if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
if (hooks (SWT.PaintItem)) {
GdkRectangle rect = new GdkRectangle ();
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
OS.gtk_tree_path_free (path);
// A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=459117
if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
GdkRectangle r2 = new GdkRectangle ();
OS.gdk_cairo_get_clip_rectangle (cr, r2);
rect.x = r2.x;
rect.width = r2.width;
}
ignoreSize = true;
int [] contentX = new int [1], contentWidth = new int [1];
gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null);
OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null);
ignoreSize = false;
Image image = item.getImage (columnIndex);
int imageWidth = 0;
if (image != null) {
Rectangle bounds = image.getBounds ();
imageWidth = bounds.width;
}
// On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle
// need to adjust clip rectangle with image width
if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) {
rect.x -= imageWidth;
rect.width +=imageWidth;
}
contentX [0] -= imageWidth;
contentWidth [0] += imageWidth;
GC gc = getGC(cr);
if ((drawState & SWT.SELECTED) != 0) {
Color background, foreground;
if (OS.gtk_widget_has_focus (handle) || OS.GTK3) {
background = display.getSystemColor (SWT.COLOR_LIST_SELECTION);
foreground = display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT);
} else {
/*
* Feature in GTK. When the widget doesn't have focus, then
* gtk_paint_flat_box () changes the background color state_type
* to GTK_STATE_ACTIVE. The fix is to use the same values in the GC.
*/
background = Color.gtk_new (display, display.COLOR_LIST_SELECTION_INACTIVE);
foreground = Color.gtk_new (display, display.COLOR_LIST_SELECTION_TEXT_INACTIVE);
}
gc.setBackground (background);
gc.setForeground (foreground);
} else {
gc.setBackground (item.getBackground (columnIndex));
Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex);
gc.setForeground (foreground);
}
gc.setFont (item.getFont (columnIndex));
if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
gc.setClipping (rect.x, rect.y, rect.width, rect.height);
Event event = new Event ();
event.item = item;
event.index = columnIndex;
event.gc = gc;
event.x = rect.x + contentX [0];
event.y = rect.y;
event.width = contentWidth [0];
event.height = rect.height;
event.detail = drawState;
sendEvent (SWT.PaintItem, event);
gc.dispose();
}
}
}
}
private GC getGC(long /*int*/ cr) {
GC gc;
if (OS.GTK3){
GCData gcData = new GCData();
gcData.cairo = cr;
gc = GC.gtk_new(this, gcData );
} else {
gc = new GC (this);
}
return gc;
}
void resetCustomDraw () {
if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return;
int end = Math.max (1, columnCount);
for (int i=0; i<end; i++) {
boolean customDraw = columnCount != 0 ? columns [i].customDraw : firstCustomDraw;
if (customDraw) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, i);
long /*int*/ textRenderer = getTextRenderer (column);
OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, 0, 0, 0);
if (columnCount != 0) columns [i].customDraw = false;
}
}
firstCustomDraw = false;
}
@Override
void reskinChildren (int flags) {
if (items != null) {
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (item != null) item.reskin (flags);
}
}
if (columns != null) {
for (int i=0; i<columnCount; i++) {
TableColumn column = columns [i];
if (!column.isDisposed ()) column.reskin (flags);
}
}
super.reskinChildren (flags);
}
boolean searchEnabled () {
/* Disable searching when using VIRTUAL */
if ((style & SWT.VIRTUAL) != 0) return false;
return true;
}
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains
* selected. Indices that are out of range are ignored.
*
* @param index the index of the item to select
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void select (int index) {
checkWidget();
if (!(0 <= index && index < itemCount)) return;
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
TableItem item = _getItem (index);
OS.gtk_tree_selection_select_iter (selection, item.handle);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Selects the items in the range specified by the given zero-relative
* indices in the receiver. The range of indices is inclusive.
* The current selection is not cleared before the new items are selected.
* <p>
* If an item in the given range is not selected, it is selected.
* If an item in the given range was already selected, it remains selected.
* Indices that are out of range are ignored and no items will be selected
* if start is greater than end.
* If the receiver is single-select and there is more than one item in the
* given range, then all indices are ignored.
* </p>
*
* @param start the start of the range
* @param end the end of the range
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#setSelection(int,int)
*/
public void select (int start, int end) {
checkWidget ();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
if (itemCount == 0 || start >= itemCount) return;
start = Math.max (0, start);
end = Math.min (end, itemCount - 1);
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
for (int index=start; index<=end; index++) {
TableItem item = _getItem (index);
OS.gtk_tree_selection_select_iter (selection, item.handle);
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selection is not cleared before the new items are selected.
* <p>
* If the item at a given index is not selected, it is selected.
* If the item at a given index was already selected, it remains selected.
* Indices that are out of range and duplicate indices are ignored.
* If the receiver is single-select and multiple indices are specified,
* then all indices are ignored.
* </p>
*
* @param indices the array of indices for the items to select
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#setSelection(int[])
*/
public void select (int [] indices) {
checkWidget ();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
int length = indices.length;
if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
for (int i=0; i<length; i++) {
int index = indices [i];
if (!(0 <= index && index < itemCount)) continue;
TableItem item = _getItem (index);
OS.gtk_tree_selection_select_iter (selection, item.handle);
}
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
/**
* Selects all of the items in the receiver.
* <p>
* If the receiver is single-select, do nothing.
* </p>
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void selectAll () {
checkWidget();
if ((style & SWT.SINGLE) != 0) return;
boolean fixColumn = showFirstColumn ();
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_selection_select_all (selection);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
if (fixColumn) hideFirstColumn ();
}
void selectFocusIndex (int index) {
/*
* Note that this method both selects and sets the focus to the
* specified index, so any previous selection in the list will be lost.
* gtk does not provide a way to just set focus to a specified list item.
*/
if (!(0 <= index && index < itemCount)) return;
TableItem item = _getItem (index);
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_view_set_cursor (handle, path, 0, false);
/*
* Bug in GTK. For some reason, when an event loop is run from
* within a key pressed handler and a dialog is displayed that
* contains a GtkTreeView, gtk_tree_view_set_cursor() does
* not set the cursor or select the item. The fix is to select the
* item with gtk_tree_selection_select_iter() as well.
*
* NOTE: This happens in GTK 2.2.1 and is fixed in GTK 2.2.4.
*/
OS.gtk_tree_selection_select_iter (selection, item.handle);
OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_path_free (path);
}
@Override
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
if (!OS.GTK3) {
OS.gtk_widget_modify_base (handle, 0, color);
} else {
// Setting the background color overrides the selected background color
// so we have to reset it the default.
GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION;
GdkRGBA selectedBackground = new GdkRGBA ();
selectedBackground.alpha = 1;
selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF;
selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF;
selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF;
OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground);
}
}
@Override
void setBackgroundPixmap (Image image) {
ownerDraw = true;
recreateRenderers ();
}
@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
/*
* Bug on GTK. The tree view sometimes does not get a paint
* event or resizes to a one pixel square when resized in a new
* shell that is not visible after any event loop has been run. The
* problem is intermittent. It doesn't seem to happen the first time
* a new shell is created. The fix is to ensure the tree view is realized
* after it has been resized.
*/
OS.gtk_widget_realize (handle);
return result;
}
/**
* Sets the order that the items in the receiver should
* be displayed in to the given argument which is described
* in terms of the zero-relative ordering of when the items
* were added.
*
* @param order the new order to display the items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
* </ul>
*
* @see Table#getColumnOrder()
* @see TableColumn#getMoveable()
* @see TableColumn#setMoveable(boolean)
* @see SWT#Move
*
* @since 3.1
*/
public void setColumnOrder (int [] order) {
checkWidget ();
if (order == null) error (SWT.ERROR_NULL_ARGUMENT);
if (columnCount == 0) {
if (order.length > 0) error (SWT.ERROR_INVALID_ARGUMENT);
return;
}
if (order.length != columnCount) error (SWT.ERROR_INVALID_ARGUMENT);
boolean [] seen = new boolean [columnCount];
for (int i = 0; i<order.length; i++) {
int index = order [i];
if (index < 0 || index >= columnCount) error (SWT.ERROR_INVALID_RANGE);
if (seen [index]) error (SWT.ERROR_INVALID_ARGUMENT);
seen [index] = true;
}
for (int i=0; i<order.length; i++) {
long /*int*/ column = columns [order [i]].handle;
long /*int*/ baseColumn = i == 0 ? 0 : columns [order [i-1]].handle;
OS.gtk_tree_view_move_column_after (handle, column, baseColumn);
}
}
@Override
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
TableColumn[] columns = getColumns ();
for (int i = 0; i < columns.length; i++) {
if (columns[i] != null) {
columns[i].setFontDescription (font);
}
}
}
@Override
void setForegroundColor (GdkColor color) {
setForegroundColor (handle, color, false);
}
/**
* Marks the receiver's header as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, marking
* it visible may not actually cause it to be displayed.
* </p>
*
* @param show the new visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setHeaderVisible (boolean show) {
checkWidget ();
OS.gtk_tree_view_set_headers_visible (handle, show);
}
/**
* Sets the number of items contained in the receiver.
*
* @param count the number of items
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.0
*/
public void setItemCount (int count) {
checkWidget ();
count = Math.max (0, count);
if (count == itemCount) return;
boolean isVirtual = (style & SWT.VIRTUAL) != 0;
if (!isVirtual) setRedraw (false);
remove (count, itemCount - 1);
int length = Math.max (4, (count + 3) / 4 * 4);
TableItem [] newItems = new TableItem [length];
System.arraycopy (items, 0, newItems, 0, itemCount);
items = newItems;
if (isVirtual) {
long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
if (iter == 0) error (SWT.ERROR_NO_HANDLES);
if (fixAccessibility ()) {
ignoreAccessibility = true;
}
for (int i=itemCount; i<count; i++) {
OS.gtk_list_store_append (modelHandle, iter);
}
if (fixAccessibility ()) {
ignoreAccessibility = false;
OS.g_object_notify (handle, OS.model);
}
OS.g_free (iter);
itemCount = count;
} else {
for (int i=itemCount; i<count; i++) {
new TableItem (this, SWT.NONE, i, true);
}
}
if (!isVirtual) setRedraw (true);
}
/**
* Marks the receiver's lines as visible if the argument is <code>true</code>,
* and marks it invisible otherwise. Note that some platforms draw grid lines
* while others may draw alternating row colors.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, marking
* it visible may not actually cause it to be displayed.
* </p>
*
* @param show the new visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLinesVisible (boolean show) {
checkWidget();
if (!OS.GTK3) {
OS.gtk_tree_view_set_rules_hint (handle, show);
}
//Note: this is overriden by the active theme in GTK3.
OS.gtk_tree_view_set_grid_lines (handle, show ? OS.GTK_TREE_VIEW_GRID_LINES_VERTICAL : OS.GTK_TREE_VIEW_GRID_LINES_NONE);
}
void setModel (long /*int*/ newModel) {
display.removeWidget (modelHandle);
OS.g_object_unref (modelHandle);
modelHandle = newModel;
display.addWidget (modelHandle, this);
if (fixAccessibility ()) {
OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.getClosure (ROW_INSERTED), true);
OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.getClosure (ROW_DELETED), true);
}
}
@Override
void setOrientation (boolean create) {
super.setOrientation (create);
for (int i=0; i<itemCount; i++) {
if (items[i] != null) items[i].setOrientation (create);
}
for (int i=0; i<columnCount; i++) {
if (columns[i] != null) columns[i].setOrientation (create);
}
}
@Override
void setParentBackground () {
ownerDraw = true;
recreateRenderers ();
}
@Override
void setParentWindow (long /*int*/ widget) {
long /*int*/ window = eventWindow ();
OS.gtk_widget_set_parent_window (widget, window);
}
@Override
public void setRedraw (boolean redraw) {
checkWidget();
super.setRedraw (redraw);
if (redraw && drawCount == 0) {
/* Resize the item array to match the item count */
if (items.length > 4 && items.length - itemCount > 3) {
int length = Math.max (4, (itemCount + 3) / 4 * 4);
TableItem [] newItems = new TableItem [length];
System.arraycopy (items, 0, newItems, 0, itemCount);
items = newItems;
}
}
}
void setScrollWidth (long /*int*/ column, TableItem item) {
if (columnCount != 0 || currentItem == item) return;
int width = OS.gtk_tree_view_column_get_fixed_width (column);
int itemWidth = calculateWidth (column, item.handle);
if (width < itemWidth) {
OS.gtk_tree_view_column_set_fixed_width (column, itemWidth);
}
}
/**
* Sets the column used by the sort indicator for the receiver. A null
* value will clear the sort indicator. The current sort column is cleared
* before the new column is set.
*
* @param column the column used by the sort indicator or <code>null</code>
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.2
*/
public void setSortColumn (TableColumn column) {
checkWidget ();
if (column != null && column.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (sortColumn != null && !sortColumn.isDisposed()) {
OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
}
sortColumn = column;
if (sortColumn != null && sortDirection != SWT.NONE) {
OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
}
}
/**
* Sets the direction of the sort indicator for the receiver. The value
* can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>.
*
* @param direction the direction of the sort indicator
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.2
*/
public void setSortDirection (int direction) {
checkWidget ();
if (direction != SWT.UP && direction != SWT.DOWN && direction != SWT.NONE) return;
sortDirection = direction;
if (sortColumn == null || sortColumn.isDisposed ()) return;
if (sortDirection == SWT.NONE) {
OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
} else {
OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
}
}
/**
* Selects the item at the given zero-relative index in the receiver.
* The current selection is first cleared, then the new item is selected,
* and if necessary the receiver is scrolled to make the new selection visible.
*
* @param index the index of the item to select
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#deselectAll()
* @see Table#select(int)
*/
public void setSelection (int index) {
checkWidget ();
boolean fixColumn = showFirstColumn ();
deselectAll ();
selectFocusIndex (index);
showSelection ();
if (fixColumn) hideFirstColumn ();
}
/**
* Selects the items in the range specified by the given zero-relative
* indices in the receiver. The range of indices is inclusive.
* The current selection is cleared before the new items are selected,
* and if necessary the receiver is scrolled to make the new selection visible.
* <p>
* Indices that are out of range are ignored and no items will be selected
* if start is greater than end.
* If the receiver is single-select and there is more than one item in the
* given range, then all indices are ignored.
* </p>
*
* @param start the start index of the items to select
* @param end the end index of the items to select
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#deselectAll()
* @see Table#select(int,int)
*/
public void setSelection (int start, int end) {
checkWidget ();
deselectAll();
if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
if (itemCount == 0 || start >= itemCount) return;
boolean fixColumn = showFirstColumn ();
start = Math.max (0, start);
end = Math.min (end, itemCount - 1);
selectFocusIndex (start);
if ((style & SWT.MULTI) != 0) {
select (start, end);
}
showSelection ();
if (fixColumn) hideFirstColumn ();
}
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selection is cleared before the new items are selected,
* and if necessary the receiver is scrolled to make the new selection visible.
* <p>
* Indices that are out of range and duplicate indices are ignored.
* If the receiver is single-select and multiple indices are specified,
* then all indices are ignored.
* </p>
*
* @param indices the indices of the items to select
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#deselectAll()
* @see Table#select(int[])
*/
public void setSelection (int [] indices) {
checkWidget ();
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
deselectAll ();
int length = indices.length;
if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
boolean fixColumn = showFirstColumn ();
selectFocusIndex (indices [0]);
if ((style & SWT.MULTI) != 0) {
select (indices);
}
showSelection ();
if (fixColumn) hideFirstColumn ();
}
/**
* Sets the receiver's selection to the given item.
* The current selection is cleared before the new item is selected,
* and if necessary the receiver is scrolled to make the new selection visible.
* <p>
* If the item is not in the receiver, then it is ignored.
* </p>
*
* @param item the item to select
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the item is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.2
*/
public void setSelection (TableItem item) {
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
setSelection (new TableItem [] {item});
}
/**
* Sets the receiver's selection to be the given array of items.
* The current selection is cleared before the new items are selected,
* and if necessary the receiver is scrolled to make the new selection visible.
* <p>
* Items that are not in the receiver are ignored.
* If the receiver is single-select and multiple items are specified,
* then all items are ignored.
* </p>
*
* @param items the array of items
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
* <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#deselectAll()
* @see Table#select(int[])
* @see Table#setSelection(int[])
*/
public void setSelection (TableItem [] items) {
checkWidget ();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
boolean fixColumn = showFirstColumn ();
deselectAll ();
int length = items.length;
if (!(length == 0 || ((style & SWT.SINGLE) != 0 && length > 1))) {
boolean first = true;
for (int i = 0; i < length; i++) {
int index = indexOf (items [i]);
if (index != -1) {
if (first) {
first = false;
selectFocusIndex (index);
} else {
select (index);
}
}
}
showSelection ();
}
if (fixColumn) hideFirstColumn ();
}
/**
* Sets the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items
* are scrolled or new items are added and removed.
*
* @param index the index of the top item
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setTopIndex (int index) {
checkWidget();
if (!(0 <= index && index < itemCount)) return;
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, _getItem (index).handle);
OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
OS.gtk_tree_path_free (path);
}
/**
* Shows the column. If the column is already showing in the receiver,
* this method simply returns. Otherwise, the columns are scrolled until
* the column is visible.
*
* @param column the column to be shown
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the column is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the column has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 3.0
*/
public void showColumn (TableColumn column) {
checkWidget ();
if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
if (column.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
if (column.parent != this) return;
OS.gtk_tree_view_scroll_to_cell (handle, 0, column.handle, false, 0, 0);
}
boolean showFirstColumn () {
/*
* Bug in GTK. If no columns are visible, changing the selection
* will fail. The fix is to temporarily make a column visible.
*/
int columnCount = Math.max (1, this.columnCount);
for (int i=0; i<columnCount; i++) {
long /*int*/ column = OS.gtk_tree_view_get_column (handle, i);
if (OS.gtk_tree_view_column_get_visible (column)) return false;
}
long /*int*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
OS.gtk_tree_view_column_set_visible (firstColumn, true);
return true;
}
/**
* Shows the item. If the item is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
* the item is visible.
*
* @param item the item to be shown
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the item is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#showSelection()
*/
public void showItem (TableItem item) {
checkWidget ();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
if (item.parent != this) return;
showItem (item.handle);
}
void showItem (long /*int*/ iter) {
long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
OS.gtk_tree_view_scroll_to_cell (handle, path, 0, false, 0, 0);
OS.gtk_tree_path_free (path);
}
/**
* Shows the selection. If the selection is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
* the selection is visible.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Table#showItem(TableItem)
*/
public void showSelection () {
checkWidget();
TableItem [] selection = getSelection ();
if (selection.length == 0) return;
TableItem item = selection [0];
showItem (item.handle);
}
@Override
void updateScrollBarValue (ScrollBar bar) {
super.updateScrollBarValue (bar);
/*
* Bug in GTK. Scrolling changes the XWindow position
* and makes the child widgets appear to scroll even
* though when queried their position is unchanged.
* The fix is to queue a resize event for each child to
* force the position to be corrected.
*/
long /*int*/ parentHandle = parentingHandle ();
long /*int*/ list = OS.gtk_container_get_children (parentHandle);
if (list == 0) return;
long /*int*/ temp = list;
while (temp != 0) {
long /*int*/ widget = OS.g_list_data (temp);
if (widget != 0) OS.gtk_widget_queue_resize (widget);
temp = OS.g_list_next (temp);
}
OS.g_list_free (list);
}
@Override
long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ user_data) {
switch ((int)/*64*/user_data) {
case EXPOSE_EVENT_INVERSE: {
/*
* Feature in GTK. When the GtkTreeView has no items it does not propagate
* expose events. The fix is to fill the background in the inverse expose
* event.
*/
if (itemCount == 0 && (state & OBSCURED) == 0) {
if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) {
Control control = findBackgroundControl ();
if (control != null) {
GdkEventExpose gdkEvent = new GdkEventExpose ();
OS.memmove (gdkEvent, arg0, GdkEventExpose.sizeof);
long /*int*/ window = OS.gtk_tree_view_get_bin_window (handle);
if (window == gdkEvent.window) {
drawBackground (control, window, gdkEvent.region, gdkEvent.area_x, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height);
}
}
}
}
break;
}
}
return super.windowProc (handle, arg0, user_data);
}
}
| [
"[email protected]"
] | |
1b67bcf19dc41dce3376fab9f5eefee16b1eacb3 | 67104e5f13432ce15212975b4d71fb169fbf2a05 | /MuberRESTfulGrupo18/src/main/java/bd2/Muber/model/Driver.java | 02dab4f03a25c41e88cbd8c6fa567a7fae6bd4f4 | [] | no_license | ErwinGutbrod/MuberEtapa2 | 742119dae56470749df2b4418df7e675e32d2241 | 6e2cbcec486bfc6aa4155b6db0c2acc9e67fe766 | refs/heads/master | 2021-01-20T00:41:07.805406 | 2017-05-22T14:00:21 | 2017-05-22T14:00:21 | 89,171,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 431 | java | package bd2.Muber.model;
import java.util.Calendar;
public class Driver extends User{
//Attributes
private Calendar licenseExpirationDate;
//Constructor
public Driver(){
super();
}
//Getters & Setters
public Calendar getLicenseExpirationDate() {
return licenseExpirationDate;
}
public void setLicenseExpirationDate(Calendar licenseExpirationDate) {
this.licenseExpirationDate = licenseExpirationDate;
}
}
| [
"Erwin@DESKTOP-0D3IOUK"
] | Erwin@DESKTOP-0D3IOUK |
a71d05bd745ee0e9cc6a260f03c5002611ce8423 | 5d45404ffb115717717482f04177f268d29062a4 | /src/br/com/tg/repositorio/RepositorioStatusPessoa.java | ba0ce40882e58bdc36aaf96dbb8d57adb77c2a1f | [] | no_license | tgondim/auxPlot | 67afbfef8b4a5a7b61ad193de94ab60d7567999b | b657ca43905b14bbfb83f9757e4956bfef15bd5d | refs/heads/master | 2020-06-03T08:45:28.785806 | 2010-09-02T15:54:51 | 2010-09-02T15:54:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 418 | java | package br.com.tg.repositorio;
import java.util.List;
import br.com.tg.entidades.StatusPessoa;
public interface RepositorioStatusPessoa {
public void inserir(StatusPessoa statusPessoa);
public void atualizar(StatusPessoa statusPessoa);
public StatusPessoa getStatusPessoa(Integer idStatusPessoa);
public List<StatusPessoa> listar();
public void remover(StatusPessoa statusPessoa);
}
| [
"gondim@gondim-PC"
] | gondim@gondim-PC |
98263e79da97a64736d0272d205fc1be16970db1 | b732c150b6a2376d0390f993141dfcb60593e43f | /Assignment 1 (Banking System)/Assignment1/src/main/java/connection/ConnectionDB.java | e91a7aebb9dfa4ab27367241152492e5d1376b47 | [] | no_license | CodreaAncuta/Software-Design-Assignments | 063cd88574686f9fc43ed724d444b3ee4b9bbfb7 | 49a98a78d7df3085b0010e51aa26c4837178a499 | refs/heads/master | 2021-10-27T15:18:30.979213 | 2019-04-17T21:20:20 | 2019-04-17T21:20:20 | 110,878,965 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,058 | java | package connection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ConnectionDB {
private static final Logger LOGGER = Logger.getLogger(ConnectionDB.class.getName());
private static final String DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DBURL = "jdbc:mysql://127.0.0.1:3306/bank?useSSL=false";
private static final String USER = "root";
private static final String PASS = "root";
private static ConnectionDB singleInstance = new ConnectionDB();
private ConnectionDB() {
try {
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private Connection createConnection() {
Connection connection = null;
try {
connection = DriverManager.getConnection(DBURL, USER, PASS);
} catch (SQLException e) {
LOGGER.log(Level.WARNING, "An error occured while trying to connect to the database");
e.printStackTrace();
}
return connection;
}
public static Connection getConnection() {
return singleInstance.createConnection();
}
public static void close(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
LOGGER.log(Level.WARNING, "An error occured while trying to close the connection");
}
}
}
public static void close(Statement statement) {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
LOGGER.log(Level.WARNING, "An error occured while trying to close the statement");
}
}
}
public static void close(ResultSet resultSet) {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
LOGGER.log(Level.WARNING, "An error occured while trying to close the ResultSet");
}
}
}
/*public static void main(String[] args) {
Connection dbConnection = ConnectionDB.getConnection();
System.out.println(dbConnection);
}*/
}
| [
"[email protected]"
] | |
18e50b0d69d27f5df73a70221e61f34e3186f527 | 5245085c230929cdb91db049672f8f276646560c | /mula-base/src/main/java/org/mula/finance/core/io/RewireDBImporter.java | 307180277fd8ff6285365f04fefdfd5cbef5a3e9 | [] | no_license | katrinaannhadi/MULAFinanceApp | 9e7371778d2fe2fbcc61e94cd6d3832409cd6115 | 3130dbd1dfc7438268621cf0320c0856e836e00e | refs/heads/master | 2022-04-25T04:50:36.130679 | 2020-04-30T03:51:17 | 2020-04-30T03:51:17 | 258,404,445 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,133 | java | /* Mula */
package org.mula.finance.core.io;
import androidx.annotation.*;
import org.mula.finance.core.database.Cursor;
import org.mula.finance.core.database.Database;
import org.mula.finance.core.database.DatabaseOpener;
import org.mula.finance.core.models.Frequency;
import org.mula.finance.core.models.Habit;
import org.mula.finance.core.models.HabitList;
import org.mula.finance.core.models.ModelFactory;
import org.mula.finance.core.models.Reminder;
import org.mula.finance.core.models.Timestamp;
import org.mula.finance.core.models.WeekdayList;
import org.mula.finance.core.utils.DateUtils;
import java.io.*;
import java.util.*;
import javax.inject.*;
/**
* Class that imports database files exported by Rewire.
*/
public class RewireDBImporter extends AbstractImporter
{
private ModelFactory modelFactory;
@NonNull
private final DatabaseOpener opener;
@Inject
public RewireDBImporter(@NonNull HabitList habits,
@NonNull ModelFactory modelFactory,
@NonNull DatabaseOpener opener)
{
super(habits);
this.modelFactory = modelFactory;
this.opener = opener;
}
@Override
public boolean canHandle(@NonNull File file) throws IOException
{
if (!isSQLite3File(file)) return false;
Database db = opener.open(file);
Cursor c = db.query("select count(*) from SQLITE_MASTER " +
"where name='CHECKINS' or name='UNIT'");
boolean result = (c.moveToNext() && c.getInt(0) == 2);
c.close();
db.close();
return result;
}
@Override
public void importHabitsFromFile(@NonNull File file) throws IOException
{
Database db = opener.open(file);
db.beginTransaction();
createHabits(db);
db.setTransactionSuccessful();
db.endTransaction();
db.close();
}
private void createHabits(Database db)
{
Cursor c = null;
try
{
c = db.query("select _id, name, description, schedule, " +
"active_days, repeating_count, days, period " +
"from habits");
if (!c.moveToNext()) return;
do
{
int id = c.getInt(0);
String name = c.getString(1);
String description = c.getString(2);
int schedule = c.getInt(3);
String activeDays = c.getString(4);
int repeatingCount = c.getInt(5);
int days = c.getInt(6);
int periodIndex = c.getInt(7);
Habit habit = modelFactory.buildHabit();
habit.setName(name);
habit.setDescription(description == null ? "" : description);
int periods[] = { 7, 31, 365 };
int numerator, denominator;
switch (schedule)
{
case 0:
numerator = activeDays.split(",").length;
denominator = 7;
break;
case 1:
numerator = days;
denominator = (periods[periodIndex]);
break;
case 2:
numerator = 1;
denominator = repeatingCount;
break;
default:
throw new IllegalStateException();
}
habit.setFrequency(new Frequency(numerator, denominator));
habitList.add(habit);
createReminder(db, habit, id);
createCheckmarks(db, habit, id);
} while (c.moveToNext());
}
finally
{
if (c != null) c.close();
}
}
private void createCheckmarks(@NonNull Database db,
@NonNull Habit habit,
int rewireHabitId)
{
Cursor c = null;
try
{
String[] params = { Integer.toString(rewireHabitId) };
c = db.query(
"select distinct date from checkins where habit_id=? and type=2",
params);
if (!c.moveToNext()) return;
do
{
String date = c.getString(0);
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(4, 6));
int day = Integer.parseInt(date.substring(6, 8));
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
cal.set(year, month - 1, day);
habit.getRepetitions().toggle(new Timestamp(cal));
} while (c.moveToNext());
}
finally
{
if (c != null) c.close();
}
}
private void createReminder(Database db, Habit habit, int rewireHabitId)
{
String[] params = { Integer.toString(rewireHabitId) };
Cursor c = null;
try
{
c = db.query(
"select time, active_days from reminders where habit_id=? limit 1",
params);
if (!c.moveToNext()) return;
int rewireReminder = Integer.parseInt(c.getString(0));
if (rewireReminder <= 0 || rewireReminder >= 1440) return;
boolean reminderDays[] = new boolean[7];
String activeDays[] = c.getString(1).split(",");
for (String d : activeDays)
{
int idx = (Integer.parseInt(d) + 1) % 7;
reminderDays[idx] = true;
}
int hour = rewireReminder / 60;
int minute = rewireReminder % 60;
WeekdayList days = new WeekdayList(reminderDays);
Reminder reminder = new Reminder(hour, minute, days);
habit.setReminder(reminder);
habitList.update(habit);
}
finally
{
if (c != null) c.close();
}
}
}
| [
"[email protected]"
] | |
048f4878cc2d2c9c2838dbed383030c8ed48d773 | 7ab2047c2dab9b9fd29901e71f5521a2b8293f3b | /src/main/java/ghidra/app/cmd/data/rtti/gcc/VtableModel.java | 14541fc3b9954ab210609c61137afe3b901fea6a | [
"MIT"
] | permissive | ohyeah521/Ghidra-Cpp-Class-Analyzer-1 | 03bb6eddd63f2b2ea4128a4bb142f87ac583cb3e | 49e9d43ff5673516c23e3787d0f8631db08807bc | refs/heads/master | 2020-12-10T05:45:05.720555 | 2020-01-07T02:00:29 | 2020-01-07T02:00:29 | 233,516,647 | 1 | 0 | MIT | 2020-01-13T05:16:24 | 2020-01-13T05:16:23 | null | UTF-8 | Java | false | false | 13,277 | java | package ghidra.app.cmd.data.rtti.gcc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import ghidra.program.model.data.Array;
import ghidra.program.model.data.ArrayDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.data.InvalidDataTypeException;
import ghidra.program.model.data.PointerDataType;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.mem.MemoryBufferImpl;
import ghidra.util.Msg;
import ghidra.app.cmd.data.rtti.ClassTypeInfo;
import ghidra.app.cmd.data.rtti.Vtable;
import ghidra.app.cmd.data.rtti.gcc.GnuUtils;
import ghidra.app.cmd.data.rtti.gcc.factory.TypeInfoFactory;
import static ghidra.app.util.datatype.microsoft.MSDataTypeUtils.getAbsoluteAddress;
/**
* Model for GNU Vtables
*/
public class VtableModel implements Vtable {
public static final String SYMBOL_NAME = "vtable";
public static final String CONSTRUCTION_SYMBOL_NAME = "construction-"+SYMBOL_NAME;
public static final String DESCRIPTION = "Vtable Model";
public static final String MANGLED_PREFIX = "_ZTV";
private Program program;
private boolean isValid = true;
private Address address;
private static final int FUNCTION_TABLE_ORDINAL = 2;
private static final int MAX_PREFIX_ELEMENTS = 3;
private int arrayCount;
private boolean construction;
private Set<Function> functions = new HashSet<>();
private ClassTypeInfo type = null;
private long[] offsets;
private List<VtablePrefixModel> vtablePrefixes;
public static final VtableModel NO_VTABLE = new VtableModel();
private VtableModel() {
isValid = false;
}
public VtableModel(Program program, Address address, ClassTypeInfo type) {
this(program, address, type, -1, false);
}
public VtableModel(Program program, Address address) {
this(program, address, null, -1, false);
}
/**
* Constructs a new VtableModel
*
* @param program program the vtable is in.
* @param address starting address of the vtable or the first typeinfo pointer.
* @param type the ClassTypeInfo this vtable belongs to.
* @param arrayCount the maximum vtable table count, if known.
* @param construction true if this should be a construction vtable.
*/
public VtableModel(Program program, Address address, ClassTypeInfo type,
int arrayCount, boolean construction) {
this.program = program;
this.address = address;
this.type = type;
this.arrayCount = arrayCount;
this.construction = construction;
if (TypeInfoUtils.isTypeInfoPointer(program, address)) {
if (this.type == null) {
Address typeAddress = getAbsoluteAddress(program, address);
this.type = (ClassTypeInfo) TypeInfoFactory.getTypeInfo(program, typeAddress);
}
} else if (this.type == null) {
int length = VtableUtils.getNumPtrDiffs(program, address);
DataType ptrdiff_t = GnuUtils.getPtrDiff_t(program.getDataTypeManager());
Address typePointerAddress = address.add(length * ptrdiff_t.getLength());
Address typeAddress = getAbsoluteAddress(program, typePointerAddress);
this.type = (ClassTypeInfo) TypeInfoFactory.getTypeInfo(program, typeAddress);
}
try {
setupVtablePrefixes();
this.isValid = !vtablePrefixes.isEmpty();
} catch (InvalidDataTypeException e) {
this.isValid = false;
}
}
@Override
public ClassTypeInfo getTypeInfo() throws InvalidDataTypeException {
validate();
if (type == null) {
type = VtableUtils.getTypeInfo(program, address);
}
return type;
}
@Override
public void validate() throws InvalidDataTypeException {
if (!isValid) {
if (address != null) {
throw new InvalidDataTypeException(
"Vtable at "+address.toString()+" is not valid.");
} throw new InvalidDataTypeException(
"Invalid Vtable.");
}
}
@Override
public int hashCode() {
try {
getTypeInfo();
if (type != null) {
return type.hashCode();
}
} catch (InvalidDataTypeException e) {}
return super.hashCode();
}
@Override
public boolean equals(Object object) {
if (!(object instanceof VtableModel)) {
return false;
}
try {
getTypeInfo();
ClassTypeInfo otherType = ((VtableModel) object).getTypeInfo();
if (type != null && otherType != null) {
return type.equals(otherType);
}
} catch (InvalidDataTypeException e) {}
return super.equals(object);
}
/**
* Gets the corrected start address of the vtable.
*
* @return the correct start address or NO_ADDRESS if invalid.
*/
public Address getAddress() {
return address;
}
@Override
public Address[] getTableAddresses() throws InvalidDataTypeException {
validate();
Address[] result = new Address[vtablePrefixes.size()];
for (int i = 0; i < result.length; i++) {
try {
result[i] = vtablePrefixes.get(i).getTableAddress();
} catch (IndexOutOfBoundsException e) {
result = Arrays.copyOf(result, i);
break;
}
}
return result;
}
@Override
public Function[][] getFunctionTables() throws InvalidDataTypeException {
validate();
Address[] tableAddresses = getTableAddresses();
if (tableAddresses.length == 0) {
return new Function[0][];
}
Function[][] result = new Function[tableAddresses.length][];
for (int i = 0; i < tableAddresses.length; i++) {
result[i] = VtableUtils.getFunctionTable(program, tableAddresses[i]);
} return result;
}
@Override
public boolean containsFunction(Function function) throws InvalidDataTypeException {
if (functions.isEmpty()) {
getFunctionTables();
} return functions.contains(function);
}
/**
* @see ghidra.program.model.data.DataType#getLength()
* @return
*/
public int getLength() {
if (!isValid) {
return 0;
}
int size = 0;
for (VtablePrefixModel prefix : vtablePrefixes) {
size += prefix.getPrefixSize();
}
return size;
}
/**
* Gets the ptrdiff_t value within the base offset array.
*
* @param index the index in the vtable_prefix array.
* @param ordinal the offset ordinal.
* @return the offset value.
* @throws InvalidDataTypeException
*/
public long getOffset(int index, int ordinal) throws InvalidDataTypeException {
validate();
if (ordinal >= getElementCount()) {
return Long.MAX_VALUE;
}
return vtablePrefixes.get(index).getBaseOffset(ordinal);
}
/**
* Gets the whole ptrdiff_t array.
*
* @return the whole ptrdiff_t array.
* @throws InvalidDataTypeException
*/
public long[] getBaseOffsetArray() throws InvalidDataTypeException {
validate();
if (offsets == null) {
offsets = vtablePrefixes.get(0).getBaseOffsets();
}
return offsets;
}
/**
* Gets the number of vtable_prefix's in this vtable.
*
* @return the number of vtable_prefix's in this vtable.
* @throws InvalidDataTypeException
*/
public int getElementCount() throws InvalidDataTypeException {
validate();
return vtablePrefixes.size();
}
private Address getNextPrefixAddress() {
int size = 0;
for (VtablePrefixModel prefix : vtablePrefixes) {
size += prefix.getPrefixSize();
}
return address.add(size);
}
public List<DataType> getDataTypes() {
List<DataType> result = new ArrayList<>(vtablePrefixes.size() * MAX_PREFIX_ELEMENTS);
for (VtablePrefixModel prefix : vtablePrefixes) {
result.addAll(prefix.dataTypes);
}
return result;
}
private void setupVtablePrefixes() throws InvalidDataTypeException {
vtablePrefixes = new ArrayList<>();
int count = construction ? 2 : type.getVirtualParents().size()+1;
VtablePrefixModel prefix = new VtablePrefixModel(getNextPrefixAddress(), count);
if (!prefix.isValid()) {
return;
}
if (TypeInfoUtils.isTypeInfoPointer(program, address)) {
address = prefix.prefixAddress;
}
if (arrayCount < 0) {
while (prefix.isValid()) {
vtablePrefixes.add(prefix);
prefix = new VtablePrefixModel(getNextPrefixAddress());
}
} else {
vtablePrefixes.add(prefix);
for (int i = 1; i < arrayCount; i++) {
prefix = new VtablePrefixModel(getNextPrefixAddress());
if (!prefix.isValid()) {
break;
}
vtablePrefixes.add(prefix);
}
}
}
public List<VtablePrefixModel> getVtablePrefixes() {
return vtablePrefixes;
}
private class VtablePrefixModel {
private Address prefixAddress;
private List<DataType> dataTypes;
private VtablePrefixModel(Address prefixAddress) {
this(prefixAddress, -1);
}
private VtablePrefixModel(Address prefixAddress, int ptrDiffs) {
this.prefixAddress = prefixAddress;
int numPtrDiffs = ptrDiffs > 0 ? ptrDiffs :
VtableUtils.getNumPtrDiffs(program, prefixAddress);
dataTypes = new ArrayList<>(3);
if (numPtrDiffs > 0) {
DataTypeManager dtm = program.getDataTypeManager();
DataType ptrdiff_t = GnuUtils.getPtrDiff_t(dtm);
int pointerSize = program.getDefaultPointerSize();
if (TypeInfoUtils.isTypeInfoPointer(program, prefixAddress)) {
this.prefixAddress = prefixAddress.subtract(numPtrDiffs * ptrdiff_t.getLength());
}
dataTypes.add(new ArrayDataType(ptrdiff_t, numPtrDiffs, ptrdiff_t.getLength(), dtm));
dataTypes.add(new PointerDataType(null, pointerSize, dtm));
Address tableAddress = this.prefixAddress.add(getPrefixSize());
int tableSize = VtableUtils.getFunctionTableLength(program, tableAddress);
if (tableSize > 0) {
ArrayDataType table = new ArrayDataType(
PointerDataType.dataType, tableSize, pointerSize, dtm);
dataTypes.add(table);
}
}
}
private boolean isValid() {
if (dataTypes.size() > 1) {
int offset = dataTypes.get(0).getLength();
Address pointee = getAbsoluteAddress(
program, prefixAddress.add(offset));
if (pointee != null) {
return pointee.equals(type.getAddress());
}
}
return false;
}
private int getPrefixSize() {
int size = 0;
for (DataType dt : dataTypes) {
size += dt.getLength();
}
return size;
}
private Address getTableAddress() {
int size = 0;
for (int i = 0; i < FUNCTION_TABLE_ORDINAL; i++) {
size += dataTypes.get(i).getLength();
}
return prefixAddress.add(size);
}
private long[] getBaseOffsets() {
try {
Array array = (Array) dataTypes.get(0);
MemoryBufferImpl prefixBuf = new MemoryBufferImpl(
program.getMemory(), prefixAddress);
int length = array.getElementLength();
long[] result = new long[array.getNumElements()];
for (int i = 0; i < result.length; i++) {
result[i] = prefixBuf.getBigInteger(i*length, length, true).longValue();
}
return result;
} catch (MemoryAccessException e) {
Msg.error(this, "Failed to retreive base offsets at "+prefixAddress, e);
return new long[0];
}
}
private long getBaseOffset(int ordinal) {
Array array = (Array) dataTypes.get(0);
if (ordinal >= array.getElementLength()) {
return -1;
}
return getBaseOffsets()[ordinal];
}
}
} | [
"[email protected]"
] | |
7fe910b60d9e1b158ddc6c72c6813a60176fdc9b | 2d19d2ef3cc4ef4a4af94642b7fd0534ce048764 | /GamesUtils/src/main/java/com/ongraph/greatsgames/exception/GreatGamesAuthenticationException.java | 5b90923fd667c8c4d6effebe6a72f2dc513de52a | [] | no_license | RinkalTomar/great_game | 09dcdc4f348dc0700dd16a05f24714fb07691e88 | d5bffe0ac80d1abbdcc6bd4302d782b81cb20049 | refs/heads/master | 2022-12-21T09:45:53.406316 | 2020-02-02T16:44:04 | 2020-02-02T16:44:04 | 237,784,707 | 0 | 0 | null | 2022-12-16T04:31:03 | 2020-02-02T14:38:09 | Java | UTF-8 | Java | false | false | 219 | java | package com.ongraph.greatsgames.exception;
public class GreatGamesAuthenticationException extends GreatGamesException {
public GreatGamesAuthenticationException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
2748826b8b97fa9ab1e92e8af3a2155854462f0a | d0acf844cae913c3fa8520b15e156c1db2da9125 | /src/main/java/cg/wbd/grandemonstration/service/StudentService.java | 0a81b128d3f49f3beb3d67459f28d62c5c5a0771 | [] | no_license | hung060798/demo1-nhom | 39a9b74326d92260d5b26fcea0115e7e11d2c319 | 7e6fa8859159456cc6ffd1aa28cc4ebd4f48953d | refs/heads/master | 2023-08-15T23:02:04.209913 | 2021-09-26T08:34:20 | 2021-09-26T08:34:20 | 409,624,836 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,097 | java | package cg.wbd.grandemonstration.service;
import cg.wbd.grandemonstration.models.Student;
import cg.wbd.grandemonstration.repository.IStudentRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class StudentService implements IStudentService{
@Autowired
IStudentRepo studentRepo;
@Override
public Page<Student> findAll(Pageable pageable) {
return studentRepo.findAll(pageable);
}
@Override
public Optional<Student> findOne(Long id) {
return studentRepo.findById(id);
}
@Override
public void save(Student student) {
studentRepo.save(student);
}
@Override
public void delete(Long id ) {
studentRepo.deleteById(id);
}
@Override
public Iterable<Student> findAllByNameContaining(String nameStudent) {
return studentRepo.findAllByNameContaining(nameStudent);
}
}
| [
"[email protected]"
] | |
afdbcc4ed165a913659321a03e6c97f29a24a74b | 431ea1047c8862f9051bc447f3e1a4fd637a5248 | /src/java/com/Model/User.java | 82144b96740dba1cc6d92bbf81254ff3e63ff135 | [] | no_license | raoelson/GestionCommades | c82ae3cd5abe3516cefbcc6bd59059ecf8e35ec3 | cdecacd2493876152a1e31efa046e4cce9d24843 | refs/heads/master | 2021-07-04T14:38:38.434012 | 2017-09-28T12:15:11 | 2017-09-28T12:15:11 | 105,139,083 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 846 | java | package com.Model;
// Generated 19 oct. 2015 12:59:09 by Hibernate Tools 3.6.0
/**
* User generated by hbm2java
*/
public class User implements java.io.Serializable {
private Integer id;
private String login;
private String password;
public User() {
}
public User(String login, String password) {
this.login = login;
this.password = password;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getLogin() {
return this.login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"[email protected]"
] | |
09dca4ee80f1ef3446373889404352dc394ad6f8 | 8ba0fb28b3c73510dbab16af944835e19557812a | /src/java/view/ListTeams.java | 1b66aa0b032741d47fbad6f66e847d9c3d014641 | [] | no_license | Perreault-Dale/FinalServlets | de37552b6273d53072a16467fee8d54bf199e107 | c33e6051b5adeb86dee8b6233a6b0370033ef022 | refs/heads/master | 2020-03-08T18:34:40.508092 | 2018-04-11T21:52:15 | 2018-04-11T21:52:15 | 128,308,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 607 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package view;
import control.TeamControl;
import java.util.List;
import model.Team;
/**
*
* @author Dale
*/
public class ListTeams implements Handler {
@Override
public String execute() {
List<Team> tl = TeamControl.getRecords();
if (tl.isEmpty()) { tl = TeamControl.InitialLoad(); }
String html = TeamControl.formatHtml(tl);
return html;
}
}
| [
"[email protected]"
] | |
0f7ff83d0db82db7d85fcba2e318d04f673c826c | 15129fbd583734e1133d642950e1712303d06669 | /satellite-api/src/main/java/com/baidu/deimos/satellite/api/DeimosSatelliteAPI.java | 9f2953344386250489bc34cecd4618d674427db3 | [] | no_license | ahmatjan/SedaFramework | 98241b1dadca7b67f11a07bc0a5f9b4724269d26 | 5074fdaa41d1be1af0f9f9f40dd95a85490a6fe2 | refs/heads/master | 2020-12-31T03:03:44.387182 | 2014-09-24T03:47:20 | 2014-09-24T03:47:20 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 7,739 | java | package com.baidu.deimos.satellite.api;
import java.util.HashMap;
import java.util.Map;
import org.springframework.amqp.rabbit.core.ChannelCallback;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import com.baidu.deimos.satellite.api.bo.DeimosSatelliteRequest;
import com.baidu.deimos.satellite.api.constant.Infotype;
import com.baidu.deimos.satellite.api.constant.SatApiConstant;
import com.rabbitmq.client.Channel;
/**
* 提供给使用方的API,用以辅助进行消息推送。
*
* Created on Jan 15, 2014 2:41:25 PM
* @author chenchao03
* @version 1.0
* @since 1.0
*/
public class DeimosSatelliteAPI {
@Autowired
private RabbitTemplate amqpTemplate;
boolean keepAlive = false;
/**
* 消息推送函数。仅需消息主体内容即可
*
* @param content
* 消息内容
* @author chenchao03
* @date Nov 29, 2013
*/
public void pub(Object content) {
pub(null, null, null, null, content, null, null, null);
}
/**
* 消息推送函数。仅需消息内容以及消息类型
*
* @param content
* 消息内容主体
* @param infotype
* 消息类型
* @author chenchao03
* @date Dec 25, 2013
*/
public void pub(Object content, Infotype infotype) {
pub(null, null, null, null, content, null, infotype, null);
}
/**
* 消息推送函数。推送报警使用
*
* @param content
* 消息内容
* @param infotype
* 消息类型
* @author chenchao03
* @date Dec 25, 2013
*/
public void pubAlarm(Object content, Infotype infotype) {
pub(null, null, "collect.alarm.*", null, content, null, infotype, null);
}
/**
* 带错误异常的消息推送
*
* @param content
* 消息内容
* @param t
* 异常信息
* @author chenchao03
* @date Nov 29, 2013
*/
public void pub(Object content, Throwable t) {
pub(null, null, null, null, content, t, null, null);
}
/**
* 带上pubkey
*
* @param pubKey
* 发布消息的key
* @param content
* 消息内容
* @param t
* 异常信息
* @author chenchao03
* @date Nov 29, 2013
*/
public void pub(String pubKey, Object content, Throwable t) {
pub(null, null, pubKey, null, content, t, null, null);
}
/**
* 带上exchange, 设置是否需要长连接
*
* @param exchangeName
* 交换机名字
* @param pubKey
* 推送的key
* @param content
* 消息内容
* @param t
* 异常信息
* @author chenchao03
* @date Nov 30, 2013
*/
public void pub(String exchangeName, String pubKey, Object content, Throwable t) {
pub(null, exchangeName, pubKey, null, content, t, null, null);
}
/**
* 带上exchange,不带异常,带上keepAlive和附加信息
*
* @param exchangeName
* 交换机名字
* @param pubKey
* 推送消息的key
* @param content
* 消息内容
* @param keepAlive
* 是否保持长连接
* @param appendMsg
* 附加信息
* @author chenchao03
* @date Nov 29, 2013
*/
public void pub(String exchangeName, String pubKey, Object content, boolean keepAlive,
Map<String, Object> appendMsg) {
this.keepAlive = keepAlive;
pub(null, exchangeName, pubKey, null, content, null, null, appendMsg);
}
/**
* 通用发布消息函数
*
* @param timeStamp
* 时间戳。默认为当前时间
* @param exchangeName
* 发布到的交换机。默认为deimos-common
* @param pubKey
* 发布的内容key。默认为collect.log,即收集log。因为其最常用
* @param client
* 客户端,默认为FC-AO
* @param content
* 消息内容主体
* @param e
* 异常信息。由于需要printstack,所以只能把整个对象传递过去。
* @param appendMsg
* 填入附加信息
* @param infoType
* 消息类型
* @author chenchao03
* @date Nov 29, 2013
*/
public void pub(Long timeStamp, String exchangeName, String pubKey, String client, Object content, Throwable e,
Infotype infoType, Map<String, Object> appendMsg) {
if (content == null) {
return;
}
DeimosSatelliteRequest request = new DeimosSatelliteRequest();
if (client != null && !client.trim().equals("")) {
request.setClient(client);
}
if (exchangeName != null && !exchangeName.trim().equals("")) {
request.setDestination(exchangeName);
}
if (pubKey != null && !pubKey.trim().equals("")) {
request.setPubKey(pubKey);
}
request.setTimestamp(timeStamp == null ? System.currentTimeMillis() : timeStamp);
Map<String, Object> data = new HashMap<String, Object>();
data.put(SatApiConstant.EXCEPTION, e);
if (appendMsg != null && !appendMsg.isEmpty()) {
data.putAll(appendMsg);
}
request.setData(data);
request.setRealData(content);
request.setInfoType(infoType != null ? infoType : Infotype.INFOTYPE_LOG_INFO);
amqpTemplate.convertAndSend(request.getDestination(), request.getPubKey(), request);
// 是否保持长连接,默认不保持长连接,如果需要则调用close函数
if (!keepAlive) {
this.close();
}
}
/**
* 给logtype打上info
*
* @param content
* 消息内容
* @author chenchao03
* @date Nov 29, 2013
*/
public void infoPub(String content) {
pub(null, null, "collect.log.info", null, content, null, Infotype.INFOTYPE_LOG_INFO, null);
}
/**
* 给logtype打上warn
*
* @param content
* 消息内容
* @author chenchao03
* @date Nov 29, 2013
*/
public void warnPub(String content) {
pub(null, null, "collect.log.warn", null, content, null, Infotype.INFOTYPE_LOG_WARN, null);
}
/**
* 给logtype打上debug
*
* @param content
* 消息内容
* @author chenchao03
* @date Nov 29, 2013
*/
public void debugPub(String content) {
pub(null, null, "collect.log.debug", null, content, null, Infotype.INFOTYPE_LOG_DEBUG, null);
}
/**
* 给logtype打上error
*
* @param content
* 消息内容
* @author chenchao03
* @date Nov 29, 2013
*/
public void errorPub(String content) {
pub(null, null, "collect.log.error", null, content, null, Infotype.INFOTYPE_MONITOR_INFO, null);
}
/**
* 给logtype打上error
*
* @param content
* 消息内容
* @param t
* 异常信息
* @author chenchao03
* @date Nov 29, 2013
*/
public void errorPub(String content, Throwable t) {
pub(null, null, "collect.log.error", null, content, t, Infotype.INFOTYPE_MONITOR_INFO, null);
}
/**
* 显示关闭
*
* @author chenchao03
* @date Nov 30, 2013
*/
public void close() {
amqpTemplate.execute(new ChannelCallback<Object>() {
public Object doInRabbit(Channel channel) throws Exception {
channel.close();
channel.abort();
channel.getConnection().close();
return null;
}
});
}
} | [
"[email protected]"
] | |
5f6082bdedec0cd4a8cfe5f40ea9a70ab84b91cd | 7e14a944b5e26a919d9bd286a4c7f62cf42a4ca7 | /RM-EMPRESARIAL-ejb/src/main/java/com/rm/empresarial/servicio/ProvinciaServicio.java | c740fb498016701b3ac19edf72b480f05827ee2a | [] | no_license | bryan1090/RegistroPropiedad | 7bcca20dbb1a67da97c85716b67d516916aee3fa | 182406c840187a6cc31458f38522f717cc34e258 | refs/heads/master | 2022-07-07T08:06:20.251959 | 2020-01-02T03:02:34 | 2020-01-02T03:02:34 | 231,295,897 | 0 | 0 | null | 2022-06-30T20:22:05 | 2020-01-02T02:50:13 | Java | UTF-8 | Java | false | false | 444 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.rm.empresarial.servicio;
import com.rm.empresarial.puente.ProvinciaPuente;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
/**
*
* @author Prueba
*/
@LocalBean
@Stateless
public class ProvinciaServicio extends ProvinciaPuente{
}
| [
"[email protected]"
] | |
fb0fa7f189c1426bc32a2eb5820f695542f63f77 | 21d5650428c145e96c2db75e81fb26ad8eb2a662 | /com/syntax/class04/HW1.java | ab913e7e0046eb6db7f7df47d827f5c9b263a874 | [] | no_license | OlgaLiV/Selenium | f904f33cba4e21c532b8ffad8a0e6cedb0dddf0a | c90434fc55d80ac3c5fe728de70990d927f53f9e | refs/heads/master | 2023-01-24T19:43:16.162926 | 2020-11-25T23:30:17 | 2020-11-25T23:30:17 | 283,334,265 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,040 | java | package com.syntax.class04;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class HW1 {
public static String url = "http://166.62.36.207/syntaxpractice/basic-radiobutton-demo.html";
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "drivers/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get(url);
List<WebElement> optionRadioButtons = driver.findElements(By.xpath("//input[@name = 'optradio']"));
for (WebElement sexRadioButton : optionRadioButtons) {
if (sexRadioButton.isEnabled()) {
String radioButton = sexRadioButton.getAttribute("value");
if (radioButton.equals("Female")) {
sexRadioButton.click();
break;
}
}
}
List<WebElement> optionRadioButtons2 = driver.findElements(By.xpath("//input[@name = 'gender']"));
for (WebElement sexRadioButton2 : optionRadioButtons2) {
if(sexRadioButton2.isEnabled()) {}
String radioButton2 = sexRadioButton2.getAttribute("value");
if(radioButton2.equals("Female")) {
sexRadioButton2.click();
break;
}
}
List<WebElement> ageButtons = driver.findElements(By.xpath("//input[@name = 'ageGroup']"));
for (WebElement ageCheck : ageButtons) {
String ageRadio = ageCheck.getAttribute("value");
if(ageRadio.equals("15 - 50")) {
ageCheck.click();
Thread.sleep(1000);
break;
}
}
driver.findElement(By.xpath("//button[text() = 'Get values']")).click();
WebElement buttonGetValues = driver.findElement(By.cssSelector("p[class = 'groupradiobutton']"));
if(buttonGetValues.isDisplayed()) {
String resultText = buttonGetValues.getText();
if(resultText.contains("Sex : Female") && resultText.contains("15 - 50")) {
System.out.println("Input is correct");
}else {
System.out.println("Incorrect input");
}
}
Thread.sleep(2000);
driver.quit();
}
}
| [
"[email protected]"
] | |
11e0ebb0ffbec01ddd07d9ed7fdfb98ae9b4fb2b | b743fa1a7b41b918ab3513047ae2ca462270cb06 | /Classy_Android/app/src/main/java/csci201/classy/Adapters/DepartmentAdapter.java | cdeffb8d9f9dda820f7ed4a6a4d8346ef5629d63 | [] | no_license | tsinghal/Classy | 3133b1b4621e4e8105ecac1dfedc28b4005da081 | ed349e56ff7b65986214849d28cfb16f5bd4a4cc | refs/heads/master | 2021-01-20T06:46:55.442638 | 2017-08-26T23:04:33 | 2017-08-26T23:04:33 | 101,517,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,486 | java | package csci201.classy.Adapters;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.Map;
import csci201.classy.R;
/**
* Created by edward on 11/16/16.
*/
public class DepartmentAdapter extends ArrayAdapter {
Context context;
int resource;
Object[] objects;
public DepartmentAdapter(Context context, int resource, Object[] objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
this.objects = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
convertView = inflater.inflate(resource, parent, false);
}
Map<String, Object> dataItem = (Map<String, Object>) objects[position];
//set all of convertview
TextView departmentNameTextView = (TextView) convertView.findViewById(R.id.departmentNameTextView);
departmentNameTextView.setText((String) dataItem.get("name"));
TextView departmentCodeTextView = (TextView) convertView.findViewById(R.id.departmentCodeTextView);
departmentCodeTextView.setText((String) dataItem.get("code"));
return convertView;
}
}
| [
"[email protected]"
] | |
3deeb2a652d7735e1ddf6bf77f082182298ac8a6 | 384b095e4c3cf5ee6820bbec1c411242ad34ce2d | /src/ie/lyit/hotel/Person.java | 8b83578a0d8f05d6f0d9dfe0ac1464cc02154e7c | [] | no_license | dean0193/l00097028_hotel | 3918b97737f781b8413732615c10ef7cdce8d55c | b6976ac111353e9b615fa34f1d9d0a030170e0a3 | refs/heads/master | 2021-08-23T10:41:53.077103 | 2017-12-04T15:18:55 | 2017-12-04T15:18:55 | 113,059,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,298 | java | /**
* Dean Comiskey L00097028
* Software Implementation
* Description: Models a Person
* Date: 25/09/2017
**/
package ie.lyit.hotel;
import java.io.Serializable;
public abstract class Person implements Serializable{
protected Name name; // COMPOSITION - Person HAS-A name
protected String address;
protected String phoneNumber;
// Default Constructor
// Called when object is created like this
// ==> Person pObj = new Person();
// NOTE-This won't work because Person is abstract
public Person(){
name=new Name();
address=null;
phoneNumber=null;
}
// Initialisation Constructor
// Called when object would have been created like this (not possible cos abstract!)
// ==> Person pObj = new Person("Mr", "Joe", "Doe", "2 Hi Road, Ennis", "087 1234567");
public Person(String t, String fN, String sn, String address, String phoneNumber){
name=new Name(t, fN, sn); // Calls Name initialisation constructor
this.address=address;
this.phoneNumber=phoneNumber;
}
// toString() method
// ==> Calls Name's toString() to display name and
// then displays address and phoneNumber
@Override // Overrides Object toString()
public String toString(){
return name + "," + address + "," + phoneNumber;
}
// equals() method
// ==> Called when comparing an object with another object,
// e.g. - if(p1.equals(p2))
// ==> Calls Name's equals() to compare name to personIn's name, and
// compares phoneNumber to personIn's phoneNumber
@Override // Overrides Object equals()
public boolean equals(Object obj){
Person pObject;
if (obj instanceof Person)
pObject = (Person)obj;
else
return false;
return(name.equals(pObject.name) &&
address.equals(pObject.address) &&
phoneNumber.equals(pObject.phoneNumber));
}
// set() and get() methods
public void setName(Name nameIn){
name = nameIn;
}
public Name getName(){
return name;
}
public void setAddress(String addressIn){
address = addressIn;
}
public String getAddress(){
return address;
}
public void setPhoneNumber(String phoneNumberIn){
phoneNumber = phoneNumberIn;
}
public String getPhoneNumber(){
return phoneNumber;
}
}
| [
"[email protected]"
] | |
86eeeb9c958bf1407d02b6595639e5cd0823e378 | 4ccbe571f5ce9e4f9e14eb96fd825352395e69d3 | /mmadu-identity/src/main/java/com/mmadu/identity/providers/token/TokenCreationProvider.java | 6873f3d59aa3fc4381c8bc41c07b82d4adbdb5b9 | [
"MIT"
] | permissive | yudori/mmadu | cefdd4a48a5b04f0a87910c07ca5c29f563e3050 | 310703d1b21bf2f4a03e6573586fc2aac069572e | refs/heads/master | 2022-11-10T16:16:54.678079 | 2020-06-29T19:44:10 | 2020-06-29T19:44:10 | 275,921,054 | 0 | 0 | MIT | 2020-06-29T20:38:59 | 2020-06-29T20:38:59 | null | UTF-8 | Java | false | false | 323 | java | package com.mmadu.identity.providers.token;
import com.mmadu.identity.models.client.MmaduClient;
import com.mmadu.identity.models.token.TokenRequest;
import com.mmadu.identity.models.token.TokenResponse;
public interface TokenCreationProvider {
TokenResponse createToken(TokenRequest request, MmaduClient client);
}
| [
"[email protected]"
] | |
f2a1ad9ac611fafed2b074d1cdd70c7a5ad77468 | 90122c18b51d027810b54bc519caeefd8b2f587b | /app/src/main/java/ru/evendate/android/models/EventRegistered.java | d57585fd9b68f7505666d6061efa1b103ab129f5 | [] | no_license | KardanovIR/evendate-android | c9da1b458f7fc5140a27c55efb808feedb4a70a7 | 87fce26681fdc51fcb9ab57123a0d9c9d2de2b89 | refs/heads/master | 2021-03-24T12:43:11.271688 | 2017-11-22T22:14:33 | 2017-11-22T22:14:33 | 53,123,544 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 695 | java | package ru.evendate.android.models;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import ru.evendate.android.network.ServiceUtils;
/**
* Created by Aedirn on 07.03.17.
*/
public interface EventRegistered {
String FIELDS_LIST = "dates" + ServiceUtils.encloseFields(EventDate.FIELDS_LIST) + "," +
"location,my_tickets_count,sold_tickets_count," +
"tickets" + ServiceUtils.encloseFields(Ticket.FIELDS_LIST, Ticket.ORDER_BY);
int getEntryId();
String getTitle();
String getLocation();
Date getNearestDateTime();
List<Ticket> getTickets();
int getMyTicketsCount();
ArrayList<EventDate> getDateList();
}
| [
"[email protected]"
] | |
449285210d9c135ac0bf23376a077ff771277ead | c94d12c362ab57c315b355dcc81afa5f07e84a38 | /presentation/src/main/java/com/sixthsolution/easymvp/tvmaze/internal/di/module/RepositoryModule.java | 0a57ddef2e1f88b569a1e921c7d0627406eb8e14 | [] | no_license | mohamad-amin/TvMaze-CleanArchitecture | 28baa183f506ab991759b24d505b7a90fe2d5683 | 4d9b75fd788fce49275d92c1cc1eca4f1302d1f6 | refs/heads/master | 2021-01-19T22:21:06.401722 | 2016-10-25T11:05:06 | 2016-10-25T11:05:06 | 71,249,678 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package com.sixthsolution.easymvp.tvmaze.internal.di.module;
import com.sixthsolution.easymvp.data.repository.FilmDataRepository;
import com.sixthsolution.easymvp.data.repository.FilmSearchRepository;
import com.sixthsolution.easymvp.domain.repository.FilmRepository;
import com.sixthsolution.easymvp.domain.repository.SearchRepository;
import dagger.Module;
import dagger.Provides;
/**
* @author MohamadAmin Mohamadi ([email protected]) on 10/21/16.
*/
@Module
public class RepositoryModule {
@Provides
FilmRepository provideFilmRepository(FilmDataRepository repository) {
return repository;
}
@Provides
SearchRepository provideSearchRepository(FilmSearchRepository repository) {
return repository;
}
}
| [
"[email protected]"
] | |
6366dad17dcf192a7b523da78316506d749cd8df | 12ddd902bc6a9ac00ecf03f7706ff827e925dbbe | /src/TemplateMethod/Multiliplty.java | 59e2e44f6d8ce3b7129bc94529b445be06ab0e1f | [] | no_license | chengyue5923/javaMethod | 09bfa177ff5a3b24506d00c1127996d6b7e9d6d0 | bd4d107ca42fb57c23c02100e89dd49868261be2 | refs/heads/master | 2021-01-20T13:07:05.653569 | 2017-05-06T09:15:49 | 2017-05-06T09:15:49 | 90,451,350 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 198 | java | package TemplateMethod;
public class Multiliplty extends AnstractCalculator {
@Override
public int calculate(int num1, int num2) {
// TODO Auto-generated method stub
return num1*num2;
}
}
| [
"[email protected]"
] | |
bfebc2c5e0e0a9992b79a183244502740fdba688 | fddd2931431d326d151e7a2b5374124539398b5c | /src/battlecard/Nidhogg.java | 3e453dbc2b7ca5c9d3f249edd26934d17ea7ca23 | [] | no_license | strtsoia/AgeOfMyth | f7f83af0b20f7a99f6ed13ecf32981da5fc89e7f | 4df92700a4ec37c9d0180bcf653856c7923482e5 | refs/heads/master | 2021-01-16T19:04:50.212846 | 2011-11-14T23:25:33 | 2011-11-14T23:25:33 | 2,656,218 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 987 | java | package battlecard;
import java.util.Hashtable;
import global.GlobalDef;
public final class Nidhogg extends BattleCard{
private static Nidhogg nidhogg;
private Nidhogg()
{
cost.put(GlobalDef.Resources.FAVOR, 1);
cost.put(GlobalDef.Resources.GOLD, 4);
cost.put(GlobalDef.Resources.FOOD, 0);
cost.put(GlobalDef.Resources.WOOD, 0);
}
private final int rolls = 7;
private int bonus = 0;
private Hashtable<GlobalDef.Resources, Integer> cost = new Hashtable<GlobalDef.Resources, Integer>();
public int getRolls() {
return rolls + bonus;
}
public Hashtable<GlobalDef.Resources, Integer> getCost() {
return cost;
}
public static Nidhogg getInstance()
{
if(nidhogg == null){
nidhogg = new Nidhogg();
return nidhogg;
}
return nidhogg;
}
public void CheckBonus(BattleCard opponent)
{
if (GiantKiller.contains(opponent))
bonus = 4;
else
bonus = 0;
}
}
| [
"[email protected]"
] | |
d60e19bfc2adc812bb5b8f9f14e7b365ab9b465d | 6d9b29b0ff89bfc307fda40f336cb2fe8babeab8 | /src/main/java/seedu/meeting/commons/events/ui/JumpToMeetingListRequestEvent.java | b8fef2673317e688c553ef97d60b0f635b7cb910 | [
"MIT"
] | permissive | PakornUe/main | 945619adb53dda93abd011de2c9e02c2a68d9fcd | dd2a9f510e7119c39dc88cf8cdf7dfc76eb3ddf6 | refs/heads/master | 2021-09-28T00:03:32.070328 | 2018-11-11T14:10:46 | 2018-11-11T14:10:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 544 | java | package seedu.meeting.commons.events.ui;
import seedu.meeting.commons.core.index.Index;
import seedu.meeting.commons.events.BaseEvent;
/**
* Indicates a request to jump to the list of meetings.
* {@author jeffreyooi}
*/
public class JumpToMeetingListRequestEvent extends BaseEvent {
public final int targetIndex;
public JumpToMeetingListRequestEvent(Index targetIndex) {
this.targetIndex = targetIndex.getZeroBased();
}
@Override
public String toString() {
return getClass().getSimpleName();
}
}
| [
"[email protected]"
] | |
80de20dd260a2b139d7f68ec79124e43dbadf84a | 192bba47612258e74d4db83ed846ed386c0efbe8 | /LTHDT/thuchanhonline/lthdt/ctu/edu/vn/SinhVien1.java | e272ef1193cae1b7866010b8cc95c3c9350d1733 | [] | no_license | Tamabcxyz/javacode | 68369518e2052abb2220608213233c01e7099843 | f856cbd1934874114705cf3421ca97a1e65b5023 | refs/heads/master | 2020-05-16T20:06:09.795304 | 2019-04-25T01:49:45 | 2019-04-25T01:49:45 | 183,277,418 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 978 | java | package thuchanhonline.lthdt.ctu.edu.vn;
public class SinhVien1 extends SinhVien{
private double diemTB;
private XepLoai loai;
public SinhVien1() {
super();
// TODO Auto-generated constructor stub
}
public SinhVien1(int ma, String ten,double diemTB) {
super(ma, ten);
this.diemTB = diemTB;
this.loai=kqloai();
// TODO Auto-generated constructor stub
}
public SinhVien1(SinhVien a) {
super(a);
// TODO Auto-generated constructor stub
}
public double getDiemTB() {
return diemTB;
}
public void setDiemTB(float diemTB) {
this.diemTB = diemTB;
}
public XepLoai kqloai() {
if(this.diemTB>=8) {
loai=XepLoai.gioi;
}
else if(this.diemTB>6.5&&diemTB<=8) {
loai=XepLoai.kha;
}
else if(this.diemTB>5&&diemTB<6.5) {
loai=XepLoai.trungbinh;
}
else {
loai=XepLoai.yeu;
}
return loai;
}
public String toString() {
String s=super.toString();
return s+" \tDiem TB "+this.diemTB+" \txep loai: "+this.loai.getMota();
}
}
| [
"[email protected]"
] | |
465de71ae342001e1340c8a6f48e36149e799d38 | fc3940a77a19fc3790264a2a06670655306274b9 | /app/src/androidTest/java/com/example/istbr/dagitikdersproje/ExampleInstrumentedTest.java | b9417437c6a6892dcdd4237e63a228a9f84fab1c | [] | no_license | BurakSSonmez/Number-Guessing-Game | 5e330ec5c43adea286b13c0529a4180c23e4df4f | 8d71c8c7d33feeafa25635c0d4dba2e3aec9737b | refs/heads/master | 2021-02-18T10:07:47.059022 | 2021-01-03T15:29:18 | 2021-01-03T15:29:18 | 245,185,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 752 | java | package com.example.istbr.dagitikdersproje;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.istbr.dagitikdersproje", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
099db01441a423fc6d22171cd79185051b25708e | cdc1d2c416b79abce38941608cf058cfba1a6592 | /src/main/java/com/pla/core/domain/model/BranchName.java | 7722de54e0b7c56c97645e3a4f8fd3f6fcdb1674 | [] | no_license | ekochnev/pla | e3824d8b5a6b03ba056188697246275c80bfba92 | b48b2c9a0d284395e7458293bff9e70a6f795f84 | refs/heads/master | 2021-05-15T21:16:08.734937 | 2015-08-21T11:57:30 | 2015-08-21T11:57:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 482 | java | package com.pla.core.domain.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import javax.persistence.Embeddable;
import java.io.Serializable;
/**
* Created by User on 3/24/2015.
*/
@Embeddable
@EqualsAndHashCode(of = "branchName")
@NoArgsConstructor
@Getter
public class BranchName implements Serializable {
private String branchName;
public BranchName(String branchName) {
this.branchName = branchName;
}
}
| [
"[email protected]"
] | |
fcc36eeb81cf33017044bbf5ccf242b33f7a7140 | 7e892591a22018cebc2a9df5613cd8a462502c21 | /z-common/src/main/java/logan/common/base/utils/xml/XmlJaxbUtils.java | 5fced50d907856d3c5f821206df7c5ab36232ca5 | [] | no_license | lengqiufeifeng/cloud | b6314f1a7d27549c95117a2e39fb23b16986fc51 | f2761160625d983f49d696ca7962b8fd15b1deff | refs/heads/master | 2021-10-11T07:20:46.209140 | 2019-01-23T07:02:43 | 2019-01-23T07:02:48 | 111,528,337 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,433 | java | package logan.common.base.utils.xml;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;
@SuppressWarnings("restriction" )
public class XmlJaxbUtils {
@SuppressWarnings("unchecked" )
public static <E> E fromXML(String xml, Class<E> clazz) throws Exception {
JAXBContext context = JAXBContext.newInstance(new Class[]{clazz});
Unmarshaller unmarshaller = context.createUnmarshaller();
try {
return (E) unmarshaller.unmarshal(new StringReader(xml));
} catch (Exception e) {
throw new Exception("解析xml出错! [" + xml + "]", e);
}
}
@SuppressWarnings("unchecked" )
public static <E> E fromXML(File xmlFile, Class<E> clazz) throws Exception {
JAXBContext context = JAXBContext.newInstance(new Class[]{clazz});
Unmarshaller unmarshaller = context.createUnmarshaller();
try {
return (E) unmarshaller.unmarshal(xmlFile);
} catch (Exception e) {
throw new Exception("解析xml出错! ! " + xmlFile, e);
}
}
public static String toXML(Object pojo) throws Exception {
return toXML(pojo, "UTF-8" );
}
public static String toXML(Object pojo, String encoding) throws Exception {
JAXBContext context = JAXBContext.newInstance(new Class[]{pojo.getClass()});
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty("jaxb.encoding", encoding);
marshaller.setProperty("jaxb.formatted.output", Boolean.valueOf(true));
StringWriter writer = new StringWriter();
marshaller.marshal(pojo, writer);
String xml = writer.toString();
return xml;
}
public static void toXML(Object pojo, File xmlFile) throws Exception {
toXML(pojo, "UTF-8", xmlFile);
}
public static void toXML(Object pojo, String encoding, File xmlFile) throws Exception {
JAXBContext context = JAXBContext.newInstance(new Class[]{pojo.getClass()});
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty("jaxb.encoding", encoding);
marshaller.setProperty("jaxb.formatted.output", Boolean.valueOf(true));
marshaller.marshal(pojo, xmlFile);
}
}
| [
"[email protected]"
] | |
91baaaeb348ac24c086eb265ea292aa3986d64f4 | 1d9957b6ebaa74fe311bd97b6131f502db2f25f2 | /data-manager-web/src/main/java/com/magotzis/dm/model/DataHistory.java | 9b13d0a9c97aa99d2111c3e974154715e93b9884 | [] | no_license | Magotzis/data-manager-server | 74579fabf88857d44c00835813cc561842a22dc7 | a2bb25b884ce1a2ad9f84284ab4acf51cdcb0da5 | refs/heads/master | 2021-05-03T07:40:05.170728 | 2018-05-13T12:21:30 | 2018-05-13T12:21:30 | 120,553,699 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,941 | java | package com.magotzis.dm.model;
import java.util.Date;
/**
* @author dengyq on 10:33 2018/4/10
*/
public class DataHistory {
private int id;
private int userId;
private String applyContent;
private int state;
private String errorMsg;
private String content;
private Date updateTime;
private int type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getApplyContent() {
return applyContent;
}
public void setApplyContent(String applyContent) {
this.applyContent = applyContent;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
@Override
public String toString() {
return "DataHistory{" +
"id=" + id +
", userId=" + userId +
", applyContent='" + applyContent + '\'' +
", state=" + state +
", errorMsg='" + errorMsg + '\'' +
", content='" + content + '\'' +
", updateTime=" + updateTime +
", type=" + type +
'}';
}
}
| [
"[email protected]"
] | |
76a17c13c0e53e064f6cca15708d73309cb21eef | 3aa02b7ca7fea1352653c579451fb3b59438bdad | /src/main/java/me/tassu/queue/queue/QueueManager.java | 0e5b6b4801a9bb95e70549072f93ed5c738fdb4d | [
"MIT"
] | permissive | supertassu/Queue | 44ba749a87b4fe44477c6f70e0e482005bafb04e | c17e46526e743a97f15588b2fd084a28af277567 | refs/heads/master | 2021-08-07T08:32:01.982009 | 2018-11-03T11:49:49 | 2018-11-03T11:49:49 | 129,263,347 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,244 | java | /*
* MIT License
*
* Copyright (c) 2018 Tassu
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.tassu.queue.queue;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import lombok.val;
import me.tassu.queue.QueuePlugin;
import me.tassu.queue.file.ConfigFile;
import me.tassu.queue.file.FileManager;
import me.tassu.queue.message.Message;
import me.tassu.queue.message.MessageManager;
import me.tassu.queue.queue.impl.SimpleQueue;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import java.util.Optional;
import java.util.Set;
@Singleton
public class QueueManager {
private QueuePlugin plugin;
@Inject
public QueueManager(QueuePlugin plugin, FileManager fileManager, MessageManager messageManager) {
this.plugin = plugin;
queueConfig = fileManager.getQueueFile();
queueResettingMsg = messageManager.getMessage("QUEUE_RESET");
}
private ConfigFile queueConfig;
private Message queueResettingMsg;
private Set<IQueue> queueSet = Sets.newHashSet();
/**
* Reloads and clears all queues.
*/
public void refreshQueues() {
queueSet.forEach(queue -> queue.getPlayers().forEach(player -> queueResettingMsg
.addPlaceholder("QUEUE_NAME", queue.getName())
.send(player)));
queueSet.clear();
queueConfig.getKeys().forEach(key ->
queueSet.add(loadQueueFromConfig(key))
);
}
/**
* loads a queue from configuration
*
* @param id queue id
* @return the queue
*/
private IQueue loadQueueFromConfig(String id) {
val config = queueConfig.getSection(id);
if (config == null) return null;
if (config.getString("type").equalsIgnoreCase("SimpleQueue")) {
SimpleQueue.Builder queue = SimpleQueue.builder()
.id(id)
.server(ProxyServer.getInstance().getServerInfo(config.getString("server")))
.name(config.getString("display"))
.messager(QueueMessagingProperties.fromConfig(config));
if (config.getKeys().contains("sendDelay")) {
queue.sendDelay(config.getInt("sendDelay"));
}
if (config.getKeys().contains("requiredProtocol")) {
val protocol = config.getSection("requiredProtocol");
if (protocol.getKeys().contains("exact")) {
queue.requiredExactProtocol(protocol.getInt("exact"));
} else {
if (protocol.getKeys().contains("min")) {
queue.requiredMinProtocol(protocol.getInt("min"));
}
if (protocol.getKeys().contains("max")) {
queue.requiredMaxProtocol(protocol.getInt("max"));
}
}
}
return queue.build();
} else {
plugin.getLogger().severe("unknown queue type " + config.getString("type"));
}
return null;
}
/**
* refreshes & clears a queue
*
* @param queue specific queue
*/
public void refreshQueue(String queue) {
IQueue tempQueue = queueSet.stream().filter(it -> it.getId().equalsIgnoreCase(queue)).findFirst().orElseThrow(() -> new IllegalArgumentException("queue not found"));
queueResettingMsg.send(tempQueue.getPlayers().toArray(new ProxiedPlayer[0]));
queueSet.removeIf(it -> it.getId().equalsIgnoreCase(queue));
queueSet.add(loadQueueFromConfig(queue));
}
/**
* @return All queues on the system.
*/
public Set<IQueue> getAllQueues() {
return Sets.newHashSet(queueSet);
}
public Optional<IQueue> getQueueById(String name) {
return getAllQueues().stream().filter(it -> it.getId().equalsIgnoreCase(name)).findFirst();
}
public Optional<IQueue> getQueueForPlayer(ProxiedPlayer player) {
return getAllQueues().stream().filter(it -> it.isQueued(player)).findFirst();
}
}
| [
"[email protected]"
] | |
aeb743b02bcaa3f00792de0ae9b7c5b1f31cc426 | eefd94a670861c01cff074b80daa32e3393e296f | /todolist1/src/main/java/com/example/todolist1/business/abstracts/UserService.java | 09936a88d87e3bc7153396d5fb5723dd0464bdce | [] | no_license | kaankullac/todolist | 05b86a75902d0e1d46bb299bc2cd2f746aecbf5b | 6eaf3516e60bfe85a334485aa5a1173ff301cc76 | refs/heads/master | 2023-08-26T21:36:53.700350 | 2021-10-28T12:37:34 | 2021-10-28T12:37:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 374 | java | package com.example.todolist1.business.abstracts;
import java.util.List;
import com.example.todolist1.core.utilities.result.Result;
import com.example.todolist1.entities.concretes.User;
public interface UserService {
List<User> getAll();
Result Add(User user);
Result Delete(User user);
User GetUserByEmail(String email);
boolean ExistUserByEmail(String email);
}
| [
"[email protected]"
] | |
40379e2423c695be978b07903c8cefdb9374656e | 9cf6615a785c489b7b9e960115f615d245682356 | /EnglishGraduateWord/src/main/java/com/english/database/EnglishDBOperate.java | 3c96841afda0bfd3553f6dc730ea0d33bdb1c35a | [] | no_license | malijie/EnglishWord | e9afa780c1453c7c86dfb47a87a47bfef0a7d2ec | 3e4a1ec5b43a26a9d5a060a061d47113026e7d30 | refs/heads/master | 2021-05-16T05:25:17.774075 | 2018-12-03T15:11:00 | 2018-12-03T15:11:00 | 58,785,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,060 | java | package com.english.database;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.text.Html;
import android.widget.Toast;
import com.english.model.ReadingInfo;
import com.english.model.WordInfo;
import com.english.model.WrittingInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class EnglishDBOperate {
private SQLiteDatabase db = null;
private final String QUERY_ALL_WORDS = "select * from vocabulary";
private final String QUERY_WORDS_BY_INDEX = "SELECT * FROM VOCABULARY WHERE ID BETWEEN ";
private final String UPDATE_WORDS = "UPDATE VOCABULARY SET";
private Context context;
public EnglishDBOperate(SQLiteDatabase db, Context context){
this.db = db;
this.context = context;
}
/**
*
* @return ���ؿγ�����
*/
public int getLessonsSize(){
String strCount = "0";
Cursor result = null;
try{
db.beginTransaction();
db.setTransactionSuccessful();
String sql = "select count(id) as total from vocabulary";
result = db.rawQuery(sql, null);
if(!result.isAfterLast() ){
result.moveToFirst();
strCount = result.getString(result.getColumnIndex("total"));
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return Integer.parseInt(strCount);
}
/**
* 将当前课程的正确率置为0
* @param index 课程号
*/
public void resumeAccuracyCount(int index){
db.beginTransaction();
String sql = "update vocabulary set is_known='false' where id between " + (index*100+1) + " and " + (index*100+100);
db.execSQL(sql);
db.setTransactionSuccessful();
db.endTransaction();
}
/**
* ��ݴ���Ŀγ̺ţ������Ҫ��ʾ�����
* @param lesson �γ̺�
* @return
*/
public List<Map<String, String>> getWordsListByLesson(int lesson){
Cursor result = null;
List<Map<String,String>> wordsList = null;
try{
db.beginTransaction();
db.setTransactionSuccessful();
wordsList = new ArrayList<Map<String,String>>();
String sql = QUERY_WORDS_BY_INDEX + (lesson * 100 - 99) + " AND " + lesson * 100;
result = db.rawQuery(sql, null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
Map<String, String> mWord = new HashMap<String, String>();
mWord.put("id", result.getString(result.getColumnIndex("id")));
mWord.put("symbols", result.getString(result.getColumnIndex("symbols")));
mWord.put("word", result.getString(result.getColumnIndex("word")));
mWord.put("content", result.getString(result.getColumnIndex("content")));
mWord.put("example", result.getString(result.getColumnIndex("example")));
mWord.put("note", result.getString(result.getColumnIndex("note")));
wordsList.add(mWord);
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
db.endTransaction();
}
}
return wordsList;
}
/**
* ���id���ҵ���
* @return ����
*/
public WordInfo getWordById(int index){
WordInfo mWordInfo = null;
Cursor result = null;
try{
db.beginTransaction();
String sql = QUERY_ALL_WORDS + " where id=" + index;
result = db.rawQuery(sql, null);
if(!result.isAfterLast()){
result.moveToFirst();
mWordInfo = new WordInfo();
mWordInfo.setId(result.getInt(result.getColumnIndex("id")));
mWordInfo.setSymbols(result.getString(result.getColumnIndex("symbols")));
mWordInfo.setWord(result.getString(result.getColumnIndex("word")));
mWordInfo.setContent(result.getString(result.getColumnIndex("content")));
mWordInfo.setExample(result.getString(result.getColumnIndex("example")));
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return mWordInfo;
}
/**
* ��ݿγ̺Ų�����γ��е�����Ϣ
* @param lesson�γ̺�
* @return
*/
public List<WordInfo> getWordsByLesson(int lesson){
List<WordInfo> lessonWords = null;
Cursor result = null;
try{
db.beginTransaction();
lessonWords = new ArrayList<WordInfo>();
String sql = QUERY_ALL_WORDS + " WHERE ID BETWEEN " + (lesson*100+1) + " AND " + (lesson*100+100);
result = db.rawQuery(sql, null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
WordInfo mWordInfo = new WordInfo();
mWordInfo.setId(result.getInt(result.getColumnIndex("id")));
mWordInfo.setSymbols(result.getString(result.getColumnIndex("symbols")));
mWordInfo.setWord(result.getString(result.getColumnIndex("word")));
mWordInfo.setContent(result.getString(result.getColumnIndex("content")));
mWordInfo.setExample(result.getString(result.getColumnIndex("example")));
lessonWords.add(mWordInfo);
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
db.endTransaction();
}
}
return lessonWords;
}
/**
* ���µ����Ƿ�Ϊ���״̬
* @param id id��
*/
public void updateWordIsStrangerById(boolean isStranger, int index){
db.beginTransaction();
try{
int id = index + 1;
String sql = UPDATE_WORDS + " is_stranger='" + isStranger + "' WHERE ID=" + id;
db.execSQL(sql);
db.setTransactionSuccessful();
}catch(Exception e){
Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show();
}finally{
db.endTransaction();
}
}
/**
* ���µ����Ƿ�Ϊ���״̬
* @param index lessonWords����
*/
public void updateWordIsKnownByIndex(boolean isKnown, int index){
db.beginTransaction();
try{
int id = index + 1; //lessonWords��index��ʼλ��Ϊ0�� ��ݿ���id��ʼλ��Ϊ1��������Ҫ+1
String sql = UPDATE_WORDS + " is_known='" + isKnown + "' WHERE ID=" + id;
db.execSQL(sql);
db.setTransactionSuccessful();
}catch(Exception e){
Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show();
}finally{
db.endTransaction();
}
}
public void updateWordIsKnownById(boolean isKnown, int id){
db.beginTransaction();
try{
String sql = UPDATE_WORDS + " is_known='" + isKnown + "' WHERE ID=" + id;
db.execSQL(sql);
db.setTransactionSuccessful();
}catch(Exception e){
Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show();
}finally{
db.endTransaction();
}
}
/**
* ���id���µ���������ʱ��
* @param date ������ʱ��
* @param id ����id
*/
public void updateLastVisitDateById(String date, int id){
db.beginTransaction();
try{
String sql = UPDATE_WORDS + " last_visit='" + date + "' WHERE ID=" + id;
db.execSQL(sql);
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show();
}finally{
db.endTransaction();
}
}
/**
* ��ݿγ̺Ų�ѯ������������ʱ��
* @param lesson �γ̺�
* @return ���пγ�����ʱ�伯��
*/
public List<String> getLastVisitDateListByLesson(int lesson){
List<String> dateList = null;
String sql = "";
Cursor result = null;
db.beginTransaction();
try{
dateList = new ArrayList<String>();
for(int i=0;i<lesson;i++){
sql = "select last_visit from vocabulary WHERE ID BETWEEN " + (i*100+1) + " AND " + (i*100+100) + " ORDER BY last_visit desc LIMIT 0,1";
result =db.rawQuery(sql,null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
dateList.add(result.getString(result.getColumnIndex("last_visit")));
}
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return dateList;
}
/**
* ��ݿγ̺Ų�ѯÿ���е�һ�����ʵĵ��ʣ������Լ�����
*/
public List<Map<String,String>> getAbstractListByLesson(int lesson){
List<Map<String,String>> abList = null;
String sql = "";
Cursor result = null;
try{
abList = new ArrayList<Map<String,String>>();
db.beginTransaction();
for(int i=0; i<lesson; i++){
// sql = "select word,symbols,content,example from vocabulary WHERE ID=" + (i*100+1);
// sql = "select word,symbols from vocabulary WHERE ID=" + (i*100+1);
sql = "select word,symbols,content,example from vocabulary WHERE ID=1";
result =db.rawQuery(sql,null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
Map<String,String> mapWordInfo = new HashMap<String,String>();
mapWordInfo.put("word", result.getString(result.getColumnIndex("word")));
mapWordInfo.put("symbols", result.getString(result.getColumnIndex("symbols")));
mapWordInfo.put("content", result.getString(result.getColumnIndex("content")));
mapWordInfo.put("example", result.getString(result.getColumnIndex("example")));
abList.add(mapWordInfo);
}
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return abList;
}
/**
*
* @param lesson �γ̺�
* @return ÿ���лش���ȷ�ĵ�����
*/
public List<Integer> getAccuracyCountByListen(int lesson){
List<Integer> acList = null;
String sql = "";
Cursor result = null;
try{
acList = new ArrayList<Integer>();
db.beginTransaction();
for(int i=0;i<1;i++){
sql = "select count(id) as total from vocabulary where id between " + (i*100+1) + " and " + (i*100+100) + " and is_known='true'";
result = db.rawQuery(sql, null);
for(result.moveToFirst();!result.isAfterLast();result.moveToNext()){
acList.add(result.getInt(result.getColumnIndex("total")));
}
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return acList;
}
/**
*
* @return �����������
*/
public List<WordInfo> getAllUnknownWords(){
List<WordInfo> uWordsList = null;
String sql = null;
Cursor result = null;
try{
uWordsList = new ArrayList<WordInfo>();
db.beginTransaction();
sql = "select * from vocabulary where is_known='false'";
result = db.rawQuery(sql, null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
WordInfo uWord = new WordInfo();
System.out.println("uWord-->" + uWord);
uWord.setId(Integer.parseInt(result.getString(result.getColumnIndex("id"))));
uWord.setSymbols(result.getString(result.getColumnIndex("symbols")));
uWord.setContent(result.getString(result.getColumnIndex("content")));
uWord.setWord(result.getString(result.getColumnIndex("word")));
uWord.setExample(result.getString(result.getColumnIndex("example")));
uWordsList.add(uWord);
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
db.endTransaction();
if(result != null){
result.close();
}
db.close();
}
return uWordsList;
}
/**
* ���idֵ�������״̬
*/
public void updateUnknownWordStatusById(int id){
String sql = "";
try{
db.beginTransaction();
sql = UPDATE_WORDS + " is_known='true' where id=" + id;
db.execSQL(sql);
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
db.endTransaction();
db.close();
}
}
/**
*
* @return
*/
public List<ReadingInfo> getAllReadingInfoByDate(int date){
List<ReadingInfo> readInfoList = null;
String sql = "";
Cursor result = null;
try{
db.beginTransaction();
sql = "select * from reading where date=" + date;
result = db.rawQuery(sql,null);
readInfoList = new ArrayList<ReadingInfo>();
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
ReadingInfo readingInfo = new ReadingInfo();
readingInfo.setId(Integer.parseInt(result.getString(result.getColumnIndex("id"))));
readingInfo.setTitle(result.getString(result.getColumnIndex("title")));
readingInfo.setDate(Integer.parseInt(result.getString(result.getColumnIndex("date"))));
readingInfo.setContent(result.getString(result.getColumnIndex("content")));
readingInfo.setAnswer(result.getString(result.getColumnIndex("answer")));
readInfoList.add(readingInfo);
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return readInfoList;
}
/**
*
* ����д����Ϣ
* @return
*/
public List<WrittingInfo> getAllWrittingInfoByDate(){
List<WrittingInfo> writtingInfoList = null;
String sql = "";
Cursor result = null;
try{
db.beginTransaction();
sql = "select * from writting";
result = db.rawQuery(sql,null);
writtingInfoList = new ArrayList<WrittingInfo>();
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
WrittingInfo writtingInfo = new WrittingInfo();
writtingInfo.setId(Integer.parseInt(result.getString(result.getColumnIndex("id"))));
writtingInfo.setQuestion(result.getString(result.getColumnIndex("question")));
writtingInfo.setDate(result.getString(result.getColumnIndex("date")));
writtingInfo.setHaveImage(result.getString(result.getColumnIndex("have_image")));
writtingInfo.setAnswer(result.getString(result.getColumnIndex("answer")));
writtingInfo.setImagePath(result.getString(result.getColumnIndex("image_path")));
writtingInfo.setTitle(result.getString(result.getColumnIndex("title")));
writtingInfoList.add(writtingInfo);
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return writtingInfoList;
}
public List<WordInfo> getSearchResult(String keyWord) {
List<WordInfo> wordInfos = null;
String sql = "";
Cursor result1 = null;
Cursor result2 = null;
Cursor result3 = null;
boolean isFoundInWord = true;
boolean isFoundInContent = true;
try{
wordInfos = new ArrayList<WordInfo>();
db.beginTransaction();
sql = "select * from vocabulary where word='" + keyWord + "'";
result1 = db.rawQuery(sql, null);
for(result1.moveToFirst();!result1.isAfterLast();result1.moveToNext()){
WordInfo wordInfo = new WordInfo();
wordInfo.setId(result1.getInt(result1.getColumnIndex("id")));
wordInfo.setWord(result1.getString(result1.getColumnIndex("word")));
wordInfo.setSymbols(result1.getString(result1.getColumnIndex("symbols")));
wordInfo.setContent(result1.getString(result1.getColumnIndex("content")));
wordInfo.setExample(Html.fromHtml(result1.getString(result1.getColumnIndex("example"))).toString());
wordInfos.add(wordInfo);
isFoundInWord = false;
isFoundInContent = false;
}
if(isFoundInWord){//����ģ���ѯ
sql = "select * from vocabulary where word like '" + keyWord + "%'";
result2 = db.rawQuery(sql, null);
for(result2.moveToFirst(); !result2.isAfterLast(); result2.moveToNext()){
WordInfo wordInfo = new WordInfo();
wordInfo.setId(result2.getInt(result2.getColumnIndex("id")));
wordInfo.setWord(result2.getString(result2.getColumnIndex("word")));
wordInfo.setSymbols(result2.getString(result2.getColumnIndex("symbols")));
wordInfo.setContent(result2.getString(result2.getColumnIndex("content")));
wordInfo.setExample(result2.getString(result2.getColumnIndex("example")));
wordInfos.add(wordInfo);
isFoundInContent = false;
}
}
if(isFoundInContent){//���ҵ�����������
sql = "select * from vocabulary where content like '%" + keyWord + "%'";
result3 = db.rawQuery(sql, null);
for(result3.moveToFirst(); !result3.isAfterLast(); result3.moveToNext()){
WordInfo wordInfo = new WordInfo();
wordInfo.setId(result3.getInt(result3.getColumnIndex("id")));
wordInfo.setWord(result3.getString(result3.getColumnIndex("word")));
wordInfo.setSymbols(result3.getString(result3.getColumnIndex("symbols")));
wordInfo.setContent(result3.getString(result3.getColumnIndex("content")));
wordInfo.setExample(result3.getString(result3.getColumnIndex("example")));
wordInfos.add(wordInfo);
}
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result1 != null){
result1.close();
result1 = null;
}
if(result2 != null){
result2.close();
result2 = null;
}
if(result3 != null){
result3.close();
result3 = null;
}
db.endTransaction();
}
return wordInfos;
}
public List<Map<String,String>> test(int index){
List<Map<String,String>> abList = null;
String sql = "";
Cursor result = null;
try{
abList = new ArrayList<Map<String,String>>();
db.beginTransaction();
sql = "select word,symbols,content,example from vocabulary WHERE ID=" + (index*100+1);
result =db.rawQuery(sql,null);
for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){
Map<String,String> mapWordInfo = new HashMap<String,String>();
mapWordInfo.put("word", result.getString(result.getColumnIndex("word")));
mapWordInfo.put("symbols", result.getString(result.getColumnIndex("symbols")));
mapWordInfo.put("content", result.getString(result.getColumnIndex("content")));
mapWordInfo.put("example", result.getString(result.getColumnIndex("example")));
abList.add(mapWordInfo);
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return abList;
}
public Integer test2(int index){
String sql = "";
Cursor result = null;
int acCount = 0;
try{
db.beginTransaction();
sql = "select count(id) as total from vocabulary where id between " + (index*100+1) + " and " + (index*100+100) + " and is_known='true'";
result = db.rawQuery(sql, null);
result.moveToFirst();
if(!result.isAfterLast()){
acCount = result.getInt(result.getColumnIndex("total"));
result.moveToNext();
}
db.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
}finally{
if(result != null){
result.close();
}
db.endTransaction();
}
return acCount;
}
}
| [
"[email protected]"
] | |
62c6c92957296ed592e594b337ff59afa80e336e | 0c0b99d02617b62139171349a6f95d81730c6eef | /app/src/main/java/com/quintus/labs/reminder/ReminderContract.java | b8f1a3b34bff825ba63edbf48f1fdb5a6dd282b6 | [] | no_license | rohitnotes/Reminder | 68207ac6eed2aba31d99979d0d2ceb701750f735 | 51849bcaa3be385b121686a4e6be1b87e01ebeec | refs/heads/master | 2021-09-14T21:01:09.129446 | 2018-05-19T15:17:09 | 2018-05-19T15:17:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,222 | java | package com.quintus.labs.reminder;
import android.content.ContentResolver;
import android.net.Uri;
import android.provider.BaseColumns;
/**
* Created by quintuslabs on 10/06/17.
*/
public final class ReminderContract {
/**
* The authority of the provider.
*/
public static final String AUTHORITY =
"com.quintus.labs.reminder";
/**
* The content URI for the top-level
* authority.
*/
public static final Uri BASE_CONTENT_URI =
Uri.parse("content://" + AUTHORITY);
public static final String PATH_ALL = "all";
public static final String PATH_ALL_ID = "all/#";
public static final String PATH_NOTE = "note";
public static final String PATH_NOTE_ID = "note/#";
public static final String PATH_ALERT = "alert";
public static final String PATH_ALERT_ID = "alert/#";
public static final String _ID = "_id";
public static final String TYPE = "type";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String TIME = "time";
public static final String FREQUENCY = "frequency";
public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY};
public static final class Notes implements BaseColumns {
public static final String TABLE_NAME = "reminders";
public static final String _ID = "_id";
public static final String TYPE = "type";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final Uri CONTENT_URI =
BASE_CONTENT_URI.buildUpon().appendPath(PATH_NOTE).build();
// Custom MIME types
public static final String CONTENT_TYPE =
ContentResolver.CURSOR_DIR_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_NOTE;
public static final String CONTENT_ITEM_TYPE =
ContentResolver.CURSOR_ITEM_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_NOTE;
public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT};
}
public static final class Alerts implements BaseColumns {
public static final String TABLE_NAME = "reminders";
public static final String _ID = "_id";
public static final String TYPE = "type";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String TIME = "time";
public static final String FREQUENCY = "frequency";
public static final Uri CONTENT_URI =
BASE_CONTENT_URI.buildUpon().appendPath(PATH_ALERT).build();
// Custom MIME types
public static final String CONTENT_TYPE =
ContentResolver.CURSOR_DIR_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_ALERT;
public static final String CONTENT_ITEM_TYPE =
ContentResolver.CURSOR_ITEM_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_ALERT;
public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY};
}
public static final class All implements BaseColumns {
public static final String TABLE_NAME = "reminders";
public static final String _ID = "_id";
public static final String TYPE = "type";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String TIME = "time";
public static final String FREQUENCY = "frequency";
public static final Uri CONTENT_URI =
BASE_CONTENT_URI.buildUpon().appendPath(PATH_ALL).build();
// Custom MIME types
public static final String CONTENT_TYPE =
ContentResolver.CURSOR_DIR_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_ALL;
public static final String CONTENT_ITEM_TYPE =
ContentResolver.CURSOR_ITEM_BASE_TYPE +
"/" + AUTHORITY + "/" + PATH_ALL;
public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY};
}
} | [
"[email protected]"
] | |
c3e667b32962816bc293813290d0d550fb330e47 | 65c587993fd89625640af404c9a2b60ee24735e6 | /automation_practice/src/main/java/com/generic/MasterPageFactory.java | fffb785f35f631b45e6937102af0d15a5290550c | [] | no_license | studentqa2020/susmita-Nishir-14 | 74203961a113abb2cc009dbce33c1f075521fb9d | c1126a887fe9b6b1a46a4e7796ea9cc7ad97bf86 | refs/heads/master | 2023-06-06T12:19:21.537390 | 2021-06-27T18:21:50 | 2021-06-27T18:21:50 | 380,806,958 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 798 | java | package com.generic;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class MasterPageFactory {
MasterPageFactory(WebDriver driver) {
PageFactory.initElements(driver, this);
}
public WebElement getSigninBtn() {
return signinBtn;
}
public WebElement getEmail() {
return email;
}
public WebElement getPass() {
return pass;
}
public WebElement getLoginbtn() {
return loginbtn;
}
@FindBy(xpath="//*[@class='login']")
private WebElement signinBtn;
@FindBy(xpath="//*[@id='email']")
private WebElement email;
@FindBy(xpath="//*[@id='passwd']")
private WebElement pass;
@FindBy(xpath="//*[@class='icon-lock left']")
private WebElement loginbtn;
}
| [
"sikan@LAPTOP-7AE2PAGQ"
] | sikan@LAPTOP-7AE2PAGQ |
e3810aaed3df28ff5a028ff3c69a662beeade219 | e85305c47876735317032fe47812ca4c8775a403 | /src/problems/JewelsAndStones0771.java | ffdc98d3a3c68adf4c709ff50853ea8b03e35773 | [] | no_license | arenasoy/LeetCode | 76840c32f0a574640c00ccbdb5d80024363e7b21 | e4de91422cf1743acc90b21b30b8930c2279c1a5 | refs/heads/master | 2021-05-24T15:41:33.785481 | 2020-10-05T18:55:20 | 2020-10-05T18:55:20 | 253,636,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 525 | java | package problems;
import java.util.*;
public class JewelsAndStones0771 {
//O(N) time, O(N) space
public int numJewelsInStones(String J, String S) {
int result = 0;
Set<Character> set = new HashSet<Character>();
for (int i = 0; i < J.length(); i++) {
set.add(J.charAt(i));
}
for (int i = 0; i < S.length(); i++) {
if (set.contains(S.charAt(i)))
result++;
}
return result;
}
} | [
"[email protected]"
] | |
343b8c3f0e4547db587d59bfada84336dde0d275 | 7ab6f4e52dd665714e244c6f34e08f1fd4ef3469 | /ciyuanplus2/app/src/main/java/com/ciyuanplus/mobile/activity/chat/UserMessageListActivity.java | 62d8a1dc50735245aac37f4c50609fe1aa9021ec | [] | no_license | heqianqian0516/ciyuan | 2e9f8f84a1595317e8911cfece2e3f3919ebddeb | 44410726a8f7e4467f06fab1ae709451ef293b3b | refs/heads/master | 2020-07-11T04:11:24.935457 | 2019-11-06T03:37:45 | 2019-11-06T03:37:45 | 204,436,467 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,706 | java | package com.ciyuanplus.mobile.activity.chat;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.ciyuanplus.mobile.MyBaseActivity;
import com.ciyuanplus.mobile.R;
import com.ciyuanplus.mobile.adapter.UserNoticesAdapter;
import com.ciyuanplus.mobile.image_select.utils.StatusBarCompat;
import com.ciyuanplus.mobile.inter.MyOnClickListener;
import com.ciyuanplus.mobile.manager.SharedPreferencesManager;
import com.ciyuanplus.mobile.manager.UserInfoData;
import com.ciyuanplus.mobile.module.comment_detail.CommentDetailActivity;
import com.ciyuanplus.mobile.module.forum_detail.daily_detail.DailyDetailActivity;
import com.ciyuanplus.mobile.module.forum_detail.food_detail.FoodDetailActivity;
import com.ciyuanplus.mobile.module.forum_detail.note_detail.NoteDetailActivity;
import com.ciyuanplus.mobile.module.forum_detail.stuff_detail.StuffDetailActivity;
import com.ciyuanplus.mobile.module.forum_detail.twitter_detail.TwitterDetailActivity;
import com.ciyuanplus.mobile.module.others.new_others.OthersActivity;
import com.ciyuanplus.mobile.net.ApiContant;
import com.ciyuanplus.mobile.net.LiteHttpManager;
import com.ciyuanplus.mobile.net.MyHttpListener;
import com.ciyuanplus.mobile.net.ResponseData;
import com.ciyuanplus.mobile.net.bean.FreshNewItem;
import com.ciyuanplus.mobile.net.bean.NoticeItem;
import com.ciyuanplus.mobile.net.parameter.GetNoticeListApiParameter;
import com.ciyuanplus.mobile.net.response.NoticeListResponse;
import com.ciyuanplus.mobile.pulltorefresh.XListView;
import com.ciyuanplus.mobile.statistics.StatisticsConstant;
import com.ciyuanplus.mobile.statistics.StatisticsManager;
import com.ciyuanplus.mobile.utils.Constants;
import com.ciyuanplus.mobile.utils.Utils;
import com.ciyuanplus.mobile.widget.CommonToast;
import com.ciyuanplus.mobile.widget.TitleBarView;
import com.litesuits.http.exception.HttpException;
import com.litesuits.http.request.StringRequest;
import com.litesuits.http.request.param.HttpMethods;
import com.litesuits.http.response.Response;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import java.util.ArrayList;
import java.util.Arrays;
import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
/**
* Created by Alen on 2017/6/22.
* <p>
* 新粉丝列表页面 评论和赞 收藏
*/
public class UserMessageListActivity extends MyBaseActivity implements OnRefreshListener, OnLoadMoreListener {
@BindView(R.id.m_user_message_list)
XListView mUserMessageList;
@BindView(R.id.m_user_message_null_lp)
LinearLayout mUserMessageNullLp;
@BindView(R.id.m_user_message_list_common_title)
TitleBarView m_js_common_title;
@BindView(R.id.smartRefreshLayout)
SmartRefreshLayout mRefreshLayout;
@BindView(R.id.tv_notice)
TextView noticeText;
private String mType;
private UserNoticesAdapter mAdapter;
private final ArrayList<NoticeItem> mlist = new ArrayList<>();
private int mPage = 0;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_user_message_list);
StatusBarCompat.compat(this, getResources().getColor(R.color.title));
mType = getIntent().getStringExtra(Constants.INTENT_ACTIVITY_TYPE);
if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) {
StatisticsManager.onEventInfo(StatisticsConstant.MODULE_COMMENTS, StatisticsConstant.OP_COMMENTS_PAGE_LOAD);
} else {
StatisticsManager.onEventInfo(StatisticsConstant.MODULE_FANS, StatisticsConstant.OP_FANS_PAGE_LOAD);
}
this.initView();
this.requestList();
}
private void requestList() {
StringRequest postRequest = new StringRequest(ApiContant.URL_HEAD + ApiContant.REQUEST_USER_NOTICE_LIST_URL);
postRequest.setMethod(HttpMethods.Post);
int PAGE_SIZE = 20;
postRequest.setHttpBody(new GetNoticeListApiParameter(mPage + "", PAGE_SIZE + "", mType).getRequestBody());
String sessionKey = SharedPreferencesManager.getString(
Constants.SHARED_PREFERENCES_SET, Constants.SHARED_PREFERENCES_LOGIN_USER_SESSION_KEY, "");
if (!Utils.isStringEmpty(sessionKey)) postRequest.addHeader("authToken", sessionKey);
postRequest.setHttpListener(new MyHttpListener<String>(this) {
@Override
public void onSuccess(String s, Response<String> response) {
super.onSuccess(s, response);
finishRefreshAndLoadMore();
NoticeListResponse response1 = new NoticeListResponse(s);
if (Utils.isStringEquals(response1.mCode, ResponseData.CODE_OK) && response1.noticeListInfo.list != null) {
if (response1.noticeListInfo.list.length > 0) {
if (mPage == 0) mlist.clear();
mlist.addAll(Arrays.asList(response1.noticeListInfo.list));
mAdapter.notifyDataSetChanged();
mPage++;
updateView();
}
} else {
CommonToast.getInstance(response1.mMsg, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(HttpException e, Response<String> response) {
super.onFailure(e, response);
// mUserMessageList.stopRefresh();
// mUserMessageList.stopLoadMore();
finishRefreshAndLoadMore();
}
});
LiteHttpManager.getInstance().executeAsync(postRequest);
}
private void initView() {
Unbinder unbinder = ButterKnife.bind(this);
m_js_common_title.setOnBackListener(new MyOnClickListener() {
@Override
public void performRealClick(View v) {
onBackPressed();
}
});
m_js_common_title.setTitle(Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS) ? "评论和赞" : "新粉丝");
noticeText.setText(Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS) ? "暂无消息" : "暂无新粉丝");
mAdapter = new UserNoticesAdapter(this, mlist);
this.mUserMessageList.setAdapter(mAdapter);
mUserMessageList.setPullLoadEnable(false);
mUserMessageList.setPullRefreshEnable(false);
// mUserMessageList.setXListViewListener(this);
mRefreshLayout.setOnRefreshListener(this);
mRefreshLayout.setOnLoadMoreListener(this);
mUserMessageList.setOnItemClickListener((parent, view, position, id) -> {
if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) {
StatisticsManager.onEventInfo(StatisticsConstant.MODULE_COMMENTS, StatisticsConstant.OP_COMMENTS_LIST_ITEM_CLICK);
} else {
StatisticsManager.onEventInfo(StatisticsConstant.MODULE_FANS, StatisticsConstant.OP_FANS_LIST_ITEM_CLICK);
}
if (id == -1) {
return;
}
int index = (int) id;
Log.e("UserMessageListActivity", "position = " + position);
Log.e("UserMessageListActivity", "id = " + id);
NoticeItem item = mAdapter.getItem(index);
Log.e("UserMessageListActivity", "item = " + item.toString());
if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_FOLLOW)) { // 如果是被关注了
// 如果是匿名 或者 是自己发布的帖子,不允许进入他人页面
if (Utils.isStringEquals(item.fromUserUuid, UserInfoData.getInstance().getUserInfoItem().uuid))
return;
Intent intent = new Intent(UserMessageListActivity.this, OthersActivity.class);
intent.putExtra(Constants.INTENT_USER_ID, item.fromUserUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) { // 如果是评论和赞
if (item.noticeType == 1) { // 评论
Intent intent = new Intent(UserMessageListActivity.this, CommentDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_COMMENT_ID_ITEM, item.currentBizUuid);
intent.putExtra(Constants.INTENT_ACTIVITY_TYPE, "UserMessageListActivity");
intent.putExtra(Constants.INTENT_RENDER_TYPE, item.renderType);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (item.noticeType == 2 || item.noticeType == 9) {// 赞
if (item.bizType == FreshNewItem.FRESH_ITEM_STUFF) {//宝贝
Intent intent = new Intent(UserMessageListActivity.this, StuffDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (item.bizType == FreshNewItem.FRESH_ITEM_DAILY) {
Intent intent = new Intent(UserMessageListActivity.this, DailyDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (item.bizType == FreshNewItem.FRESH_ITEM_POST || item.bizType == FreshNewItem.FRESH_ITEM_ANSWER) { // 长文和说说
Intent intent = new Intent(UserMessageListActivity.this, TwitterDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (item.bizType == FreshNewItem.FRESH_ITEM_NEWS
|| item.bizType == FreshNewItem.FRESH_ITEM_NOTE
|| item.bizType == FreshNewItem.FRESH_ITEM_NEWS_COLLECTION) {
Intent intent = new Intent(UserMessageListActivity.this, NoteDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
} else if (item.bizType == FreshNewItem.FRESH_ITEM_FOOD
|| item.bizType == FreshNewItem.FRESH_ITEM_LIVE
|| item.bizType == FreshNewItem.FRESH_ITEM_COMMENT) {
Intent intent = new Intent(UserMessageListActivity.this, FoodDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
UserMessageListActivity.this.startActivity(intent);
}
} else if (item.noticeType == 5) {// 回复
Intent intent = new Intent(UserMessageListActivity.this, CommentDetailActivity.class);
intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid);
intent.putExtra(Constants.INTENT_COMMENT_ID_ITEM, item.currentBizUuid);
intent.putExtra(Constants.INTENT_ACTIVITY_TYPE, "UserMessageListActivity");
intent.putExtra(Constants.INTENT_RENDER_TYPE, item.renderType);
intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType);
Log.e("UserMessageListActivity", "INTENT_NEWS_ID_ITEM = " + item.bizUuid);
Log.e("UserMessageListActivity", "INTENT_COMMENT_ID_ITEM = " + item.currentBizUuid);
Log.e("UserMessageListActivity", "NTENT_RENDER_TYPE = " + item.renderType);
Log.e("UserMessageListActivity", "INTENT_BIZE_TYPE = " + item.bizType);
UserMessageListActivity.this.startActivity(intent);
}
}
});
}
private void updateView() {
if (mlist.size() > 0) {
mUserMessageNullLp.setVisibility(View.GONE);
this.mUserMessageList.setVisibility(View.VISIBLE);
} else {
mUserMessageNullLp.setVisibility(View.VISIBLE);
this.mUserMessageList.setVisibility(View.GONE);
}
}
@Override
public void onRefresh(RefreshLayout refreshlayout) {
mPage = 0;
requestList();
}
@Override
public void onLoadMore(RefreshLayout refreshlayout) {
requestList();
}
private void finishRefreshAndLoadMore() {
mRefreshLayout.finishRefresh();
mRefreshLayout.finishLoadMore();
}
}
| [
"[email protected]"
] | |
0575ada4e394ebd855b712c008994cd9c7c1c99a | 6068c9ec095d23608e8484fb9d48e3fff759b13a | /src/test/java/katas/foliva/AlternatingCaseTest.java | c656cae60b01521d1e1b9169e22ba3713a3c1bb2 | [
"Unlicense"
] | permissive | CFHLopez/bootcamp-2021-5 | 6cb6b2eefaf6d46e85d6153503efdfd7dc3b1fc9 | 89d1c511ed3e6fd2afd83d9d7e48b321ae3acf02 | refs/heads/main | 2023-09-04T17:27:22.401261 | 2021-11-22T16:47:36 | 2021-11-22T16:47:36 | 419,761,613 | 0 | 0 | Unlicense | 2021-10-21T14:42:05 | 2021-10-21T14:42:05 | null | UTF-8 | Java | false | false | 1,673 | java | package katas.foliva;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AlternatingCaseTest {
@Test
public void allLowerCase(){
assertEquals("HELLO WORLD", StringUtils.toAlternativeString("hello world"));
}
@Test
public void allUpperCase(){
assertEquals("hello world", StringUtils.toAlternativeString("HELLO WORLD"));
}
@Test
public void oneLowerOneUpper(){
assertEquals("HELLO world", StringUtils.toAlternativeString("hello WORLD"));
}
@Test
public void allNumbers(){
assertEquals("12345", StringUtils.toAlternativeString("12345"));
}
@Test
public void twoConvertions(){
assertEquals("Hello World", StringUtils.toAlternativeString(StringUtils.toAlternativeString("Hello World")));
}
@Test
public void otherCases() {
assertEquals("hEllO wOrld", StringUtils.toAlternativeString("HeLLo WoRLD"));
assertEquals("1A2B3C4D5E", StringUtils.toAlternativeString("1a2b3c4d5e"));
assertEquals("sTRINGuTILS.TOaLTERNATINGcASE", StringUtils.toAlternativeString("StringUtils.toAlternatingCase"));
}
@Test
public void kataTitleTests() {
assertEquals("ALTerNAtiNG CaSe", StringUtils.toAlternativeString("altERnaTIng cAsE"));
assertEquals("altERnaTIng cAsE", StringUtils.toAlternativeString("ALTerNAtiNG CaSe"));
assertEquals("ALTerNAtiNG CaSe <=> altERnaTIng cAsE", StringUtils.toAlternativeString("altERnaTIng cAsE <=> ALTerNAtiNG CaSe"));
assertEquals("altERnaTIng cAsE <=> ALTerNAtiNG CaSe", StringUtils.toAlternativeString("ALTerNAtiNG CaSe <=> altERnaTIng cAsE"));
}
}
| [
"[email protected]"
] | |
a9a4a060abf3e9b3ffd1c4cb861fea01c4bc7d77 | dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9 | /data_defect4j/preprossed_method_corpus/Math/40/org/apache/commons/math/dfp/BracketingNthOrderBrentSolverDFP_getMaximalOrder_89.java | 806ada00c334d637913bc3baa09e63488db2392e | [] | no_license | hvdthong/NetML | dca6cf4d34c5799b400d718e0a6cd2e0b167297d | 9bb103da21327912e5a29cbf9be9ff4d058731a5 | refs/heads/master | 2021-06-30T15:03:52.618255 | 2020-10-07T01:58:48 | 2020-10-07T01:58:48 | 150,383,588 | 1 | 1 | null | 2018-09-26T07:08:45 | 2018-09-26T07:08:44 | null | UTF-8 | Java | false | false | 854 | java |
org apach common math dfp
modif
href http mathworld wolfram brent method brentsmethod html brent algorithm
respect origin brent algorithm
return chosen current interv
user link allow solut allowedsolut
maxim order invert polynomi root search
user invert quadrat
interv bracket root
version
bracket nth order brent solver dfp bracketingnthorderbrentsolverdfp
maxim order
maxim order
maxim order getmaximalord
maxim order maximalord
| [
"[email protected]"
] | |
189bece4e9e9df2cfee2c40e301bb668b23e0fa5 | 750b6b218afc3206a7e674092197a1e701664987 | /PAO Part 3 + Project-Remake/Interface/JobsManager.java | 2f7a88c2b1daee52dcf6ea7a4b58d54809a3fc01 | [] | no_license | kkrogmerio/java-fundamentals | e2762648b727770a25120c415dbc1bb60b02e61c | 5bd8a297d425eb2353e0959d2e872f18fc5178d8 | refs/heads/master | 2022-10-19T18:05:37.517599 | 2020-06-03T16:41:35 | 2020-06-03T16:41:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,196 | java | package Interface;
import SystemManagement.Services;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.CardLayout;
import java.awt.Font;
import javax.swing.table.DefaultTableModel;
import java.awt.GridLayout;
import java.util.Arrays;
import java.util.Scanner;
import javax.swing.border.LineBorder;
class JobsManager extends JFrame implements ActionListener {
//@SuppressWarnings("unused")
//private Statement stm=null;
private static final long serialVersionUID = 1L;
private JPanel contentPane;
static Services s;
JButton insertJobButton;
JButton deleteJobButton;
JButton updateJobButton;
JScrollPane scrollPane;
/**
* Create the frame.
*/
JTextArea bonusWorkcondUpdate;
JTextArea bonusDisabilityUpdate;
JTextArea idDelete;
JButton dataJob;
JButton insertJob;
JButton deleteJob;
JButton updateJob;
JPanel deletePanel;
JPanel updatePanel;
JPanel insertPanel;
JPanel dataPanel;
JTextArea idUpdate;
private JTextField typeJobInsert;
private JTextField bonusWorkcondInsert;
private JTextField bonusDisabInsert;
private JTable table;
private JTable table_1;
private JPanel cardPanel;
FileWriter fw;
private JPanel panel_1;
private JLabel lblNewLabel_6;
private JLabel lblNewLabel_7;
private JTextArea jobNameInsert;
private Statement stm;
private static JobsManager instance;
public static JobsManager getInstance(Services st, Statement stm) throws IOException, SQLException {
if (instance == null)
instance = new JobsManager(st, stm);
return instance;
}
private JobsManager(Services st, Statement stm) throws IOException, SQLException {
fw = new FileWriter("./src/FileResources/File");
this.stm = stm;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
JPopupMenu popupMenu = new JPopupMenu();
addPopup(this, popupMenu);
JButton btnNewButton = new JButton("New button");
popupMenu.add(btnNewButton);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JToolBar toolBar = new JToolBar();
toolBar.setBackground(Color.GRAY);
toolBar.setForeground(Color.BLACK);
toolBar.setBounds(0, 0, 596, 38);
contentPane.add(toolBar);
Border b = BorderFactory.createLineBorder(Color.black);
insertJob = new JButton("Insert Job");
toolBar.add(insertJob);
insertJob.setBackground(Color.WHITE);
insertJob.addActionListener(this);
deleteJob = new JButton("Delete Job");
toolBar.add(deleteJob);
deleteJob.setBackground(Color.WHITE);
deleteJob.addActionListener(this);
updateJob = new JButton("Update Job");
updateJob.setBackground(Color.WHITE);
toolBar.add(updateJob);
updateJob.addActionListener(this);
dataJob = new JButton("Data Job");
dataJob.addActionListener(this);
dataJob.setBackground(Color.WHITE);
toolBar.add(dataJob);
cardPanel = new JPanel();
cardPanel.setBounds(10, 48, 576, 305);
contentPane.add(cardPanel);
cardPanel.setLayout(new CardLayout(0, 0));
insertPanel = new JPanel();
cardPanel.add(insertPanel, "name_40189397865800");
insertPanel.setLayout(null);
JLabel lblNewLabel = new JLabel("Insert a job");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblNewLabel.setBounds(221, 68, 134, 48);
insertPanel.add(lblNewLabel);
typeJobInsert = new JTextField();
typeJobInsert.setBounds(164, 158, 96, 19);
insertPanel.add(typeJobInsert);
typeJobInsert.setColumns(10);
bonusDisabInsert = new JTextField();
bonusDisabInsert.setText("0");
bonusDisabInsert.setColumns(10);
bonusDisabInsert.setBounds(349, 226, 96, 19);
insertPanel.add(bonusDisabInsert);
JLabel lblNewLabel_1 = new JLabel("Type Job (normal/special)");
lblNewLabel_1.setBounds(26, 161, 128, 13);
insertPanel.add(lblNewLabel_1);
JLabel lblBonusDisability = new JLabel("Bonus disability");
lblBonusDisability.setBounds(269, 229, 70, 13);
insertPanel.add(lblBonusDisability);
insertJobButton = new JButton("Insert Job");
insertJobButton.addActionListener(this);
insertJobButton.setBounds(240, 263, 85, 21);
insertPanel.add(insertJobButton);
panel_1 = new JPanel();
panel_1.setBorder(new LineBorder(new Color(0, 0, 0)));
panel_1.setBounds(26, 209, 451, 48);
insertPanel.add(panel_1);
panel_1.setLayout(null);
JLabel lblBonusWorkcond = new JLabel("Bonus workcond");
lblBonusWorkcond.setBounds(10, 22, 82, 13);
panel_1.add(lblBonusWorkcond);
bonusWorkcondInsert = new JTextField();
bonusWorkcondInsert.setText("0");
bonusWorkcondInsert.setBounds(102, 19, 96, 19);
panel_1.add(bonusWorkcondInsert);
bonusWorkcondInsert.setColumns(10);
lblNewLabel_6 = new JLabel("Only for special job:");
lblNewLabel_6.setBounds(26, 186, 96, 13);
insertPanel.add(lblNewLabel_6);
lblNewLabel_7 = new JLabel("Job Name");
lblNewLabel_7.setBounds(299, 161, 45, 13);
insertPanel.add(lblNewLabel_7);
jobNameInsert = new JTextArea();
jobNameInsert.setBounds(363, 155, 114, 22);
insertPanel.add(jobNameInsert);
updatePanel = new JPanel();
updatePanel.setLayout(null);
cardPanel.add(updatePanel, "name_40189412089400");
JLabel lblNewLabel_2 = new JLabel("Update a job");
lblNewLabel_2.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblNewLabel_2.setBounds(236, 79, 102, 32);
updatePanel.add(lblNewLabel_2);
idUpdate = new JTextArea();
idUpdate.setBounds(108, 152, 114, 22);
updatePanel.add(idUpdate);
bonusWorkcondUpdate = new JTextArea();
bonusWorkcondUpdate.setBounds(108, 225, 114, 22);
updatePanel.add(bonusWorkcondUpdate);
bonusDisabilityUpdate = new JTextArea();
bonusDisabilityUpdate.setBounds(373, 225, 114, 22);
updatePanel.add(bonusDisabilityUpdate);
JLabel lblNewLabel_3 = new JLabel("ID");
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setBounds(53, 158, 45, 13);
updatePanel.add(lblNewLabel_3);
JLabel lblWorkcond = new JLabel("Bonus Workcond");
lblWorkcond.setBounds(10, 231, 88, 13);
updatePanel.add(lblWorkcond);
JLabel lblBonusDisability_1 = new JLabel("Bonus disability");
lblBonusDisability_1.setBounds(286, 231, 77, 13);
updatePanel.add(lblBonusDisability_1);
updateJobButton = new JButton("Update job");
updateJobButton.setBounds(235, 274, 85, 21);
updateJobButton.addActionListener(this);
updatePanel.add(updateJobButton);
deletePanel = new JPanel();
cardPanel.add(deletePanel, "name_40189426321000");
deletePanel.setLayout(null);
JLabel lblNewLabel_4 = new JLabel("Delete a job");
lblNewLabel_4.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_4.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblNewLabel_4.setBounds(149, 88, 276, 30);
deletePanel.add(lblNewLabel_4);
deleteJobButton = new JButton("Delete job");
deleteJobButton.addActionListener(this);
deleteJobButton.setBounds(258, 220, 85, 21);
deletePanel.add(deleteJobButton);
JLabel lblNewLabel_5 = new JLabel("ID");
lblNewLabel_5.setHorizontalAlignment(SwingConstants.TRAILING);
lblNewLabel_5.setBounds(166, 178, 59, 13);
deletePanel.add(lblNewLabel_5);
idDelete = new JTextArea();
idDelete.setBounds(235, 172, 123, 22);
deletePanel.add(idDelete);
dataPanel = new JPanel();
cardPanel.add(dataPanel, "name_41104845133400");
dataPanel.setLayout(null);
scrollPane = new JScrollPane();
scrollPane.setBounds(0, 5, 576, 300);
dataPanel.add(scrollPane);
ResultSet length = stm.executeQuery("select count(*) from jobs");
length.next();
Object[][] data = new Object[length.getInt(1)][];
ResultSet resultSetJob = stm.executeQuery("select * from jobs");
int i = -1;
while (resultSetJob.next()) {
int id = resultSetJob.getInt(1);
String jobType = resultSetJob.getString(2);
int amount = resultSetJob.getInt(3);
int workcond = resultSetJob.getInt(4);
int disability = resultSetJob.getInt(5);
String jobName = resultSetJob.getString(6);
String thread = resultSetJob.getString(7);
i += 1;
data[i] = new Object[]{id, jobType, amount, workcond, disability, jobName, thread};
//dataJob.add(Arrays.asList(String.valueOf(id),jobType,String.valueOf(amount),String.valueOf(workcond),String.valueOf(disability),jobName,resultSetJob.getString(7)));
}
String[] column = {"jobID", "jobType", "amount", "workcond", "disabiity", "jobName", "thread"};
table = new JTable(data, column);
scrollPane.setViewportView(table);
//dataJob.add(table);
dataJob.addActionListener(this);
this.s = st;
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setPreferredSize(new Dimension(600, 400));
pack();
setVisible(true);
}
public void switchPanels(JPanel panel) {
cardPanel.removeAll();
cardPanel.add(panel);
cardPanel.repaint();
cardPanel.revalidate();
}
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
JButton clicked = (JButton) e.getSource();
if (clicked == deleteJob) {
switchPanels(deletePanel);
} else if (clicked == insertJob) {
switchPanels(insertPanel);
} else if (clicked == updateJob) {
switchPanels(updatePanel);
} else if (clicked == dataJob) {
switchPanels(dataPanel);
ResultSet length = null;
try {
length = stm.executeQuery("select count(*) from jobs");
length.next();
Object[][] data = new Object[length.getInt(1)][];
ResultSet resultSetJob = stm.executeQuery("select * from jobs");
int i = -1;
while (resultSetJob.next()) {
int id = resultSetJob.getInt(1);
String jobType = resultSetJob.getString(2);
int amount = resultSetJob.getInt(3);
int workcond = resultSetJob.getInt(4);
int disability = resultSetJob.getInt(5);
String jobName = resultSetJob.getString(6);
String thread = resultSetJob.getString(7);
i += 1;
data[i] = new Object[]{id, jobType, amount, workcond, disability, jobName, thread};
//dataJob.add(Arrays.asList(String.valueOf(id),jobType,String.valueOf(amount),String.valueOf(workcond),String.valueOf(disability),jobName,resultSetJob.getString(7)));
}
String[] column = {"jobID", "jobType", "amount", "workcond", "disabiity", "jobName", "thread"};
table = new JTable(data, column);
scrollPane.setViewportView(table);
} catch (SQLException ex) {
ex.printStackTrace();
}
} else if (clicked == deleteJobButton) {
int val = Integer.parseInt(idDelete.getText());
try {
fw.append("9 jobs " + idDelete.getText() + " 0 ");
System.out.println(fw.toString());
fw.flush();
s.application();
idDelete.setText("");
JOptionPane.showMessageDialog(this, "Succesful");
} catch (FileNotFoundException ef) {
ef.printStackTrace();
} catch (IOException eio) {
eio.printStackTrace();
}
} else if (clicked == updateJobButton) {
try {
if (bonusWorkcondUpdate.getText().equals("") == false) {
fw.append("8 jobs " + idUpdate.getText());
fw.append(" 0 " + bonusWorkcondUpdate.getText() + " 0 ");
fw.flush();
s.application();
}
if (bonusDisabilityUpdate.getText().equals("") == false) {
fw.append("8 jobs " + idUpdate.getText());
fw.append(" 1 " + bonusDisabilityUpdate.getText() + " 0 ");
fw.flush();
s.application();
}
JOptionPane.showMessageDialog(this, "Succesful");
} catch (FileNotFoundException ef) {
ef.printStackTrace();
} catch (IOException eio) {
eio.printStackTrace();
}
} else if (clicked == insertJobButton) {
try {
fw.append("7 3 " + typeJobInsert.getText() + " ");
if (typeJobInsert.getText().equals("special")) {
fw.append(jobNameInsert.getText() + " " + bonusWorkcondInsert.getText() + " " + bonusDisabInsert.getText() + " 6 " + " -1 " + " 0 " + " 0 ");//+s.getLastId()+" 0 "+" 0 ");
fw.flush();
s.application();
} else if (typeJobInsert.getText().equals("normal")) {
fw.append(jobNameInsert.getText() + " 6 " + " -1 " + " 0 " + " 0 ");
fw.flush();
s.application();
}
jobNameInsert.setText("");
bonusWorkcondInsert.setText("0");
bonusDisabInsert.setText("0");
typeJobInsert.setText("");
JOptionPane.showMessageDialog(this, "Succesful");
} catch (FileNotFoundException ef) {
ef.printStackTrace();
} catch (IOException eio) {
eio.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
1cb45c95d84e0f048e0d9c03ce029b903d6ad955 | bee3260be858709a32595c7df5fc64f934c00f8b | /src/main/java/com/schlenz/blackjack/Hand.java | 3fcb68786c23fa0b5f28d4832f595d877db7e2ad | [
"Apache-2.0"
] | permissive | eschlenz/Blackjack-Testing-Playground | 8beb9d1afb81ff79dc1742267b9858463d1db13f | 52a3d03f99321e36afe43a512b98601e9d5175e5 | refs/heads/master | 2020-03-27T13:29:16.771896 | 2018-08-29T14:57:21 | 2018-08-29T14:57:21 | 146,612,449 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 189 | java | package com.schlenz.blackjack;
public interface Hand {
void takeDealtCard(Card card);
int getHandValue();
boolean isBusted();
boolean isSoft();
String getHandInfo();
}
| [
"[email protected]"
] | |
d50bed9bcdeb30e2e853df5d1327dfb2dd7c5317 | 63e0779a511f1af30d72bd8ec27f27d5814d6f76 | /Tshogyen/app/src/main/java/edu/gcit/tshogyen/BoyCulC.java | 79141a38dfa43b9d3f9c1379536a0bee0666fc7d | [] | no_license | Sonamdema123/Project2021 | 609baad24b44a10ce3d78bd88fc2b7e51935f706 | 0b2eaed2d66f994bdd0acd2a5dccfedbb08f0d40 | refs/heads/main | 2023-07-17T20:41:07.436882 | 2021-08-26T14:36:13 | 2021-08-26T14:36:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,516 | java | package edu.gcit.tshogyen;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QuerySnapshot;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import java.util.ArrayList;
import java.util.List;
public class BoyCulC extends AppCompatActivity {
RecyclerView mRecyclerView;
List<Candidates> candidateList;
FirebaseFirestore fStore;
ProgressDialog pd;
VoteListAdapter mAdapter;
FirebaseStorage firebaseStorage;
StorageReference storageReference;
FirebaseAuth fAuth;
ImageView imageView;
EditText candidateRole;
FloatingActionButton gotonext;
// CollectionReference collectionReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_boy_cul_c);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
int gridColumnCount = getResources().getInteger(R.integer.grid_column_count);
fAuth = FirebaseAuth.getInstance();
pd = new ProgressDialog(this);
candidateRole = findViewById(R.id.candidate_role);
imageView = findViewById(R.id.image_resultView);
firebaseStorage = FirebaseStorage.getInstance();
storageReference = firebaseStorage.getReference("Candidate_Images");
mRecyclerView = findViewById(R.id.voterecyclerView);
//Set the Layout Manager
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//Initialize the ArrayList that will contain the data
candidateList = new ArrayList<>();
//Initialize the adapter and set it ot the RecyclerView
mAdapter = new VoteListAdapter(this, candidateList);
mRecyclerView.setAdapter(mAdapter);
//for the different orientation and device sizes
mRecyclerView.setLayoutManager(new GridLayoutManager(this, gridColumnCount));
fStore = FirebaseFirestore.getInstance();
// collectionReference = fStore.collection("Candidates");
gotonext = findViewById(R.id.gotoGirlCulC);
gotonext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), GirlCulC.class));
finish();
}
});
//show data in recyclerview
showBoyCulturalCoordinator();
}
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
private void showBoyCulturalCoordinator() {
//set title of progress dialog
pd.setTitle("Loading Candidates...");
//show progress dialog
pd.show();
fStore.collection("Boy Cultural Coordinator")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
// candidatesList.clear();
//called when data is retrieved
pd.dismiss();
//show candidate
for (DocumentSnapshot can: task.getResult()){
Candidates candidates = new Candidates(
can.getString("id"),
can.getString("FullName"),
can.getString("CandidateEmail"),
can.getString("CandidateID"),
can.getString("CandidateRole"),
can.getString("Uri"),
can.getLong("Votes").intValue());
candidateList.add(candidates);
}
//adapter
mAdapter = new VoteListAdapter(getApplicationContext(), candidateList);
//set adapter to recyclerview
mRecyclerView.setAdapter(mAdapter);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
//called when there is any error while retrieving
pd.dismiss();
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
}
if(item.getItemId() == R.id.logout){
FirebaseAuth.getInstance().signOut();
startActivity(new Intent(getApplicationContext(), LoginActivity.class));
finish();
}
if(item.getItemId() == R.id.user_profile){
startActivity(new Intent(getApplicationContext(), UserProfile.class));
}
if(item.getItemId() == R.id.about){
startActivity(new Intent(getApplicationContext(), AboutPage.class));
}
return super.onOptionsItemSelected(item);
}
} | [
"[email protected]"
] | |
94e300d887c7747d8961e2ecb5d32fc141e95369 | 3a47d7d1d6968daea4f2154de479ac18b17ad7db | /com.sg.vim/src/com/sg/vim/service/fuellabel/HelloWorld.java | e500f9a35db62297210c7c21714572f720c65f65 | [] | no_license | sgewuhan/vim | ef64fce49f9ab481521a21901157c81910e57e5e | d7d193f5be3b357bace4e0f7b703281ade15ae7f | refs/heads/master | 2021-01-19T03:12:56.079503 | 2013-06-26T00:51:24 | 2013-06-26T00:51:24 | 9,443,167 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 762 | java |
package com.sg.vim.service.fuellabel;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "HelloWorld")
public class HelloWorld {
}
| [
"[email protected]"
] | |
2c743039a5bd0c49842e02ef2fd26264857305d8 | f7a2b5789fa1b517bf071f237ce9639961cb2cb7 | /src/model/Voiture.java | 428a6b77c3812eab65bc1957813c65b98f14712d | [] | no_license | amostin/ProjetJava | cb537445e399e3216ac8faa65baf2bfa36de6bf0 | 9e4219cdfec8b80c0dbecbd87b4c7c5859c02aae | refs/heads/master | 2022-11-30T04:59:43.549396 | 2020-08-19T10:33:02 | 2020-08-19T10:33:02 | 275,386,141 | 0 | 0 | null | 2020-08-05T12:37:24 | 2020-06-27T14:12:51 | Java | ISO-8859-1 | Java | false | false | 9,053 | java | /**
*
*/
package model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* Cette classe permet de créer des voitures
* @author Ambroise Mostin
*
*/
public class Voiture implements Comparable<Voiture>{
private String marque;
private String type;
private String puissance;
private String bva;
private String gps;
private String porte;
private String clim;
private String etat;
private String prix;
private String prixKm;
private String amende;
private static int i = 0;
/**
* Ce constructeur permet de créer une voiture automatiquement
* @param variete le numero correspond à un type de voiture
*/
public Voiture(int variete) {
switch (variete) {
case 0:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "2000";
this.bva = "oui";
this.gps = "oui";
this.porte = "3";
this.clim = "oui";
this.prix = "100";
this.prixKm = "5.0";
this.amende = "50.0";
this.etat = "disponible";
i++;
break;
case 1:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1800";
this.bva = "non";
this.gps = "oui";
this.porte = "3";
this.clim = "oui";
this.prix = "90";
this.prixKm = "4.5";
this.amende = "45.0";
this.etat = "disponible";
i++;
break;
case 2:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1600";
this.bva = "oui";
this.gps = "non";
this.porte = "3";
this.clim = "non";
this.prix = "80";
this.prixKm = "4.0";
this.amende = "40.0";
this.etat = "disponible";
i++;
break;
case 3:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1500";
this.bva = "non";
this.gps = "oui";
this.porte = "5";
this.clim = "oui";
this.prix = "70";
this.prixKm = "3.5";
this.amende = "35.0";
this.etat = "disponible";
i++;
break;
case 4:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1400";
this.bva = "oui";
this.gps = "non";
this.porte = "5";
this.clim = "non";
this.prix = "60";
this.prixKm = "3.0";
this.amende = "30.0";
this.etat = "disponible";
i++;
break;
case 5:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1300";
this.bva = "non";
this.gps = "non";
this.porte = "3";
this.clim = "non";
this.prix = "50";
this.prixKm = "2.5";
this.amende = "25.0";
this.etat = "disponible";
i++;
break;
case 6:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1200";
this.bva = "non";
this.gps = "non";
this.porte = "5";
this.clim = "oui";
this.prix = "40";
this.prixKm = "2.0";
this.amende = "20.0";
this.etat = "disponible";
i++;
break;
case 7:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1100";
this.bva = "oui";
this.gps = "oui";
this.porte = "5";
this.clim = "non";
this.prix = "30";
this.prixKm = "1.5";
this.amende = "15.0";
this.etat = "disponible";
i++;
break;
case 8:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "1000";
this.bva = "non";
this.gps = "oui";
this.porte = "5";
this.clim = "non";
this.prix = "20";
this.prixKm = "1.0";
this.amende = "10.0";
this.etat = "disponible";
i++;
break;
case 9:
this.marque = "marque_"+i;
this.type = "type_"+i;
this.puissance = "800";
this.bva = "oui";
this.gps = "non";
this.porte = "5";
this.clim = "oui";
this.prix = "15";
this.prixKm = "0.75";
this.amende = "7.5";
this.etat = "disponible";
i++;
break;
default:
break;
}
}
/**
* Ce constructeur permet de créer une voiture selon les caractéristiques choisies
* @param marque marque de la voiture
* @param type type de la voiture
* @param puissance puissance de la voiture
* @param bva boite de vitesse de la voiture
* @param gps gps de la voiture
* @param porte porte de la voiture
* @param clim clim de la voiture
* @param prix prix de la voiture
* @param prixKm prixKm de la voiture
* @param amende amende de la voiture
*/
public Voiture(String marque, String type, String puissance, String bva, String gps, String porte, String clim, String prix, String prixKm, String amende) {
this.marque = marque + '_' + i;
this.type = type + '_' + i;
this.puissance = puissance;
this.bva = bva;
this.gps = gps;
this.porte = porte;
this.clim = clim;
this.prix = prix;
this.prixKm = prixKm;
this.amende = amende;
this.etat = "disponible";
i++;
}
@Override
/**
* Cette méthode permet d'afficher les caractéristiques de la voiture
*/
public String toString() {
return "marque=" + marque + ", type=" + type + ", puissance=" + puissance + ", bva=" + bva + ", gps="
+ gps + ", porte=" + porte + ", clim=" + clim + ", etat=" + etat + ", prix=" + prix + ", prixKm=" + prixKm + ", amende=" + amende;
}
/**
* Cette méthode permet d'obtenir un identifant unique
*/
public static int getI() {
return i;
}
/**
* Cette méthode permet de modifier l'identifant unique
*/
public static void setI(int i) {
Voiture.i = i;
}
/**
* Cette méthode permet d'obtenir la marque
*/
public String getMarque() {
return marque;
}
/**
* Cette méthode permet de modifier la marque
* @param marque la marque
*/
public void setMarque(String marque) {
this.marque = marque;
}
/**
* Cette méthode permet d'obtenir le type
*/
public String getType() {
return type;
}
/**
* Cette méthode permet de modifier le type
* @param type le type
*/
public void setType(String type) {
this.type = type;
}
/**
* Cette méthode permet d'obtenir la puissance
*/
public String getPuissance() {
return puissance;
}
/**
* Cette méthode permet de modifier la puissance
* @param puissance la puissance
*/
public void setPuissance(String puissance) {
this.puissance = puissance;
}
/**
* Cette méthode permet d'obtenir la boite de vitesse
*/
public String getBva() {
return bva;
}
/**
* Cette méthode permet de modifier la boite de vitesse
* @param bva la boite de vitesse
*/
public void setBva(String bva) {
this.bva = bva;
}
/**
* Cette méthode permet d'obtenir le gps
*/
public String getGps() {
return gps;
}
/**
* Cette méthode permet de modifier le gps
* @param gps le gps
*/
public void setGps(String gps) {
this.gps = gps;
}
/**
* Cette méthode permet d'obtenir le nombre de porte
*/
public String getPorte() {
return porte;
}
/**
* Cette méthode permet de modifier le nombre de porte
* @param porte le nombre de porte
*/
public void setPorte(String porte) {
this.porte = porte;
}
/**
* Cette méthode permet d'obtenir la clim
*/
public String getClim() {
return clim;
}
/**
* Cette méthode permet de modifier la clim
* @param clim la clim
*/
public void setClim(String clim) {
this.clim = clim;
}
/**
* Cette méthode permet d'obtenir l'état
*/
public String getEtat() {
return etat;
}
/**
* Cette méthode permet de modifier l'état
* @param etat l'état de la voiture
*/
public void setEtat(String etat) {
this.etat = etat;
}
/**
* Cette méthode permet d'obtenir le prix
*/
public String getPrix() {
return prix;
}
/**
* Cette méthode permet de modifier le prix
* @param prix le prix
*/
public void setPrix(String prix) {
this.prix = prix;
}
/**
* Cette méthode permet d'obtenir le prix au km
*/
public String getPrixKm() {
return prixKm;
}
/**
* Cette méthode permet de modifier le prix au km
* @param prixKm le prix au km
*/
public void setPrixKm(String prixKm) {
this.prixKm = prixKm;
}
/**
* Cette méthode permet d'obtenir l'amende
*/
public String getAmende() {
return amende;
}
/**
* Cette méthode permet de modifier l'amende
* @param amende le montant de l'amende
*/
public void setAmende(String amende) {
this.amende = amende;
}
@Override
/**
* Cette méthode permet de comparer chaque voiture en fonction du prix
* @param voiture la voiture avec laquelle comparer
*/
public int compareTo(Voiture voiture) {
return (int)(Integer.parseInt(this.prix) - Integer.parseInt(voiture.getPrix()));
}
/**
* Cette méthode permet de trier chaque voiture en fonction du prix
* @param voitureParPrix la liste des voitures par prix
*/
public static ArrayList<Voiture> tri(ArrayList<Voiture> voitureParPrix){
Collections.sort(voitureParPrix);
return voitureParPrix;
}
}
| [
"[email protected]"
] | |
42ea77e41c4f311dd84c2d6c8e721e2460485c4b | 18cbd04c5e84a478e3d809027864a0de39581c7a | /cloud-consumer-feign-order80/src/main/java/com/atguigu/springcloud/controller/OrderFeignController.java | 2df19da110801c3d18cb265c67195ef59f860076 | [] | no_license | guohangbk/2020springcloud-atguigu | f559436ac9cf0fd97becc42d810f20e7e9b7aac3 | 1d93ca35cac3e88ad439529f0babb585893bd148 | refs/heads/master | 2023-02-19T12:07:01.854905 | 2021-01-09T08:59:04 | 2021-01-09T08:59:04 | 328,108,864 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,034 | java | package com.atguigu.springcloud.controller;
import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import com.atguigu.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author guohang
* @Description
* @Date 2020/4/19 15:45
*/
@RestController
@Slf4j
public class OrderFeignController {
@Autowired
private PaymentFeignService paymentFeignService;
@GetMapping("/consumer/payment/get/{id}")
public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
return paymentFeignService.getPaymentById(id);
}
@GetMapping("/comsumer/payment/feign/timeout")
public String paymentFeignTimeout(){
return paymentFeignService.paymentFeignTimeout();
}
}
| [
"[email protected]"
] | |
040c57452450d776649b83d40b1305dca8d24e68 | c7579eac78326015a53d89ea4dd8124660e707b1 | /tddl-qatest/src/test/java/com/taobao/tddl/qatest/matrix/join/JoinTest.java | 10ca500ec3879598e65e3d011a30ccd546aef9e2 | [
"Apache-2.0"
] | permissive | quyixiao/TDDL | 07f3db5e4a78ec19b68dfb4b5d98fb9d7edb2a60 | 1bc33f047f94b878f6e13edb06c03dc3f8c2cb21 | refs/heads/master | 2023-04-02T02:28:51.288020 | 2021-03-30T03:58:26 | 2021-03-30T03:58:26 | 352,864,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,610 | java | package com.taobao.tddl.qatest.matrix.join;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized.Parameters;
import com.taobao.tddl.qatest.BaseMatrixTestCase;
import com.taobao.tddl.qatest.BaseTestCase;
import com.taobao.tddl.qatest.ExecuteTableName;
import com.taobao.tddl.qatest.util.EclipseParameterized;
/**
* join测试
*
* @author zhuoxue
* @since 5.0.1
*/
@RunWith(EclipseParameterized.class)
public class JoinTest extends BaseMatrixTestCase {
// common fields
private final long module_id = Math.abs(rand.nextLong());
private final long hostgroup_id = Math.abs(rand.nextLong());
// monitor_module_info fields
private final long product_id = Math.abs(rand.nextLong());
private final String module_name = "my_module_name";
private final long parent_module_id = Math.abs(rand.nextLong());
private final String applevel = "my_applevel";
private final String apprisk = "my_apprisk";
private final long sequence = Math.abs(rand.nextLong());
private final String module_description = "my_module_description";
private final String alias_name = "my_alias_name";
// monitor_host_info fields
private final long host_id = Math.abs(rand.nextLong());
private final String host_name = "my_host_name";
private final String host_ip = "my_host_ip";
private final String host_type_id = "my_host_type_id";
private final String station_id = "my_station_id";
private final String snmp_community = "my_snmp_community";
private final String status = "my_status";
private final long host_flag = Math.abs(rand.nextLong());
// monitor_hostgroup_info fields
private final String gstation_id = "my_gstation_id";
private final String hostgroup_name = "my_hostgroup_name";
private final long nagios_id = Math.abs(rand.nextLong());
private final long hostgroup_flag = Math.abs(rand.nextLong());
String[] columnParam = { "APPNAME", "HOSTIP", "STATIONID", "HOSTGROUPNAME" };
@Parameters(name = "{index}:table0={0},table1={1},table2={2},table3={3},table4={4}")
public static List<String[]> prepareDate() {
return Arrays.asList(ExecuteTableName.hostinfoHostgoupStudentModuleinfoModulehostTable(dbType));
}
public JoinTest(String monitor_host_infoTableName, String monitor_hostgroup_infoTableName, String studentTableName,
String monitor_module_infoTableName, String monitor_module_hostTableName) throws Exception{
BaseTestCase.host_info = monitor_host_infoTableName;
BaseTestCase.hostgroup_info = monitor_hostgroup_infoTableName;
BaseTestCase.studentTableName = studentTableName;
BaseTestCase.module_info = monitor_module_infoTableName;
BaseTestCase.module_host = monitor_module_hostTableName;
init();
}
public void init() throws Exception {
tddlUpdateData("delete from " + module_info, null);
tddlUpdateData("delete from " + host_info, null);
tddlUpdateData("delete from " + hostgroup_info, null);
mysqlUpdateData("delete from " + module_info, null);
mysqlUpdateData("delete from " + host_info, null);
mysqlUpdateData("delete from " + hostgroup_info, null);
// insert monitor_module_info
String sql = "replace into "
+ module_info
+ "(module_id, product_id,module_name, parent_module_id, applevel, apprisk, sequence,module_description, alias_name) values(?,?,?,?,?,?,?,?,?)";
tddlUpdateData(sql,
Arrays.asList(new Object[] { module_id, product_id, module_name, parent_module_id, applevel, apprisk,
sequence, module_description, alias_name }));
mysqlUpdateData(sql,
Arrays.asList(new Object[] { module_id, product_id, module_name, parent_module_id, applevel, apprisk,
sequence, module_description, alias_name }));
// insert monitor_host_info
sql = "replace into "
+ host_info
+ "(host_id, host_name, host_ip,host_type_id, hostgroup_id, station_id, snmp_community, status, host_flag) values(?,?,?,?,?,?,?,?,?)";
tddlUpdateData(sql,
Arrays.asList(new Object[] { host_id, host_name, host_ip, host_type_id, hostgroup_id, station_id,
snmp_community, status, host_flag }));
mysqlUpdateData(sql,
Arrays.asList(new Object[] { host_id, host_name, host_ip, host_type_id, hostgroup_id, station_id,
snmp_community, status, host_flag }));
// insert monitor_hostgroup_info
sql = "replace into " + hostgroup_info
+ "(hostgroup_id, station_id,hostgroup_name, module_id, nagios_id, hostgroup_flag) values(?,?,?,?,?,?)";
tddlUpdateData(sql,
Arrays.asList(new Object[] { hostgroup_id, gstation_id, hostgroup_name, module_id, nagios_id,
hostgroup_flag }));
mysqlUpdateData(sql,
Arrays.asList(new Object[] { hostgroup_id, gstation_id, hostgroup_name, module_id, nagios_id,
hostgroup_flag }));
}
@After
public void destory() throws Exception {
psConRcRsClose(rc, rs);
}
// private static void prepare(String insert, Object[] args) throws
// Exception {
// ResultCursor rc = execute(null, insert, Arrays.asList(args));
// Assert.assertEquals(Integer.valueOf(1), rc.getIngoreTableName(rc.next(),
// ResultCursor.AFFECT_ROW));
// Assert.assertNull(rc.getException());
// rc.close();
// }
/**
* 三表join,直接在from后面跟三张表(不指点join类型)where a.module_id = c.module_id and
* c.hostgroup_id = b.hostgroup_id and b.status=status
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinA() throws Exception {
String sql = "select a.module_name as appname ,a.applevel as applevel, b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from "
+ module_info
+ " a ,"
+ ""
+ host_info
+ " b ,"
+ hostgroup_info
+ " c "
+ "where a.module_id = c.module_id and c.hostgroup_id = b.hostgroup_id and b.status='"
+ status
+ "'";
String[] columnParam = { "APPNAME", "HOSTIP", "STATIONID", "HOSTGROUPNAME", "applevel" };
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and a.applevel=applevel and
* c.nagios_id=nagios_id
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinA1() throws Exception {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + host_info + " b ," + "" + module_info + " a ,"
+ hostgroup_info + " c "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and a.applevel='"
+ applevel + "' and c.nagios_id=" + nagios_id;
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and b.status=status
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinB() throws Exception {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + host_info + " b ,"
+ hostgroup_info + " c "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status
+ "'";
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and b.status=status and
* a.applevel=applevel and c.nagios_id=nagios_id
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinB1() throws Exception {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + host_info + " b ,"
+ hostgroup_info + " c "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status
+ "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id;
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* c.hostgroup_id = b.hostgroup_id and b.status=status
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinC() throws Exception {
// bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询
if (module_info.contains("mysql")) {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info
+ " c, " + host_info + " b "
+ "where c.module_id = a.module_id and c.hostgroup_id = b.hostgroup_id and b.status='"
+ status + "'";
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and b.status=status and
* a.applevel=applevel and c.nagios_id=nagios_id
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinC1() throws Exception {
// bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询
if (module_info.contains("mysql")) {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info
+ " c, " + host_info + " b "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='"
+ status + "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id;
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and b.status=status
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinD() throws Exception {
// bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询
if (module_info.contains("mysql")) {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info
+ " c, " + host_info + " b "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='"
+ status + "'";
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
}
/**
* 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and
* b.hostgroup_id = c.hostgroup_id and b.status=status and
* a.applevel=applevel and c.nagios_id=nagios_id
*
* @author zhuoxue
* @since 5.0.1
*/
@Test
public void testJoinD1() throws Exception {
// bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询
if (module_info.contains("mysql")) {
String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid,"
+ "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info
+ " c, " + host_info + " b "
+ "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='"
+ status + "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id;
selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST);
}
}
}
| [
"[email protected]"
] | |
bcbbbeda4917fda1ca2c530690603444728f9137 | 694fda5049cb91d8f3631a4832e714d18152cf8c | /Slumber Time/src/edu/northwestern/cbits/intellicare/slumbertime/SettingsActivity.java | 213a0a9e5dfeb34bd730f14c625ad4058b32c58e | [] | no_license | cbitstech/Intellicare-Template | c3a5d0f34a6690f0629f24dec517f829b1baab97 | d2fdf3171bf6558c88a9111096c6f353e92149c0 | refs/heads/master | 2016-09-07T10:37:53.505475 | 2014-07-23T17:22:58 | 2014-07-23T17:22:58 | 12,496,363 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 2,850 | java | package edu.northwestern.cbits.intellicare.slumbertime;
import java.util.HashMap;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.widget.TimePicker;
import edu.northwestern.cbits.intellicare.ConsentedActivity;
import edu.northwestern.cbits.intellicare.logging.LogManager;
public class SettingsActivity extends PreferenceActivity
{
@SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setTitle(R.string.title_settings);
this.addPreferencesFromResource(R.layout.activity_settings);
}
public void onResume()
{
super.onResume();
HashMap<String, Object> payload = new HashMap<String, Object>();
LogManager.getInstance(this).log("opened_settings", payload);
}
public void onPause()
{
HashMap<String, Object> payload = new HashMap<String, Object>();
LogManager.getInstance(this).log("closed_settings", payload);
super.onPause();
}
@SuppressWarnings("deprecation")
public boolean onPreferenceTreeClick (PreferenceScreen screen, Preference preference)
{
String key = preference.getKey();
if (key == null)
{
}
else if (key.equals("settings_reminder_time"))
{
final SettingsActivity me = this;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
TimePickerDialog dialog = new TimePickerDialog(this, new OnTimeSetListener()
{
public void onTimeSet(TimePicker arg0, int hour, int minute)
{
Editor editor = prefs.edit();
editor.putInt(AlarmService.REMINDER_HOUR, hour);
editor.putInt(AlarmService.REMINDER_MINUTE, minute);
editor.commit();
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put("hour", hour);
payload.put("minute", minute);
payload.put("source", "settings");
payload.put("full_mode", prefs.getBoolean("settings_full_mode", true));
LogManager.getInstance(me).log("set_reminder_time", payload);
}
}, prefs.getInt(AlarmService.REMINDER_HOUR, 9), prefs.getInt(AlarmService.REMINDER_MINUTE, 0), DateFormat.is24HourFormat(this));
dialog.show();
return true;
}
else if (key.equals("copyright_statement"))
ConsentedActivity.showCopyrightDialog(this);
return super.onPreferenceTreeClick(screen, preference);
}
}
| [
"[email protected]"
] | |
e4a9659db543a8e0e547694c15ded2ab5f3cc082 | cc8d194313b9c99c86b62b421abe77bd329dba67 | /test/cellsTest2.java | b7a76289a25ae310f1beb78616b1973ba4cc3269 | [] | no_license | RogerTorra/SpreadsheetA | 2e69c2ba9d7ca377b9b35b0a5975a0f9cb7f95bb | 3a897522bb82be908dcc46d972828a22dba9af51 | refs/heads/master | 2021-01-19T06:32:51.308351 | 2014-05-01T16:23:12 | 2014-05-01T16:23:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 900 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import spreadsheet.SomeValue;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Before;
import spreadsheet.Expression;
import static spreadsheet.Spreadsheet.*;
/**
*
* @author rtv1
*/
public class cellsTest2 {
@Before
public void setup(){
//put("a3",plus(1.0,1.0));
put("a2",plus("a0","a1"));
}
@Test
public void cell_has_no_value_if_depends_on_empty_cells(){
assertFalse(get("a2").hasValue());
}
@Test
public void value_test(){
put("a0",1.0);
put("a1",1.0);
//assertEquals(new SomeValue(2.0), get("a3"));
assertEquals(new SomeValue(4.0), get("a2"));
}
public cellsTest2() {
}
}
| [
"[email protected]"
] | |
f4e8e0de5d8484dab93e1dc90ac6588c07e3c3da | beb2fbdd8e5343fe76c998824c7228a546884c5e | /com.kabam.marvelbattle/src/com/google/android/gms/tagmanager/cq.java | ed97f8eb36e5406b0013cad58b12427b609cd1c5 | [] | no_license | alamom/mcoc_11.2.1_store_apk | 4a988ab22d6c7ad0ca5740866045083ec396841b | b43c41d3e8a43f63863d710dad812774cd14ace0 | refs/heads/master | 2021-01-11T17:13:02.358134 | 2017-01-22T19:51:35 | 2017-01-22T19:51:35 | 79,740,812 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,613 | java | package com.google.android.gms.tagmanager;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import com.google.android.gms.internal.c.f;
import com.google.android.gms.internal.ol.a;
import com.google.android.gms.internal.pm;
import com.google.android.gms.internal.pn;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.json.JSONException;
class cq
implements o.f
{
private final String aoc;
private final ExecutorService aqA;
private bg<ol.a> aqt;
private final Context mContext;
cq(Context paramContext, String paramString)
{
this.mContext = paramContext;
this.aoc = paramString;
this.aqA = Executors.newSingleThreadExecutor();
}
private cr.c a(ByteArrayOutputStream paramByteArrayOutputStream)
{
Object localObject = null;
try
{
paramByteArrayOutputStream = ba.cG(paramByteArrayOutputStream.toString("UTF-8"));
return paramByteArrayOutputStream;
}
catch (UnsupportedEncodingException paramByteArrayOutputStream)
{
for (;;)
{
bh.S("Failed to convert binary resource to string for JSON parsing; the file format is not UTF-8 format.");
paramByteArrayOutputStream = (ByteArrayOutputStream)localObject;
}
}
catch (JSONException paramByteArrayOutputStream)
{
for (;;)
{
bh.W("Failed to extract the container from the resource file. Resource is a UTF-8 encoded string but doesn't contain a JSON container");
paramByteArrayOutputStream = (ByteArrayOutputStream)localObject;
}
}
}
private void d(ol.a parama)
throws IllegalArgumentException
{
if ((parama.gs == null) && (parama.ass == null)) {
throw new IllegalArgumentException("Resource and SupplementedResource are NULL.");
}
}
private cr.c k(byte[] paramArrayOfByte)
{
try
{
cr.c localc = cr.b(c.f.a(paramArrayOfByte));
paramArrayOfByte = localc;
if (localc != null)
{
bh.V("The container was successfully loaded from the resource (using binary file)");
paramArrayOfByte = localc;
}
}
catch (pm paramArrayOfByte)
{
for (;;)
{
bh.T("The resource file is corrupted. The container cannot be extracted from the binary file");
paramArrayOfByte = null;
}
}
catch (cr.g paramArrayOfByte)
{
for (;;)
{
bh.W("The resource file is invalid. The container from the binary file is invalid");
paramArrayOfByte = null;
}
}
return paramArrayOfByte;
}
public void a(bg<ol.a> parambg)
{
this.aqt = parambg;
}
public void b(final ol.a parama)
{
this.aqA.execute(new Runnable()
{
public void run()
{
cq.this.c(parama);
}
});
}
boolean c(ol.a parama)
{
boolean bool = false;
localFile = oS();
try
{
FileOutputStream localFileOutputStream = new java/io/FileOutputStream;
localFileOutputStream.<init>(localFile);
try
{
localFileOutputStream.close();
throw parama;
}
catch (IOException localIOException)
{
for (;;)
{
bh.W("error closing stream for writing resource to disk");
}
}
}
catch (FileNotFoundException parama)
{
for (;;)
{
try
{
localFileOutputStream.write(pn.f(parama));
bool = true;
}
catch (IOException parama)
{
parama = parama;
bh.W("Error writing resource to disk. Removing resource from disk.");
localFile.delete();
try
{
localFileOutputStream.close();
}
catch (IOException parama)
{
bh.W("error closing stream for writing resource to disk");
}
continue;
}
finally {}
try
{
localFileOutputStream.close();
return bool;
parama = parama;
bh.T("Error opening resource file for writing");
}
catch (IOException parama)
{
bh.W("error closing stream for writing resource to disk");
}
}
}
}
public cr.c ff(int paramInt)
{
for (;;)
{
try
{
localObject1 = this.mContext.getResources().openRawResource(paramInt);
bh.V("Attempting to load a container from the resource ID " + paramInt + " (" + this.mContext.getResources().getResourceName(paramInt) + ")");
}
catch (Resources.NotFoundException localNotFoundException)
{
Object localObject1;
ByteArrayOutputStream localByteArrayOutputStream;
bh.W("Failed to load the container. No default container resource found with the resource ID " + paramInt);
cr.c localc = null;
continue;
localc = k(localByteArrayOutputStream.toByteArray());
continue;
}
try
{
localByteArrayOutputStream = new java/io/ByteArrayOutputStream;
localByteArrayOutputStream.<init>();
cr.b((InputStream)localObject1, localByteArrayOutputStream);
localObject1 = a(localByteArrayOutputStream);
if (localObject1 == null) {
continue;
}
bh.V("The container was successfully loaded from the resource (using JSON file format)");
}
catch (IOException localIOException)
{
bh.W("Error reading the default container with resource ID " + paramInt + " (" + this.mContext.getResources().getResourceName(paramInt) + ")");
Object localObject2 = null;
}
}
return (cr.c)localObject1;
}
/* Error */
void oR()
{
// Byte code:
// 0: aload_0
// 1: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 4: ifnonnull +13 -> 17
// 7: new 232 java/lang/IllegalStateException
// 10: dup
// 11: ldc -22
// 13: invokespecial 235 java/lang/IllegalStateException:<init> (Ljava/lang/String;)V
// 16: athrow
// 17: aload_0
// 18: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 21: invokeinterface 240 1 0
// 26: ldc -14
// 28: invokestatic 111 com/google/android/gms/tagmanager/bh:V (Ljava/lang/String;)V
// 31: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce;
// 34: invokevirtual 252 com/google/android/gms/tagmanager/ce:oK ()Lcom/google/android/gms/tagmanager/ce$a;
// 37: getstatic 258 com/google/android/gms/tagmanager/ce$a:aqi Lcom/google/android/gms/tagmanager/ce$a;
// 40: if_acmpeq +15 -> 55
// 43: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce;
// 46: invokevirtual 252 com/google/android/gms/tagmanager/ce:oK ()Lcom/google/android/gms/tagmanager/ce$a;
// 49: getstatic 261 com/google/android/gms/tagmanager/ce$a:aqj Lcom/google/android/gms/tagmanager/ce$a;
// 52: if_acmpne +32 -> 84
// 55: aload_0
// 56: getfield 28 com/google/android/gms/tagmanager/cq:aoc Ljava/lang/String;
// 59: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce;
// 62: invokevirtual 264 com/google/android/gms/tagmanager/ce:getContainerId ()Ljava/lang/String;
// 65: invokevirtual 270 java/lang/String:equals (Ljava/lang/Object;)Z
// 68: ifeq +16 -> 84
// 71: aload_0
// 72: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 75: getstatic 276 com/google/android/gms/tagmanager/bg$a:apM Lcom/google/android/gms/tagmanager/bg$a;
// 78: invokeinterface 279 2 0
// 83: return
// 84: new 281 java/io/FileInputStream
// 87: astore_1
// 88: aload_1
// 89: aload_0
// 90: invokevirtual 142 com/google/android/gms/tagmanager/cq:oS ()Ljava/io/File;
// 93: invokespecial 282 java/io/FileInputStream:<init> (Ljava/io/File;)V
// 96: new 47 java/io/ByteArrayOutputStream
// 99: astore_2
// 100: aload_2
// 101: invokespecial 212 java/io/ByteArrayOutputStream:<init> ()V
// 104: aload_1
// 105: aload_2
// 106: invokestatic 215 com/google/android/gms/tagmanager/cr:b (Ljava/io/InputStream;Ljava/io/OutputStream;)V
// 109: aload_2
// 110: invokevirtual 225 java/io/ByteArrayOutputStream:toByteArray ()[B
// 113: invokestatic 286 com/google/android/gms/internal/ol$a:l ([B)Lcom/google/android/gms/internal/ol$a;
// 116: astore_2
// 117: aload_0
// 118: aload_2
// 119: invokespecial 288 com/google/android/gms/tagmanager/cq:d (Lcom/google/android/gms/internal/ol$a;)V
// 122: aload_0
// 123: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 126: aload_2
// 127: invokeinterface 291 2 0
// 132: aload_1
// 133: invokevirtual 292 java/io/FileInputStream:close ()V
// 136: ldc_w 294
// 139: invokestatic 111 com/google/android/gms/tagmanager/bh:V (Ljava/lang/String;)V
// 142: goto -59 -> 83
// 145: astore_1
// 146: ldc_w 296
// 149: invokestatic 65 com/google/android/gms/tagmanager/bh:S (Ljava/lang/String;)V
// 152: aload_0
// 153: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 156: getstatic 276 com/google/android/gms/tagmanager/bg$a:apM Lcom/google/android/gms/tagmanager/bg$a;
// 159: invokeinterface 279 2 0
// 164: goto -81 -> 83
// 167: astore_1
// 168: ldc_w 298
// 171: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 174: goto -38 -> 136
// 177: astore_2
// 178: aload_0
// 179: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 182: getstatic 301 com/google/android/gms/tagmanager/bg$a:apN Lcom/google/android/gms/tagmanager/bg$a;
// 185: invokeinterface 279 2 0
// 190: ldc_w 303
// 193: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 196: aload_1
// 197: invokevirtual 292 java/io/FileInputStream:close ()V
// 200: goto -64 -> 136
// 203: astore_1
// 204: ldc_w 298
// 207: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 210: goto -74 -> 136
// 213: astore_2
// 214: aload_0
// 215: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg;
// 218: getstatic 301 com/google/android/gms/tagmanager/bg$a:apN Lcom/google/android/gms/tagmanager/bg$a;
// 221: invokeinterface 279 2 0
// 226: ldc_w 305
// 229: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 232: aload_1
// 233: invokevirtual 292 java/io/FileInputStream:close ()V
// 236: goto -100 -> 136
// 239: astore_1
// 240: ldc_w 298
// 243: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 246: goto -110 -> 136
// 249: astore_2
// 250: aload_1
// 251: invokevirtual 292 java/io/FileInputStream:close ()V
// 254: aload_2
// 255: athrow
// 256: astore_1
// 257: ldc_w 298
// 260: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V
// 263: goto -9 -> 254
// Local variable table:
// start length slot name signature
// 0 266 0 this cq
// 87 46 1 localFileInputStream java.io.FileInputStream
// 145 1 1 localFileNotFoundException FileNotFoundException
// 167 30 1 localIOException1 IOException
// 203 30 1 localIOException2 IOException
// 239 12 1 localIOException3 IOException
// 256 1 1 localIOException4 IOException
// 99 28 2 localObject1 Object
// 177 1 2 localIOException5 IOException
// 213 1 2 localIllegalArgumentException IllegalArgumentException
// 249 6 2 localObject2 Object
// Exception table:
// from to target type
// 84 96 145 java/io/FileNotFoundException
// 132 136 167 java/io/IOException
// 96 132 177 java/io/IOException
// 196 200 203 java/io/IOException
// 96 132 213 java/lang/IllegalArgumentException
// 232 236 239 java/io/IOException
// 96 132 249 finally
// 178 196 249 finally
// 214 232 249 finally
// 250 254 256 java/io/IOException
}
File oS()
{
String str = "resource_" + this.aoc;
return new File(this.mContext.getDir("google_tagmanager", 0), str);
}
public void oc()
{
this.aqA.execute(new Runnable()
{
public void run()
{
cq.this.oR();
}
});
}
public void release()
{
try
{
this.aqA.shutdown();
return;
}
finally
{
localObject = finally;
throw ((Throwable)localObject);
}
}
}
/* Location: C:\tools\androidhack\com.kabam.marvelbattle\classes.jar!\com\google\android\gms\tagmanager\cq.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
1bc08f81c35591378d537396b53d877f196f8b0f | cecc61169b2949b9ad1cfc91d24690595cc897ce | /src/main/java/com/china/mybootstrap/dao/UsrMapper.java | 7516394795cffef9261795f1f8fe31eab65de978 | [] | no_license | li1xiang/mybootstrap | c83804818e5b98e9d7b28c7f86dd70605ccc84f7 | 3eb3c97a0075c2a45d097e700f9ebcd6724e7a66 | refs/heads/master | 2022-10-27T13:21:01.499961 | 2019-07-31T15:11:07 | 2019-07-31T15:11:07 | 199,878,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 807 | java | package com.china.mybootstrap.dao;
import com.china.mybootstrap.entity.Usr;
import com.china.mybootstrap.entity.UsrExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UsrMapper {
long countByExample(UsrExample example);
int deleteByExample(UsrExample example);
int deleteByPrimaryKey(Integer usrId);
int insert(Usr record);
int insertSelective(Usr record);
List<Usr> selectByExample(UsrExample example);
Usr selectByPrimaryKey(Integer usrId);
int updateByExampleSelective(@Param("record") Usr record, @Param("example") UsrExample example);
int updateByExample(@Param("record") Usr record, @Param("example") UsrExample example);
int updateByPrimaryKeySelective(Usr record);
int updateByPrimaryKey(Usr record);
} | [
"[email protected]"
] | |
49a6dda50f928ccce33bf541f4692b4a40dcc335 | 53ca207904e6c7ab573d9e81b61b593cbe076ef1 | /veterinaria/src/trasveterinaria/dao/ComprobantesDAO.java | 6fcc958562b46662455348c529c355c86d6e4fee | [] | no_license | aknarf/veterinaria-upc-201401 | 96cfa45f8f240bc7a4bda0e35da771e2e82b97a2 | c4cadf0e2dc416490125c688e15c488f965f7866 | refs/heads/master | 2021-01-02T09:15:11.137258 | 2014-08-09T17:30:41 | 2014-08-09T17:30:41 | 38,780,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,492 | java | package trasveterinaria.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import trasveterinaria.excepcion.DAOExcepcion;
import trasveterinaria.modelo.Citas;
import trasveterinaria.modelo.Comprobantes;
import trasveterinaria.util.ConexionBD;
public class ComprobantesDAO extends BaseDAO {
public void insertar (Comprobantes vo) throws DAOExcepcion {
String query = "insert into comprobantes " +
"(NroComprobante,serie,Correlativo,Tipo,direccion,fechaRegistro,Citas_nroCita)" +
"values (?,?,?,?,?,?,?)";
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = ConexionBD.obtenerConexion();
stmt = con.prepareStatement(query);
stmt.setInt(1, vo.getNroComprobante());
stmt.setString(2, vo.getSerie());
stmt.setString(3, vo.getCorrelativo());
stmt.setString(4, vo.getTipo());
stmt.setString(5, vo.getDireccion());
stmt.setString(6, vo.getFechaRegistro());
stmt.setInt(7, vo.getNroCita());
//stmt.setString(2, vo.getNombre());
int i = stmt.executeUpdate();
if (i != 1) {
throw new SQLException("No se pudo insertar");
}
} catch (SQLException e) {
System.err.println(e.getMessage());
throw new DAOExcepcion(e.getMessage());
} finally {
this.cerrarResultSet(rs);
this.cerrarStatement(stmt);
this.cerrarConexion(con);
}
}
}
| [
"[email protected]"
] | |
5456ae30aeb7d9ae8d7f5ea8767d0ca08ea81287 | bddaae4327543483799fc6be3010e1f95f7b02cd | /src/main/java/com/hillel/bugtracker/BugTrackerApplication.java | eb61598bbfef5f181eb00fe13a1cf46815b1bdc2 | [] | no_license | AbidSaleh/Spring-Boot-BugTracker | 20acc0509f03b818d384ea21ac0d28d6a219a6a1 | 1d018c0f83c5f31e9526984e5298b3d36ec8b047 | refs/heads/master | 2022-04-09T20:50:19.430968 | 2020-03-18T07:50:59 | 2020-03-18T07:50:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 723 | java | package com.hillel.bugtracker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaRepositories
@EnableAutoConfiguration
public class BugTrackerApplication {
public static void main(String[] args) {
SpringApplication.run(BugTrackerApplication.class, args);
}
}
| [
"[email protected]"
] | |
bc3217ccf5ff49b8de8ff99d7d0c15d192138b4e | a348e363cf746bd77c2e6a3e48b7f04ad2fae959 | /src/PenTest.java | b117996c904369f31d5cf647a31e395b974b7460 | [] | no_license | nik-rusak/qaacademy | 00a9f68fba19b240d259aff55f33ad65a790bbc8 | 9b7a30f87c35804d81e927a03b5dcda7d38a0809 | refs/heads/master | 2021-01-10T06:27:37.891183 | 2015-11-25T07:28:29 | 2015-11-25T09:47:12 | 46,844,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,214 | java | import org.testng.Assert;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
* Created by n.rusak on 24.11.2015.
*/
public class PenTest {
@Test
public void testGetColorBlack() throws Exception {
Assert.assertEquals(new Pen(1000,1,"BLACK").getColor(), "BLACK");
}
@Test
public void testGetColorBlue() throws Exception {
Assert.assertEquals(new Pen(1000, 1, "BLUE").getColor(),"BLUE");
}
@Test
public void testGetColorNull() throws Exception {
Assert.assertEquals(new Pen(1000, 1, "").getColor(), "");
}
@Test
public void testIsWorkPositive() throws Exception {
assertTrue(new Pen(1000, 1, "GREEN").isWork());
}
@Test
public void testIsWorkNegative() throws Exception {
assertFalse(new Pen(-1000, 1, "GREEN").isWork());
}
@Test
public void testIsWorkNull() throws Exception {
assertFalse(new Pen(0, 1, "GREEN").isWork());
}
@Test
public void testWriteEmptyPen() throws Exception {
Assert.assertEquals(new Pen(0, 1, "BLACK").write("Something"), "");
}
@Test
public void testWriteNull() throws Exception {
Assert.assertEquals(new Pen(1000,1,"BLACK").write(""), "");
}
@Test
public void testWriteUsual() throws Exception {
Assert.assertEquals(new Pen(200,1,"BLACK").write("Something"), "Something");
}
@Test
public void testWriteNotEnough() throws Exception {
Assert.assertEquals(new Pen(2,1,"BLACK").write("Something"), "So");
}
@Test
public void testWriteNotEnoughBigLetters() throws Exception {
Assert.assertEquals(new Pen(6,3,"BLACK").write("Something"), "So");
}
@Test
public void testWriteEnoughBigLetters() throws Exception {
Assert.assertEquals(new Pen(1000,2,"BLACK").write("Something"), "Something");
}
@Test
public void testWriteNegativeInk() throws Exception {
Assert.assertEquals(new Pen(-1,1,"BLACK").write("Something"), "");
}
@Test
public void testWriteNegativeSize() throws Exception {
Assert.assertEquals(new Pen(10,-1,"BLACK").write("Something"), "");
}
@Test
public void testWriteNullSize() throws Exception {
Assert.assertEquals(new Pen(10,0,"BLACK").write("Something"), "");
}
@Test
public void testWriteSecondWord() throws Exception {
Pen pen = new Pen(100,1,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "world");
}
@Test
public void testWriteSecondWordNotEnough() throws Exception {
Pen pen = new Pen(6,1,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "w");
}
@Test
public void testWriteSecondWordNotEnoughBigLetters() throws Exception {
Pen pen = new Pen(12,2,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "w");
}
@Test
public void testWriteSecondWordEmpty() throws Exception {
Pen pen = new Pen(5,1,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "");
}
@Test
public void testWriteSecondWordNegativeInk() throws Exception {
Pen pen = new Pen(-1,1,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "");
}
@Test
public void testWriteSecondWordNegativeSize() throws Exception {
Pen pen = new Pen(1,-1,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "");
}
@Test
public void testWriteSecondWordNullSize() throws Exception {
Pen pen = new Pen(1,0,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "");
}
@Test
public void testWriteSecondWordEnoughBigLetters() throws Exception {
Pen pen = new Pen(20,2,"BLACK");
pen.write("Hello");
Assert.assertEquals(pen.write("world"), "world");
}
@Test
public void testWriteSecondWordEnoughSmallLetters() throws Exception {
Pen pen = new Pen(1,0.2,"BLACK");
pen.write("Test");
Assert.assertEquals(pen.write("Test1"), "T");
}
} | [
"[email protected]"
] | |
d6e3a95e31689869b7ab2e713b0975e3d9c5c442 | fc7e53847869e06c99a2a844c78eeb71dabf2cad | /practise/src/_28_OverloadedConstructors/Pizza.java | 3dfd3b62589f540dc967b5ca5e2a0eff7568ac08 | [] | no_license | loquy/java-core | ca670eb6661ebeadb46bc82b802c58b5beb20d42 | 223ed928dd48e210f4071e52287b7b5b2b25246a | refs/heads/main | 2023-08-05T02:30:14.243286 | 2021-09-19T02:35:02 | 2021-09-19T02:35:02 | 407,595,887 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 480 | java | package _28_OverloadedConstructors;
public class Pizza {
String bread;
String sauce;
String cheese;
String topping;
Pizza(String bread, String sauce, String cheese) {
this.bread = bread;
this.sauce = sauce;
this.cheese = cheese;
}
Pizza(String bread, String sauce, String cheese, String topping) {
this.bread = bread;
this.sauce = sauce;
this.cheese = cheese;
this.topping = topping;
}
}
| [
"[email protected]"
] | |
cb80c6332140df7e2489b94e7573c99979d96cff | 3ec81e2880f7abb468de5a9b832ee495242678d2 | /app/src/androidTest/java/com/example/invoicetextdetector/ExampleInstrumentedTest.java | 86d2a2264b4820d52498a16f1d6235ab69b877f5 | [] | no_license | NEETI9952/TextRecognizer | 6ae3ee792acbdfebf159640b050162c86583ab9f | afd85bee379861aa3b099526fbdf00ab7a587993 | refs/heads/master | 2023-03-16T18:46:25.649993 | 2021-03-06T07:27:41 | 2021-03-06T07:27:41 | 343,415,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 776 | java | package com.example.invoicetextdetector;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.invoicetextdetector", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
31328daeed2a80ef49a2cc984553be82669ed508 | 5a66b6809a3cddced0e84b56a8cf3a612a78989f | /TestNg_DataDriven_Framework/src/main/java/User_Login/Login.java | 2b13dc0ab0daa96d0671e4fbe3f977289f982ba8 | [] | no_license | Vampire010/DDF | 338d3252f9c1dd7131f0ef80ea67ba337594217b | c0b395a58c8f9f7f070c64b07f40fa27b71c547a | refs/heads/master | 2023-08-25T01:45:14.147783 | 2021-10-22T16:15:34 | 2021-10-22T16:15:34 | 419,163,600 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 700 | java | package User_Login;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import Browser_Configuration.Launch_Browsers;
import Browser_Configuration.Page_Assertions;
public class Login extends Launch_Browsers
{
public void login_page(String Username , String Password)
{
WebElement Usrname = driver.findElement(By.id("username"));
Usrname.sendKeys(Username);
WebElement Usrpassword = driver.findElement(By.id("password"));
Usrpassword.sendKeys(Password);
WebElement Location_session = driver.findElement(By.id("Registration Desk"));
Location_session.click();
WebElement Lobin_btn = driver.findElement(By.id("loginButton"));
Lobin_btn.click();
}
}
| [
"[email protected]"
] | |
001fe34b688e35fd2aa8eb4a064373aeb3455ad6 | bc98d806362fe82f5a235134bbde911e517a29fe | /src/grapher/ui/Main.java | de2b9a8f1ca66542216289ee74bed48c4eb24055 | [] | no_license | monthebrice2000/ihm | 9dcdd650a8f3f4375ce539d2019374af49613d6f | 5e4c2c73aabafb0403ab97c36879c1d546dbc6ed | refs/heads/main | 2023-08-31T09:12:06.661372 | 2021-10-25T14:37:44 | 2021-10-25T14:37:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,428 | java | /* grapher.ui.Main
* (c) [email protected] 2021– */
package grapher.ui;
import grapher.fc.Function;
import grapher.fc.FunctionFactory;
import javax.swing.*;
import javax.swing.JSplitPane;
import javax.swing.border.Border;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Arrays;
// main that launch a grapher.ui.Grapher
public class Main extends JFrame {
Main(String title, String[] expressions) {
super(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Grapher grapher = new Grapher();
String[] ex = {"sin(x)", "cos(x)", "tan(x)"};
for(String expression: ex) {
grapher.add(expression);
}
Interaction i = new Interaction( grapher );
grapher.addMouseListener( i );
grapher.addMouseMotionListener( i );
add(grapher);
javax.swing.JSplitPane splitPane = new javax.swing.JSplitPane( javax.swing.JSplitPane.HORIZONTAL_SPLIT );
DefaultListModel<String> model = new DefaultListModel<>();
JList<String> myList = new JList<String>( model );
model.addAll(Arrays.asList(ex));
splitPane.setRightComponent( grapher );
JButton button1 = new JButton("+");
JButton button2 = new JButton("-");
JPanel panel = new JPanel();
JPanel buttonsPanel = new JPanel();
splitPane.setLeftComponent( panel );
panel.setLayout( new GridLayout( 2,1));
panel.add( myList);
panel.add( buttonsPanel );
buttonsPanel.setLayout( new GridLayout(1,2));
buttonsPanel.add( button1 );
buttonsPanel.add( button2 );
splitPane.setDividerSize( 10 );
splitPane.setDividerLocation( 100 );
splitPane.setOneTouchExpandable( true );
splitPane.addMouseListener( i );
add( splitPane );
myList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
if( myList.getSelectionModel().getMinSelectionIndex( ) >= 0 ){
System.out.println( "+++++"+model.get( myList.getSelectionModel().getMinSelectionIndex() ) );
String selectedItem = myList.getSelectedValue().toString();
Function f = FunctionFactory.createFunction( selectedItem );
grapher.setSelectedFunctions( f );
}
}
}
});
//ToolbarClass toolbar = new ToolbarClass();
//toolbar.createAndShowGUI();
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if( action.equals( "+" ) ){
System.out.println( "J'ajoute une fonction");
}
}
});
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
ListSelectionModel selmodel = myList.getSelectionModel();
int index = selmodel.getMinSelectionIndex();
if (index >= 0)
System.out.println( index );
System.out.println( model );
model.removeElementAt( index );
grapher.removeFunctionByClicked();
myList.setSelectedIndex( model.getSize() - 1 );
}
});
pack();
}
public static void main(String[] argv) {
final String[] expressions = argv;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Main("grapher", expressions).setVisible(true);
}
});
}
}
| [
"[email protected]"
] | |
9fa5670b26eeb6f84762e3764d27d001cfda9586 | 75c4712ae3f946db0c9196ee8307748231487e4b | /src/main/java/com/alipay/api/response/AlipayCommerceDataResultSendResponse.java | 285dc2a1043abda5d342f1efb77aab1f17b0ef35 | [
"Apache-2.0"
] | permissive | yuanbaoMarvin/alipay-sdk-java-all | 70a72a969f464d79c79d09af8b6b01fa177ac1be | 25f3003d820dbd0b73739d8e32a6093468d9ed92 | refs/heads/master | 2023-06-03T16:54:25.138471 | 2021-06-25T14:48:21 | 2021-06-25T14:48:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 375 | java | package com.alipay.api.response;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.commerce.data.result.send response.
*
* @author auto create
* @since 1.0, 2019-01-07 20:51:15
*/
public class AlipayCommerceDataResultSendResponse extends AlipayResponse {
private static final long serialVersionUID = 7489223471598993392L;
}
| [
"[email protected]"
] | |
4571be5a5e34e2c787c9e6987df2856f106746f2 | b5cc497b581f0775dedde5ebd5ed2a7c82d17c5b | /src/main/java/com/cctv/peoplay/admin/goods/model/dto/GoodsCategoryDTO.java | de7a674640eae2c5921920af4e7a3b6f21557a8d | [] | no_license | clzlckzkch1509/peoPlay | dd131b482adbf5f560b0c06d9f37287ecae2ce8f | 6d2131bb1167d502d7375428aa5f19fdaaf12bf1 | refs/heads/master | 2023-06-07T01:07:19.592413 | 2021-07-06T02:31:37 | 2021-07-06T02:31:37 | 373,686,005 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 896 | java | package com.cctv.peoplay.admin.goods.model.dto;
public class GoodsCategoryDTO {
private int goodsCategoryNum;
private String goodsCategoryName;
public int getGoodsCategoryNum() {
return goodsCategoryNum;
}
public void setGoodsCategoryNum(int goodsCategoryNum) {
this.goodsCategoryNum = goodsCategoryNum;
}
public String getGoodsCategoryName() {
return goodsCategoryName;
}
public void setGoodsCategoryName(String goodsCategoryName) {
this.goodsCategoryName = goodsCategoryName;
}
@Override
public String toString() {
return "GoodsCategoryDTO [goodsCategoryNum=" + goodsCategoryNum + ", goodsCategoryName=" + goodsCategoryName
+ "]";
}
public GoodsCategoryDTO() {
}
public GoodsCategoryDTO(int goodsCategoryNum, String goodsCategoryName) {
this.goodsCategoryNum = goodsCategoryNum;
this.goodsCategoryName = goodsCategoryName;
}
}
| [
"[email protected]"
] | |
231a73387fcb6d34959c2a9c371c33922ccb4263 | cd6e8f2f067f69b17f1050f793ffdfe0906efafb | /MeuPrograma/src/meuprograma/MeuPrograma.java | dee25fde558743fe07f4292a7082688faf2e0857 | [] | no_license | eudavidavi/Faculdade-UVA | 65ceb69a8f9b4eea02559c19d47309f3eb5e0d30 | 13df7829dd4239e9700e4467bea1fcbe3ca08812 | refs/heads/main | 2023-03-18T11:22:03.738662 | 2021-03-06T23:46:09 | 2021-03-06T23:46:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 825 | java | package meuprograma;
public class MeuPrograma {
public static void main(String[] args) {
Computador pc1 = new Computador();
Computador pc2 = new Computador();
Computador pc3 = new Computador("", "", 0, 0, false);
Computador pc4 = new Computador("", "", 0, 0, false);
System.out.println("Pc 1");
pc1.pegarDados();
System.out.println("Pc 2");
pc2.pegarDados();
System.out.println("Pc 3");
pc3.pegarDados();
System.out.println("Pc 4");
pc4.pegarDados();
System.out.println("Pc 1");
pc1.imprimir();
System.out.println("Pc 2");
pc2.imprimir();
System.out.println("Pc 3");
pc3.imprimir();
System.out.println("Pc 4");
pc4.imprimir();
}
}
| [
"[email protected]"
] | |
c866edb9f784f8856f4e3ed69a1c0563cb1e1380 | 5b9b654e77c1562a367254461c0b6e5933be31c5 | /src/LeetCode226.java | 9aef96f2a0eddbe7e5a33b7d4a92200be8181762 | [] | no_license | sparkfengbo/LeetcodeSourceJava | 865d7328899d09b5e1b7164edb2a6a91b4a48e4a | 26b6e5f827822a18a0482623acb24fe363cd9374 | refs/heads/master | 2022-05-30T15:10:42.561864 | 2022-05-18T04:56:57 | 2022-05-18T04:56:57 | 146,726,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,808 | java | import datastruct.TreeNode;
/**
* 翻转二叉树
*
* 翻转一棵二叉树。
*
* 示例:
*
* 输入:
*
* 4
* / \
* 2 7
* / \ / \
* 1 3 6 9
* 输出:
*
* 4
* / \
* 7 2
* / \ / \
* 9 6 3 1
* 备注:
* 这个问题是受到 Max Howell 的 原问题 启发的 :
*
* 谷歌:我们90%的工程师使用您编写的软件(Homebrew),但是您却无法在面试时在白板上写出翻转二叉树这道题,这太糟糕了。
*/
public class LeetCode226 {
public static void main(String[] args) {
TreeNode root = new TreeNode(4);
TreeNode node1 = new TreeNode(2);
TreeNode node2 = new TreeNode(7);
root.left = node1;
root.right = node2;
TreeNode node3 = new TreeNode(1);
TreeNode node4 = new TreeNode(3);
node1.left = node3;
node1.right = node4;
TreeNode node5 = new TreeNode(6);
TreeNode node6 = new TreeNode(9);
node2.left = node5;
node2.right = node6;
TreeNode result = invertTree(root);
System.out.println();
}
public static TreeNode invertTree(TreeNode root) {
if (root == null) {
return null;
}
if (root.left != null && root.right != null) {
TreeNode tmp = root.left;
root.left = root.right;
root.right = tmp;
invertTree(root.left);
invertTree(root.right);
} else if (root.left == null) {
root.left = root.right;
root.right = null;
invertTree(root.left);
} else if (root.right == null) {
root.right = root.left;
root.left = null;
invertTree(root.right);
}
return root;
}
}
| [
"[email protected]"
] | |
fc59cb6bf35c06dee0fc33052d21faa7cced88f5 | b653c6d0bbe1094a65474aa0524226808cf39184 | /src/main/java/com/dotaciones/service/model/Dispositivo.java | 32fe8bb53393a85f9eff246e9a10fffbb9a60103 | [] | no_license | nikodius/ApiRestDotaciones | 388b7d8d312c2d7f0f01c4e96d82637cbe70db92 | 61db87ca2662070e1a8285a99a2f051b3fb1ea70 | refs/heads/main | 2023-07-23T18:26:10.827546 | 2021-08-24T16:43:32 | 2021-08-24T16:43:32 | 399,537,125 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,853 | java | package com.dotaciones.service.model;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name = "dispositivos")
public class Dispositivo {
@Id
private String serial;
@Column(name = "nombre")
private String nombre;
@Column(name = "so")
private String so;
@OneToOne(mappedBy = "dispositivo", cascade = CascadeType.ALL)
private Asignacion asignacion;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "fk_tipo")
private TipoDispositivo tipoDispositivo;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "fk_propietario")
private Propietario propietario;
public Dispositivo(String serial, String nombre, TipoDispositivo tipoDispositivo,
Propietario propietario) {
super();
this.serial = serial;
this.nombre = nombre;
this.tipoDispositivo = tipoDispositivo;
this.propietario = propietario;
}
public Dispositivo() {
super();
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Asignacion getAsignacion() {
return asignacion;
}
public void setAsignacion(Asignacion asignacion) {
this.asignacion = asignacion;
}
public TipoDispositivo getTipoDispositivo() {
return tipoDispositivo;
}
public void setTipoDispositivo(TipoDispositivo tipoDispositivo) {
this.tipoDispositivo = tipoDispositivo;
}
public Propietario getPropietario() {
return propietario;
}
public void setPropietario(Propietario propietario) {
this.propietario = propietario;
}
}
| [
"[email protected]"
] | |
1384ceb1ba965cc48d9cccf110148c67be915264 | c178a5e7564f53f9aa5fa0376c8e32f3d8563fb9 | /src/com/duanxr/yith/midium/MaximizeDistanceToClosestPerson.java | 4fcd81e664d03b8842fae974ce0d254f68538360 | [] | no_license | duanxr/Great-Algorithm-of-Yith | d775283648809a6f15bf4d7fa2f28c31551f0779 | 76110f9ce8e914f8deae8c18eba1cbf00b0d6e8a | refs/heads/master | 2021-12-01T10:20:29.155610 | 2021-11-23T02:56:24 | 2021-11-23T02:56:24 | 165,953,707 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,582 | java | package com.duanxr.yith.midium;
/**
* @author 段然 2021/3/8
*/
public class MaximizeDistanceToClosestPerson {
/**
* You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
*
* There is at least one empty seat, and at least one person sitting.
*
* Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.
*
* Return that maximum distance to the closest person.
*
*
*
* Example 1:
*
*
* Input: seats = [1,0,0,0,1,0,1]
* Output: 2
* Explanation:
* If Alex sits in the second open seat (i.e. seats[2]), then the closest person has distance 2.
* If Alex sits in any other open seat, the closest person has distance 1.
* Thus, the maximum distance to the closest person is 2.
* Example 2:
*
* Input: seats = [1,0,0,0]
* Output: 3
* Explanation:
* If Alex sits in the last seat (i.e. seats[3]), the closest person is 3 seats away.
* This is the maximum distance possible, so the answer is 3.
* Example 3:
*
* Input: seats = [0,1]
* Output: 1
*
*
* Constraints:
*
* 2 <= seats.length <= 2 * 104
* seats[i] is 0 or 1.
* At least one seat is empty.
* At least one seat is occupied.
*
* 给你一个数组 seats 表示一排座位,其中 seats[i] = 1 代表有人坐在第 i 个座位上,seats[i] = 0 代表座位 i 上是空的(下标从 0 开始)。
*
* 至少有一个空座位,且至少有一人已经坐在座位上。
*
* 亚历克斯希望坐在一个能够使他与离他最近的人之间的距离达到最大化的座位上。
*
* 返回他到离他最近的人的最大距离。
*
*
*
* 示例 1:
*
*
* 输入:seats = [1,0,0,0,1,0,1]
* 输出:2
* 解释:
* 如果亚历克斯坐在第二个空位(seats[2])上,他到离他最近的人的距离为 2 。
* 如果亚历克斯坐在其它任何一个空位上,他到离他最近的人的距离为 1 。
* 因此,他到离他最近的人的最大距离是 2 。
* 示例 2:
*
* 输入:seats = [1,0,0,0]
* 输出:3
* 解释:
* 如果亚历克斯坐在最后一个座位上,他离最近的人有 3 个座位远。
* 这是可能的最大距离,所以答案是 3 。
* 示例 3:
*
* 输入:seats = [0,1]
* 输出:1
*
*
* 提示:
*
* 2 <= seats.length <= 2 * 104
* seats[i] 为 0 或 1
* 至少有一个 空座位
* 至少有一个 座位上有人
*
*/
class Solution {
public int maxDistToClosest(int[] seats) {
return Math.max(Math.max(lDis(seats), mDis(seats)), rDis(seats));
}
private int mDis(int[] seats) {
int count = 0;
int max = Integer.MIN_VALUE;
for (int seat : seats) {
if (seat == 0) {
count++;
} else {
if (count > max) {
max = count;
}
count = 0;
}
}
return (max + 1) / 2;
}
private int lDis(int[] seats) {
int count = 0;
for (int seat : seats) {
if (seat != 0) {
return count;
}
count++;
}
return count;
}
private int rDis(int[] seats) {
int count = 0;
for (int i = seats.length - 1; i >= 0; i--) {
if (seats[i] != 0) {
return count;
}
count++;
}
return count;
}
}
}
| [
"[email protected]"
] | |
9fae828c0a42d665c103bff3c807572bfe046594 | 5598faaaaa6b3d1d8502cbdaca903f9037d99600 | /code_changes/Apache_projects/HDFS-142/f0d8a5db10a28484ad3fcd66601475ebceee3c84/TestNameNodeMXBean.java | ec52d558b3e028e6aa7171cfcb81b294d1b17b93 | [] | no_license | SPEAR-SE/LogInBugReportsEmpirical_Data | 94d1178346b4624ebe90cf515702fac86f8e2672 | ab9603c66899b48b0b86bdf63ae7f7a604212b29 | refs/heads/master | 2022-12-18T02:07:18.084659 | 2020-09-09T16:49:34 | 2020-09-09T16:49:34 | 286,338,252 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,894 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.hadoop.hdfs.server.namenode;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
import org.junit.Test;
import junit.framework.Assert;
/**
* Class for testing {@link NameNodeMXBean} implementation
*/
public class TestNameNodeMXBean {
@Test
public void testNameNodeMXBeanInfo() throws Exception {
Configuration conf = new Configuration();
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster(conf, 1, true, null);
cluster.waitActive();
FSNamesystem fsn = cluster.getNameNode().namesystem;
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName mxbeanName = new ObjectName("HadoopInfo:type=NameNodeInfo");
// get attribute "ClusterId"
String clusterId = (String) mbs.getAttribute(mxbeanName, "ClusterId");
Assert.assertEquals(fsn.getClusterId(), clusterId);
// get attribute "BlockpoolId"
String blockpoolId = (String) mbs.getAttribute(mxbeanName, "BlockpoolId");
Assert.assertEquals(fsn.getBlockpoolId(), blockpoolId);
// get attribute "Version"
String version = (String) mbs.getAttribute(mxbeanName, "Version");
Assert.assertEquals(fsn.getVersion(), version);
// get attribute "Used"
Long used = (Long) mbs.getAttribute(mxbeanName, "Used");
Assert.assertEquals(fsn.getUsed(), used.longValue());
// get attribute "Total"
Long total = (Long) mbs.getAttribute(mxbeanName, "Total");
Assert.assertEquals(fsn.getTotal(), total.longValue());
// get attribute "safemode"
String safemode = (String) mbs.getAttribute(mxbeanName, "Safemode");
Assert.assertEquals(fsn.getSafemode(), safemode);
// get attribute nondfs
Long nondfs = (Long) (mbs.getAttribute(mxbeanName, "NonDfsUsedSpace"));
Assert.assertEquals(fsn.getNonDfsUsedSpace(), nondfs.longValue());
// get attribute percentremaining
Float percentremaining = (Float) (mbs.getAttribute(mxbeanName,
"PercentRemaining"));
Assert.assertEquals(fsn.getPercentRemaining(), percentremaining
.floatValue());
// get attribute Totalblocks
Long totalblocks = (Long) (mbs.getAttribute(mxbeanName, "TotalBlocks"));
Assert.assertEquals(fsn.getTotalBlocks(), totalblocks.longValue());
// get attribute alivenodeinfo
String alivenodeinfo = (String) (mbs.getAttribute(mxbeanName,
"LiveNodes"));
Assert.assertEquals(fsn.getLiveNodes(), alivenodeinfo);
// get attribute deadnodeinfo
String deadnodeinfo = (String) (mbs.getAttribute(mxbeanName,
"DeadNodes"));
Assert.assertEquals(fsn.getDeadNodes(), deadnodeinfo);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
}
| [
"[email protected]"
] | |
aab43d2be59e5588310b6d44531f075f2c17719d | 42c19fee51d4b6b3283638cc9abad3d57c2f72c3 | /netw/TCPServer.java | 1891f91f29463928fa6ba22619e8b029b2142271 | [] | no_license | Mahmoud168/Network-projetc | 3cd8639cbd37dcfb8f014ae6c091c084cec1530d | 8fa656de1bea77553c9d0e5febb157119dc7a7f0 | refs/heads/master | 2020-05-07T20:38:38.082495 | 2019-04-17T21:59:45 | 2019-04-17T21:59:45 | 180,870,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 913 | java | package netw;
import java.io.*;
import java.net.*;
public class TCPServer {
public static void main(String argv[]) throws Exception
{
String clientSentence;
String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(6789);
while(true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient =
new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
DataOutputStream outToClient =
new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence);
}
}
}
| [
"[email protected]"
] | |
9783b4e457067d5be9f67759313083927966790b | 7a75c899fc8eaf97d195f8e05063d5f835bcf893 | /src/test/java/com/example/demo/LjhApplicationTests.java | b105e75dbdafdb852d1d9c5b964841d4fcb53ade | [] | no_license | silverljh/ljhdemo | 13f1c90840824c7fb8c6a5c9442fd5e368804c2f | 935b7b8c788fcf63a88c38f5ed346d7602cecbeb | refs/heads/master | 2021-05-23T10:23:33.741985 | 2020-04-05T13:29:11 | 2020-04-05T13:29:11 | 253,241,656 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 214 | java | package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class LjhApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
1b0dbfa649579987a04bed2487f987f0f01884c4 | b7bfc55d03983231e13737cc7ab53909172fa95f | /86.分隔链表.java | b87896c6ee23d9e5dbe7502860ad995f90d9a186 | [] | no_license | tunye/leetcode | 5d7dc6c943cc1ee0dd561469f8656f07baabe336 | bdb9c06b31f742494238b5408f49b71e96c25306 | refs/heads/master | 2022-11-22T13:17:36.427866 | 2020-07-27T05:54:14 | 2020-07-27T05:54:14 | 279,529,083 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,824 | java | // https://leetcode-cn.com/problems/partition-list
public class Solution {
public static class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
}
}
public ListNode partition(ListNode head, int x) {
ListNode small = new ListNode(-1);
ListNode smallList = small;
ListNode big = new ListNode(-1);
ListNode bigList = big;
while (head != null) {
if (head.val < x) {
smallList.next = head;
smallList = smallList.next;
} else {
bigList.next = head;
bigList = bigList.next;
}
head = head.next;
}
bigList.next = null;
smallList.next = big.next;
return small.next;
}
private void toString(ListNode listNode, StringBuilder stringBuilder) {
stringBuilder.append(listNode.val);
if (listNode.next != null) {
stringBuilder.append(" -> ");
toString(listNode.next, stringBuilder);
}
}
public static void main(String[] args) {
Solution solution = new Solution();
ListNode param = new ListNode(-1);
ListNode tmp = param;
tmp.next = new ListNode(9);
tmp = tmp.next;
tmp.next = new ListNode(3);
tmp = tmp.next;
tmp.next = new ListNode(4);
tmp = tmp.next;
tmp.next = new ListNode(1);
tmp = tmp.next;
tmp.next = new ListNode(15);
tmp = tmp.next;
tmp.next = new ListNode(7);
ListNode result = solution.partition(param.next, 6);
StringBuilder resultString = new StringBuilder();
solution.toString(result, resultString);
System.err.println("result " + resultString.toString());
}
} | [
"[email protected]"
] | |
1438bb67d7ebb5c8cb161f4f2659912dd2137169 | 544861597d2e8bb8eae50e411e0bbda47543a4ae | /app/src/main/java/cn/mark/frame/ui/fragment/ImageFragment.java | df21cdb89fe7d9017b94d9cc1f3b701279f6be61 | [] | no_license | ahkkfh/MyFrame | 0a199d351b46470fac0f9498cb431c1f02c9b7cd | f20b4dea833c3468fb6e9bcdb78c2653d6a0d510 | refs/heads/master | 2021-01-21T14:44:35.228065 | 2017-09-01T05:46:46 | 2017-09-01T05:46:46 | 59,712,251 | 5 | 2 | null | 2017-06-16T02:52:30 | 2016-05-26T02:11:06 | Java | UTF-8 | Java | false | false | 627 | java | package cn.mark.frame.ui.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import cn.mark.frame.R;
/***
* @author marks.luo
* @Description: TODO()
* @date:2017-04-07 14:06
*/
public class ImageFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_image,container,false);
}
}
| [
"[email protected]"
] | |
331f064a18d978b33a512490496fe3cfd3106c3f | c8ad41421ae5230a3f411f2c3e6691b51b5f1d9a | /TechnicalDictionary/src/main/java/com/techdict/app/dao/WordRepository.java | b554ed829422a5993e9a9de58bea4e8c84c0e786 | [
"MIT"
] | permissive | kopalbhatnagar05/Technical-Web-Dictionary | c49c80d95767c66159d9defc7b213b6fc0419c53 | 53484cc7090cf5673c2e5ddecb1e535f3071e51c | refs/heads/main | 2023-08-15T10:54:00.591359 | 2021-10-18T06:24:51 | 2021-10-18T06:24:51 | 418,363,852 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 293 | java | package com.techdict.app.dao;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import com.techdict.app.model.Word;
public interface WordRepository extends JpaRepository<Word, Integer> {
public Optional<Word> findByTitle(String title);
}
| [
"[email protected]"
] | |
9a242bfa9af3086363d0ee99bebbfb5d52c35058 | 6fdb33408e81beb11cdcbd5db20c3bd0d1fb44c2 | /Lesson2/Lab3/Task1to4/app/src/main/java/com/kat2n/practice_android/lesson2/lab3/task1to4/MainActivity.java | 9ab5a5c08a3ab23c69c2fe925f8bb06f4ed523b5 | [] | no_license | daisu8e/practice-android | f2b8e0a99598645434bc137bdb4db71ff2bcb6dc | 5e29532a6a39f93a7df173d0f19d43295f724371 | refs/heads/master | 2020-04-09T21:08:13.482022 | 2019-06-19T05:45:55 | 2019-06-19T05:45:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,887 | java | package com.kat2n.practice_android.lesson2.lab3.task1to4;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.ShareCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
private EditText mWebsiteEditText;
private EditText mLocationEditText;
private EditText mShareTextEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebsiteEditText = findViewById(R.id.website_edittext);
mLocationEditText = findViewById(R.id.location_edittext);
mShareTextEditText = findViewById(R.id.share_edittext);
}
public void openWebsite(View view) {
String url = mWebsiteEditText.getText().toString();
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Log.d("ImplicitIntents", "Can't handle this!");
}
}
public void openLocation(View view) {
String loc = mLocationEditText.getText().toString();
Uri addressUri = Uri.parse("geo:0,0?q=" + loc);
Intent intent = new Intent(Intent.ACTION_VIEW, addressUri);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
} else {
Log.d("ImplicitIntents", "Can't handle this intent!");
}
}
public void shareText(View view) {
String txt = mShareTextEditText.getText().toString();
String mimeType = "text/plain";
ShareCompat.IntentBuilder
.from(this)
.setType(mimeType)
.setChooserTitle("Share this text with: ")
.setText(txt)
.startChooser();
}
}
| [
"[email protected]"
] | |
1ed22fe7adc854adf59633c2cdc6f7ff0e26398d | a8fa3df75b9be4daef1e9eade252a7bdc69e1177 | /src/main/java/com/imooc/o2o/dao/ShopDao.java | 248be09d9b1acd32c43ca5bb4b0315292bec50bb | [] | no_license | NJTKID/njtkidMaven | 1a33ce42c5ad65c38e6ee9062ab642d8c71317b5 | e0de461cbd2cfd5c272e3a42dff0776d72dd6908 | refs/heads/master | 2022-12-20T04:49:07.028341 | 2021-03-10T07:52:47 | 2021-03-10T07:52:47 | 243,459,604 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,102 | java | package com.imooc.o2o.dao;
import com.imooc.o2o.entity.ProductCategory;
import com.imooc.o2o.entity.Shop;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ShopDao {
/**
* 分页查询店铺,可输入的条件有:店铺名(模糊),店铺状态,店铺类别,区域ID,owner
* @param shopCondition
* @param rowIndex 从第几行开始取数据
* @param pageSize 返回的条数
*/
List<Shop> queryShopList(@Param("shopCondition") Shop shopCondition,@Param("rowIndex") int rowIndex,@Param("pageSize") int pageSize);
/**
*返回queryShopList总数
* @param shopCondition
* @return
*/
int queryShopCount(@Param("shopCondition") Shop shopCondition);
/**
* 通过shop id查询店铺
*
* @param shopId
* @return shop
*/
Shop queryByShopId(long shopId);
/**
* 新增店铺
* @param shop
* @return
*/
int insertShop(Shop shop);
/**
* 更新店铺
* @param shop
* @return
*/
int updateShop(Shop shop);
}
| [
"[email protected]"
] | |
53df3f7a34dcaed5aed994adfa754e0015604117 | f91a3991669100b8c145c1e442e34cc68943b3dc | /inner/src/main/java/com/gamesky/card/inner/controller/ContentHandler.java | a5dc2df750f856aca535ce01557c42ddf4caa825 | [] | no_license | lianghongbin/cardbox | ab8c68ca626f61a3af83970979e85142c9e1d076 | 7151338c479197668bf1d7930a46a37a19f56cef | refs/heads/master | 2021-01-10T08:43:52.749728 | 2015-11-17T06:51:09 | 2015-11-17T06:51:09 | 36,861,451 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 148 | java | package com.gamesky.card.inner.controller;
/**
* lianghongbin on 15/8/5.
*/
public interface ContentHandler<D> {
public void handle(D d);
}
| [
"[email protected]"
] | |
e5e4ce4b9f8b0fa308022a7a58dd7a7beb397d41 | 3ba1e5505f66acef84427fe3819ddb53073dbc9f | /app/src/main/java/com/dyamail/gankapp/utils/PhoneUtils.java | 48d10d58e07fd86f24672d113670b8b4c37f999f | [] | no_license | dyamail/GankApp | fb6768c5cdf95dfb617dea997340dd3891fa505a | f9a71e3f03a7cf26862499d31737599151137467 | refs/heads/master | 2021-01-20T09:26:48.655521 | 2017-08-30T08:50:28 | 2017-08-30T08:50:28 | 101,594,957 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,010 | java | package com.dyamail.gankapp.utils;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.SystemClock;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Xml;
import org.xmlpull.v1.XmlSerializer;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/08/02
* desc : 手机相关工具类
* </pre>
*/
public final class PhoneUtils {
private PhoneUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 判断设备是否是手机
*
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isPhone() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null && tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
/**
* 获取IMEI码
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return IMEI码
*/
@SuppressLint("HardwareIds")
public static String getIMEI() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getDeviceId() : null;
}
/**
* 获取IMSI码
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return IMSI码
*/
@SuppressLint("HardwareIds")
public static String getIMSI() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getSubscriberId() : null;
}
/**
* 获取移动终端类型
*
* @return 手机制式
* <ul>
* <li>{@link TelephonyManager#PHONE_TYPE_NONE } : 0 手机制式未知</li>
* <li>{@link TelephonyManager#PHONE_TYPE_GSM } : 1 手机制式为GSM,移动和联通</li>
* <li>{@link TelephonyManager#PHONE_TYPE_CDMA } : 2 手机制式为CDMA,电信</li>
* <li>{@link TelephonyManager#PHONE_TYPE_SIP } : 3</li>
* </ul>
*/
public static int getPhoneType() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getPhoneType() : -1;
}
/**
* 判断sim卡是否准备好
*
* @return {@code true}: 是<br>{@code false}: 否
*/
public static boolean isSimCardReady() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null && tm.getSimState() == TelephonyManager.SIM_STATE_READY;
}
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @return sim卡运营商名称
*/
public static String getSimOperatorName() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
return tm != null ? tm.getSimOperatorName() : null;
}
/**
* 获取Sim卡运营商名称
* <p>中国移动、如中国联通、中国电信</p>
*
* @return 移动网络运营商名称
*/
public static String getSimOperatorByMnc() {
TelephonyManager tm = (TelephonyManager) Utils.getContext().getSystemService(Context.TELEPHONY_SERVICE);
String operator = tm != null ? tm.getSimOperator() : null;
if (operator == null) return null;
switch (operator) {
case "46000":
case "46002":
case "46007":
return "中国移动";
case "46001":
return "中国联通";
case "46003":
return "中国电信";
default:
return operator;
}
}
/**
* 获取手机状态信息
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_PHONE_STATE"/>}</p>
*
* @return DeviceId(IMEI) = 99000311726612<br>
* DeviceSoftwareVersion = 00<br>
* Line1Number =<br>
* NetworkCountryIso = cn<br>
* NetworkOperator = 46003<br>
* NetworkOperatorName = 中国电信<br>
* NetworkType = 6<br>
* honeType = 2<br>
* SimCountryIso = cn<br>
* SimOperator = 46003<br>
* SimOperatorName = 中国电信<br>
* SimSerialNumber = 89860315045710604022<br>
* SimState = 5<br>
* SubscriberId(IMSI) = 460030419724900<br>
* VoiceMailNumber = *86<br>
*/
@SuppressLint("HardwareIds")
public static String getPhoneStatus() {
TelephonyManager tm = (TelephonyManager) Utils.getContext()
.getSystemService(Context.TELEPHONY_SERVICE);
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion() + "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "PhoneType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str;
}
/**
* 跳至拨号界面
*
* @param phoneNumber 电话号码
*/
public static void dial(final String phoneNumber) {
Utils.getContext().startActivity(IntentUtils.getDialIntent(phoneNumber));
}
/**
* 拨打电话
* <p>需添加权限 {@code <uses-permission android:name="android.permission.CALL_PHONE"/>}</p>
*
* @param phoneNumber 电话号码
*/
public static void call(final String phoneNumber) {
Utils.getContext().startActivity(IntentUtils.getCallIntent(phoneNumber));
}
/**
* 跳至发送短信界面
*
* @param phoneNumber 接收号码
* @param content 短信内容
*/
public static void sendSms(final String phoneNumber, final String content) {
Utils.getContext().startActivity(IntentUtils.getSendSmsIntent(phoneNumber, content));
}
/**
* 发送短信
* <p>需添加权限 {@code <uses-permission android:name="android.permission.SEND_SMS"/>}</p>
*
* @param phoneNumber 接收号码
* @param content 短信内容
*/
public static void sendSmsSilent(final String phoneNumber, final String content) {
if (StringUtils.isEmpty(content)) return;
PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getContext(), 0, new Intent(), 0);
SmsManager smsManager = SmsManager.getDefault();
if (content.length() >= 70) {
List<String> ms = smsManager.divideMessage(content);
for (String str : ms) {
smsManager.sendTextMessage(phoneNumber, null, str, sentIntent, null);
}
} else {
smsManager.sendTextMessage(phoneNumber, null, content, sentIntent, null);
}
}
/**
* 获取手机联系人
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>}</p>
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_CONTACTS"/>}</p>
*
* @return 联系人链表
*/
public static List<HashMap<String, String>> getAllContactInfo() {
SystemClock.sleep(3000);
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
// 1.获取内容解析者
ContentResolver resolver = Utils.getContext().getContentResolver();
// 2.获取内容提供者的地址:com.android.contacts
// raw_contacts表的地址 :raw_contacts
// view_data表的地址 : data
// 3.生成查询地址
Uri raw_uri = Uri.parse("content://com.android.contacts/raw_contacts");
Uri date_uri = Uri.parse("content://com.android.contacts/data");
// 4.查询操作,先查询raw_contacts,查询contact_id
// projection : 查询的字段
Cursor cursor = resolver.query(raw_uri, new String[]{"contact_id"}, null, null, null);
try {
// 5.解析cursor
if (cursor != null) {
while (cursor.moveToNext()) {
// 6.获取查询的数据
String contact_id = cursor.getString(0);
// cursor.getString(cursor.getColumnIndex("contact_id"));//getColumnIndex
// : 查询字段在cursor中索引值,一般都是用在查询字段比较多的时候
// 判断contact_id是否为空
if (!StringUtils.isEmpty(contact_id)) {//null ""
// 7.根据contact_id查询view_data表中的数据
// selection : 查询条件
// selectionArgs :查询条件的参数
// sortOrder : 排序
// 空指针: 1.null.方法 2.参数为null
Cursor c = resolver.query(date_uri, new String[]{"data1",
"mimetype"}, "raw_contact_id=?",
new String[]{contact_id}, null);
HashMap<String, String> map = new HashMap<String, String>();
// 8.解析c
if (c != null) {
while (c.moveToNext()) {
// 9.获取数据
String data1 = c.getString(0);
String mimetype = c.getString(1);
// 10.根据类型去判断获取的data1数据并保存
if (mimetype.equals("vnd.android.cursor.item/phone_v2")) {
// 电话
map.put("phone", data1);
} else if (mimetype.equals("vnd.android.cursor.item/name")) {
// 姓名
map.put("name", data1);
}
}
}
// 11.添加到集合中数据
list.add(map);
// 12.关闭cursor
if (c != null) {
c.close();
}
}
}
}
} finally {
// 12.关闭cursor
if (cursor != null) {
cursor.close();
}
}
return list;
}
/**
* 打开手机联系人界面点击联系人后便获取该号码
* <p>参照以下注释代码</p>
*/
public static void getContactNum() {
Log.d("tips", "U should copy the following code.");
/*
Intent intent = new Intent();
intent.setAction("android.intent.action.PICK");
intent.setType("vnd.android.cursor.dir/phone_v2");
startActivityForResult(intent, 0);
@Override
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (data != null) {
Uri uri = data.getData();
String num = null;
// 创建内容解析者
ContentResolver contentResolver = getContentResolver();
Cursor cursor = contentResolver.query(uri,
null, null, null, null);
while (cursor.moveToNext()) {
num = cursor.getString(cursor.getColumnIndex("data1"));
}
cursor.close();
num = num.replaceAll("-", "");//替换的操作,555-6 -> 5556
}
}
*/
}
/**
* 获取手机短信并保存到xml中
* <p>需添加权限 {@code <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>}</p>
* <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_SMS"/>}</p>
*/
public static void getAllSMS() {
// 1.获取短信
// 1.1获取内容解析者
ContentResolver resolver = Utils.getContext().getContentResolver();
// 1.2获取内容提供者地址 sms,sms表的地址:null 不写
// 1.3获取查询路径
Uri uri = Uri.parse("content://sms");
// 1.4.查询操作
// projection : 查询的字段
// selection : 查询的条件
// selectionArgs : 查询条件的参数
// sortOrder : 排序
Cursor cursor = resolver.query(uri, new String[]{"address", "date", "type", "body"}, null, null, null);
// 设置最大进度
int count = cursor.getCount();//获取短信的个数
// 2.备份短信
// 2.1获取xml序列器
XmlSerializer xmlSerializer = Xml.newSerializer();
try {
// 2.2设置xml文件保存的路径
// os : 保存的位置
// encoding : 编码格式
xmlSerializer.setOutput(new FileOutputStream(new File("/mnt/sdcard/backupsms.xml")), "utf-8");
// 2.3设置头信息
// standalone : 是否独立保存
xmlSerializer.startDocument("utf-8", true);
// 2.4设置根标签
xmlSerializer.startTag(null, "smss");
// 1.5.解析cursor
while (cursor.moveToNext()) {
SystemClock.sleep(1000);
// 2.5设置短信的标签
xmlSerializer.startTag(null, "sms");
// 2.6设置文本内容的标签
xmlSerializer.startTag(null, "address");
String address = cursor.getString(0);
// 2.7设置文本内容
xmlSerializer.text(address);
xmlSerializer.endTag(null, "address");
xmlSerializer.startTag(null, "date");
String date = cursor.getString(1);
xmlSerializer.text(date);
xmlSerializer.endTag(null, "date");
xmlSerializer.startTag(null, "type");
String type = cursor.getString(2);
xmlSerializer.text(type);
xmlSerializer.endTag(null, "type");
xmlSerializer.startTag(null, "body");
String body = cursor.getString(3);
xmlSerializer.text(body);
xmlSerializer.endTag(null, "body");
xmlSerializer.endTag(null, "sms");
System.out.println("address:" + address + " date:" + date + " type:" + type + " body:" + body);
}
xmlSerializer.endTag(null, "smss");
xmlSerializer.endDocument();
// 2.8将数据刷新到文件中
xmlSerializer.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
a86e4239fbeeab25d9057b7bf28eb2e4afa393e7 | f5d71af461b1aee8b509dc85fe3b07aaa5c80e34 | /src/Chapter4/CompFuel.java | 46d02e005c2effc62fb51d71c1a7c3e6b47fabf4 | [] | no_license | Esmien/Shildt | 83815667650e5377ca92f23a3d1d5213ba270ed3 | 8c0233df290f9f12d4ddb7dd9d8693a9bed3d389 | refs/heads/master | 2020-08-11T21:05:58.242228 | 2019-10-12T10:26:19 | 2019-10-12T10:26:19 | 214,618,635 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 558 | java | package Chapter4;
public class CompFuel {
public static void main(String[] args) {
Vehicle minivan = new Vehicle(7, 16, 21);
Vehicle sportscar = new Vehicle(2, 14, 12);
double gallons;
int dist = 252;
gallons = minivan.fuelneeded(dist);
System.out.println("Minivan needs " + gallons + " gallons of fuel to overcome " + dist + " miles.");
gallons = sportscar.fuelneeded(dist);
System.out.println("Sportscar needs " + gallons + " gallons of fuel to overcome " + dist + " miles.");
}
}
| [
"[email protected]"
] | |
bd6f1ec2f0acbfb7ab9b2c7420cef052c6505a93 | a0167f108a63128cf5c8ce15f4911682fc0ba691 | /financep2p/financep2p_action/src/main/java/zyk/finance/action/filter/GetHttpResponseHeader.java | 3f982888e04a1ff5cc02a21763fc7c7f10cd608c | [] | no_license | zhouyankun/Finance_P2P | 755ae5404013fb40c7056f07ff15eb212fc7d9b4 | 5c78b47b4018eb68c6c1685ace76d065fa99f040 | refs/heads/master | 2021-04-15T04:15:37.122234 | 2018-03-26T06:21:44 | 2018-03-26T06:21:44 | 126,487,621 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,424 | java | package zyk.finance.action.filter;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import zyk.finance.cache.BaseCacheService;
import zyk.finance.service.util.SpringContext;
import zyk.finance.utils.ConfigurableConstants;
public class GetHttpResponseHeader {
private static BaseCacheService baseCacheService = (BaseCacheService) SpringContext.getInstance().getBean("redisCache");
private static RedisTemplate<String, Object> redisTemplate;
/**
* @param request
* @return
*/
public static String getHeadersInfo(HttpServletRequest request) {
Map<String, String> map = new HashMap<String, String>();
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
map.put(key, value);
}
String token=map.get("token"); //获取token
if (!StringUtils.isEmpty(token)) { // 判断token是否为空,如果token不为空,取消失效时间,重新设置失效时间
baseCacheService.setPersist(token);
String tokenValid=ConfigurableConstants.getProperty("token.validity", "30");
baseCacheService.expire(token, Integer.parseInt(tokenValid)*60);//设置过期时间
}
return token;
}
} | [
"[email protected]"
] | |
7446651d22690c23c3a467ce10067a87ab25b118 | 134581bf28ed36991b2a79e4443751afd9d0fa5f | /wms/src/main/java/com/free4lab/account/annotation/util/PrivacyUtil.java | 8eacae926a9f9331be7b04f60ee5eb1e66b17d36 | [
"MIT"
] | permissive | zihanbobo/WebRTC | b6e8b111d71ef325a3ce8ac2895475c78461b19f | 0044d07f8b96fb6ed8439b75864b65f525092800 | refs/heads/master | 2021-06-13T05:44:42.591871 | 2017-03-10T02:20:19 | 2017-03-10T02:20:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 800 | java | /**
* File: PrivacyUtil.java
* Author: weed
* Create Time: 2013-4-3
*/
package com.free4lab.account.annotation.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.free4lab.account.annotation.Privacy;
/**
* @author weed
*
*/
public class PrivacyUtil {
public static void setPrivacyByAnnotaion(Object o, String key, String value)
throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
Method[] methods = o.getClass().getMethods();
for (Method m : methods) {
if (m.getName().startsWith("set")) {
String annoKey = m.getAnnotation(Privacy.class).key();
if (annoKey != null && annoKey.equals(key)) {
m.invoke(o, value);
break;
}
}
}
}
}
| [
"[email protected]"
] | |
f5fb9b2f619f31f7523605b056570e0dda6d8bff | a00326c0e2fc8944112589cd2ad638b278f058b9 | /src/main/java/000/129/478/CWE190_Integer_Overflow__int_getParameter_Servlet_add_66b.java | 1e7ab2ad09a1a28d10b534a72b5181963ddfb3e1 | [] | no_license | Lanhbao/Static-Testing-for-Juliet-Test-Suite | 6fd3f62713be7a084260eafa9ab221b1b9833be6 | b095b11c7cb6d4a5bb2b76181e35d6ee00e96e68 | refs/heads/master | 2020-08-24T13:34:04.004149 | 2019-10-25T09:26:00 | 2019-10-25T09:26:00 | 216,822,684 | 0 | 1 | null | 2019-11-08T09:51:54 | 2019-10-22T13:37:13 | Java | UTF-8 | Java | false | false | 2,058 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE190_Integer_Overflow__int_getParameter_Servlet_add_66b.java
Label Definition File: CWE190_Integer_Overflow__int.label.xml
Template File: sources-sinks-66b.tmpl.java
*/
/*
* @description
* CWE: 190 Integer Overflow
* BadSource: getParameter_Servlet Read data from a querystring using getParameter()
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks: add
* GoodSink: Ensure there will not be an overflow before adding 1 to data
* BadSink : Add 1 to data, which can cause an overflow
* Flow Variant: 66 Data flow: data passed in an array from one method to another in different source files in the same package
*
* */
import javax.servlet.http.*;
public class CWE190_Integer_Overflow__int_getParameter_Servlet_add_66b
{
public void badSink(int dataArray[] , HttpServletRequest request, HttpServletResponse response) throws Throwable
{
int data = dataArray[2];
/* POTENTIAL FLAW: if data == Integer.MAX_VALUE, this will overflow */
int result = (int)(data + 1);
IO.writeLine("result: " + result);
}
/* goodG2B() - use goodsource and badsink */
public void goodG2BSink(int dataArray[] , HttpServletRequest request, HttpServletResponse response) throws Throwable
{
int data = dataArray[2];
/* POTENTIAL FLAW: if data == Integer.MAX_VALUE, this will overflow */
int result = (int)(data + 1);
IO.writeLine("result: " + result);
}
/* goodB2G() - use badsource and goodsink */
public void goodB2GSink(int dataArray[] , HttpServletRequest request, HttpServletResponse response) throws Throwable
{
int data = dataArray[2];
/* FIX: Add a check to prevent an overflow from occurring */
if (data < Integer.MAX_VALUE)
{
int result = (int)(data + 1);
IO.writeLine("result: " + result);
}
else
{
IO.writeLine("data value is too large to perform addition.");
}
}
}
| [
"[email protected]"
] | |
abf6964a0eb2fb191e4dd4b854df205d6fa4666c | da68446ad3fa56c5d5f9a55b4428e21e0f0ed406 | /src/main/java/mac/appkit/enums/NSStackViewGravity.java | 01943e8b30d8a32c5793d63b219572ad0d55a91a | [] | no_license | multi-os-engine/moe-mac-core | 90d9764ab38807cac004aed70b68ca54c5c8a79b | 0ffb7b52af9cdd75f25b33d0c4723903a521d2f7 | refs/heads/master | 2020-04-06T06:58:01.357013 | 2016-08-09T18:57:05 | 2016-08-09T18:57:05 | 65,319,982 | 4 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,083 | java | /*
Copyright 2014-2016 Intel Corporation
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 mac.appkit.enums;
import org.moe.natj.general.ann.Generated;
@Generated
public final class NSStackViewGravity {
@Generated
private NSStackViewGravity() {
}
@Generated
public static final long Top = 0x0000000000000001L;
@Generated
public static final long Leading = 0x0000000000000001L;
@Generated
public static final long Center = 0x0000000000000002L;
@Generated
public static final long Bottom = 0x0000000000000003L;
@Generated
public static final long Trailing = 0x0000000000000003L;
}
| [
"[email protected]"
] | |
96f9094270c4509bd3ca6b2be1d9147442e8a40a | c7116095ce5082db69eab7a5b3b60ff6c5235c17 | /Laborator04/ContactsManager/app/src/main/java/lab04/eim/systems/cs/pub/ro/contactsmanager/MainActivity.java | e757fa1811631ba7b745f69128576802e2bea9a0 | [] | no_license | Meehai/EIM-Labs-2016 | 9dd298aa0d4bded7a5ccdafe4276a1fc774628c5 | 7b2808728704c118bb677eb323f9e19bc3b41266 | refs/heads/master | 2021-01-18T21:56:48.287760 | 2016-05-21T13:55:21 | 2016-05-21T13:55:21 | 53,205,102 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,839 | java | package lab04.eim.systems.cs.pub.ro.contactsmanager;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private Button saveButton, cancelButton;
private ToggleButton additionalFieldsButton;
private EditText nameText, phoneText, emailText, addressText, jobTitleText, companyNameText,
websiteText, IMText;
private void changeButtonsVisibility() {
jobTitleText.setVisibility(additionalFieldsButton.isChecked() ?
View.VISIBLE : View.GONE);
companyNameText.setVisibility(additionalFieldsButton.isChecked() ?
View.VISIBLE : View.GONE);
websiteText.setVisibility(additionalFieldsButton.isChecked() ?
View.VISIBLE : View.GONE);
IMText.setVisibility(additionalFieldsButton.isChecked() ?
View.VISIBLE : View.GONE);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
additionalFieldsButton = (ToggleButton)findViewById(R.id.aditional_fields_button);
saveButton = (Button)findViewById(R.id.save_button);
cancelButton = (Button)findViewById(R.id.cancel_action);
nameText = (EditText)findViewById(R.id.name_text);
phoneText = (EditText)findViewById(R.id.phone_number_text);
emailText = (EditText)findViewById(R.id.email_text);
addressText = (EditText)findViewById(R.id.address_text);
jobTitleText = (EditText)findViewById(R.id.job_title);
companyNameText = (EditText)findViewById(R.id.company_name);
websiteText = (EditText)findViewById(R.id.web_site);
IMText = (EditText)findViewById(R.id.IM);
if(savedInstanceState != null)
this.changeButtonsVisibility();
Intent intent = getIntent();
if (intent != null) {
String phone = intent.getStringExtra("ro.pub.cs.systems.eim.lab04.contactsmanager.PHONE_NUMBER_KEY");
if (phone != null) {
phoneText.setText(phone);
} else {
Toast.makeText(this, getResources().getString(R.string.phone_error), Toast.LENGTH_LONG).show();
}
}
View.OnClickListener buttonListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.aditional_fields_button:
changeButtonsVisibility();
break;
case R.id.cancel_action:
setResult(Activity.RESULT_CANCELED, new Intent());
finish();
break;
case R.id.save_button:
Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
if (nameText != null) {
intent.putExtra(ContactsContract.Intents.Insert.NAME,
nameText.getText().toString());
}
if (phoneText != null) {
intent.putExtra(ContactsContract.Intents.Insert.PHONE,
phoneText.getText().toString());
}
if (emailText != null) {
intent.putExtra(ContactsContract.Intents.Insert.EMAIL,
emailText.getText().toString());
}
if (addressText != null) {
intent.putExtra(ContactsContract.Intents.Insert.POSTAL,
addressText.getText().toString());
}
if (jobTitleText != null) {
intent.putExtra(ContactsContract.Intents.Insert.JOB_TITLE,
jobTitleText.getText().toString());
}
if (companyNameText != null) {
intent.putExtra(ContactsContract.Intents.Insert.COMPANY,
companyNameText.getText().toString());
}
ArrayList<ContentValues> contactData = new ArrayList<ContentValues>();
if (websiteText != null) {
ContentValues websiteRow = new ContentValues();
websiteRow.put(ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Website.CONTENT_ITEM_TYPE);
websiteRow.put(ContactsContract.CommonDataKinds.Website.URL,
websiteText.getText().toString());
contactData.add(websiteRow);
}
if (IMText != null) {
ContentValues imRow = new ContentValues();
imRow.put(ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE);
imRow.put(ContactsContract.CommonDataKinds.Im.DATA,
IMText.getText().toString());
contactData.add(imRow);
}
intent.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA,
contactData);
startActivityForResult(intent, Constants.CONTACTS_MANAGER_REQUEST_CODE);
break;
}
}
};
additionalFieldsButton.setOnClickListener(buttonListener);
saveButton.setOnClickListener(buttonListener);
cancelButton.setOnClickListener(buttonListener);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onRestoreInstanceState(Bundle savedState) {
super.onRestoreInstanceState(savedState);
this.changeButtonsVisibility();
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch(requestCode) {
case Constants.CONTACTS_MANAGER_REQUEST_CODE:
setResult(resultCode, new Intent());
finish();
break;
}
}
}
| [
"[email protected]"
] | |
a31574fdefec824ca42c05a5db326fa2954982e3 | 16da1aec4387b149d77d26e15d8dde9d1f1bb0a5 | /src/main/java/com/karthikbashetty/leetcodepractice/MaximumDepthofBinaryTree.java | 33b92705581a8195ffd5de03c1b7a2bd741d7bb3 | [] | no_license | krats/leetcodepractice | ee93c549fa8027602e5c87262e2c4d66ccef38c2 | 68086281de4de9e23355d72ffe3f7dfd26f33bc0 | refs/heads/master | 2020-03-15T19:31:17.092626 | 2018-05-13T05:34:40 | 2018-05-13T05:34:40 | 132,310,804 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,153 | java | package com.karthikbashetty.leetcodepractice;
import java.util.Stack;
public class MaximumDepthofBinaryTree {
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) {
val = x;
}
}
public int maxDepthRecursive(TreeNode root) {
if(root == null) {
return 0;
}
else return Math.max(maxDepthRecursive(root.left), maxDepthRecursive(root.right)) + 1;
}
public int maxDepth(TreeNode root) {
if(root == null) {
return 0;
}
int ans = 0;
Stack<TreeNode> stack = new Stack<TreeNode>();
stack.push(root);
while (stack.size() != 0) {
Stack<TreeNode> newStack = new Stack<TreeNode>();
ans += 1;
while (stack.size() != 0) {
TreeNode current = stack.pop();
if(current.left != null)
newStack.push(current.left);
if(current.right != null)
newStack.push(current.right);
}
stack = newStack;
}
return ans;
}
}
| [
"[email protected]"
] | |
b0ae79c0e98abc55de70374371e2e2d6a95e0878 | eaea5e3d29fbd882dc0825b9b48bcadb7d3b6860 | /app/src/main/java/com/silvaaisya/uas_rating_silva_wirda/product/IdolAdapter.java | dbc6e03615474307509abca1438f8cedbdd06006 | [] | no_license | SilvaAisya/UAS_Rating_Silva_Wirda | 7777f8b78d963989c94cb2e3ffc33d49f778e490 | f9d896f8258c06235a41c9557f9f307b67cb0aba | refs/heads/master | 2020-05-28T10:48:31.179603 | 2019-05-30T13:16:37 | 2019-05-30T13:16:37 | 188,974,080 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,714 | java | package com.silvaaisya.uas_rating_silva_wirda.product;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.google.gson.Gson;
import com.silvaaisya.uas_rating_silva_wirda.R;
import com.silvaaisya.uas_rating_silva_wirda.model.IdolModel;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import me.zhanghai.android.materialratingbar.MaterialRatingBar;
public class IdolAdapter extends RecyclerView.Adapter<IdolAdapter.IdolHolder> {
public interface OnClickListenerAdapter {
void onItemClicked(String idol);
}
private IdolAdapter.OnClickListenerAdapter onClickListenerAdapter;
private List<IdolModel> listIdolModel;
public IdolAdapter(List<IdolModel> listIdolModel) {
this.listIdolModel = listIdolModel;
}
@NonNull
@Override
public IdolAdapter.IdolHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_idol, parent, false);
return new IdolAdapter.IdolHolder(view);
}
@Override
public void onBindViewHolder(@NonNull IdolAdapter.IdolHolder holder, int position) {
final IdolModel model = listIdolModel.get(position);
holder.totalStarRating.setRating(Float.parseFloat(String.valueOf(model.getTotalRating())));
holder.tvIdolName.setText(model.getNameIdol());
holder.tvAgensi.setText(model.getAgensi());
holder.cvItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onClickListenerAdapter != null) {
onClickListenerAdapter.onItemClicked(new Gson().toJson(model));
}
}
});
}
@Override
public int getItemCount() {
return listIdolModel.size();
}
public void setOnClickListenerAdapter(IdolAdapter.OnClickListenerAdapter onClickListenerAdapter) {
this.onClickListenerAdapter = onClickListenerAdapter;
}
public class IdolHolder extends RecyclerView.ViewHolder {
@BindView(R.id.tv_idol_name)
TextView tvIdolName;
@BindView(R.id.tv_agensi)
TextView tvAgensi;
@BindView(R.id.total_star_rating)
MaterialRatingBar totalStarRating;
@BindView(R.id.cv_item)
CardView cvItem;
public IdolHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
}
| [
"[email protected]"
] | |
2b44c3f1f2e06b59a04eda7a1ad5829b1f531a1d | b863a4cb472574417305d085d11155f05a31f2b5 | /src/goryachev/fxtexteditor/EditorSelection.java | 61d5177d5d686407d2b7d46cfb38292351a529c5 | [
"Apache-2.0"
] | permissive | andy-goryachev/FxTextEditor | 0d09a4eedb88bf4580b7d2647687124869b51877 | 44730cc1a24165c4214216cdbfaecb17d2949138 | refs/heads/master | 2023-02-23T19:46:15.865245 | 2023-02-06T00:18:56 | 2023-02-06T00:18:56 | 186,166,002 | 15 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,340 | java | // Copyright © 2017-2023 Andy Goryachev <[email protected]>
package goryachev.fxtexteditor;
import goryachev.common.util.CKit;
/**
* An immutable object that represents text selection within FxEditor.
* FxTextEditor supports neither multiple carets nor multiple selection segments.
*/
public class EditorSelection
{
public static final EditorSelection EMPTY = createEmpty();
private final SelectionSegment segment;
public EditorSelection(SelectionSegment segment)
{
this.segment = segment;
}
public String toString()
{
return CKit.toStringOrNull(segment);
}
private static EditorSelection createEmpty()
{
return new EditorSelection(new SelectionSegment(Marker.ZERO, Marker.ZERO, false));
}
/** returns original segment array */
public SelectionSegment getSegment()
{
return segment;
}
public boolean isEmpty()
{
return (segment == null);
}
public boolean isNotEmpty()
{
return !isEmpty();
}
public EditorSelection getSelection()
{
return new EditorSelection(segment);
}
public Marker getCaret()
{
if(isEmpty())
{
return null;
}
return segment.getCaret();
}
public Marker getAnchor()
{
if(isEmpty())
{
return null;
}
return segment.getAnchor();
}
}
| [
"[email protected]"
] | |
9634fed30ac0a94d4091ed9200c37e400cd60712 | 7b493250111e86a58fdeba55603697661edc0eb4 | /bundle/src/main/java/com/adobe/acs/commons/json/JcrJsonAdapter.java | ee4056317c839f004edd2ae3e30a5a9c64538f25 | [
"Apache-2.0"
] | permissive | rbotha78/acs-aem-commons | 1d96b37157cbf5f624d81789216a56077979e3d6 | bfe1c01ee1bb5e6af2fa02af7fb66e8975423ee9 | refs/heads/master | 2022-06-30T04:53:53.431252 | 2022-05-31T07:02:36 | 2022-05-31T07:02:36 | 125,922,488 | 0 | 0 | Apache-2.0 | 2022-05-31T21:52:06 | 2018-03-19T21:27:04 | Java | UTF-8 | Java | false | false | 3,392 | java | /*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2018 Adobe
* %%
* 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.
* #L%
*/
package com.adobe.acs.commons.json;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
/**
* Type adapter to convert JCR Nodes to JSON Objects (replacement for deprecated
* NodeItemWriter.)
*/
public class JcrJsonAdapter extends TypeAdapter<Node> {
@Override
public void write(JsonWriter writer, Node t) throws IOException {
if (t != null) {
try {
writer.beginObject();
for (PropertyIterator pi = t.getProperties(); pi.hasNext();) {
Property p = (Property) pi.next();
writer.name(p.getName());
if (p.isMultiple()) {
writer.beginArray();
for (Value v : p.getValues()) {
writeValue(writer, v);
}
writer.endArray();
} else {
writeValue(writer, p.getValue());
}
}
for (NodeIterator ni = t.getNodes(); ni.hasNext();) {
Node child = ni.nextNode();
writer.name(child.getName());
write(writer, child);
}
writer.endObject();
} catch (RepositoryException ex) {
throw new IOException(ex);
}
}
}
private void writeValue(JsonWriter writer, Value v) throws IOException, RepositoryException {
switch (v.getType()) {
case PropertyType.BINARY:
writer.value("(binary value)");
break;
case PropertyType.BOOLEAN:
writer.value(v.getBoolean());
break;
case PropertyType.DATE:
case PropertyType.LONG:
writer.value(v.getLong());
break;
case PropertyType.DECIMAL:
case PropertyType.DOUBLE:
writer.value(v.getDecimal().toPlainString());
break;
default:
// case PropertyType.PATH:
// case PropertyType.STRING:
// case PropertyType.URI:
writer.value(v.getString());
}
}
@Override
public Node read(JsonReader reader) throws IOException {
throw new UnsupportedOperationException("JcrJsonAdaper.read(JsonReader) is not supported yet.");
}
} | [
"[email protected]"
] | |
d9f773d06331356acba018a3f31a538bd2b37a70 | 37ff7404e19a46a57ed0de8b02fb8bd2f7700b2e | /example-spring-java/src/main/java/com/peak/config/CompactDisc.java | 960416979b19a1a433a3c541cfab370756a870b6 | [] | no_license | gaofeng0527/example | 4cee6565c06e65e4ae82cb7e51bd9083c7148cd2 | 11de5aa934a41264e1121c1d4f1a01b32392a446 | refs/heads/master | 2020-04-11T15:27:46.604917 | 2019-05-24T05:31:44 | 2019-05-24T05:31:44 | 139,731,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 77 | java | package com.peak.config;
public interface CompactDisc {
void play();
}
| [
"[email protected]"
] | |
a58db8621ff8d274d666564e4c2b1582fe21c87d | 0a08715b41d7dacfffd5a45698a07b39aca5d3fc | /app/src/main/java/com/syzible/hair/Common/Objects/OpeningTime.java | 55ff70a0de20d4f80ddf92c9e1c4abff0d29b77e | [] | no_license | oflynned/Trym-Android | 800482d2398ad56eee8e3b052d4828d2a73388b7 | c96dcf36548769e88baa2fa34fa5ca1d53184da3 | refs/heads/master | 2021-09-09T11:40:47.959116 | 2018-03-15T19:56:17 | 2018-03-15T19:56:17 | 118,915,963 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,421 | java | package com.syzible.hair.Common.Objects;
import java.util.Calendar;
public class OpeningTime {
private String day, openingTime, closingTime;
public OpeningTime(String day, String openingTime, String closingTime) throws OpeningTimeNotFoundException {
this.day = day;
this.openingTime = openingTime;
this.closingTime = closingTime;
}
public Calendar getOpeningTime() throws OpeningTimeNotFoundException {
return getTimeAsDate(day, openingTime);
}
public Calendar getClosingTime() throws OpeningTimeNotFoundException {
return getTimeAsDate(day, closingTime);
}
private Calendar getCurrentTime() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
return calendar;
}
public String getFormattedOpeningTime() {
return openingTime + " - " + closingTime;
}
public boolean isOpenNow() throws OpeningTimeNotFoundException {
Calendar currentTime = getCurrentTime();
return currentTime.getTime().getDay() == getOpeningTime().getTime().getDay() &&
currentTime.after(getOpeningTime()) &&
currentTime.before(getClosingTime());
}
private Calendar getTimeAsDate(String day, String time) throws OpeningTimeNotFoundException {
String[] separatedTime = time.split(":");
int hour = Integer.parseInt(separatedTime[0]);
int minutes = Integer.parseInt(separatedTime[1]);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MINUTE, minutes);
calendar.set(Calendar.HOUR, hour);
calendar.set(Calendar.AM_PM, (hour >= 0 || hour < 12) ? Calendar.AM : Calendar.PM);
calendar.set(Calendar.DAY_OF_WEEK, getDayOfWeek(day));
return calendar;
}
private int getDayOfWeek(String dayName) throws OpeningTimeNotFoundException {
switch (dayName) {
case "sunday":
return 1;
case "monday":
return 2;
case "tuesday":
return 3;
case "wednesday":
return 4;
case "thursday":
return 5;
case "friday":
return 6;
case "saturday":
return 7;
}
throw new OpeningTimeNotFoundException("Day name not found in map");
}
}
| [
"[email protected]"
] | |
d56a4021ffc5482fe69262c43241d31fed382d0a | 327974f3330a7b609905205ee74724f23952dabb | /src/main/java/com/lp2/equipos_app/modelo/Equipo.java | f3c81a0a485c95b527966992fbeb299e6c95c61c | [] | no_license | cheloesperguel/equipo_app_spring | 660424eb3abc07b064ccc4394803977ee1562bb7 | 9790e1df166b8a2cf1859f2e9dff9723da5fe01b | refs/heads/master | 2020-05-31T17:45:15.519878 | 2019-06-05T15:05:26 | 2019-06-05T15:05:26 | 190,416,513 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,697 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.lp2.equipos_app.modelo;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
/**
*
* @author Marcelo Esperguel
*/
@Entity
@Table(name = "equipo")
@NamedQueries({
@NamedQuery(name = "Equipo.findAll", query = "SELECT e FROM Equipo e")})
public class Equipo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Size(max = 255)
@Column(name = "nombre")
private String nombre;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idEquipo", fetch = FetchType.LAZY)
private List<Jugador> jugadorList;
public Equipo() {
}
public Equipo(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public List<Jugador> getJugadorList() {
return jugadorList;
}
public void setJugadorList(List<Jugador> jugadorList) {
this.jugadorList = jugadorList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Equipo)) {
return false;
}
Equipo other = (Equipo) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.lp2.equipos_app.modelo.Equipo[ id=" + id + " ]";
}
}
| [
"[email protected]"
] | |
7db4408e56dca11b355b5ece4a78a1dfee8efaff | 410453a12abf555f4fd8d4ea30553c58ca3a83cf | /microservices3/CustomerMicroservice/src/main/java/com/example/demo/repository/ProductRepository.java | 7f3c385f9837f5340611fc96c010b11f6a0cff17 | [] | no_license | shefalibs/Rentkaro | 15fad48550ba5adfa54929bfeb5c8de65da97572 | c5a44a703ceb04bf93088a839dec3c2a64a2ada5 | refs/heads/master | 2023-01-25T01:37:25.486511 | 2019-12-13T06:26:46 | 2019-12-13T06:26:46 | 226,787,844 | 0 | 0 | null | 2023-01-07T12:37:13 | 2019-12-09T04:56:13 | HTML | UTF-8 | Java | false | false | 352 | java | package com.example.demo.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.example.demo.entity.Product;
@Repository
public interface ProductRepository extends JpaRepository<Product, Integer> {
List<Product> findByProductid(String pid);
}
| [
"[email protected]"
] | |
073b99aa66607d15258bae13ee85f44ff6a092f1 | de03b252a8306b7a36d04b7d00517c88867a6a4a | /Microservice-Parent/Microservice-Task/src/main/java/com/beyondalgo/app/controllers/TaskController.java | 7db0d5576b2fcbbd7262bd091822b11170f7b5d9 | [] | no_license | ronymathewjose/SpringBoot-SampleApplication | 2973d53ba7a897bf563742b55134d3ba91e8f8ca | 47efba89767f5850700819334025093a4c8d6f1e | refs/heads/master | 2021-12-10T07:12:45.851493 | 2016-07-14T12:13:41 | 2016-07-14T12:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 376 | java | package com.beyondalgo.app.controllers;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TaskController {
@RequestMapping(value="/task")
public String testTask(){
System.out.println("Task Service - Task Controller Hit");
return "Welcome to Task Service";
}
}
| [
"[email protected]"
] | |
76a0e5b945fd358c9e3f22d9957410b01b6e2e6c | 8fc2d289622be92f235eeee21de8813005da4f90 | /06-JPADemo/src/com/cg/jpastart/entities/SeatInfo.java | 69b66a0e0e2d70edd8b84e3a8bdb23389d0b4c88 | [] | no_license | Priyanka-Malladi/soumya | 56349bb9a1f3c7555f8ec42faf4a5f289374bd5c | 137fc9378385932dfb81112bd41bd597934fdcbd | refs/heads/master | 2020-04-03T22:45:34.781790 | 2018-11-09T12:44:22 | 2018-11-09T12:44:22 | 155,608,822 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,200 | java | package com.cg.jpastart.entities;
import javax.persistence.Embeddable;
@Embeddable
public class SeatInfo {
int totalSeatCount;
int availableSeatCount;
int bookedSeatCount;
public int getTotalSeatCount() {
return totalSeatCount;
}
public void setTotalSeatCount(int totalSeatCount) {
this.totalSeatCount = totalSeatCount;
}
public int getAvailableSeatCount() {
return availableSeatCount;
}
public void setAvailableSeatCount(int availableSeatCount) {
this.availableSeatCount = availableSeatCount;
}
public int getBookedSeatCount() {
return bookedSeatCount;
}
public void setBookedSeatCount(int bookedSeatCount) {
this.bookedSeatCount = bookedSeatCount;
}
@Override
public String toString() {
return "SeatInfo [totalSeatCount=" + totalSeatCount
+ ", availableSeatCount=" + availableSeatCount
+ ", bookedSeatCount=" + bookedSeatCount + "]";
}
public SeatInfo(int totalSeatCount, int availableSeatCount,
int bookedSeatCount) {
super();
this.totalSeatCount = totalSeatCount;
this.availableSeatCount = availableSeatCount;
this.bookedSeatCount = bookedSeatCount;
}
public SeatInfo() {
super();
}
}
| [
"[email protected]"
] | |
daf1ff636e7fa368f1e22f0964d2b7a8b1d7a584 | 64e2975070d6c1a0b296a103b5c8d1aeefa6b78e | /src/com/company/Account.java | 21bd6776d11bd6c7ce57edd389c374ea2d54276f | [] | no_license | Camilla666/OOP-projects | f2a0a3b5d14dd63d1106a9982ba9b7be637d8047 | 46e15dc621c6aa99428a13d14d7ea882d2283032 | refs/heads/master | 2020-04-24T22:23:30.221532 | 2019-02-24T07:50:10 | 2019-02-24T07:50:10 | 172,310,250 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,197 | java | package com.company;
public class Account {
int id;
Customer customer;
double balance = 0.0;
public Account(int id, Customer customer, double balance) {
this.id = id;
this.customer = customer;
this.balance = balance;
}
public Account(int id, Customer customer) {
this.id = id;
this.customer = customer;
}
public int getId() {
return id;
}
public Customer getCustomer() {
return customer;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance){
this.balance = balance;
}
public String getCustomerName(){
return customer.getName();
}
public Account deposit(double amount){
this.balance+=amount;
return this;
}
public Account withdraw(double amount){
if(balance >= amount)
{
this.balance -= amount;
}else{
System.out.println("amount withdraw exceeds the current balance?");
}
return this;
}
@Override
public String toString() {
return String.format("%s balance=$%2f", customer, balance);
}
}
| [
"[email protected]"
] | |
6b6b4ae8c4aeed4fdd8fc1cfdb3435f6ca0a48a1 | eb55f2120008aaf634a30dc4102e41eb7b646288 | /src/com/company/Debt.java | 6adaee8749f48b56762207ce1d34d0019e9fc355 | [] | no_license | vladik1762/Client | ce12d681e5f23404c0aecccdf1b66febdb7baa97 | aa73d51bfafb4aaf122e337bdf1097ab1657d309 | refs/heads/master | 2023-01-31T09:33:45.683502 | 2020-12-13T19:36:23 | 2020-12-13T19:36:23 | 321,144,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 541 | java | package com.company;
public class Debt extends Operation {
private String destination;
private String kindOfDebt;
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getKindOfDebt() {
return kindOfDebt;
}
public void setKindOfDebt(String kindOfDebt) {
this.kindOfDebt = kindOfDebt;
}
@Override
public String getType() {
return "Долг";
}
}
| [
"[email protected]"
] | |
50971ec62b3ddc8559ee70df94481375a75d819e | 166ea65ce52b48df3c186d8bd3be15882e7f6f55 | /src/main/java/repository/user/SQL_Server_UserDAO.java | 72cf04725def9474d9af33a85e9edda6bce12212 | [] | no_license | lisek96/WarCardGame | e857ec5f9625f49ba203f0b5cdeaf552047596f0 | 273dcf4449b671c69168b99b553cc4f292994cf0 | refs/heads/main | 2023-03-19T06:13:50.191817 | 2021-03-09T02:30:45 | 2021-03-09T02:30:45 | 337,875,419 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,561 | java | package repository.user;
import model.user.User;
import repository.utils.Helper;
import repository.connection.SQL_Server_DBConnectionProvider;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class SQL_Server_UserDAO implements UserDAO {
@Override
public void create(User user) {
CallableStatement callableStatement = null;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC createNewUser ?, ?, ?, ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, user.getLogin());
callableStatement.setString(2, user.getSalt());
callableStatement.setString(3, user.getPassword());
callableStatement.setString(4, user.getEmail());
callableStatement.execute();
} catch (SQLException e ){
e.printStackTrace();
}
}
@Override
public Integer getIDByLogin(String login) {
CallableStatement callableStatement = null;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try
(Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getIDByLogin ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet resultSet = callableStatement.executeQuery();
if (resultSet.next()) return resultSet.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public Integer getIDByEmail(String email) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getIDByEmail ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, email);
ResultSet resultSet = callableStatement.executeQuery();
if (resultSet.next()) return resultSet.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public String[] getIdAndEmailByLogin(String login) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getIdAndEmailByLogin ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet rs = callableStatement.executeQuery();
rs.next();
return new String[]{rs.getString(1), rs.getString(2)};
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public String getEmailByLogin(String login) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try
(Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getEmailByLogin ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet resultSet = callableStatement.executeQuery();
if (resultSet.next()) return resultSet.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public String getPasswordByLogin(String login) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try
(Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getPasswordByLogin ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet resultSet = callableStatement.executeQuery();
if (resultSet.next()) return resultSet.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public String getSaltByLogin(String login) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try
(Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getSaltByLogin ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet resultSet = callableStatement.executeQuery();
if (resultSet.next()) return resultSet.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public void setActivated(boolean status, int id) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC setActivated ?, ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
if (status == true)
callableStatement.setString(1, "true");
else
callableStatement.setString(1, "false");
callableStatement.setInt(2, id);
callableStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public boolean isUserActivated(String login) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC isUserActivated ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setString(1, login);
ResultSet info = callableStatement.executeQuery();
info.next();
String isActivated = info.getString(1);
if (isActivated.equals("true")) return true;
else return false;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
@Override
public int[] getWinsAndLoses(int userId) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getWinsAndLoses ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setInt(1, userId);
ResultSet rs = callableStatement.executeQuery();
rs.next();
return new int[]{rs.getInt(1), rs.getInt(2)};
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public void incrementWins(int idUser) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC incrementWins ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setInt(1, idUser);
callableStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void incrementLoses(int idUser) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC incrementLoses ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setInt(1, idUser);
callableStatement.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public List<List<String>> getLoginWinsLosesOfUsers(int howMany) {
CallableStatement callableStatement;
SQL_Server_DBConnectionProvider sql_server_dbConnectionProvider = new SQL_Server_DBConnectionProvider();
try (Connection connection = sql_server_dbConnectionProvider.provideConnection()) {
String sql = "EXEC getLoginWinsLosesOfUsers ?";
callableStatement = connection.prepareCall(sql);
callableStatement.setEscapeProcessing(true);
callableStatement.setInt(1, howMany);
ResultSet rs = callableStatement.executeQuery();
List<List<String>> listOfRows = Helper.getAllRowsFromResultSetIntoStringList(rs, 3);
return listOfRows;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
] | |
563cd849ece551a1475a24e9fd2c9438258963dc | 1fade6d8c6650a6af485720ea442f0ac272c7c8d | /src/main/java/net/devaction/kafka/accountbalanceconsumer/AccountBalanceConsumer.java | ce2766b135fd4bb39a093832fb3a3009f2990ce4 | [
"MIT"
] | permissive | chmad18/transfers_websockets_service | 51d1e0f123f2ad615b6fe47ac3f4ccbf095fac2c | 8825512f1051bd25c5a6fcaba8971a9a8291f06d | refs/heads/master | 2023-03-15T18:19:59.921890 | 2020-04-13T17:57:46 | 2020-04-13T17:57:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 293 | java | package net.devaction.kafka.accountbalanceconsumer;
import net.devaction.kafka.avro.AccountBalance;
import net.devaction.kafka.consumer.TopicConsumer;
/**
* @author Víctor Gil
*
* since September 2019
*/
public interface AccountBalanceConsumer extends TopicConsumer<AccountBalance> {
}
| [
"[email protected]"
] | |
392834fa36588dbc167d406c9f5a11fc93635d64 | fefa0ac67409e985633dc46482d232f921957428 | /services/hrdb/src/com/auto_kusnjyaduy/hrdb/Employee.java | 92ad7a89d6112f47140597088388eb90601e8896 | [] | no_license | wavemakerapps/Auto_KUsNJYaDuY | f4a9a7eaff796766414353dec9fffea98f6b1bfd | c491ef3a7cc0990944eb0c4417bf92e3e8afc3d9 | refs/heads/master | 2020-03-17T17:52:55.372262 | 2018-05-17T11:51:39 | 2018-05-17T11:51:39 | 133,805,816 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,431 | java | /*Copyright (c) 2015-2016 wavemaker.com All Rights Reserved.
This software is the confidential and proprietary information of wavemaker.com You shall not disclose such Confidential Information and shall use it only in accordance
with the terms of the source code license agreement you entered into with wavemaker.com*/
package com.auto_kusnjyaduy.hrdb;
/*This is a Studio Managed File. DO NOT EDIT THIS FILE. Your changes may be reverted by Studio.*/
import java.io.Serializable;
import java.sql.Date;
import java.util.List;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PostPersist;
import javax.persistence.Table;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* Employee generated by WaveMaker Studio.
*/
@Entity
@Table(name = "`EMPLOYEE`")
public class Employee implements Serializable {
private Integer empId;
private String firstname;
private String lastname;
private String street;
private String city;
private String state;
private String zip;
private Date birthdate;
private String picurl;
private String jobTitle;
private Integer deptId;
private String username;
private String password;
private String role;
private Integer managerId;
private Integer tenantId;
private Department department;
private Employee employeeByManagerId;
private List<Employee> employeesForManagerId;
private List<Vacation> vacations;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`EMP_ID`", nullable = false, scale = 0, precision = 10)
public Integer getEmpId() {
return this.empId;
}
public void setEmpId(Integer empId) {
this.empId = empId;
}
@Column(name = "`FIRSTNAME`", nullable = true, length = 255)
public String getFirstname() {
return this.firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
@Column(name = "`LASTNAME`", nullable = true, length = 255)
public String getLastname() {
return this.lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
@Column(name = "`STREET`", nullable = true, length = 255)
public String getStreet() {
return this.street;
}
public void setStreet(String street) {
this.street = street;
}
@Column(name = "`CITY`", nullable = true, length = 255)
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
@Column(name = "`STATE`", nullable = true, length = 2)
public String getState() {
return this.state;
}
public void setState(String state) {
this.state = state;
}
@Column(name = "`ZIP`", nullable = true, length = 255)
public String getZip() {
return this.zip;
}
public void setZip(String zip) {
this.zip = zip;
}
@Column(name = "`BIRTHDATE`", nullable = true)
public Date getBirthdate() {
return this.birthdate;
}
public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}
@Column(name = "`PICURL`", nullable = true, length = 255)
public String getPicurl() {
return this.picurl;
}
public void setPicurl(String picurl) {
this.picurl = picurl;
}
@Column(name = "`JOB_TITLE`", nullable = true, length = 40)
public String getJobTitle() {
return this.jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
@Column(name = "`DEPT_ID`", nullable = true, scale = 0, precision = 10)
public Integer getDeptId() {
return this.deptId;
}
public void setDeptId(Integer deptId) {
this.deptId = deptId;
}
@Column(name = "`USERNAME`", nullable = true, length = 255)
public String getUsername() {
return this.username;
}
public void setUsername(String username) {
this.username = username;
}
@Column(name = "`PASSWORD`", nullable = true, length = 255)
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name = "`ROLE`", nullable = true, length = 255)
public String getRole() {
return this.role;
}
public void setRole(String role) {
this.role = role;
}
@Column(name = "`MANAGER_ID`", nullable = true, scale = 0, precision = 10)
public Integer getManagerId() {
return this.managerId;
}
public void setManagerId(Integer managerId) {
this.managerId = managerId;
}
@Column(name = "`TENANT_ID`", nullable = true, scale = 0, precision = 10)
public Integer getTenantId() {
return this.tenantId;
}
public void setTenantId(Integer tenantId) {
this.tenantId = tenantId;
}
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "`DEPT_ID`", referencedColumnName = "`DEPT_ID`", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "`DEPTFKEY`"))
@Fetch(FetchMode.JOIN)
public Department getDepartment() {
return this.department;
}
public void setDepartment(Department department) {
if(department != null) {
this.deptId = department.getDeptId();
}
this.department = department;
}
// ignoring self relation properties to avoid circular loops & unwanted fields from the related entity.
@JsonIgnoreProperties({"employeeByManagerId", "employeesForManagerId"})
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "`MANAGER_ID`", referencedColumnName = "`EMP_ID`", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "`MGRFKEY`"))
@Fetch(FetchMode.JOIN)
public Employee getEmployeeByManagerId() {
return this.employeeByManagerId;
}
public void setEmployeeByManagerId(Employee employeeByManagerId) {
if(employeeByManagerId != null) {
this.managerId = employeeByManagerId.getEmpId();
}
this.employeeByManagerId = employeeByManagerId;
}
// ignoring self relation properties to avoid circular loops & unwanted fields from the related entity.
@JsonIgnoreProperties({"employeeByManagerId", "employeesForManagerId"})
@JsonInclude(Include.NON_EMPTY)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "employeeByManagerId")
@Cascade({CascadeType.SAVE_UPDATE})
public List<Employee> getEmployeesForManagerId() {
return this.employeesForManagerId;
}
public void setEmployeesForManagerId(List<Employee> employeesForManagerId) {
this.employeesForManagerId = employeesForManagerId;
}
@JsonInclude(Include.NON_EMPTY)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "employee")
@Cascade({CascadeType.SAVE_UPDATE})
public List<Vacation> getVacations() {
return this.vacations;
}
public void setVacations(List<Vacation> vacations) {
this.vacations = vacations;
}
@PostPersist
public void onPostPersist() {
if(employeesForManagerId != null) {
employeesForManagerId.forEach(employee -> employee.setEmployeeByManagerId(this));
}
if(vacations != null) {
vacations.forEach(vacation -> vacation.setEmployee(this));
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Employee)) return false;
final Employee employee = (Employee) o;
return Objects.equals(getEmpId(), employee.getEmpId());
}
@Override
public int hashCode() {
return Objects.hash(getEmpId());
}
}
| [
"[email protected]"
] | |
4aae67d8cb3809eca186e54e87c056972c3d6bff | 099d1b1cd8046881c26b3a388acff0c9cf46a563 | /src/main/java/com/example/WowApp/Model/WorldQuest.java | 77e92c8355144d5185096b68ccc44999fb5e9bf4 | [] | no_license | jean2978/worldquest-tracker | 3308f1f39c4fb57ebba9594cf01dd8a833d934ca | 45eeb23dc6d553bee9cae61911076baed0940c27 | refs/heads/main | 2023-01-23T10:49:06.286057 | 2020-11-20T19:02:59 | 2020-11-20T19:02:59 | 304,427,128 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 852 | java | package com.example.WowApp.Model;
public class WorldQuest {
private boolean venomfin;
private boolean skreeg;
private boolean vraxthul;
private boolean puscilla;
private boolean blistermaw;
public boolean isVenomfin() {
return venomfin;
}
public void setVenomfin(boolean venomfin) {
this.venomfin = venomfin;
}
public boolean isSkreeg() {
return skreeg;
}
public void setSkreeg(boolean skreeg) {
this.skreeg = skreeg;
}
public boolean isVraxthul() {
return vraxthul;
}
public void setVraxthul(boolean vraxthul) {
this.vraxthul = vraxthul;
}
public boolean isPuscilla() {
return puscilla;
}
public void setPuscilla(boolean puscilla) {
this.puscilla = puscilla;
}
public boolean isBlistermaw() {
return blistermaw;
}
public void setBlistermaw(boolean blistermaw) {
this.blistermaw = blistermaw;
}
}
| [
"[email protected]"
] | |
13a591115e8602da16b122178c5a25a8c4348d34 | f2d7262deb82f713c99832f6aa4b59a0104b5447 | /Mapmo/app/src/main/java/com/example/mapmo/getUUID.java | 9a3deef523202de8e450ed725c67883dd13cdc5c | [] | no_license | taese0ng/MapmoProject | 0d2d24b7bbbacb85f4f01da48ae4f3c5f253dba5 | 24cd71ff560e5817237114c3a555a57fa77a5694 | refs/heads/master | 2020-07-26T18:42:55.250758 | 2019-09-30T00:27:27 | 2019-09-30T00:27:27 | 208,735,596 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,943 | java | package com.example.mapmo;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
public class getUUID {
protected static final String PREFS_FILE = "device_id.xml";
protected static final String PREFS_DEVICE_ID = "device_id";
protected volatile static UUID uuid;
public getUUID(Context context) {
if (uuid == null) {
synchronized (getUUID.class) {
if (uuid == null) {
final SharedPreferences prefs = context
.getSharedPreferences(PREFS_FILE, 0);
final String id = prefs.getString(PREFS_DEVICE_ID, null);
if (id != null) {
// Use the ids previously computed and stored in the
// prefs file
uuid = UUID.fromString(id);
} else {
final String androidId = Secure.getString(
context.getContentResolver(), Secure.ANDROID_ID);
// Use the Android ID unless it's broken, in which case
// fallback on deviceId,
// unless it's not available, then fallback on a random
// number which we store to a prefs file
try {
if (!"9774d56d682e549c".equals(androidId)) {
uuid = UUID.nameUUIDFromBytes(androidId
.getBytes("utf8"));
} else {
@SuppressLint("MissingPermission") final String deviceId = (
(TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE))
.getDeviceId();
uuid = deviceId != null ? UUID
.nameUUIDFromBytes(deviceId
.getBytes("utf8")) : UUID
.randomUUID();
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
// Write the value out to the prefs file
prefs.edit()
.putString(PREFS_DEVICE_ID, uuid.toString())
.commit();
}
}
}
}
}
public UUID getDeviceUuid() {
return uuid;
}
}
| [
"[email protected]"
] | |
947dc223450292f6e22e62b5c8b257b5f07f34f6 | 1b2ea02b63c62847e195ce7f8d49220909e6f409 | /src/main/java/hu/unideb/fupn26/controller/dto/MatchFullRequestDto.java | 8b40e7f0a0229a825dfe0599f7badfc30e41c18d | [] | no_license | fupn26/Webfejl_2020_AustralianFootball | c33170dcd51794ba791093d0f73504fec96b8daa | df2ee50b7aeaaf72c1b2274db8e2b924372409fa | refs/heads/main | 2023-01-23T19:42:55.936580 | 2020-12-09T19:48:54 | 2020-12-09T19:48:54 | 315,746,888 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,155 | java | package hu.unideb.fupn26.controller.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.time.LocalDateTime;
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class MatchFullRequestDto extends MatchMinimalRequestDto{
private String startDate;
private String venue;
private Integer attendants;
private Integer margin;
private Integer homeQ1Goals;
private Integer homeQ2Goals;
private Integer homeQ3Goals;
private Integer homeQ4Goals;
private Integer homeExtraTimeGoals;
private Integer homeQ1Behinds;
private Integer homeQ2Behinds;
private Integer homeQ3Behinds;
private Integer homeQ4Behinds;
private Integer homeExtraTimeBehinds;
private Integer awayQ1Goals;
private Integer awayQ2Goals;
private Integer awayQ3Goals;
private Integer awayQ4Goals;
private Integer awayExtraTimeGoals;
private Integer awayQ1Behinds;
private Integer awayQ2Behinds;
private Integer awayQ3Behinds;
private Integer awayQ4Behinds;
private Integer awayExtraTimeBehinds;
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.