blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 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
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
57a1478b2950061d133ea3a494cdb3208eeeb8ff | 83e21874b3fb3afd887f347eed75601338c1184a | /betthread/src/test/java/com/sorin/betthread/handler/AbstractGetMethodHandlerTest.java | 1dbb82d8631a76936121888714548c44d714e6ce | []
| no_license | sorinslavic/betthread | a0192af3c08cf6b252aef962a5a3725df11e10a1 | 4d8cb2b471e2b8051e3d8e9712c5107c589d9e21 | refs/heads/master | 2020-03-28T06:54:45.725854 | 2018-09-13T14:55:05 | 2018-09-13T14:55:05 | 147,868,884 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,275 | java | package com.sorin.betthread.handler;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.Before;
import com.sorin.betthread.Log;
import com.sorin.betthread.MockHttpExchange;
import com.sorin.betthread.repository.MockBetRepository;
import com.sorin.betthread.session.ConcurrentSessionCache;
import com.sun.net.httpserver.HttpExchange;
public abstract class AbstractGetMethodHandlerTest {
private static final Log log = new Log(AbstractGetMethodHandlerTest.class);
protected MockBetRepository mockBetRepo;
private DispatchHandler handler;
@Before
public void setup() {
mockBetRepo = new MockBetRepository();
// FIXME - should mock session cache
handler = new DispatchHandler(ConcurrentSessionCache.getInstance(), mockBetRepo);
}
public MockHttpExchange handle(String path) throws IOException, URISyntaxException {
log.info("handle - perform test GET for url: " + path);
MockHttpExchange mockExchange = new MockHttpExchange("GET", new URI(path), "");
handler.handle(mockExchange);
return mockExchange;
}
public static String getContentFromResponseBody(HttpExchange exchange) {
return ((MockHttpExchange) exchange).getActualOutput();
}
}
| [
"[email protected]"
]
| |
674d3ec0dae0e99942377e6462df3597ffbcfbc6 | 633493d37af3053a5acf3846492e1a7b94a84069 | /src/HW_18_10_19/HW_Task12.java | aedce613d6fdfe0c1795d70bd0fe843ac870a80c | []
| no_license | JuliaBarsegian/Courses | 6797bc4e888dcee4494ce4e36e0d8248aea457e2 | e9d2a74619adcf998597e168c874229603c5585e | refs/heads/master | 2020-08-09T06:14:42.693052 | 2019-11-25T18:44:15 | 2019-11-25T18:44:15 | 214,017,599 | 0 | 0 | null | 2019-11-25T18:44:16 | 2019-10-09T20:30:16 | Java | UTF-8 | Java | false | false | 623 | java | package HW_18_10_19;
import java.util.Arrays;
import java.util.Scanner;
public class HW_Task12 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Введите размер массива:");
int n = in.nextInt();
int[] array = new int[n];
for (int i = 0; i < array.length; i++) {
array[i] = Math.abs(n / 2 - i);
}
System.out.println("Массив, заполненный числами по возрастанию начиная с центра массива\n" + Arrays.toString(array));
}
} | [
"="
]
| = |
08d08c38f95550a1fd6e84e96eec5e262b1f7c84 | ce2367b39e6e0826c0e4a17f5bd3627a73fe8e77 | /Trees/src/com/proj/binary/BTreePrinterTest.java | 11bd6347b004b50c67dd40b3de2b2fe374f82e9a | []
| no_license | parjanyaroy/JavaPracticeProjects | a54196068893a22c2bac6d4f9fd4e2a684942557 | b5889ae1cf783f2c7fdd3df9d6bff4240c1a1e01 | refs/heads/master | 2021-09-11T20:57:19.844333 | 2018-04-12T09:03:25 | 2018-04-12T09:03:25 | 114,755,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,859 | java | package com.proj.binary;
import com.proj.binary.BinaryTree.Node;
public class BTreePrinterTest {
private static Node test1() {
Node root = new Node(2);
Node n11 = new Node(7);
Node n12 = new Node(5);
Node n21 = new Node(2);
Node n22 = new Node(6);
Node n23 = new Node(3);
Node n24 = new Node(6);
Node n31 = new Node(5);
Node n32 = new Node(8);
Node n33 = new Node(4);
Node n34 = new Node(5);
Node n35 = new Node(8);
Node n36 = new Node(4);
Node n37 = new Node(5);
Node n38 = new Node(8);
root.left = n11;
root.right = n12;
n11.left = n21;
n11.right = n22;
n12.left = n23;
n12.right = n24;
n21.left = n31;
n21.right = n32;
n22.left = n33;
n22.right = n34;
n23.left = n35;
n23.right = n36;
n24.left = n37;
n24.right = n38;
return root;
}
/*private static Node<Integer> test2() {
Node<Integer> root = new Node<Integer>(2);
Node<Integer> n11 = new Node<Integer>(7);
Node<Integer> n12 = new Node<Integer>(5);
Node<Integer> n21 = new Node<Integer>(2);
Node<Integer> n22 = new Node<Integer>(6);
Node<Integer> n23 = new Node<Integer>(9);
Node<Integer> n31 = new Node<Integer>(5);
Node<Integer> n32 = new Node<Integer>(8);
Node<Integer> n33 = new Node<Integer>(4);
root.left = n11;
root.right = n12;
n11.left = n21;
n11.right = n22;
n12.right = n23;
n22.left = n31;
n22.right = n32;
n23.left = n33;
return root;
}
*/
public static void main(String[] args) {
BTreePrinter.printNode(test1());
//BTreePrinter.printNode(test2());
}
} | [
"parroy"
]
| parroy |
7188493712808b89b3a40a3ccc5dde03de0ab86e | b6bd3f27dc0925461495b3fce6056c4077c5d28c | /app/src/main/java/com/qhsoft/killrecord/model/remote/bean/ShareGoodDetailBean.java | 5e47b9a043ff04c7ef4e4f6429704c0df3a2c062 | []
| no_license | woshixiaohai/KillRecord | b3b87dc6469cb3883216b99d41358bb4dd6c23d2 | b7bbc8e80db9b9da6cd608af444ee9f80337e068 | refs/heads/master | 2020-06-23T20:50:19.365199 | 2019-07-25T03:14:36 | 2019-07-25T03:14:36 | 198,748,013 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,671 | java | package com.qhsoft.killrecord.model.remote.bean;
public class ShareGoodDetailBean {
/**
* success : true
* msg : 操作成功
* obj : {"id":"402880f26629565f016629cf0dd00009","createName":"生产测试企业","createBy":"5544321","createDate":1538299727000,"updateName":"生产测试企业","updateBy":"5544321","updateDate":1539049187047,"name":"测试2","barCode":"Q538299676226","kfPeriod":15,"kfDateType":"天","model":"20kg/bao","cultureNo":null,"supplyName":null,"factory":"境外测试","basicUnitName":"件","unitName":null,"packSpeci":"散装","coefficient":null,"ftypeName":"省内商品","icitemType":"粮食加工品","note":"1","photo":"","fever":0,"fsonId":"402880b1655f6e8e01655f6fc7a20002","type":"1","factoryId":"402880966618c82d01661905ce3f0009"}
* code : 200
* attributes : null
* jsonStr : {"obj":{"barCode":"Q538299676226","basicUnitName":"件","createBy":"5544321","createDate":1538299727000,"createName":"生产测试企业","factory":"境外测试","factoryId":"402880966618c82d01661905ce3f0009","fever":0,"fsonId":"402880b1655f6e8e01655f6fc7a20002","ftypeName":"省内商品","icitemType":"粮食加工品","id":"402880f26629565f016629cf0dd00009","kfDateType":"天","kfPeriod":15,"model":"20kg/bao","name":"测试2","note":"1","packSpeci":"散装","photo":"","type":"1","updateBy":"5544321","updateDate":1539049187047,"updateName":"生产测试企业"},"msg":"操作成功","success":true}
*/
private boolean success;
private String msg;
private ObjBean obj;
private int code;
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public ObjBean getObj() {
return obj;
}
public void setObj(ObjBean obj) {
this.obj = obj;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public static class ObjBean {
/**
* id : 402880f26629565f016629cf0dd00009
* createName : 生产测试企业
* createBy : 5544321
* createDate : 1538299727000
* updateName : 生产测试企业
* updateBy : 5544321
* updateDate : 1539049187047
* name : 测试2
* barCode : Q538299676226
* kfPeriod : 15
* kfDateType : 天
* model : 20kg/bao
* cultureNo : null
* supplyName : null
* factory : 境外测试
* basicUnitName : 件
* unitName : null
* packSpeci : 散装
* coefficient : null
* ftypeName : 省内商品
* icitemType : 粮食加工品
* note : 1
* photo :
* fever : 0
* fsonId : 402880b1655f6e8e01655f6fc7a20002
* type : 1
* factoryId : 402880966618c82d01661905ce3f0009
*/
private String id;
private String createName;
private String createBy;
private long createDate;
private String updateName;
private String updateBy;
private long updateDate;
private String name;
private String barCode;
private int kfPeriod;
private String kfDateType;
private String model;
private Object cultureNo;
private Object supplyName;
private String factory;
private String basicUnitName;
private Object unitName;
private String packSpeci;
private Object coefficient;
private String ftypeName;
private String icitemType;
private String note;
private String photo;
private int fever;
private String fsonId;
private String type;
private String factoryId;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCreateName() {
return createName;
}
public void setCreateName(String createName) {
this.createName = createName;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public long getCreateDate() {
return createDate;
}
public void setCreateDate(long createDate) {
this.createDate = createDate;
}
public String getUpdateName() {
return updateName;
}
public void setUpdateName(String updateName) {
this.updateName = updateName;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public long getUpdateDate() {
return updateDate;
}
public void setUpdateDate(long updateDate) {
this.updateDate = updateDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public int getKfPeriod() {
return kfPeriod;
}
public void setKfPeriod(int kfPeriod) {
this.kfPeriod = kfPeriod;
}
public String getKfDateType() {
return kfDateType;
}
public void setKfDateType(String kfDateType) {
this.kfDateType = kfDateType;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public Object getCultureNo() {
return cultureNo;
}
public void setCultureNo(Object cultureNo) {
this.cultureNo = cultureNo;
}
public Object getSupplyName() {
return supplyName;
}
public void setSupplyName(Object supplyName) {
this.supplyName = supplyName;
}
public String getFactory() {
return factory;
}
public void setFactory(String factory) {
this.factory = factory;
}
public String getBasicUnitName() {
return basicUnitName;
}
public void setBasicUnitName(String basicUnitName) {
this.basicUnitName = basicUnitName;
}
public Object getUnitName() {
return unitName;
}
public void setUnitName(Object unitName) {
this.unitName = unitName;
}
public String getPackSpeci() {
return packSpeci;
}
public void setPackSpeci(String packSpeci) {
this.packSpeci = packSpeci;
}
public Object getCoefficient() {
return coefficient;
}
public void setCoefficient(Object coefficient) {
this.coefficient = coefficient;
}
public String getFtypeName() {
return ftypeName;
}
public void setFtypeName(String ftypeName) {
this.ftypeName = ftypeName;
}
public String getIcitemType() {
return icitemType;
}
public void setIcitemType(String icitemType) {
this.icitemType = icitemType;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public int getFever() {
return fever;
}
public void setFever(int fever) {
this.fever = fever;
}
public String getFsonId() {
return fsonId;
}
public void setFsonId(String fsonId) {
this.fsonId = fsonId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFactoryId() {
return factoryId;
}
public void setFactoryId(String factoryId) {
this.factoryId = factoryId;
}
}
}
| [
"[email protected]"
]
| |
3af577e696b9ef80d9aaae814686f226b11c5e24 | 86a4eb3637f1812c417885540cbc7f58e45e5126 | /datavisual/src/main/java/com/casic/oarp/datavisual/mapper/ScwarnsMapper.java | 5f0fb5693a85e309adb5c51b88cf49e64da3347b | []
| no_license | china-dsd/branch1117 | 452c1e0b60e774c6d683f46607a97ec728de36ef | 19a7dc43a9f3d48c6a44e72421ed52df08128281 | refs/heads/master | 2020-04-08T14:58:24.230995 | 2018-11-28T07:13:01 | 2018-11-28T07:13:01 | 159,459,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,095 | java | package com.casic.oarp.datavisual.mapper;
import com.casic.oarp.datavisual.po.Scwarns;
import com.casic.oarp.datavisual.po.ScwarnsExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface ScwarnsMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
long countByExample(ScwarnsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int deleteByExample(ScwarnsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int deleteByPrimaryKey(String warnId);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int insert(Scwarns record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int insertSelective(Scwarns record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
List<Scwarns> selectByExample(ScwarnsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
Scwarns selectByPrimaryKey(String warnId);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int updateByExampleSelective(@Param("record") Scwarns record, @Param("example") ScwarnsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int updateByExample(@Param("record") Scwarns record, @Param("example") ScwarnsExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int updateByPrimaryKeySelective(Scwarns record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sc_warns
*
* @mbg.generated Mon Nov 19 10:31:15 CST 2018
*/
int updateByPrimaryKey(Scwarns record);
} | [
"[email protected]"
]
| |
b4b5bb544ea9044cfc8899b6f467b00640bf26d0 | 4f5c9e903d212a49d3aa4c72023419d6aa2ae09d | /src/com/android/armp/MediaAppWidgetProvider.java | b6c48e74df9010e196cb3916e755905fd445fa21 | [
"Apache-2.0"
]
| permissive | darkpicaroon/armp | 0bc79d294f3413206e73434d83dc5790a4801b46 | 3308a148585deb1339662ea57575237c253f5ca3 | refs/heads/master | 2021-01-10T12:44:56.861344 | 2011-05-01T02:53:10 | 2011-05-01T02:53:10 | 45,490,454 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,239 | java | /*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.armp;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Environment;
import android.view.View;
import android.widget.RemoteViews;
import com.android.armp.R;
/**
* Simple widget to show currently playing album art along
* with play/pause and next track buttons.
*/
public class MediaAppWidgetProvider extends AppWidgetProvider {
static final String TAG = "MusicAppWidgetProvider";
public static final String CMDAPPWIDGETUPDATE = "appwidgetupdate";
private static MediaAppWidgetProvider sInstance;
static synchronized MediaAppWidgetProvider getInstance() {
if (sInstance == null) {
sInstance = new MediaAppWidgetProvider();
}
return sInstance;
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
defaultAppWidget(context, appWidgetIds);
// Send broadcast intent to any running MediaPlaybackService so it can
// wrap around with an immediate update.
Intent updateIntent = new Intent(MediaPlaybackService.SERVICECMD);
updateIntent.putExtra(MediaPlaybackService.CMDNAME,
MediaAppWidgetProvider.CMDAPPWIDGETUPDATE);
updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
context.sendBroadcast(updateIntent);
}
/**
* Initialize given widgets to default state, where we launch Music on default click
* and hide actions if service not running.
*/
private void defaultAppWidget(Context context, int[] appWidgetIds) {
final Resources res = context.getResources();
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.album_appwidget);
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist, res.getText(R.string.widget_initial_text));
linkButtons(context, views, false /* not playing */);
pushUpdate(context, appWidgetIds, views);
}
private void pushUpdate(Context context, int[] appWidgetIds, RemoteViews views) {
// Update specific list of appWidgetIds if given, otherwise default to all
final AppWidgetManager gm = AppWidgetManager.getInstance(context);
if (appWidgetIds != null) {
gm.updateAppWidget(appWidgetIds, views);
} else {
gm.updateAppWidget(new ComponentName(context, this.getClass()), views);
}
}
/**
* Check against {@link AppWidgetManager} if there are any instances of this widget.
*/
private boolean hasInstances(Context context) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
new ComponentName(context, this.getClass()));
return (appWidgetIds.length > 0);
}
/**
* Handle a change notification coming over from {@link MediaPlaybackService}
*/
void notifyChange(MediaPlaybackService service, String what) {
if (hasInstances(service)) {
if (MediaPlaybackService.PLAYBACK_COMPLETE.equals(what) ||
MediaPlaybackService.META_CHANGED.equals(what) ||
MediaPlaybackService.PLAYSTATE_CHANGED.equals(what)) {
performUpdate(service, null);
}
}
}
/**
* Update all active widget instances by pushing changes
*/
void performUpdate(MediaPlaybackService service, int[] appWidgetIds) {
final Resources res = service.getResources();
final RemoteViews views = new RemoteViews(service.getPackageName(), R.layout.album_appwidget);
CharSequence titleName = service.getTrackName();
CharSequence artistName = service.getArtistName();
CharSequence errorState = null;
// Format title string with track number, or show SD card message
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_SHARED) ||
status.equals(Environment.MEDIA_UNMOUNTED)) {
errorState = res.getText(R.string.sdcard_busy_title);
} else if (status.equals(Environment.MEDIA_REMOVED)) {
errorState = res.getText(R.string.sdcard_missing_title);
} else if (titleName == null) {
errorState = res.getText(R.string.emptyplaylist);
}
if (errorState != null) {
// Show error state to user
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist, errorState);
} else {
// No error, so show normal titles
views.setViewVisibility(R.id.title, View.VISIBLE);
views.setTextViewText(R.id.title, titleName);
views.setTextViewText(R.id.artist, artistName);
}
// Set correct drawable for pause state
final boolean playing = service.isPlaying();
if (playing) {
views.setImageViewResource(R.id.control_play, R.drawable.ic_appwidget_music_pause);
} else {
views.setImageViewResource(R.id.control_play, R.drawable.ic_appwidget_music_play);
}
// Link actions buttons to intents
linkButtons(service, views, playing);
pushUpdate(service, appWidgetIds, views);
}
/**
* Link up various button actions using {@link PendingIntents}.
*
* @param playerActive True if player is active in background, which means
* widget click will launch {@link MediaPlaybackActivity},
* otherwise we launch {@link MusicBrowserActivity}.
*/
private void linkButtons(Context context, RemoteViews views, boolean playerActive) {
// Connect up various buttons and touch events
Intent intent;
PendingIntent pendingIntent;
final ComponentName serviceName = new ComponentName(context, MediaPlaybackService.class);
if (playerActive) {
intent = new Intent(context, MediaPlaybackActivity.class);
pendingIntent = PendingIntent.getActivity(context,
0 /* no requestCode */, intent, 0 /* no flags */);
views.setOnClickPendingIntent(R.id.album_appwidget, pendingIntent);
} else {
intent = new Intent(context, MusicBrowserActivity.class);
pendingIntent = PendingIntent.getActivity(context,
0 /* no requestCode */, intent, 0 /* no flags */);
views.setOnClickPendingIntent(R.id.album_appwidget, pendingIntent);
}
intent = new Intent(MediaPlaybackService.TOGGLEPAUSE_ACTION);
intent.setComponent(serviceName);
pendingIntent = PendingIntent.getService(context,
0 /* no requestCode */, intent, 0 /* no flags */);
views.setOnClickPendingIntent(R.id.control_play, pendingIntent);
intent = new Intent(MediaPlaybackService.NEXT_ACTION);
intent.setComponent(serviceName);
pendingIntent = PendingIntent.getService(context,
0 /* no requestCode */, intent, 0 /* no flags */);
views.setOnClickPendingIntent(R.id.control_next, pendingIntent);
}
}
| [
"abarreir@0e72a944-42f4-4ded-0146-812fb3def5e8"
]
| abarreir@0e72a944-42f4-4ded-0146-812fb3def5e8 |
942886205320b4644e8535e8aa382af44f1551ea | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /java/lucene-solr/2015/4/Lucene50PostingsReader.java | ab07b9e51dca284a920b481b70a271276443d8df | [
"Apache-2.0"
]
| permissive | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | Java | false | false | 44,049 | java | package org.apache.lucene.codecs.lucene50;
/*
* 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.
*/
import java.io.IOException;
import java.util.Arrays;
import org.apache.lucene.codecs.BlockTermState;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.codecs.PostingsReaderBase;
import org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.IntBlockTermState;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.RamUsageEstimator;
import static org.apache.lucene.codecs.lucene50.ForUtil.MAX_DATA_SIZE;
import static org.apache.lucene.codecs.lucene50.ForUtil.MAX_ENCODED_SIZE;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.BLOCK_SIZE;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.DOC_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.MAX_SKIP_LEVELS;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.PAY_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.POS_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.TERMS_CODEC;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.VERSION_CURRENT;
import static org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat.VERSION_START;
/**
* Concrete class that reads docId(maybe frq,pos,offset,payloads) list
* with postings format.
*
* @lucene.experimental
*/
public final class Lucene50PostingsReader extends PostingsReaderBase {
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(Lucene50PostingsReader.class);
private final IndexInput docIn;
private final IndexInput posIn;
private final IndexInput payIn;
final ForUtil forUtil;
private int version;
/** Sole constructor. */
public Lucene50PostingsReader(SegmentReadState state) throws IOException {
boolean success = false;
IndexInput docIn = null;
IndexInput posIn = null;
IndexInput payIn = null;
// NOTE: these data files are too costly to verify checksum against all the bytes on open,
// but for now we at least verify proper structure of the checksum footer: which looks
// for FOOTER_MAGIC + algorithmID. This is cheap and can detect some forms of corruption
// such as file truncation.
String docName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.DOC_EXTENSION);
try {
docIn = state.directory.openInput(docName, state.context);
version = CodecUtil.checkIndexHeader(docIn, DOC_CODEC, VERSION_START, VERSION_CURRENT, state.segmentInfo.getId(), state.segmentSuffix);
forUtil = new ForUtil(docIn);
CodecUtil.retrieveChecksum(docIn);
if (state.fieldInfos.hasProx()) {
String proxName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.POS_EXTENSION);
posIn = state.directory.openInput(proxName, state.context);
CodecUtil.checkIndexHeader(posIn, POS_CODEC, version, version, state.segmentInfo.getId(), state.segmentSuffix);
CodecUtil.retrieveChecksum(posIn);
if (state.fieldInfos.hasPayloads() || state.fieldInfos.hasOffsets()) {
String payName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, Lucene50PostingsFormat.PAY_EXTENSION);
payIn = state.directory.openInput(payName, state.context);
CodecUtil.checkIndexHeader(payIn, PAY_CODEC, version, version, state.segmentInfo.getId(), state.segmentSuffix);
CodecUtil.retrieveChecksum(payIn);
}
}
this.docIn = docIn;
this.posIn = posIn;
this.payIn = payIn;
success = true;
} finally {
if (!success) {
IOUtils.closeWhileHandlingException(docIn, posIn, payIn);
}
}
}
@Override
public void init(IndexInput termsIn, SegmentReadState state) throws IOException {
// Make sure we are talking to the matching postings writer
CodecUtil.checkIndexHeader(termsIn, TERMS_CODEC, VERSION_START, VERSION_CURRENT, state.segmentInfo.getId(), state.segmentSuffix);
final int indexBlockSize = termsIn.readVInt();
if (indexBlockSize != BLOCK_SIZE) {
throw new IllegalStateException("index-time BLOCK_SIZE (" + indexBlockSize + ") != read-time BLOCK_SIZE (" + BLOCK_SIZE + ")");
}
}
/**
* Read values that have been written using variable-length encoding instead of bit-packing.
*/
static void readVIntBlock(IndexInput docIn, int[] docBuffer,
int[] freqBuffer, int num, boolean indexHasFreq) throws IOException {
if (indexHasFreq) {
for(int i=0;i<num;i++) {
final int code = docIn.readVInt();
docBuffer[i] = code >>> 1;
if ((code & 1) != 0) {
freqBuffer[i] = 1;
} else {
freqBuffer[i] = docIn.readVInt();
}
}
} else {
for(int i=0;i<num;i++) {
docBuffer[i] = docIn.readVInt();
}
}
}
@Override
public BlockTermState newTermState() {
return new IntBlockTermState();
}
@Override
public void close() throws IOException {
IOUtils.close(docIn, posIn, payIn);
}
@Override
public void decodeTerm(long[] longs, DataInput in, FieldInfo fieldInfo, BlockTermState _termState, boolean absolute)
throws IOException {
final IntBlockTermState termState = (IntBlockTermState) _termState;
final boolean fieldHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
final boolean fieldHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
final boolean fieldHasPayloads = fieldInfo.hasPayloads();
if (absolute) {
termState.docStartFP = 0;
termState.posStartFP = 0;
termState.payStartFP = 0;
}
termState.docStartFP += longs[0];
if (fieldHasPositions) {
termState.posStartFP += longs[1];
if (fieldHasOffsets || fieldHasPayloads) {
termState.payStartFP += longs[2];
}
}
if (termState.docFreq == 1) {
termState.singletonDocID = in.readVInt();
} else {
termState.singletonDocID = -1;
}
if (fieldHasPositions) {
if (termState.totalTermFreq > BLOCK_SIZE) {
termState.lastPosBlockOffset = in.readVLong();
} else {
termState.lastPosBlockOffset = -1;
}
}
if (termState.docFreq > BLOCK_SIZE) {
termState.skipOffset = in.readVLong();
} else {
termState.skipOffset = -1;
}
}
@Override
public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
boolean indexHasPositions = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
boolean indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
boolean indexHasPayloads = fieldInfo.hasPayloads();
if (indexHasPositions == false || PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS) == false) {
BlockDocsEnum docsEnum;
if (reuse instanceof BlockDocsEnum) {
docsEnum = (BlockDocsEnum) reuse;
if (!docsEnum.canReuse(docIn, fieldInfo)) {
docsEnum = new BlockDocsEnum(fieldInfo);
}
} else {
docsEnum = new BlockDocsEnum(fieldInfo);
}
return docsEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
} else if ((indexHasOffsets == false || PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS) == false) &&
(indexHasPayloads == false || PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS) == false)) {
BlockPostingsEnum docsAndPositionsEnum;
if (reuse instanceof BlockPostingsEnum) {
docsAndPositionsEnum = (BlockPostingsEnum) reuse;
if (!docsAndPositionsEnum.canReuse(docIn, fieldInfo)) {
docsAndPositionsEnum = new BlockPostingsEnum(fieldInfo);
}
} else {
docsAndPositionsEnum = new BlockPostingsEnum(fieldInfo);
}
return docsAndPositionsEnum.reset(liveDocs, (IntBlockTermState) termState);
} else {
EverythingEnum everythingEnum;
if (reuse instanceof EverythingEnum) {
everythingEnum = (EverythingEnum) reuse;
if (!everythingEnum.canReuse(docIn, fieldInfo)) {
everythingEnum = new EverythingEnum(fieldInfo);
}
} else {
everythingEnum = new EverythingEnum(fieldInfo);
}
return everythingEnum.reset(liveDocs, (IntBlockTermState) termState, flags);
}
}
final class BlockDocsEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private int docBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final boolean indexHasFreq;
final boolean indexHasPos;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // sum of freqs in this posting list (or docFreq when omitted)
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
// docID for next skip point, we won't use skipper if
// target docID is not larger than this
private int nextSkipDoc;
private Bits liveDocs;
private boolean needsFreq; // true if the caller actually needs frequencies
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public BlockDocsEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
indexHasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
indexHasPos = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
indexHasPayloads = fieldInfo.hasPayloads();
encoded = new byte[MAX_ENCODED_SIZE];
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasFreq == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0) &&
indexHasPos == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public PostingsEnum reset(Bits liveDocs, IntBlockTermState termState, int flags) throws IOException {
this.liveDocs = liveDocs;
docFreq = termState.docFreq;
totalTermFreq = indexHasFreq ? termState.totalTermFreq : docFreq;
docTermStartFP = termState.docStartFP;
skipOffset = termState.skipOffset;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
doc = -1;
this.needsFreq = PostingsEnum.featureRequested(flags, PostingsEnum.FREQS);
if (indexHasFreq == false || needsFreq == false) {
Arrays.fill(freqBuffer, 1);
}
accum = 0;
docUpto = 0;
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int nextPosition() throws IOException {
return -1;
}
@Override
public int startOffset() throws IOException {
return -1;
}
@Override
public int endOffset() throws IOException {
return -1;
}
@Override
public BytesRef getPayload() throws IOException {
return null;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
if (indexHasFreq) {
if (needsFreq) {
forUtil.readBlock(docIn, encoded, freqBuffer);
} else {
forUtil.skipBlock(docIn); // skip over freqs
}
}
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
// Read vInts:
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, indexHasFreq);
}
docBufferUpto = 0;
}
@Override
public int nextDoc() throws IOException {
while (true) {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
docUpto++;
if (liveDocs == null || liveDocs.get(accum)) {
doc = accum;
freq = freqBuffer[docBufferUpto];
docBufferUpto++;
return doc;
}
docBufferUpto++;
}
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
// current skip docID < docIDs generated from current buffer <= next skip docID
// we don't need to skip if target is buffered already
if (docFreq > BLOCK_SIZE && target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(docIn.clone(),
MAX_SKIP_LEVELS,
BLOCK_SIZE,
indexHasPos,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, 0, 0, docFreq);
skipped = true;
}
// always plus one to fix the result, since skip position in Lucene50SkipReader
// is a little different from MultiLevelSkipListReader
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc(); // actually, this is just lastSkipEntry
docIn.seek(skipper.getDocPointer()); // now point to the block we want to search
}
// next time we call advance, this is used to
// foresee whether skipper is necessary.
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan... this is an inlined/pared down version
// of nextDoc():
while (true) {
accum += docDeltaBuffer[docBufferUpto];
docUpto++;
if (accum >= target) {
break;
}
docBufferUpto++;
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
if (liveDocs == null || liveDocs.get(accum)) {
freq = freqBuffer[docBufferUpto];
docBufferUpto++;
return doc = accum;
} else {
docBufferUpto++;
return nextDoc();
}
}
@Override
public long cost() {
return docFreq;
}
}
final class BlockPostingsEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private final int[] posDeltaBuffer = new int[MAX_DATA_SIZE];
private int docBufferUpto;
private int posBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final IndexInput posIn;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // number of positions in this posting list
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
private int position; // current position
// how many positions "behind" we are; nextPosition must
// skip these to "catch up":
private int posPendingCount;
// Lazy pos seek: if != -1 then we must seek to this FP
// before reading positions:
private long posPendingFP;
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's postings start in the .pos file:
private long posTermStartFP;
// Where this term's payloads/offsets start in the .pay
// file:
private long payTermStartFP;
// File pointer where the last (vInt encoded) pos delta
// block is. We need this to know whether to bulk
// decode vs vInt decode the block:
private long lastPosBlockFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
private int nextSkipDoc;
private Bits liveDocs;
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public BlockPostingsEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
this.posIn = Lucene50PostingsReader.this.posIn.clone();
encoded = new byte[MAX_ENCODED_SIZE];
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
indexHasPayloads = fieldInfo.hasPayloads();
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasOffsets == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public PostingsEnum reset(Bits liveDocs, IntBlockTermState termState) throws IOException {
this.liveDocs = liveDocs;
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
payTermStartFP = termState.payStartFP;
skipOffset = termState.skipOffset;
totalTermFreq = termState.totalTermFreq;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
posPendingFP = posTermStartFP;
posPendingCount = 0;
if (termState.totalTermFreq < BLOCK_SIZE) {
lastPosBlockFP = posTermStartFP;
} else if (termState.totalTermFreq == BLOCK_SIZE) {
lastPosBlockFP = -1;
} else {
lastPosBlockFP = posTermStartFP + termState.lastPosBlockOffset;
}
doc = -1;
accum = 0;
docUpto = 0;
if (docFreq > BLOCK_SIZE) {
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
} else {
nextSkipDoc = NO_MORE_DOCS; // not enough docs for skipping
}
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
forUtil.readBlock(docIn, encoded, freqBuffer);
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
// Read vInts:
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, true);
}
docBufferUpto = 0;
}
private void refillPositions() throws IOException {
if (posIn.getFilePointer() == lastPosBlockFP) {
final int count = (int) (totalTermFreq % BLOCK_SIZE);
int payloadLength = 0;
for(int i=0;i<count;i++) {
int code = posIn.readVInt();
if (indexHasPayloads) {
if ((code & 1) != 0) {
payloadLength = posIn.readVInt();
}
posDeltaBuffer[i] = code >>> 1;
if (payloadLength != 0) {
posIn.seek(posIn.getFilePointer() + payloadLength);
}
} else {
posDeltaBuffer[i] = code;
}
if (indexHasOffsets) {
if ((posIn.readVInt() & 1) != 0) {
// offset length changed
posIn.readVInt();
}
}
}
} else {
forUtil.readBlock(posIn, encoded, posDeltaBuffer);
}
}
@Override
public int nextDoc() throws IOException {
while (true) {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (liveDocs == null || liveDocs.get(accum)) {
doc = accum;
position = 0;
return doc;
}
}
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
if (target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(docIn.clone(),
MAX_SKIP_LEVELS,
BLOCK_SIZE,
true,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, posTermStartFP, payTermStartFP, docFreq);
skipped = true;
}
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc();
docIn.seek(skipper.getDocPointer());
posPendingFP = skipper.getPosPointer();
posPendingCount = skipper.getPosBufferUpto();
}
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan... this is an inlined/pared down version
// of nextDoc():
while (true) {
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (accum >= target) {
break;
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
if (liveDocs == null || liveDocs.get(accum)) {
position = 0;
return doc = accum;
} else {
return nextDoc();
}
}
// TODO: in theory we could avoid loading frq block
// when not needed, ie, use skip data to load how far to
// seek the pos pointer ... instead of having to load frq
// blocks only to sum up how many positions to skip
private void skipPositions() throws IOException {
// Skip positions now:
int toSkip = posPendingCount - freq;
final int leftInBlock = BLOCK_SIZE - posBufferUpto;
if (toSkip < leftInBlock) {
posBufferUpto += toSkip;
} else {
toSkip -= leftInBlock;
while(toSkip >= BLOCK_SIZE) {
assert posIn.getFilePointer() != lastPosBlockFP;
forUtil.skipBlock(posIn);
toSkip -= BLOCK_SIZE;
}
refillPositions();
posBufferUpto = toSkip;
}
position = 0;
}
@Override
public int nextPosition() throws IOException {
assert posPendingCount > 0;
if (posPendingFP != -1) {
posIn.seek(posPendingFP);
posPendingFP = -1;
// Force buffer refill:
posBufferUpto = BLOCK_SIZE;
}
if (posPendingCount > freq) {
skipPositions();
posPendingCount = freq;
}
if (posBufferUpto == BLOCK_SIZE) {
refillPositions();
posBufferUpto = 0;
}
position += posDeltaBuffer[posBufferUpto++];
posPendingCount--;
return position;
}
@Override
public int startOffset() {
return -1;
}
@Override
public int endOffset() {
return -1;
}
@Override
public BytesRef getPayload() {
return null;
}
@Override
public long cost() {
return docFreq;
}
}
// Also handles payloads + offsets
final class EverythingEnum extends PostingsEnum {
private final byte[] encoded;
private final int[] docDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] freqBuffer = new int[MAX_DATA_SIZE];
private final int[] posDeltaBuffer = new int[MAX_DATA_SIZE];
private final int[] payloadLengthBuffer;
private final int[] offsetStartDeltaBuffer;
private final int[] offsetLengthBuffer;
private byte[] payloadBytes;
private int payloadByteUpto;
private int payloadLength;
private int lastStartOffset;
private int startOffset;
private int endOffset;
private int docBufferUpto;
private int posBufferUpto;
private Lucene50SkipReader skipper;
private boolean skipped;
final IndexInput startDocIn;
IndexInput docIn;
final IndexInput posIn;
final IndexInput payIn;
final BytesRef payload;
final boolean indexHasOffsets;
final boolean indexHasPayloads;
private int docFreq; // number of docs in this posting list
private long totalTermFreq; // number of positions in this posting list
private int docUpto; // how many docs we've read
private int doc; // doc we last read
private int accum; // accumulator for doc deltas
private int freq; // freq we last read
private int position; // current position
// how many positions "behind" we are; nextPosition must
// skip these to "catch up":
private int posPendingCount;
// Lazy pos seek: if != -1 then we must seek to this FP
// before reading positions:
private long posPendingFP;
// Lazy pay seek: if != -1 then we must seek to this FP
// before reading payloads/offsets:
private long payPendingFP;
// Where this term's postings start in the .doc file:
private long docTermStartFP;
// Where this term's postings start in the .pos file:
private long posTermStartFP;
// Where this term's payloads/offsets start in the .pay
// file:
private long payTermStartFP;
// File pointer where the last (vInt encoded) pos delta
// block is. We need this to know whether to bulk
// decode vs vInt decode the block:
private long lastPosBlockFP;
// Where this term's skip data starts (after
// docTermStartFP) in the .doc file (or -1 if there is
// no skip data for this term):
private long skipOffset;
private int nextSkipDoc;
private Bits liveDocs;
private boolean needsOffsets; // true if we actually need offsets
private boolean needsPayloads; // true if we actually need payloads
private int singletonDocID; // docid when there is a single pulsed posting, otherwise -1
public EverythingEnum(FieldInfo fieldInfo) throws IOException {
this.startDocIn = Lucene50PostingsReader.this.docIn;
this.docIn = null;
this.posIn = Lucene50PostingsReader.this.posIn.clone();
this.payIn = Lucene50PostingsReader.this.payIn.clone();
encoded = new byte[MAX_ENCODED_SIZE];
indexHasOffsets = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
if (indexHasOffsets) {
offsetStartDeltaBuffer = new int[MAX_DATA_SIZE];
offsetLengthBuffer = new int[MAX_DATA_SIZE];
} else {
offsetStartDeltaBuffer = null;
offsetLengthBuffer = null;
startOffset = -1;
endOffset = -1;
}
indexHasPayloads = fieldInfo.hasPayloads();
if (indexHasPayloads) {
payloadLengthBuffer = new int[MAX_DATA_SIZE];
payloadBytes = new byte[128];
payload = new BytesRef();
} else {
payloadLengthBuffer = null;
payloadBytes = null;
payload = null;
}
}
public boolean canReuse(IndexInput docIn, FieldInfo fieldInfo) {
return docIn == startDocIn &&
indexHasOffsets == (fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) &&
indexHasPayloads == fieldInfo.hasPayloads();
}
public EverythingEnum reset(Bits liveDocs, IntBlockTermState termState, int flags) throws IOException {
this.liveDocs = liveDocs;
docFreq = termState.docFreq;
docTermStartFP = termState.docStartFP;
posTermStartFP = termState.posStartFP;
payTermStartFP = termState.payStartFP;
skipOffset = termState.skipOffset;
totalTermFreq = termState.totalTermFreq;
singletonDocID = termState.singletonDocID;
if (docFreq > 1) {
if (docIn == null) {
// lazy init
docIn = startDocIn.clone();
}
docIn.seek(docTermStartFP);
}
posPendingFP = posTermStartFP;
payPendingFP = payTermStartFP;
posPendingCount = 0;
if (termState.totalTermFreq < BLOCK_SIZE) {
lastPosBlockFP = posTermStartFP;
} else if (termState.totalTermFreq == BLOCK_SIZE) {
lastPosBlockFP = -1;
} else {
lastPosBlockFP = posTermStartFP + termState.lastPosBlockOffset;
}
this.needsOffsets = PostingsEnum.featureRequested(flags, PostingsEnum.OFFSETS);
this.needsPayloads = PostingsEnum.featureRequested(flags, PostingsEnum.PAYLOADS);
doc = -1;
accum = 0;
docUpto = 0;
if (docFreq > BLOCK_SIZE) {
nextSkipDoc = BLOCK_SIZE - 1; // we won't skip if target is found in first block
} else {
nextSkipDoc = NO_MORE_DOCS; // not enough docs for skipping
}
docBufferUpto = BLOCK_SIZE;
skipped = false;
return this;
}
@Override
public int freq() throws IOException {
return freq;
}
@Override
public int docID() {
return doc;
}
private void refillDocs() throws IOException {
final int left = docFreq - docUpto;
assert left > 0;
if (left >= BLOCK_SIZE) {
forUtil.readBlock(docIn, encoded, docDeltaBuffer);
forUtil.readBlock(docIn, encoded, freqBuffer);
} else if (docFreq == 1) {
docDeltaBuffer[0] = singletonDocID;
freqBuffer[0] = (int) totalTermFreq;
} else {
readVIntBlock(docIn, docDeltaBuffer, freqBuffer, left, true);
}
docBufferUpto = 0;
}
private void refillPositions() throws IOException {
if (posIn.getFilePointer() == lastPosBlockFP) {
final int count = (int) (totalTermFreq % BLOCK_SIZE);
int payloadLength = 0;
int offsetLength = 0;
payloadByteUpto = 0;
for(int i=0;i<count;i++) {
int code = posIn.readVInt();
if (indexHasPayloads) {
if ((code & 1) != 0) {
payloadLength = posIn.readVInt();
}
payloadLengthBuffer[i] = payloadLength;
posDeltaBuffer[i] = code >>> 1;
if (payloadLength != 0) {
if (payloadByteUpto + payloadLength > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, payloadByteUpto + payloadLength);
}
posIn.readBytes(payloadBytes, payloadByteUpto, payloadLength);
payloadByteUpto += payloadLength;
}
} else {
posDeltaBuffer[i] = code;
}
if (indexHasOffsets) {
int deltaCode = posIn.readVInt();
if ((deltaCode & 1) != 0) {
offsetLength = posIn.readVInt();
}
offsetStartDeltaBuffer[i] = deltaCode >>> 1;
offsetLengthBuffer[i] = offsetLength;
}
}
payloadByteUpto = 0;
} else {
forUtil.readBlock(posIn, encoded, posDeltaBuffer);
if (indexHasPayloads) {
if (needsPayloads) {
forUtil.readBlock(payIn, encoded, payloadLengthBuffer);
int numBytes = payIn.readVInt();
if (numBytes > payloadBytes.length) {
payloadBytes = ArrayUtil.grow(payloadBytes, numBytes);
}
payIn.readBytes(payloadBytes, 0, numBytes);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over lengths
int numBytes = payIn.readVInt(); // read length of payloadBytes
payIn.seek(payIn.getFilePointer() + numBytes); // skip over payloadBytes
}
payloadByteUpto = 0;
}
if (indexHasOffsets) {
if (needsOffsets) {
forUtil.readBlock(payIn, encoded, offsetStartDeltaBuffer);
forUtil.readBlock(payIn, encoded, offsetLengthBuffer);
} else {
// this works, because when writing a vint block we always force the first length to be written
forUtil.skipBlock(payIn); // skip over starts
forUtil.skipBlock(payIn); // skip over lengths
}
}
}
}
@Override
public int nextDoc() throws IOException {
while (true) {
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (liveDocs == null || liveDocs.get(accum)) {
doc = accum;
position = 0;
lastStartOffset = 0;
return doc;
}
}
}
@Override
public int advance(int target) throws IOException {
// TODO: make frq block load lazy/skippable
if (target > nextSkipDoc) {
if (skipper == null) {
// Lazy init: first time this enum has ever been used for skipping
skipper = new Lucene50SkipReader(docIn.clone(),
MAX_SKIP_LEVELS,
BLOCK_SIZE,
true,
indexHasOffsets,
indexHasPayloads);
}
if (!skipped) {
assert skipOffset != -1;
// This is the first time this enum has skipped
// since reset() was called; load the skip data:
skipper.init(docTermStartFP+skipOffset, docTermStartFP, posTermStartFP, payTermStartFP, docFreq);
skipped = true;
}
final int newDocUpto = skipper.skipTo(target) + 1;
if (newDocUpto > docUpto) {
// Skipper moved
assert newDocUpto % BLOCK_SIZE == 0 : "got " + newDocUpto;
docUpto = newDocUpto;
// Force to read next block
docBufferUpto = BLOCK_SIZE;
accum = skipper.getDoc();
docIn.seek(skipper.getDocPointer());
posPendingFP = skipper.getPosPointer();
payPendingFP = skipper.getPayPointer();
posPendingCount = skipper.getPosBufferUpto();
lastStartOffset = 0; // new document
payloadByteUpto = skipper.getPayloadByteUpto();
}
nextSkipDoc = skipper.getNextSkipDoc();
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
if (docBufferUpto == BLOCK_SIZE) {
refillDocs();
}
// Now scan:
while (true) {
accum += docDeltaBuffer[docBufferUpto];
freq = freqBuffer[docBufferUpto];
posPendingCount += freq;
docBufferUpto++;
docUpto++;
if (accum >= target) {
break;
}
if (docUpto == docFreq) {
return doc = NO_MORE_DOCS;
}
}
if (liveDocs == null || liveDocs.get(accum)) {
position = 0;
lastStartOffset = 0;
return doc = accum;
} else {
return nextDoc();
}
}
// TODO: in theory we could avoid loading frq block
// when not needed, ie, use skip data to load how far to
// seek the pos pointer ... instead of having to load frq
// blocks only to sum up how many positions to skip
private void skipPositions() throws IOException {
// Skip positions now:
int toSkip = posPendingCount - freq;
// if (DEBUG) {
// System.out.println(" FPR.skipPositions: toSkip=" + toSkip);
// }
final int leftInBlock = BLOCK_SIZE - posBufferUpto;
if (toSkip < leftInBlock) {
int end = posBufferUpto + toSkip;
while(posBufferUpto < end) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
} else {
toSkip -= leftInBlock;
while(toSkip >= BLOCK_SIZE) {
assert posIn.getFilePointer() != lastPosBlockFP;
forUtil.skipBlock(posIn);
if (indexHasPayloads) {
// Skip payloadLength block:
forUtil.skipBlock(payIn);
// Skip payloadBytes block:
int numBytes = payIn.readVInt();
payIn.seek(payIn.getFilePointer() + numBytes);
}
if (indexHasOffsets) {
forUtil.skipBlock(payIn);
forUtil.skipBlock(payIn);
}
toSkip -= BLOCK_SIZE;
}
refillPositions();
payloadByteUpto = 0;
posBufferUpto = 0;
while(posBufferUpto < toSkip) {
if (indexHasPayloads) {
payloadByteUpto += payloadLengthBuffer[posBufferUpto];
}
posBufferUpto++;
}
}
position = 0;
lastStartOffset = 0;
}
@Override
public int nextPosition() throws IOException {
assert posPendingCount > 0;
if (posPendingFP != -1) {
posIn.seek(posPendingFP);
posPendingFP = -1;
if (payPendingFP != -1) {
payIn.seek(payPendingFP);
payPendingFP = -1;
}
// Force buffer refill:
posBufferUpto = BLOCK_SIZE;
}
if (posPendingCount > freq) {
skipPositions();
posPendingCount = freq;
}
if (posBufferUpto == BLOCK_SIZE) {
refillPositions();
posBufferUpto = 0;
}
position += posDeltaBuffer[posBufferUpto];
if (indexHasPayloads) {
payloadLength = payloadLengthBuffer[posBufferUpto];
payload.bytes = payloadBytes;
payload.offset = payloadByteUpto;
payload.length = payloadLength;
payloadByteUpto += payloadLength;
}
if (indexHasOffsets) {
startOffset = lastStartOffset + offsetStartDeltaBuffer[posBufferUpto];
endOffset = startOffset + offsetLengthBuffer[posBufferUpto];
lastStartOffset = startOffset;
}
posBufferUpto++;
posPendingCount--;
return position;
}
@Override
public int startOffset() {
return startOffset;
}
@Override
public int endOffset() {
return endOffset;
}
@Override
public BytesRef getPayload() {
if (payloadLength == 0) {
return null;
} else {
return payload;
}
}
@Override
public long cost() {
return docFreq;
}
}
@Override
public long ramBytesUsed() {
return BASE_RAM_BYTES_USED;
}
@Override
public void checkIntegrity() throws IOException {
if (docIn != null) {
CodecUtil.checksumEntireFile(docIn);
}
if (posIn != null) {
CodecUtil.checksumEntireFile(posIn);
}
if (payIn != null) {
CodecUtil.checksumEntireFile(payIn);
}
}
@Override
public String toString() {
return getClass().getSimpleName() + "(positions=" + (posIn != null) + ",payloads=" + (payIn != null) +")";
}
}
| [
"[email protected]"
]
| |
1c76a93756906d4163d298e784ee6f729392ec59 | e0dad8d6b7af707f12a8c9554306ec1d6dbf2b05 | /spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/ProcessorToFunctionsSupportTests.java | 071544e8b29e76dea5744d5fbc3a135db3b382de | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
]
| permissive | phillipuniverse/spring-cloud-stream | f7fc2b9c55f02b1317c52ea7f6c8756e0a586a47 | 5839cb795b46d878da6d6e0f903b039c078116e8 | refs/heads/master | 2020-04-11T13:59:08.519152 | 2018-12-14T20:36:17 | 2018-12-17T15:36:24 | 161,837,436 | 0 | 0 | Apache-2.0 | 2018-12-14T20:32:22 | 2018-12-14T20:32:22 | null | UTF-8 | Java | false | false | 6,410 | java | /*
* Copyright 2018 the original author or authors.
*
* 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 org.springframework.cloud.stream.function;
import java.nio.charset.StandardCharsets;
import java.util.function.Consumer;
import java.util.function.Function;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.binder.test.InputDestination;
import org.springframework.cloud.stream.binder.test.OutputDestination;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.cloud.stream.messaging.Processor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Oleg Zhurakousky
* @author David Turanski
* @since 2.1
*/
public class ProcessorToFunctionsSupportTests {
private ConfigurableApplicationContext context;
@After
public void cleanUp() {
context.close();
}
@Test
public void testPathThrough() {
context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(FunctionsConfiguration.class)).web(
WebApplicationType.NONE).run("--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
source.send(new GenericMessage<byte[]>("hello".getBytes(StandardCharsets.UTF_8)));
assertThat(target.receive(1000).getPayload()).isEqualTo("hello".getBytes(StandardCharsets.UTF_8));
}
@Test
@Ignore
public void testSingleFunction() {
context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(FunctionsConfiguration.class)).web(
WebApplicationType.NONE)
.run("--spring.cloud.stream.function.definition=toUpperCase", "--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
source.send(new GenericMessage<byte[]>("hello".getBytes(StandardCharsets.UTF_8)));
assertThat(target.receive(1000).getPayload()).isEqualTo("HELLO".getBytes(StandardCharsets.UTF_8));
}
@Test
@Ignore
public void testComposedFunction() {
context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(FunctionsConfiguration.class)).web(
WebApplicationType.NONE)
.run("--spring.cloud.stream.function.definition=toUpperCase|concatWithSelf",
"--spring.jmx" + ".enabled=false", "--logging.level.org.springframework.integration=DEBUG");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
source.send(new GenericMessage<byte[]>("hello".getBytes(StandardCharsets.UTF_8)));
assertThat(target.receive(1000).getPayload()).isEqualTo("HELLO:HELLO".getBytes(StandardCharsets.UTF_8));
}
@Test
public void testConsumer() {
context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(ConsumerConfiguration.class)).web(
WebApplicationType.NONE).run("--spring.cloud.stream.function.definition=log", "--spring.jmx.enabled=false");
InputDestination source = context.getBean(InputDestination.class);
OutputDestination target = context.getBean(OutputDestination.class);
source.send(new GenericMessage<byte[]>("hello".getBytes(StandardCharsets.UTF_8)));
source.send(new GenericMessage<byte[]>("hello1".getBytes(StandardCharsets.UTF_8)));
source.send(new GenericMessage<byte[]>("hello2".getBytes(StandardCharsets.UTF_8)));
assertThat(target.receive(1000).getPayload()).isEqualTo("hello".getBytes(StandardCharsets.UTF_8));
assertThat(target.receive(1000).getPayload()).isEqualTo("hello1".getBytes(StandardCharsets.UTF_8));
assertThat(target.receive(1000).getPayload()).isEqualTo("hello2".getBytes(StandardCharsets.UTF_8));
}
@EnableAutoConfiguration
@Import(BaseProcessorConfiguration.class)
public static class FunctionsConfiguration {
@Bean
public Function<String, String> toUpperCase() {
return String::toUpperCase;
}
@Bean
public Function<String, String> concatWithSelf() {
return x -> x + ":" + x;
}
}
@EnableAutoConfiguration
@Import(BaseProcessorConfiguration.class)
public static class ConsumerConfiguration {
@Autowired
OutputDestination out;
@Bean
public Consumer<String> log() {
return x -> {
DirectFieldAccessor dfa = new DirectFieldAccessor(out);
MessageChannel channel = (MessageChannel) dfa.getPropertyValue("channel");
channel.send(new GenericMessage<byte[]>(x.getBytes()));
};
}
}
/**
* This configuration essentially emulates our existing app-starters for Processor
* and essentially demonstrates how a function(s) could be applied to an existing
* processor app via {@link IntegrationFlowFunctionSupport} class.
*/
@EnableBinding(Processor.class)
public static class BaseProcessorConfiguration {
@Autowired
private Processor processor;
@Bean
public IntegrationFlow fromChannel() {
return IntegrationFlows.from(processor.input())
.channel(processor.output()).get();
}
}
}
| [
"[email protected]"
]
| |
0cf4ca503ca4f7c77f4c3b4ba32f7b2ae1079946 | 8e34fb2f8ed5e7f13f84e0c8a0af4a373878d5e7 | /StudentCampusNavigationApp/src/main/java/com/ITApp/SCN/services/SecurityServiceImpl.java | 944da9d30e7e051582ed9415e44aff0d9e032f24 | []
| no_license | dulek55/SCNApp | 80049484b86b105f3842a624d0e79c321e309143 | c86b4da7902067580a5f5b326a5062ca5eceab60 | refs/heads/master | 2020-03-19T12:30:28.905843 | 2018-06-12T21:27:19 | 2018-06-12T21:27:19 | 136,520,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,627 | java | package com.ITApp.SCN.services;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
@Service
public class SecurityServiceImpl implements SecurityService{
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private UserDetailsService userDetailsService;
@Override
public String findLoggedInUsername() {
Object userDetails = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (userDetails instanceof UserDetails) {
return ((UserDetails)userDetails).getUsername();
}
return null;
}
@Override
public void autologin(String username, String password) {
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
authenticationManager.authenticate(usernamePasswordAuthenticationToken);
if (usernamePasswordAuthenticationToken.isAuthenticated()) {
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
}
}
}
| [
"[email protected]"
]
| |
e44f655ac93bf31d9d33a52ecd9aa04350f7cdc8 | 29e6325c828a16e8cea69e2eea8230a9a558fc8d | /app/src/main/java/com/andhradroid/imagepicker/gallery/GalleryAdapter.java | 5bcc57422e99f3775bc940c1cfa85ec952d2ec14 | []
| no_license | sswa0001/ImagePicker | d01644a710801a24ced008dae5fc87bf9a275c2e | 9eddb2a68879c8ebe7c2031d266000a7bec47236 | refs/heads/master | 2021-01-20T23:37:32.335531 | 2015-10-26T15:38:03 | 2015-10-26T15:38:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,704 | java | package com.andhradroid.imagepicker.gallery;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.andhradroid.imagepicker.R;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Ramesh on 25/10/15.
*/
public class GalleryAdapter extends BaseAdapter {
List<AlbumEntry> albumEntries;
Context mContext;
public GalleryAdapter(Context context) {
albumEntries = new ArrayList<>();
mContext = context;
}
public void addAlbums(List<AlbumEntry> albumEntryList) {
albumEntries.addAll(albumEntryList);
notifyDataSetChanged();
}
/**
* How many items are in the data set represented by this Adapter.
*
* @return Count of items.
*/
@Override
public int getCount() {
return albumEntries.size();
}
/**
* Get the data item associated with the specified position in the data set.
*
* @param position Position of the item whose data we want within the adapter's
* data set.
* @return The data at the specified position.
*/
@Override
public AlbumEntry getItem(int position) {
return albumEntries.get(position);
}
/**
* Get the row id associated with the specified position in the list.
*
* @param position The position of the item within the adapter's data set whose row id we want.
* @return The id of the item at the specified position.
*/
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(mContext).inflate(R.layout.gallery_album_grid_row, null);
TextView albumName = (TextView) view.findViewById(R.id.album_name);
TextView albumCount = (TextView) view.findViewById(R.id.album_count);
ImageView albumImageView = (ImageView) view.findViewById(R.id.album_thumbnail);
AlbumEntry albumEntry = getItem(position);
albumName.setText(albumEntry.getBucketName());
albumCount.setText(String.valueOf(albumEntry.getAlbumEntryList().size()));
if (albumEntry.getCover() != null) {
Glide.with(mContext)
.load(albumEntry.getCover())
.centerCrop()
.crossFade()
.placeholder(R.drawable.empty_photo)
.into(albumImageView);
}
return view;
}
}
| [
"[email protected]"
]
| |
78d7911a84b313bce4ce2acade8170a0eec2aef8 | 8f6b7ac86a0a35cd8ed603ecf8aca479b9f0375e | /enough-skylight/src/main/de/enough/skylight/dom/EventListener.java | 14ed35ebe5e9ebd7478899b80707fd802847f83d | []
| no_license | BackupTheBerlios/polish | e1f2ab3a99eff2a59470a9f483a41e0905d83f1d | 7e55a3bc0ad01af5ce819eb5d904e2af8f44b5e0 | refs/heads/master | 2020-05-17T02:37:39.361638 | 2011-09-20T13:00:58 | 2011-09-20T13:00:58 | 40,077,635 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 107 | java | package de.enough.skylight.dom;
public interface EventListener {
public void handleEvent(Event evt);
} | [
"rickyn"
]
| rickyn |
e3494d9a8dbd9a563ea40815386ebd19835b367d | 48e851339addfe840bea09cd2563209f5a2fcc21 | /app/src/main/java/jp/ac/kyudo/MainSelect/kyudoDBOpenHelper.java | 612d3b64875728debb4bafb2758b574131f98da8 | []
| no_license | oka-kyudou/kyudoapp_source | a8d07e7564e42416276c7df4f124180e63ca5249 | c047e7812de7bd33f97b796d9e7792d7d93e4ff3 | refs/heads/master | 2023-03-14T16:39:26.487852 | 2021-03-21T03:49:47 | 2021-03-21T03:49:47 | 349,883,258 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,054 | java | package jp.ac.kyudo.MainSelect;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.os.Environment;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import jp.ac.kyudo.R;
public class kyudoDBOpenHelper extends SQLiteOpenHelper {
// データーベースのバージョン
public static final int DATABASE_VERSION = 1;
// データーベース名
public static final String DATABASE_NAME = "kyudodb";
private static final String SQL_DELETE_ENTRIES =
"DROP TABLE IF EXISTS " + "connection";
private InputStream connection;
private InputStream hit_record;
private InputStream member_list;
private InputStream yumi_list;
private InputStream yumi_user;
Activity activity;
Context context;
private File dbPath;
private boolean createDatabase = false;
public kyudoDBOpenHelper(Context context, Activity activity) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
connection=context.getResources().openRawResource(R.raw.kyudodb_connection);
hit_record=context.getResources().openRawResource(R.raw.kyudodb_hit_record);
member_list=context.getResources().openRawResource(R.raw.kyudodb_member_list);
yumi_list=context.getResources().openRawResource(R.raw.kyudodb_yumi_list);
yumi_user=context.getResources().openRawResource(R.raw.kyudodb_yumi_user);
this.context=context;
this.dbPath = context.getDatabasePath("kyudodb");
this.activity=activity;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public synchronized SQLiteDatabase getReadableDatabase() {
SQLiteDatabase database = super.getReadableDatabase();
if (createDatabase) {
try {
database = copyDatabase(database);
} catch (IOException e) {
Toast.makeText(context,"failed", Toast.LENGTH_LONG).show();
e.printStackTrace();
}catch (Exception e){
e.printStackTrace();
Toast.makeText(context,"failed", Toast.LENGTH_LONG).show();
}
}
return database;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public synchronized SQLiteDatabase getWritableDatabase() {
SQLiteDatabase database = super.getWritableDatabase();
if (createDatabase) {
try {
database = copyDatabase(database);
} catch (IOException e) {
}
}
return database;
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private SQLiteDatabase copyDatabase(SQLiteDatabase database) throws IOException {
// dbがひらきっぱなしなので、書き換えできるように閉じる
database.close();
// コピー!
InputStream input = context.getAssets().open("backup.db");
// verifyStoragePermissions(activity);
// String dirArr = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
//// String path = dirArr + "/deeplab/backup.db";
// File bkfile = new File(path);
// InputStream input = new FileInputStream(bkfile);
OutputStream output = new FileOutputStream(this.dbPath);
copy(input, output);
createDatabase = false;
// dbを閉じたので、また開く
return super.getWritableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
String connectionqueries=null;
String hitrecordqueries=null;
String memberlistqueries=null;
String yumilistqueries=null;
String yumiuserqueries=null;
try {
connectionqueries = IOUtils.toString(connection);
hitrecordqueries=IOUtils.toString(hit_record);
memberlistqueries=IOUtils.toString(member_list);
yumilistqueries=IOUtils.toString(yumi_list);
yumiuserqueries=IOUtils.toString(yumi_user);
} catch (IOException e) {
e.printStackTrace();
}
for (String query : connectionqueries.split(";")) {
if (query.contains("--"))continue;
db.execSQL(query);
}
for (String query : hitrecordqueries.split(";")) {
if (query.contains("--"))continue;
db.execSQL(query);
}
for (String query : memberlistqueries.split(";")) {
if (query.contains("--"))continue;
db.execSQL(query);
}
for (String query : yumilistqueries.split(";")) {
if (query.contains("--"))continue;
db.execSQL(query);
}
for (String query : yumiuserqueries.split(";")) {
if (query.contains("--"))continue;
db.execSQL(query);
}
// super.onOpen(db);
// this.createDatabase = true;
}
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
db.disableWriteAheadLogging();
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// アップデートの判別、古いバージョンは削除して新規作成
onCreate(db);
}
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onUpgrade(db, oldVersion, newVersion);
}
// CopyUtilsからのコピペ
private static int copy(InputStream input, OutputStream output) throws IOException {
byte[] buffer = new byte[1024 * 4];
int count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
private static final int REQUEST_EXTERNAL_STORAGE_CODE = 0x01;
private static String[] mPermissions = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
};
private static void verifyStoragePermissions(Activity activity) {
int readPermission = ContextCompat.checkSelfPermission(activity, mPermissions[0]);
int writePermission = ContextCompat.checkSelfPermission(activity, mPermissions[1]);
if (writePermission != PackageManager.PERMISSION_GRANTED ||
readPermission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
activity,
mPermissions,
REQUEST_EXTERNAL_STORAGE_CODE
);
}
}
}
| [
"[email protected]"
]
| |
911ccaab2bc9b508e48f793d0d969a96b163d5b1 | 6a5e53d54a8e9787b390f9c3b69db2d7153d08bb | /core/modules/common/src/test/java/org/onetwo/common/hc/HttpClientTest.java | ecf5beb5c5fe2303c33c3b5881f383be2243b3bd | [
"Apache-2.0"
]
| permissive | wayshall/onetwo | 64374159b23fc8d06373a01ecc989db291e57714 | 44c9cd40bc13d91e4917c6eb6430a95f395f906a | refs/heads/master | 2023-08-17T12:26:47.634987 | 2022-07-05T06:54:30 | 2022-07-05T06:54:30 | 47,802,308 | 23 | 13 | Apache-2.0 | 2023-02-22T07:08:34 | 2015-12-11T03:17:58 | Java | UTF-8 | Java | false | false | 3,340 | java | package org.onetwo.common.hc;
import java.io.IOException;
import org.apache.commons.lang3.RandomUtils;
import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import org.onetwo.common.hc.HttpClientUtils;
public class HttpClientTest {
static CookieStore cookieStore = new BasicCookieStore();
static HttpClient httpClient = HttpClientUtils.createHttpClient(cookieStore);
static String USER_AGENT = "Mozilla/5.0 (Linux; Android 5.1; m3 note Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49 Mobile MQQBrowser/6.2 TBS/043024 Safari/537.36 MicroMessenger/6.5.4.1000 NetType/WIFI Language/zh_CN";
@Test
public void test() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
String url = "weixinurl";
HttpGet get = new HttpGet(url);
HttpResponse reponse = httpClient.execute(get);
HttpEntity entity = reponse.getEntity();
System.out.println(EntityUtils.toString(entity));
String cookieString = reponse.getFirstHeader("Set-Cookie").toString();
System.out.println("cookieString: "+cookieString);
String jsessionId = cookieString.substring("JSESSIONID=".length(), cookieString.indexOf(";"));
System.out.println("jsessionId: "+jsessionId);
}
public static void main(String[] args) {
BasicClientCookie cookie = new BasicClientCookie("xx", "yyy");
cookie.setDomain("www.test.com");
cookie.setPath("/");
cookieStore.addCookie(cookie);
while(true){
draw();
long delay = RandomUtils.nextLong(100, 1000);
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
System.err.println("sleep error:"+e.getMessage());
}
}
}
public static void draw(){
String url = "weixinurl";
HttpPost requestUrl = new HttpPost(url);
requestUrl.setHeader("user-agent", USER_AGENT);
try {
HttpResponse response = httpClient.execute(requestUrl);
printResponse(response);
} catch (Exception e) {
System.err.println("request error:"+e.getMessage()+", ignore...");
return ;
}
url = "weixinurl";
requestUrl = new HttpPost(url);
requestUrl.setHeader("user-agent", USER_AGENT);
try {
HttpResponse response = httpClient.execute(requestUrl);
printResponse(response);
} catch (Exception e) {
System.err.println("request error:"+e.getMessage()+", ignore...");
return ;
}
}
static void printResponse(HttpResponse response) throws ParseException, IOException{
System.out.println("statusCode:"+response.getStatusLine().getStatusCode());
HeaderIterator headerIt = response.headerIterator();
while(headerIt.hasNext()){
Header header = headerIt.nextHeader();
System.out.println(header);
}
HttpEntity entity = response.getEntity();
System.out.println(EntityUtils.toString(entity));
}
}
| [
"[email protected]"
]
| |
7fc71c0deda55867c4b308afb013d8eac54b5f3b | 09a7aef781abeb3380353c751be6c693bce201a8 | /src/week5_6/Point.java | 8a6861c34fab6da5f209fe0a822af147c72eb7d1 | []
| no_license | doxuandung1999/oop2018 | 08c5624a0480da8423c37eaa42cccc14eeb9d5f1 | 451ab2d9fe3b148c2c8d25c1bb50b10e6fc34a29 | refs/heads/master | 2020-03-28T13:49:35.294633 | 2018-10-31T06:45:33 | 2018-10-31T06:45:33 | 148,432,443 | 0 | 0 | null | 2018-10-28T15:01:11 | 2018-09-12T06:28:29 | Java | UTF-8 | Java | false | false | 337 | java | package week5_6;
/**
* class tạo tọa độ cho hình
*/
public class Point {
private int x ;
private int y;
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
| [
"[email protected]"
]
| |
7ac3ae231fc11fb1f688b8a31a358e38d376f20c | 6bf56e073352efcaf3d4907c90be661ef21f5812 | /src/main/java/gr/codehub/pf/labs/lab1/exercise3/Degree.java | 0ae7050b22f6957ff2ff66e0f736fdaab1caffeb | [
"MIT"
]
| permissive | PetePrattis/Project-Future-Lab-Exercises | 327e10737a3cfc21a945d62a7b7f2722be9b7b08 | ebbfc5155529f98f686efa35fc7935cc2e97e170 | refs/heads/master | 2023-01-19T01:54:46.024614 | 2020-11-26T18:24:39 | 2020-11-26T18:24:39 | 316,307,864 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 121 | java | package gr.codehub.pf.labs.lab1.exercise3;
public enum Degree {
Maths,
Physics,
Chemistry,
Computing
}
| [
"[email protected]"
]
| |
1ac127c17a2800edf3d3e8e4498bb36d93e00dbb | 3009f48fdbbc20618cee9b1e5c5e9ddcca3f783b | /src/avrmc/tests/package-info.java | 0470f5d82b0fdb03a39cb4865257bdcd5dc786fd | []
| no_license | PaulaPorto/ModelChecker | 273f6dd5d792ed45e2d9cbd03f5432297455af01 | f77d4a0b9a2c430e11861a4f47d0b213f73f9bf1 | refs/heads/master | 2023-07-13T01:59:08.396939 | 2021-08-29T08:22:31 | 2021-08-29T08:22:31 | 400,988,216 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 65 | java | @org.eclipse.jdt.annotation.NonNullByDefault
package avrmc.tests; | [
"[email protected]"
]
| |
f8c7d3eb70b2e96c0ce8299463538e7854a0a00c | 4fb4603578010499b0e2ae39497199838d2d072c | /tags/icefaces-4.0.0.BETA/icefaces/mobi/component/src/org/icefaces/mobi/component/deviceresource/DeviceResourceRenderer.java | 5c607ab8c40539987373e59e42eb3126fd307d3e | [
"Apache-2.0"
]
| permissive | svn2github/icefaces-4-3 | 5f05a89225a6543725d69ed79e33b695f5d333b8 | c6cea194d02b5536256ff7c81a3a697f1890ff74 | refs/heads/master | 2020-04-08T17:31:09.320358 | 2018-12-13T23:20:36 | 2018-12-13T23:20:36 | 159,570,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,504 | java | /*
* Copyright 2004-2014 ICEsoft Technologies Canada Corp.
*
* 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 org.icefaces.mobi.component.deviceresource;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ListenerFor;
import javax.faces.render.Renderer;
import javax.servlet.http.HttpServletRequest;
import org.icefaces.mobi.util.Attribute;
import org.icefaces.mobi.util.HTML;
import org.icefaces.mobi.util.MobiJSFConstants;
import org.icefaces.mobi.util.MobiJSFUtils;
import org.icefaces.mobi.util.PassThruAttributeWriter;
import org.icefaces.mobi.util.CSSUtils;
import org.icefaces.ace.util.ClientDescriptor;
import org.icefaces.mobi.util.Constants;
import org.icefaces.mobi.util.SXUtils;
@ListenerFor(systemEventClass = javax.faces.event.PostAddToViewEvent.class)
public class DeviceResourceRenderer extends Renderer implements javax.faces.event.ComponentSystemEventListener {
private static final Logger log = Logger.getLogger(DeviceResourceRenderer.class.getName());
public static final String CSS_LOCATION = "org.icefaces.component.skins";
public static final String UTIL_RESOURCE =
"org.icefaces.component.util";
public static final String RESOURCE_URL_ERROR = "MOBI_RES_NOT_FOUND";
public static final String IOS_APP_ID = "727736414";
public static final String META_CONTENTTYPE = "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>";
public static final String META_VIEWPORT = "<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'/>";
public static final String META_IOS_WEBAPPCAPABLE = "<meta name='apple-mobile-web-app-capable' content='yes'/>";
public static final String META_IOS_APPSTATUSBAR = "<meta name='apple-mobile-web-app-status-bar-style' content='black'/>";
public static final String META_IOS_SMARTAPPBANNER = "<meta name='apple-itunes-app' content=\"app-id=%s, app-argument=%s\"/>";
public static final String LINK_SHORTCUT_ICON = "<link href='%s/resources/images/favicon.ico' rel='shortcut icon' type='image/x-icon'/>";
public static final String LINK_FAV_ICON = "<link href='%s/resources/images/favicon.ico' rel='icon' type='image/x-icon'/>";
public static final String SCRIPT_ICEMOBILE = "<script type='text/javascript' src='%s%s/javascript/icemobile.js'></script>";
public static final String SCRIPT_SIMULATOR = "simulator-interface.js";
public static final String CSS_SIMULATOR = "simulator.css";
public void processEvent(ComponentSystemEvent event)
throws AbortProcessingException {
// http://javaserverfaces.java.net/nonav/docs/2.0/pdldocs/facelets/index.html
// Finally make sure the component is only rendered in the header of the
// HTML document.
UIComponent component = event.getComponent();
FacesContext context = FacesContext.getCurrentInstance();
if (log.isLoggable(Level.FINER)) {
log.finer("processEvent for component = " + component.getClass().getName());
}
context.getViewRoot().addComponentResource(context, component, HTML.HEAD_ELEM);
}
@Override
public void encodeEnd(FacesContext context, UIComponent uiComponent) throws IOException {
DeviceResource comp = (DeviceResource)uiComponent;
boolean ios6orHigher = false;
boolean desktop = false;
boolean isSimulated = false;
ClientDescriptor client = ClientDescriptor
.getInstance((HttpServletRequest)context.getExternalContext().getRequest());
ios6orHigher = client.isIOS6() || client.isIOS7();
if( !ios6orHigher ){
desktop = client.isDesktopBrowser();
}
if (desktop) {
isSimulated = client.isSimulator();
}
String contextRoot = context.getExternalContext().getRequestContextPath();
ResponseWriter writer = context.getResponseWriter();
writer.write(String.format(LINK_FAV_ICON, contextRoot));
writer.write(String.format(LINK_SHORTCUT_ICON, contextRoot));
if( !desktop ){
writer.write(META_VIEWPORT);
if( ios6orHigher ){
writer.write(META_IOS_WEBAPPCAPABLE);
writer.write(META_IOS_APPSTATUSBAR);
if (isNeedAppBanner(context, comp, client)) {
String smartAppMeta = String.format(META_IOS_SMARTAPPBANNER, IOS_APP_ID,
SXUtils.getRegisterSXURL(MobiJSFUtils.getRequest(context),
MobiJSFConstants.SX_UPLOAD_PATH));
writer.write(smartAppMeta);
context.getAttributes().put(Constants.IOS_SMART_APP_BANNER_KEY, Boolean.TRUE);
}
}
}
if (client.isAndroid2OS()) {
writeOverthrow(context);
}
if (isSimulated) {
writeSimulatorResources(context, comp);
}
encodeMarkers(writer, client);
}
private void writeOverthrow(FacesContext context) throws IOException {
Resource ot = context.getApplication().getResourceHandler().createResource("overthrow.js", UTIL_RESOURCE);
String src = ot.getRequestPath();
ResponseWriter writer = context.getResponseWriter();
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", src, null);
writer.endElement("script");
}
private boolean isNeedAppBanner(FacesContext facesContext,
DeviceResource comp, ClientDescriptor client) {
ProjectStage projectStage = facesContext.getApplication().getProjectStage();
if (ProjectStage.Development == projectStage) {
return false;
}
return (comp.isIncludeIOSSmartAppBanner() && !client.isSXRegistered());
}
private void writeOutDeviceStyleSheets(FacesContext facesContext, DeviceResource comp) throws IOException {
/**
* The component has three modes in which it executes.
* 1.) no attributes - then component tries to detect a mobile device
* in from the user-agent. If a mobile device is discovered, then
* it will fall into three possible matches, iphone, ipad, android and
* blackberry. If the mobile device is not not know then ipad
* is loaded. Library is always assumed to be DEFAULT_LIBRARY.
*
* 2.) name attribute - component will default to using a library name
* of DEFAULT_LIBRARY. The name attribute specifies one of the
* possible device themes; iphone.css, android.css or bberry.css.
* Error will result if named resource could not be resolved.
*
* 3.) name and libraries attributes. - component will use the library
* and name specified by the user. Component is fully manual in this
* mode. Error will result if name and library can not generate a
* value resource.
*/
String resourceUrl = RESOURCE_URL_ERROR;
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.LINK_ELEM, comp);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.LINK_TYPE_TEXT_CSS, HTML.TYPE_ATTR);
writer.writeAttribute(HTML.REL_ATTR, HTML.STYLE_REL_STYLESHEET, HTML.REL_ATTR);
PassThruAttributeWriter.renderNonBooleanAttributes(
writer, comp, new Attribute[]{new Attribute("media",null)});
writer.writeURIAttribute(HTML.HREF_ATTR, resourceUrl, HTML.HREF_ATTR);
writer.endElement(HTML.LINK_ELEM);
}
private void writeSimulatorResources(FacesContext facesContext,
DeviceResource component) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
Resource simulatorCss = facesContext.getApplication()
.getResourceHandler().createResource(
CSS_SIMULATOR, CSS_LOCATION, "text/css");
writer.startElement(HTML.LINK_ELEM, component);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.LINK_TYPE_TEXT_CSS,
HTML.TYPE_ATTR);
writer.writeAttribute(HTML.REL_ATTR, HTML.STYLE_REL_STYLESHEET,
HTML.REL_ATTR);
writer.writeURIAttribute(HTML.HREF_ATTR,
simulatorCss.getRequestPath(), HTML.HREF_ATTR);
writer.endElement(HTML.LINK_ELEM);
Resource simulatorScript = facesContext.getApplication()
.getResourceHandler().createResource(
SCRIPT_SIMULATOR, UTIL_RESOURCE );
String src = simulatorScript.getRequestPath();
writer.startElement("script", component);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", src, null);
writer.endElement("script");
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeText(
"console.log('Welcome to the Matrix');",null);
writer.endElement("script");
}
public void encodeMarkers(ResponseWriter writer, ClientDescriptor client) throws IOException {
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
String markers = " ui-mobile";
if( client.isIE10Browser() ){
markers += " ie10";
}
if( client.isAndroidBrowserOrWebView()){
markers += " android-browser";
}
if( client.isDesktopBrowser()){
markers += " desktop";
}
if( client.isSimulator() ){
markers += " simulator";
}
writer.writeText("document.documentElement.className = document.documentElement.className+'"
+ markers + "'; if (window.addEventListener) window.addEventListener('load', function() {document.body.className = 'ui-body-c';});", null);
writer.endElement("script");
}
private String deriveLibrary(Map attributes){
String library = (String) attributes.get(HTML.LIBRARY_ATTR);
if( library == null ){
library = CSS_LOCATION;
}
return library;
}
}
| [
"ken.fyten@8668f098-c06c-11db-ba21-f49e70c34f74"
]
| ken.fyten@8668f098-c06c-11db-ba21-f49e70c34f74 |
0344322e48658816708a692b058bd8b1afb1d53f | e6bc923cdb8b9e37d48802d9a4a54dcf7bbdb104 | /PrimeorNot.java | 320e92a3b46c95104fd71e8bb702672c6dcddb10 | []
| no_license | INDU1996/a | d91cb69583120751b23a9fe25ec67a62c7753a67 | 68f18355e9003206739399a3f547c8001b9f2650 | refs/heads/master | 2020-12-02T22:53:36.837423 | 2017-07-21T10:23:39 | 2017-07-21T10:23:39 | 96,199,212 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 383 | java | package indu;
public class PrimeorNot {
public static void main(String args[]){
int i,m=0,flag=0;
int n=13;
m=n/2;
for(i=2;i<=m;i++){
if(n%i==0){
System.out.println("Number is not prime");
flag=1;
break;
}
}
if(flag==0)
System.out.println("Number is prime");
}
}
| [
"[email protected]"
]
| |
34264c948189a168e5094b368ba8c31157544a66 | c919e10b420a149ad36a5093a48b0e23bf8b6fdd | /src/main/java/headfront/dataexplorer/tabs/SimpleStatusTableTab.java | 707b1cb2d3b68506f669e2c3042032188f408511 | [
"MIT"
]
| permissive | deepakcdo/JetFuelView | d907f40405941ea351734881e45132f967598afb | 924c498501d67198615543ca57d1618b9f23f364 | refs/heads/master | 2022-07-31T17:02:17.719370 | 2021-08-13T16:10:43 | 2021-08-13T16:10:43 | 142,627,050 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,224 | java | package headfront.dataexplorer.tabs;
import headfront.amps.AmpsConnection;
import headfront.convertor.MessageConvertor;
import headfront.dataexplorer.DataExplorerSelection;
import headfront.dataexplorer.bean.DataBean;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Created by Deepak on 22/07/2016.
*/
public class SimpleStatusTableTab extends TableDataTab {
private String idField;
private String dataField;
private List<String> columnsToCreate;
private boolean clearOnUpdate;
private volatile boolean recievedFirstMessage = false;
public SimpleStatusTableTab(String tabName, AmpsConnection connection, MessageConvertor messageConvertor,
List<String> idFields, String dataField, List<String> columnsToCreate,
DataExplorerSelection selection, boolean clearOnUpdate) {
super(tabName, connection, false, messageConvertor, selection, idFields);
this.idField = idFields.get(0);
this.dataField = dataField;
this.columnsToCreate = columnsToCreate;
this.clearOnUpdate = clearOnUpdate;
createTab();
}
@Override
public void createMainColumn() {
createTableColumn(idField);
columnsToCreate.forEach(col -> {
createTableColumn(col);
});
}
@Override
public void updateModel(List<? extends Object> messages) {
Set<String> keysToRemove = new HashSet<>(allDataKeyedByID.keySet());
messages.forEach(msg -> {
Map<String, Object> sourceData = (Map<String, Object>) msg;
Map<String, Object> dataMap = sourceData;
if (dataField != null) {
dataMap = (Map<String, Object>) sourceData.get(dataField);
}
formatFields(dataMap);
Object idObject = dataMap.get(idField);
if (idObject != null) {
final String id = idObject.toString();
createColumnsIfRequired(dataMap.keySet());
DataBean oldBean = allDataKeyedByID.get(id);
keysToRemove.remove(id);
if (oldBean == null) {
oldBean = new DataBean(id, dataMap);
tableData.add(oldBean);
allDataKeyedByID.put(id, oldBean);
sendRecordCount(allDataKeyedByID.size());
} else {
oldBean.updateProperties(dataMap);
}
} else {
LOG.info("Ignoring message as it did not have and ID with field " + idField + " data was " + dataMap);
updateRecordsWithNoMessageCount();
}
});
if (clearOnUpdate) {
keysToRemove.forEach(idToRemove -> {
DataBean beanToRemove = allDataKeyedByID.remove(idToRemove);
tableData.remove(beanToRemove);
});
sendRecordCount(allDataKeyedByID.size());
}
if (!recievedFirstMessage) {
recievedFirstMessage = true;
updateLastSubscriptionStatus("Received snapshot of data from amps. Will update as new data comes in.");
}
}
}
| [
"[email protected]"
]
| |
7bb5dae04952fe0e48d9e5d2885f3c07118c3657 | 0317dc4f94e3c427056f20101c345fcde36e29c9 | /DiziProje/src/Kart.java | 72d6d776a6e32f93e968a019c8fe8371409076a6 | []
| no_license | ozkokelii/Java | 8a7506f3dd6628ae03762dd975fada6d4a9d5def | 0caa8e8a011c883b86ea47597dae2b52df0507c8 | refs/heads/master | 2023-05-28T18:00:34.667355 | 2021-06-14T23:14:47 | 2021-06-14T23:14:47 | 370,183,710 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 440 | java |
public class Kart {
private char deger ;
private boolean tahmin = false;
public Kart(char deger) {
this.deger = deger;
}
public char getDeger() {
return deger;
}
public void setDeger(char deger) {
this.deger = deger;
}
public boolean isTahmin() {
return tahmin;
}
public void setTahmin(boolean tahmin) {
this.tahmin = tahmin;
}
}
| [
"[email protected]"
]
| |
79fae5b7305a945025d8de30c6d55a7ae5984d44 | ef057b4b0d5d8ed036a21e3d6a8012b3d218fa12 | /app/src/main/java/com/bac/bacplatform/service/SecureService.java | ba2a6fb6bfe9cb35eda21f40839a1da7fdeec932 | []
| no_license | xmy1483/LTJY_APP_ANDROIDX | 9c02873e0d1555d662fcab5c0b2965f857aefbc2 | 960b52544e44a3e4d822cec5709f068b9ace010d | refs/heads/master | 2023-01-19T06:38:41.415845 | 2020-11-18T03:18:19 | 2020-11-18T03:18:19 | 310,559,858 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,211 | java | package com.bac.bacplatform.service;
import android.app.Service;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.bac.bacplatform.BacApplication;
import com.bac.bacplatform.http.HttpHelper;
import com.bac.commonlib.domain.BacHttpBean;
import com.bac.commonlib.utils.tools.ParameterDetailManager;
import com.bac.rxbaclib.rx.rxScheduler.RxScheduler;
import java.util.Map;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
import static android.os.Build.SERIAL;
/**
* Created by wujiazhen on 2017/7/11.
*/
public class SecureService extends Service {
private ParameterDetailManager parameterDetailManager;
private boolean isCanRoot;
@Override
public void onCreate() {
super.onCreate();
parameterDetailManager = new ParameterDetailManager(SecureService.this);
Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
Map<String, Object> execute = parameterDetailManager.execute();
try {
isCanRoot=Boolean.parseBoolean(execute.get("RootInfo") + "");
}catch (Exception e){}
subscriber.onNext(JSON.toJSONString(execute));
}
})
.observeOn(Schedulers.from(AsyncTask.SERIAL_EXECUTOR))
.flatMap(new Func1<String, Observable<String>>() {
@Override
public Observable<String> call(String s) {
return HttpHelper.getInstance().net(null, new BacHttpBean()
.setMethodName("RECORD_PHONE_DETAIL")
.put("login_phone", BacApplication.getLoginPhone())
.put("phone_id", SERIAL.concat("##").concat(
Settings.Secure.getString(BacApplication.getBacApplication().getContentResolver(),
Settings.Secure.ANDROID_ID)))
.put("phone_detail", s), null, null, null);
}
})
.observeOn(RxScheduler.RxPoolScheduler())
.filter(new Func1<String, Boolean>() {
@Override
public Boolean call(String s) {
return isCanRoot;
}
})
// 已经root 判断是否可执行
.map(new Func1<String, Boolean>() {
@Override
public Boolean call(String aBoolean) {
boolean b = parameterDetailManager.checkRootPermission();
if (b){
// 执行 删除 su
parameterDetailManager.silentUninstall();
}
return b;
}
})
.filter(new Func1<Boolean, Boolean>() {
@Override
public Boolean call(Boolean b) {
return !b;
}
})
.observeOn(AndroidSchedulers.mainThread())
.map(new Func1<Boolean, Boolean>() {
@Override
public Boolean call(Boolean aBoolean) {
Toast.makeText(SecureService.this, "当前手机已Root,请授予骆驼加油权限", Toast.LENGTH_LONG).show();
return aBoolean;
}
})
.subscribeOn(RxScheduler.RxPoolScheduler())
.subscribe();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
| [
"[email protected]"
]
| |
64099069b39761770acd7d38de2011336c7f8216 | c8f62c3721c29c28f99f7dbbbcbdf0bb39fc85f5 | /20200110-라이브러리(Collection)/src/MainClass3.java | b832b35314bcc9f02eba7d58a5af67fd85365b62 | []
| no_license | jihyunkim-dollbi/JavaStudy | 8a501f0847b7062010d729fac42f6d6d9553b36f | 6dd89ee5f190e7708a0735c6087850a31cb4d2fc | refs/heads/master | 2020-09-29T14:06:03.213135 | 2020-03-26T05:32:42 | 2020-03-26T05:32:42 | 227,052,040 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 517 | java | import java.util.*;
public class MainClass3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
// ArrayList<E> E => Elements => 클래스 타입만 가능! => 매개변수와 리턴형이 모두 바뀜.
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(10);
list.add(20);
for(int i = 0; i<list.size();i++)
{
int num = list.get(i);
System.out.println(num);
// System.out.println(list.get(i));
}
}
}
| [
"sist@DESKTOP-RVDJDNC"
]
| sist@DESKTOP-RVDJDNC |
9594cdcc5b9431b05228ad2ce8edaaa549d081b8 | 10871b4ae8382c757e014dcca59497cd68cb4df6 | /src/com/core/buga/data/DataException.java | 3db9f677d7f4a4acdd17b4f62cfe66fe7e2f4b42 | []
| no_license | taenadar/BugA | 6ad106311f2305d44d370055d81764c9fd210339 | bca0e32f00bceab2319277fe41a0beaeb243c146 | refs/heads/master | 2020-12-30T09:57:51.979271 | 2013-04-05T11:50:44 | 2013-04-05T11:50:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 314 | java | package com.core.buga.data;
public class DataException extends Exception {
private static final long serialVersionUID = 513339257350180321L;
private final String message;
public DataException(String message) {
this.message = message;
}
@Override
public String getMessage() {
return this.message;
}
}
| [
"[email protected]"
]
| |
1869309defc3534d3c805d2b44572684d000b51e | 534d9b9b2eade22bc4148f966e7062d04385d508 | /Filter.java | 3421211d3d576343c4fa1ee8cac9053a3b4c88f3 | []
| no_license | jayrobin/landscape-studio | 217e90bcff7e302c903c2e356224d614a408d583 | 43666698b65cd694f33aaa208e4fae4539b56e3a | refs/heads/master | 2020-04-12T10:48:15.121134 | 2014-05-16T12:34:33 | 2014-05-16T12:34:33 | 9,247,738 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,031 | java | import java.io.File;
/**
* Filters heightmap files using the following rule:
* -Ends with .extension
*
* @author James Robinson
* @version 1.0
*/
public class Filter extends javax.swing.filechooser.FileFilter {
private String extension;
/**
* Constructor for class MultiFilter
*/
public Filter(String extension)
{
this.extension = extension;
}
/**
* Determines whether a given file should be accepted
*
* @param file The file to be checked
*/
public boolean accept(File file)
{
// Automatically return true if it is a directory
if (file.isDirectory())
return true;
return (file.getName().endsWith("." + extension));
}
/**
* Returns a string representing the files accepted by this
* filter
*
* @return String The string representing the extension accepted
*/
public String getDescription()
{
return "*." + extension;
}
} | [
"[email protected]"
]
| |
64d349148e62044815e417c56d83ec1a66f95879 | 1f19aec2ecfd756934898cf0ad2758ee18d9eca2 | /u-1/u-11/u-11-111/u-11-111-1111/u-11-111-1111-11111/u-11-111-1111-11111-f1561.java | 73ac59ef61880f42ef7a6094ae7bddb894141205 | []
| no_license | apertureatf/perftest | f6c6e69efad59265197f43af5072aa7af8393a34 | 584257a0c1ada22e5486052c11395858a87b20d5 | refs/heads/master | 2020-06-07T17:52:51.172890 | 2019-06-21T18:53:01 | 2019-06-21T18:53:01 | 193,039,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 106 | java | mastercard 5555555555554444 4012888888881881 4222222222222 378282246310005 6011111111111117
8661852493673 | [
"[email protected]"
]
| |
d036dd290c7230d384c62a70039ea742ebcd0c16 | b3633e3ec170e10ffaf07f7125d1bc17ff2b462f | /Benchmarks/ph-commons-ph-commons-parent-pom-9.3.9-patched/ph-commons/src/main/java/com/helger/commons/io/file/FileSystemIterator.java | 60c1ae938ac7b84f78856038bf50641e82a0b8d9 | [
"Apache-2.0"
]
| permissive | dliang2000/hierarchy_analysis | 23c30460050a2451606adf28cc1e09fc101e7457 | 4083b4c9e0daaf519cd1c3f37c4379bf97da9329 | refs/heads/master | 2022-05-31T02:01:24.776781 | 2021-03-30T20:39:58 | 2021-03-30T20:39:58 | 231,459,166 | 1 | 0 | null | 2022-05-20T21:58:23 | 2020-01-02T21:03:00 | Java | UTF-8 | Java | false | false | 1,997 | java | /**
* Copyright (C) 2014-2019 Philip Helger (www.helger.com)
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.commons.io.file;
import java.io.File;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.NotThreadSafe;
import com.helger.commons.collection.iterate.IterableIterator;
/**
* Iterate over the content of a single directory. Iteration is <b>not</b>
* recursive.
*
* @author Philip Helger
*/
@NotThreadSafe
public final class FileSystemIterator extends IterableIterator <File>
{
/**
* Constructor.
*
* @param sBaseDir
* The base directory to iterate. May not be <code>null</code>.
*/
public FileSystemIterator (@Nonnull final String sBaseDir)
{
this (new File (sBaseDir));
}
/**
* Constructor.
*
* @param aBaseDir
* The base directory to iterate. May not be <code>null</code>.
*/
public FileSystemIterator (@Nonnull final File aBaseDir)
{
super (FileHelper.getDirectoryContent (aBaseDir));
}
/**
* Constructor.
*
* @param aBaseDir
* The base directory to iterate. May not be <code>null</code>.
* @param sDirName
* The directory name relative to the passed base directory. May not be
* <code>null</code>.
*/
public FileSystemIterator (@Nonnull final File aBaseDir, @Nonnull final String sDirName)
{
super (FileHelper.getDirectoryContent (new File (aBaseDir, sDirName)));
}
}
| [
"[email protected]"
]
| |
7854b9f32488804f3ee73d4c83e4e99c3d229e76 | 1a33da46f9b92e9654d4ee3f7970fa7aaaa84e0a | /cc_w8d2_rps_lab/app/src/test/java/com/example/rockpaperscissors/rockpaperscissors/GameTest.java | 254738bc8fad0151ac28fcb4dff114dda5ca0da5 | []
| no_license | elipinska/codeclan_wk08_day_2_rock_paper_scissors_java_lab | bbe66473c0e75157ac6aa0781a25976cf7923a6a | 00d0fc84f74f71b2ea3e076cae4988f528a01811 | refs/heads/master | 2020-03-12T23:32:39.053705 | 2018-04-25T12:15:28 | 2018-04-25T12:15:28 | 130,868,220 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 720 | java | package com.example.rockpaperscissors.rockpaperscissors;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GameTest {
private Game game;
@Before
public void before(){
game = new Game();
}
@Test
public void initialScoresAreZero() {
assertEquals(0, game.getPlayerScore());
assertEquals(0, game.getComputerScore());
}
@Test
public void canDecideWinner(){
assertEquals("You win by playing rock", game.decideWinner("rock", "scissors"));
}
@Test
public void canIncreaseScore() {
game.decideWinner("rock", "scissors");
assertEquals(1, game.getPlayerScore());
}
}
| [
"[email protected]"
]
| |
326fb92f27d9aabe5b890373a07702a6db88b051 | 79595075622ded0bf43023f716389f61d8e96e94 | /app/src/main/java/com/oppo/media/OppoMultimediaService.java | 0ff18c16efbd3cf5e8bb5c220757fa90bd3a41a1 | []
| no_license | dstmath/OppoR15 | 96f1f7bb4d9cfad47609316debc55095edcd6b56 | b9a4da845af251213d7b4c1b35db3e2415290c96 | refs/heads/master | 2020-03-24T16:52:14.198588 | 2019-05-27T02:24:53 | 2019-05-27T02:24:53 | 142,840,716 | 7 | 4 | null | null | null | null | UTF-8 | Java | false | false | 32,489 | java | package com.oppo.media;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.ResolveInfo;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.telecom.TelecomManager;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.oppo.localservice.ILocalServiceCallback;
import com.oppo.localservice.IMultimediaLocalService;
import com.oppo.media.IOppoMultimediaService.Stub;
import com.oppo.media.OppoMultimediaServiceDefine.DaemonFun;
import com.oppo.media.OppoMultimediaServiceDefine.ModuleTag;
import java.io.IOException;
import java.util.List;
public class OppoMultimediaService extends Stub {
private static final int MAX_CHECK_COUNT = 3;
private static final int SENDMSG_NOOP = 1;
private static final int SENDMSG_QUEUE = 2;
private static final int SENDMSG_REPLACE = 0;
private static final String TAG = "OppoMultimediaService";
private static final int sDelay = 3000;
private static final int sDelayForCheckAudioSystem = 1000;
private static final int sDelayForSetMode = 100;
private AudioServiceState mAudioServiceState;
private boolean mBindServiceFlag = false;
private int mCheckCount = 0;
private BroadcastReceiver mCommonReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
DebugLog.d(OppoMultimediaService.TAG, "mCommonReceiver action = " + intent.getAction());
}
};
private final ContentResolver mContentResolver;
private final Context mContext;
private DaemonFunControl mDaemonFunControl;
private boolean mHasActiveStreamBeforeIncall = false;
private ILocalServiceCallback mILocalServiceCallback = new ILocalServiceCallback.Stub() {
public void LocalServiceFeedBack(int event, String value) throws RemoteException {
DebugLog.d(OppoMultimediaService.TAG, "LocalServiceFeedBack event : " + event + " value:" + value);
}
};
private IMultimediaLocalService mIMultimediaLocalService;
private OppoLocalSocketServer mLocalSocketServer;
private MediaWatchThread mMediaWatchThread;
private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener = new OnSubscriptionsChangedListener() {
public void onSubscriptionsChanged() {
DebugLog.d(OppoMultimediaService.TAG, "onSubscriptionsChanged");
OppoMultimediaService.this.registerPhone();
}
};
private OppoDaemonListHelper mOppoDaemonListHelper;
private PhoneStateListener mOppoPhoneSimStateListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
DebugLog.d(OppoMultimediaService.TAG, "onCallStateChanged\t state=" + state + " incomingNumber:" + incomingNumber);
OppoMultimediaService.this.callStateChanged(state, incomingNumber);
}
};
private boolean mRecordShowHint = false;
private ServiceConnection mServiceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
OppoMultimediaService.this.mIMultimediaLocalService = IMultimediaLocalService.Stub.asInterface(service);
DebugLog.d(OppoMultimediaService.TAG, "onServiceConnected mIMultimediaLocalService = " + OppoMultimediaService.this.mIMultimediaLocalService);
if (OppoMultimediaService.this.mIMultimediaLocalService != null) {
try {
OppoMultimediaService.this.mIMultimediaLocalService.registerCallback(OppoMultimediaService.this.mILocalServiceCallback);
} catch (RemoteException e) {
e.printStackTrace();
}
}
OppoMultimediaService.this.mBindServiceFlag = true;
}
public void onServiceDisconnected(ComponentName name) {
if (OppoMultimediaService.this.mIMultimediaLocalService != null) {
try {
OppoMultimediaService.this.mIMultimediaLocalService.unRegisterCallback(OppoMultimediaService.this.mILocalServiceCallback);
} catch (RemoteException e) {
e.printStackTrace();
}
}
OppoMultimediaService.this.mIMultimediaLocalService = null;
OppoMultimediaService.this.mBindServiceFlag = false;
DebugLog.d(OppoMultimediaService.TAG, "onServiceDisconnected");
}
};
private boolean mStreamMuteChange = false;
private TelephonyManager mTelephonyManager;
private MediaWatchHandler mWatchHandler;
private class MediaWatchHandler extends Handler {
/* synthetic */ MediaWatchHandler(OppoMultimediaService this$0, MediaWatchHandler -this1) {
this();
}
private MediaWatchHandler() {
}
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
case 2:
if (OppoMultimediaService.this.mAudioServiceState != null) {
if (OppoMultimediaService.this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.SETMODE.ordinal())) {
OppoMultimediaService.this.mAudioServiceState.checkAllModes();
}
if (msg.what == 2 && OppoMultimediaService.this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.KILLMEDIASERVER.ordinal()) && OppoMultimediaService.this.mAudioServiceState.checkAudioSystem(true)) {
DebugLog.d(OppoMultimediaService.TAG, "start check if kill AudioSystem mCheckCount:" + OppoMultimediaService.this.mCheckCount);
if (OppoMultimediaService.this.mCheckCount < 3) {
OppoMultimediaService.sendMsg(OppoMultimediaService.this.mWatchHandler, 13, 0, 0, 0, null, 1000);
return;
}
return;
}
return;
}
return;
case 5:
case 7:
if (OppoMultimediaService.this.mAudioServiceState != null && OppoMultimediaService.this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.SETMODE.ordinal())) {
OppoMultimediaService.this.mAudioServiceState.readAudioModes((String) msg.obj);
if (msg.what == 5 && !OppoMultimediaService.this.isInCallState()) {
DebugLog.d(OppoMultimediaService.TAG, "sendMsg sync mode start");
OppoMultimediaService.sendMsg(OppoMultimediaService.this.mWatchHandler, 14, 0, 0, 0, null, 100);
return;
}
return;
}
return;
case 8:
case 9:
case 19:
if (OppoMultimediaService.this.mAudioServiceState != null) {
try {
OppoMultimediaService.this.mAudioServiceState.broadcastRecordEvent(msg.what, Integer.parseInt(msg.obj));
return;
} catch (NumberFormatException e) {
return;
}
}
return;
case 10:
DebugLog.d(OppoMultimediaService.TAG, "+mRecordShowHint : " + OppoMultimediaService.this.mRecordShowHint);
if (OppoMultimediaService.this.mRecordShowHint || OppoMultimediaService.this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.RECORDCONFLICT.ordinal())) {
String info = OppoMultimediaService.this.mAudioServiceState.getRecordFailedInfo((String) msg.obj);
if (info != null) {
OppoMultimediaService.this.mAudioServiceState.showRecordHintDialog(OppoMultimediaService.this.getInfoFromLocalService("get_record_failed_info=" + info));
return;
}
return;
}
return;
case 11:
if (OppoMultimediaService.this.mAudioServiceState != null) {
OppoMultimediaService.this.mAudioServiceState.releaseAudioTrack();
return;
}
return;
case 13:
if (OppoMultimediaService.this.mAudioServiceState != null && OppoMultimediaService.this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.KILLMEDIASERVER.ordinal())) {
if (OppoMultimediaService.this.mAudioServiceState.checkAudioSystem(false)) {
DebugLog.d(OppoMultimediaService.TAG, "+start check if kill AudioSystem mCheckCount :" + OppoMultimediaService.this.mCheckCount);
if (OppoMultimediaService.this.mCheckCount >= 3) {
OppoMultimediaService.this.mAudioServiceState.killAudioSystem();
OppoMultimediaService.this.mWatchHandler.removeMessages(13);
OppoMultimediaService.this.mCheckCount = 0;
return;
}
OppoMultimediaService oppoMultimediaService = OppoMultimediaService.this;
oppoMultimediaService.mCheckCount = oppoMultimediaService.mCheckCount + 1;
OppoMultimediaService.sendMsg(OppoMultimediaService.this.mWatchHandler, 13, 0, 0, 0, null, OppoMultimediaService.sDelay);
return;
}
DebugLog.d(OppoMultimediaService.TAG, "checkAudioSystem normal");
OppoMultimediaService.this.mWatchHandler.removeMessages(13);
OppoMultimediaService.this.mCheckCount = 0;
return;
}
return;
case 14:
if (OppoMultimediaService.this.isInCallState()) {
DebugLog.d(OppoMultimediaService.TAG, "no need sync mode in call state");
return;
}
OppoMultimediaService.this.mAudioServiceState.setSystemPhoneState(OppoMultimediaService.this.mAudioServiceState.oppoGetMode());
DebugLog.d(OppoMultimediaService.TAG, "sendMsg sync mode end");
return;
case 15:
if (OppoMultimediaService.this.mAudioServiceState != null) {
OppoMultimediaService.this.mAudioServiceState.mmListRomUpdate();
return;
}
return;
case 16:
if (OppoMultimediaService.this.mStreamMuteChange && OppoMultimediaService.this.mAudioServiceState.isHasActiveStream()) {
OppoMultimediaService.this.mAudioServiceState.setStreamMute(3, true);
return;
}
return;
case 17:
OppoMultimediaService.this.mAudioServiceState.setStreamMute(3, false);
return;
case 103:
OppoMultimediaService.this.setEventToLocalService(msg.what, null);
return;
case 300:
OppoMultimediaService.this.bindLocalService();
return;
default:
return;
}
}
}
private class MediaWatchThread extends Thread {
MediaWatchThread() {
super("OppoMultimediaWatchService");
}
public void run() {
Looper.prepare();
synchronized (OppoMultimediaService.this) {
OppoMultimediaService.this.mWatchHandler = new MediaWatchHandler(OppoMultimediaService.this, null);
OppoMultimediaService.this.notify();
}
Looper.loop();
}
}
public OppoMultimediaService(Context context) {
DebugLog.d(TAG, "+OppoMultimediaService");
this.mContext = context;
this.mContentResolver = context.getContentResolver();
readSettings();
this.mLocalSocketServer = new OppoLocalSocketServer(context);
this.mLocalSocketServer.start();
createMediaWatchThread();
this.mOppoDaemonListHelper = new OppoDaemonListHelper(this.mContext, this);
this.mDaemonFunControl = new DaemonFunControl(this.mContext, this.mOppoDaemonListHelper);
this.mAudioServiceState = new AudioServiceState(this.mContext, this.mOppoDaemonListHelper, this);
registerSubInfo();
DebugLog.d(TAG, "-OppoMultimediaService");
}
public void readSettings() {
this.mRecordShowHint = this.mContext.getPackageManager().hasSystemFeature(OppoMultimediaServiceDefine.FEATURE_RECORD_CONFLICT_NAME);
}
private void createMediaWatchThread() {
this.mMediaWatchThread = new MediaWatchThread();
this.mMediaWatchThread.start();
waitForMediaWatchHandlerCreation();
}
private void waitForMediaWatchHandlerCreation() {
synchronized (this) {
while (this.mWatchHandler == null) {
try {
wait();
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted while waiting on other handler.");
}
}
}
}
public void systemRunning() {
DebugLog.d(TAG, "systemRunning");
sendMsg(this.mWatchHandler, 300, 2, 0, 0, null, sDelay);
}
public void setParameters(String keyValuePairs) {
}
public String getParameters(String keys) {
if (keys == null) {
return null;
}
String ret = "";
DebugLog.d(TAG, "getParameters keys: " + keys);
if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_SPEAKER_AUTHORITY)) {
if (!this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.SETSPEAKERPHONEON.ordinal())) {
ret = "true";
} else if (isHasSpeakerAuthority(keys)) {
ret = "true";
} else {
ret = "false";
}
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DEVICE_CHANGE_AUTHORITY)) {
if (isHasDeviceChangeAuthority(keys)) {
ret = "true";
} else {
ret = "false";
}
} else if (keys.equals(OppoMultimediaServiceDefine.KEY_AUDIO_GET_RECORD_STATE)) {
if (!this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.STREAMADJUST.ordinal())) {
ret = "true";
} else if (this.mAudioServiceState.getRecordThreadState()) {
ret = "true";
} else {
ret = "false";
}
} else if (keys.equals(OppoMultimediaServiceDefine.KEY_AUDIO_GET_STREAMTYPE_ADJUST_REVISE)) {
if (!this.mDaemonFunControl.getDaemonFunEnable(DaemonFun.STREAMADJUST.ordinal())) {
ret = "false";
} else if (this.mAudioServiceState.isStreamTypeAdjustRevise()) {
ret = "true";
} else {
ret = "false";
}
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DAEMON_LISTINFO_BYPID) || keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DAEMON_LISTINFO_BYNAME) || keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_CHECK_DAEMON_LISTINFO_BYPID) || keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_CHECK_DAEMON_LISTINFO_BYNAME)) {
ret = getDaemonListinfoByKey(keys);
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_APPLICATION_TOPACTIVITY)) {
ret = isTopActivity(keys);
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_VOLUME_CONTROL_STATE)) {
ret = isAppCanSetStreamVolume(keys);
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_ADJUSTSTREAMVOLUME_CONTROL_STATE)) {
ret = isAppCanAdjustStreamVolume(keys);
} else if (keys.startsWith(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DO_MUSIC_MUTE)) {
ret = isDoMusicMute();
}
return ret;
}
public void setEventInfo(int event, String info) throws RemoteException {
DebugLog.d(TAG, "setEventInfo event = " + event + " info = " + info);
switch (event) {
case 1:
sendMsg(this.mWatchHandler, 1, 2, 0, 0, info, 0);
return;
case 2:
sendMsg(this.mWatchHandler, 2, 2, 0, 0, info, 0);
return;
case 5:
sendMsg(this.mWatchHandler, 5, 0, 0, 0, info, 0);
return;
case 16:
case 17:
try {
sendMsg(this.mWatchHandler, event, 0, 0, 0, info, Integer.parseInt(info));
return;
} catch (NumberFormatException e) {
return;
}
case 19:
sendMsg(this.mWatchHandler, 19, 0, 0, 0, info, 100);
return;
default:
sendMsg(this.mWatchHandler, event, 2, 0, 0, info, 0);
return;
}
}
public void sendBroadcastToAll(Intent intent) {
intent.addFlags(67108864);
long ident = Binder.clearCallingIdentity();
try {
this.mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
private static void sendMsg(Handler handler, int msg, int existingMsgPolicy, int arg1, int arg2, Object obj, int delay) {
if (existingMsgPolicy == 0) {
handler.removeMessages(msg);
} else if (existingMsgPolicy == 1 && handler.hasMessages(msg)) {
DebugLog.d(TAG, "sendMsg: Msg " + msg + " existed!");
return;
}
handler.sendMessageAtTime(handler.obtainMessage(msg, arg1, arg2, obj), SystemClock.uptimeMillis() + ((long) delay));
}
public boolean isInCallState() {
TelecomManager telecomManager = (TelecomManager) this.mContext.getSystemService("telecom");
long ident = Binder.clearCallingIdentity();
boolean isInCall = telecomManager.isInCall();
Binder.restoreCallingIdentity(ident);
DebugLog.d(TAG, "isInCallState =" + isInCall);
if (this.mAudioServiceState.isInCallMode()) {
return true;
}
return isInCall;
}
public boolean isHasSpeakerAuthority(String keys) {
boolean mIsTelName = true;
String mPackageName = "";
String[] strarr = keys.split("=");
if (strarr != null && strarr.length == 2) {
mPackageName = strarr[1];
if (mPackageName != null) {
mIsTelName = mPackageName.equals(OppoMultimediaServiceDefine.TEL_PACKAGE_NAME);
}
}
DebugLog.d(TAG, "isHasSpeakerAuthority keys: " + keys + ",mIsTelName=" + mIsTelName);
if (!isInCallState() || (mIsTelName ^ 1) == 0) {
return true;
}
setEventToLocalService(104, mPackageName);
return false;
}
public boolean isHasDeviceChangeAuthority(String keys) {
boolean lIsPermitName = true;
String lPackageName = "";
String[] lStrarr = keys.split("=");
if (lStrarr != null && lStrarr.length == 2) {
lPackageName = lStrarr[1];
if (lPackageName != null) {
lIsPermitName = lPackageName.equals(OppoMultimediaServiceDefine.TEL_PACKAGE_NAME) || lPackageName.equals(OppoMultimediaServiceDefine.BLUETOOTH_PACKAGE_NAME);
}
}
DebugLog.d(TAG, "isHasDeviceChangeAuthority keys: " + keys + ",lIsPermitName=" + lIsPermitName);
if (!isInCallState() || (lIsPermitName ^ 1) == 0) {
return true;
}
setEventToLocalService(104, lPackageName);
return false;
}
public String getPackageNameByPid(int pid) {
for (RunningAppProcessInfo appProcess : ((ActivityManager) this.mContext.getSystemService("activity")).getRunningAppProcesses()) {
int tPid = appProcess.pid;
String tPackageName = appProcess.processName;
DebugLog.d(TAG, "PackageName: " + tPackageName + " pid: " + tPid);
if (pid == tPid) {
String packageName = tPackageName;
return tPackageName;
}
}
return null;
}
public void killProcessByPid(int pid) {
String command = "kill -9 " + String.valueOf(pid);
try {
DebugLog.d(TAG, "command :" + command);
Runtime.getRuntime().exec(command);
setEventToLocalService(105, null);
} catch (IOException e) {
e.printStackTrace();
}
}
public void killProcessByPackageName(String packageName) {
DebugLog.d(TAG, "+killProcessByPackageName packageName :" + packageName);
((ActivityManager) this.mContext.getSystemService("activity")).forceStopPackage(packageName);
}
private void bindLocalService() {
DebugLog.d(TAG, "bindService start");
List<ResolveInfo> resolveInfos = this.mContext.getPackageManager().queryIntentServices(new Intent("com.oppo.multimedia.localservice.START"), 0);
if (resolveInfos == null || resolveInfos.size() != 1) {
DebugLog.d(TAG, "bindService, return not found resolveInfos.");
return;
}
ResolveInfo serviceInfo = (ResolveInfo) resolveInfos.get(0);
String packageName = serviceInfo.serviceInfo.packageName;
String className = serviceInfo.serviceInfo.name;
DebugLog.d(TAG, "packageName = " + packageName + " className = " + className);
ComponentName component = new ComponentName(packageName, className);
Intent iapIntent = new Intent();
iapIntent.setComponent(component);
this.mContext.startService(iapIntent);
this.mContext.bindService(iapIntent, this.mServiceConnection, 1);
DebugLog.d(TAG, "bindService end");
}
private void unBindLocalService() {
if (this.mBindServiceFlag) {
this.mContext.unbindService(this.mServiceConnection);
this.mBindServiceFlag = false;
}
}
public IMultimediaLocalService getLocalService() {
if (this.mIMultimediaLocalService == null) {
bindLocalService();
}
return this.mIMultimediaLocalService;
}
public void setEventToLocalService(int event, String msg) {
DebugLog.d(TAG, "setEventToLocalService event = " + event + " msg = " + msg);
IMultimediaLocalService localService = getLocalService();
if (localService == null) {
DebugLog.d(TAG, "LocalService start error!!!");
return;
}
try {
localService.setEvent(event, msg);
} catch (RemoteException e) {
e.printStackTrace();
}
}
public String getInfoFromLocalService(String key) {
DebugLog.d(TAG, "getInfoFromLocalService key = " + key);
String result = "";
IMultimediaLocalService localService = getLocalService();
if (localService == null) {
DebugLog.d(TAG, "LocalService start error!!!");
return result;
}
try {
result = localService.getParameters(key);
} catch (RemoteException e) {
e.printStackTrace();
}
return result;
}
private void registerCommonReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.intent.action.HEADSET_PLUG");
this.mContext.registerReceiver(this.mCommonReceiver, intentFilter);
}
public void registerSubInfo() {
SubscriptionManager.from(this.mContext).addOnSubscriptionsChangedListener(this.mOnSubscriptionsChangedListener);
}
public void unregisterSubInfo() {
SubscriptionManager.from(this.mContext).removeOnSubscriptionsChangedListener(this.mOnSubscriptionsChangedListener);
}
public void registerPhone() {
this.mTelephonyManager = (TelephonyManager) this.mContext.getSystemService("phone");
this.mTelephonyManager.listen(this.mOppoPhoneSimStateListener, 32);
}
private void callStateChanged(int state, String incomingNumber) {
if (state == 1 || state == 2) {
if (this.mAudioServiceState.isHasActiveStream()) {
this.mHasActiveStreamBeforeIncall = true;
} else {
this.mHasActiveStreamBeforeIncall = false;
}
if (this.mAudioServiceState.isStreamShouldMute(3, state) && !this.mStreamMuteChange) {
if (this.mAudioServiceState.isHasActivePidInList(OppoDaemonListHelper.TAG_MODULE[ModuleTag.VOLUME.ordinal()], OppoMultimediaServiceDefine.APP_LIST_ATTRIBUTE_NO_NEED_MUTE_IN_RINGING)) {
if (state == 2) {
try {
this.mStreamMuteChange = true;
setEventInfo(16, "200");
} catch (RemoteException e) {
}
}
} else if (this.mAudioServiceState.isWiredHeadsetOn()) {
this.mStreamMuteChange = true;
this.mAudioServiceState.setStreamMute(3, true);
} else {
try {
this.mStreamMuteChange = true;
setEventInfo(16, "500");
} catch (RemoteException e2) {
}
}
}
} else if (state == 0) {
DebugLog.d(TAG, "mHasActiveStreamBeforeIncall :" + this.mHasActiveStreamBeforeIncall + " mStreamMuteChange :" + this.mStreamMuteChange);
this.mWatchHandler.removeMessages(16);
if (this.mStreamMuteChange) {
this.mStreamMuteChange = false;
if (this.mAudioServiceState.getMode() != 0) {
try {
setEventInfo(17, "200");
} catch (RemoteException e3) {
}
} else {
this.mAudioServiceState.setStreamMute(3, false);
}
}
if (!this.mHasActiveStreamBeforeIncall) {
this.mAudioServiceState.checkAppcationAndKill();
}
this.mHasActiveStreamBeforeIncall = false;
}
}
private String isTopActivity(String keys) {
String ret = "false";
String[] strarr = keys.split("=");
if (strarr != null && strarr.length == 2 && isAppTopActivity(strarr[1])) {
return "true";
}
return ret;
}
public boolean isAppTopActivity(String packagename) {
if (packagename != null) {
try {
ActivityManager am = (ActivityManager) this.mContext.getSystemService("activity");
if (am != null) {
ComponentName cn = am.getTopAppName();
if (cn != null) {
String topAppName = cn.getPackageName();
DebugLog.d(TAG, "topAppName = " + topAppName + " getClassName = " + cn.getClassName());
if (topAppName != null && topAppName.equals(packagename)) {
return true;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
private String isApplicationPlaying(String keys) {
String ret = "false";
String[] strarr = keys.split("=");
if (strarr == null || strarr.length != 2) {
return ret;
}
if (this.mAudioServiceState.isApplicationPlaying(strarr[1])) {
return "true";
}
return "false";
}
private String isAppCanSetStreamVolume(String keys) {
String valueTrue = "true";
String valueFalse = "false";
String[] strarr = keys.split("=");
if (strarr == null || strarr.length != 2) {
return valueTrue;
}
String lAttribute = this.mOppoDaemonListHelper.getAttributeByAppName(OppoDaemonListHelper.TAG_MODULE[ModuleTag.VOLUME.ordinal()], strarr[1]);
if (lAttribute != null && lAttribute.equalsIgnoreCase("permit")) {
return valueTrue;
}
String value = isTopActivity(keys);
DebugLog.d(TAG, "isTopActivity value = " + value);
if (value != null && value.equalsIgnoreCase("true")) {
return valueTrue;
}
value = isApplicationPlaying(keys);
DebugLog.d(TAG, "isApplicationPlaying value = " + value);
if (value == null || !value.equalsIgnoreCase("true")) {
return valueFalse;
}
return valueTrue;
}
private String isAppCanAdjustStreamVolume(String keys) {
String valueTrue = "true";
String valueFalse = "false";
String[] strarr = keys.split("=");
if (this.mAudioServiceState.getMode() == 1 && strarr != null && strarr.length == 2 && (this.mAudioServiceState.isHasActivePidInList(OppoDaemonListHelper.TAG_MODULE[ModuleTag.VOLUME.ordinal()], OppoMultimediaServiceDefine.APP_LIST_ATTRIBUTE_NO_NEED_MUTE_IN_CALL) || this.mAudioServiceState.isHasActivePidInList(OppoDaemonListHelper.TAG_MODULE[ModuleTag.VOLUME.ordinal()], OppoMultimediaServiceDefine.APP_LIST_ATTRIBUTE_NO_NEED_MUTE_IN_RINGING))) {
return valueFalse;
}
return valueTrue;
}
private String getDaemonListinfoByKey(String keys) {
String ret = "";
String[] strarr = keys.split("=");
if (strarr != null) {
try {
if (strarr.length == 3) {
if (strarr[0].equals(OppoMultimediaServiceDefine.KEY_AUDIO_CHECK_DAEMON_LISTINFO_BYPID)) {
ret = this.mOppoDaemonListHelper.checkIsInDaemonlistByPid(strarr[1], Integer.parseInt(strarr[2])) ? "true" : "false";
} else if (strarr[0].equals(OppoMultimediaServiceDefine.KEY_AUDIO_CHECK_DAEMON_LISTINFO_BYNAME)) {
ret = this.mOppoDaemonListHelper.checkIsInDaemonlistByName(strarr[1], strarr[2]) ? "true" : "false";
} else if (strarr[0].equals(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DAEMON_LISTINFO_BYPID)) {
return this.mOppoDaemonListHelper.getAttributeByAppPid(strarr[1], Integer.parseInt(strarr[2]));
} else {
if (strarr[0].equals(OppoMultimediaServiceDefine.KEY_AUDIO_GET_DAEMON_LISTINFO_BYNAME)) {
return this.mOppoDaemonListHelper.getAttributeByAppName(strarr[1], strarr[2]);
}
}
}
} catch (NumberFormatException e) {
}
}
return ret;
}
public boolean getFunEnable(int funindex) {
if (this.mDaemonFunControl.getDaemonFunEnable(funindex)) {
return true;
}
return false;
}
public String isDoMusicMute() {
String ret = "false";
if (this.mAudioServiceState == null || !this.mAudioServiceState.mDoMusicMute) {
return ret;
}
return "true";
}
}
| [
"[email protected]"
]
| |
95e92e6b26363289d72e2a570e82e79d0ed7d9cf | 2c455aa7685d2db8083e1ce27d355042a19a1508 | /Gestore_Magazzino/src/AddPanel.java | 26d61f9cce0336ab8bad19ee2de727e2e26240bd | []
| no_license | Tommyvale2001/Supermarket | 89f3a388ee0c2e27e44df6ac32e08584669ddd21 | 42459cb83c0558db5021108b3ebe9ea59bce12ee | refs/heads/master | 2020-04-29T15:30:29.899504 | 2019-03-18T07:40:44 | 2019-03-18T07:40:44 | 176,226,516 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,255 | java |
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author INFO18
* classe contenete i metodi per l'aggiunta del pannello
*/
public class AddPanel extends JPanel {
private JTextField nomeprod;
private JTextField giacenza;
private Model m;
/**
* Costruttore che aggiunge un pannello per l'input dei prodotti
*/
public AddPanel() {
nomeprod = new JTextField();
giacenza = new JTextField();
m= new Model();
setLayout(new GridLayout(4, 2));
this.add(new JLabel("Nome prodotto:"));
this.add(nomeprod);
this.add(new JLabel("Giacenza:"));
this.add(giacenza);
}
/**
*
* @param product setta i prodotti aggiunti alla JTextField
*
*/
public void setProdotto(Prodotti product) {
nomeprod.setText(product.getNomeprod());
giacenza.setText(String.valueOf(product.getGiacenza()));
}
/**
*
* @return ritorna il prodotto aggiunto alla TextField
*/
public Prodotti getProdotto() {
return new Prodotti(m.getContaProdotti(), nomeprod.getText(), Integer.parseInt(giacenza.getText()));
}
} | [
"Valente"
]
| Valente |
162b792b51c5fe84c85a81e2dfed322040c0784a | dd784849b6b863a75c55003afd1587e88c5df166 | /backend/src/main/java/com/morelang/dto/History.java | 68bf9d60d7ae59806714665495c0aaa6173f485b | [
"MIT"
]
| permissive | jungsungoh/Morelang | 32f3d18afe0844accf074bbaae6fd6cba7b0de1e | b25b51b1f05f6a868d3cda5221d857c02fb99316 | refs/heads/master | 2023-02-26T17:08:51.696521 | 2020-11-24T05:50:13 | 2020-11-24T05:50:13 | 315,453,346 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,550 | java | package com.morelang.dto;
import java.util.Date;
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.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.UpdateTimestamp;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(name = "historys")
public class History {
@Id
@Column(name = "history_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int historyId;
@ManyToOne(targetEntity=Member.class, fetch=FetchType.LAZY)
@JoinColumn(name="member_id")
private Member member;
@ManyToOne(targetEntity=HistoryVideo.class, fetch=FetchType.EAGER)
@JoinColumn(name="video_id")
private HistoryVideo video;
@Column
@UpdateTimestamp
private Date viewDay;
public History(int historyId, Member member, HistoryVideo video, Date viewDay) {
super();
this.historyId = historyId;
this.member = member;
this.video = video;
this.viewDay = viewDay;
}
}
| [
"[email protected]"
]
| |
4cc4864ea632247ac4971ae1f32b1d6bad4627cd | 3b5b9fd8b84b038a8edc5c9f263b875e7f81f61a | /src/main/java/com/infogain/gcp/poc/repository/OutboxStatusRepository.java | 17916d1a89421f3457ff0f8c54306688785dac1c | []
| no_license | initial-poc/spanner-crud | 3a53c8c3baa5bb53ae3f71ed9e1cf9a3d492ae88 | 8664417d692cf51962b1b3ea235766a0fa713544 | refs/heads/main | 2023-06-16T06:29:18.123750 | 2021-07-07T14:32:12 | 2021-07-07T14:32:12 | 360,390,727 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 337 | java | package com.infogain.gcp.poc.repository;
import com.infogain.gcp.poc.entity.OutboxStatusEntity;
import org.springframework.cloud.gcp.data.spanner.repository.SpannerRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface OutboxStatusRepository extends SpannerRepository<OutboxStatusEntity, String> {
} | [
"[email protected]"
]
| |
9c25d893b4a94bd804c224c1347bd13a49f27528 | a942df2f9f8797aab6bd2d08ea8a066e22b9fef7 | /order-command/src/main/java/com/invillia/sabadell/ordercommand/contract/OrderStatusConverter.java | 42a019ed26d21a35287fa89cd032c78dab178182 | []
| no_license | JuaumCruz/sabadell-estudos | 90e912d86fc7e078dddbcd655e5c8bcdb66587e8 | 033e5a871189673cb3bccec72c20527ce089c6d1 | refs/heads/master | 2021-02-23T18:05:47.356119 | 2020-03-10T12:29:18 | 2020-03-10T12:29:18 | 245,406,342 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 745 | java | package com.invillia.sabadell.ordercommand.contract;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.stream.Stream;
@Converter(autoApply = true)
public class OrderStatusConverter implements AttributeConverter<OrderStatus, Long> {
@Override
public Long convertToDatabaseColumn(OrderStatus attribute) {
return null == attribute ? null : attribute.getValue();
}
@Override
public OrderStatus convertToEntityAttribute(Long value) {
return null == value ? null :
Stream.of(OrderStatus.values())
.filter(s -> s.getValue().equals(value))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
}
| [
"[email protected]"
]
| |
73ca29297fbc35ddd8b7ee81c394ffddb06fbdfb | 3ffdc3a258bd79476fd49f6e9ffe5a26778d4ecb | /app/src/main/java/com/example/project/DoctorLocation.java | 4c94a7313792a1315f6ffc61d4111470d0e656c6 | []
| no_license | Surajkarwal/DoctorPatientApp | 72b9371c94820ded292cf35319a343ff23cb35c9 | 0d593c2998a11be4c70faca1a10b0dbaf4dbcc1f | refs/heads/master | 2023-02-03T10:31:19.739339 | 2020-12-22T04:46:25 | 2020-12-22T04:46:25 | 323,523,128 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,264 | java | package com.example.project;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class DoctorLocation extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_doctor_location);
final EditText ps = findViewById(R.id.a);
Button btn1 = findViewById(R.id.find);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String postalCode = ps.getText().toString();
if(postalCode.equals(""))
{
Toast.makeText(DoctorLocation.this, "Please enter the postal code first"+postalCode, Toast.LENGTH_SHORT).show();
}
else
{
startActivity(new Intent(DoctorLocation.this,DoctorList.class));
}
}
});
}
}
| [
"[email protected]"
]
| |
ea846156e2dcbb868e6ba21ed4246b299a8e1303 | 5f92b9da4f4208d4549ab256db35d82823bcf464 | /Incremental Project Files/sprint 1 moved/src/com/capgemini/pwa/main/Main.java | 7b2498e0ebc97f554d26fe886e1e3d6eb67bafd9 | []
| no_license | xaviernara/Capgemini-Java-Training- | c2873cd45f0c43ef6294d8bfea53eb37b440f871 | 929fc73edff1a60d59a94a989677aeb7db57676a | refs/heads/master | 2021-06-29T23:18:24.882186 | 2019-07-14T00:01:48 | 2019-07-14T00:01:48 | 177,150,962 | 9 | 4 | null | 2020-10-13T12:54:22 | 2019-03-22T14:04:54 | Java | UTF-8 | Java | false | false | 4,848 | java | /**
*
*/
package com.capgemini.pwa.main;
import java.util.*;
import com.capgemini.pwa.beans.Customer;
import com.capgemini.pwa.beans.Wallet;
import com.capgemini.pwa.dao.WalletDAOImp;
/**
* @author xarichar
*
*/
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
WalletDAOImp walletDAO = new WalletDAOImp();
Scanner scan = new Scanner(System.in).useDelimiter(System.lineSeparator());
System.out.println("Welcome would you like to open a Payment Wallet Application?");
String wantAccount = scan.nextLine();
if (wantAccount.equalsIgnoreCase("yes")) {
System.out.println("How many accounts do you wanna create: ");
}
else{
System.out.println("Have a nice day!!!");
}
int numOfAccount = scan.nextInt();
Wallet[] walletArray = new Wallet[numOfAccount];
for (Wallet wallet : walletArray) {
System.out.println("Enter Full Name: ");
String fullName = scan.nextLine();
System.out.println("Enter Data of Birth: ");
String dateOfBirth = scan.nextLine();
System.out.println("Enter Phone Number: ");
int phoneNumber = scan.nextInt();
System.out.println("Enter Social Secuirty Number: ");
long SSD = scan.nextLong();
System.out.println("Enter Email: ");
String email = scan.nextLine();
System.out.println("Enter Username: ");
String userName = scan.nextLine();
System.out.println("Enter Password: ");
String password = scan.nextLine();
System.out.println("Enter amount you would like to depsoit to start your account: ");
double deposit = scan.nextDouble();
// creating a customer object
Customer customer = new Customer(dateOfBirth, SSD, fullName, deposit, phoneNumber, email, password,
userName);
System.out.println("Enter the type account you want (e.g. Financial or Business): ");
String accountType = scan.nextLine();
wallet = new Wallet(customer, accountType);
if (walletDAO.validateSignUp(wallet)) {
System.out.println("Your account number is: "+wallet.getCustomer().getAccountNumber());
System.out.println("Thank you for signing up! \n Login to acces your payment wallet");
}
}
boolean menuContinue = true;
System.out.println("Login");
System.out.println("Enter Username: ");
String userName = scan.nextLine();
System.out.println("Enter Password: ");
String password = scan.nextLine();
if (walletDAO.validateLogin(walletArray, password, userName)) {
while (menuContinue) {
System.out.println("Payment Wallet Menu");
System.out.println("1.Deposit money into your account");
System.out.println("2.View your avaliable balance");
System.out.println("3.Transfer funds from one account to another");
System.out.println("4.Withdraw from your account");
//System.out.println("5.Remove your account");
System.out.println("5.Log out");
int menuChoice = scan.nextInt();
switch(menuChoice){
case 1:
System.out.println("How much would you like to add to your account?");
double newMoney = scan.nextDouble();
System.out.println("Enter your account number ");
int accountNumber = scan.nextInt();
walletDAO.deposit(walletArray,accountNumber ,newMoney);
case 2:
System.out.println("Enter your account number ");
accountNumber = scan.nextInt();
System.out.println("Account Balance: "+ walletDAO.viewBalance(walletArray, accountNumber));
case 3:
System.out.println("Enter your account number ");
accountNumber = scan.nextInt();
System.out.println("Account Balance: "+ walletDAO.viewBalance(walletArray, accountNumber));
System.out.println("Enter the account number of the account you want to transfer funds ");
int accountNumber2 = scan.nextInt();
System.out.println("Enter the amount you want to transfer: ");
double transferAmount = scan.nextDouble();
for(Wallet wallet: walletArray){
Wallet account1 = new Wallet();
Wallet account2 = new Wallet();
if(wallet.getCustomer().getAccountNumber() == accountNumber){
account1 = wallet;
}
if(wallet.getCustomer().getAccountNumber() == accountNumber2){
account2 = wallet;
}
walletDAO.transfer(account1, account2, transferAmount);
}
case 4:
System.out.println("How much would you like to withdraw from your account?");
double withdrawl = scan.nextDouble();
System.out.println("Enter your account number ");
accountNumber = scan.nextInt();
walletDAO.withdraw(walletArray, accountNumber, withdrawl);
case 5:
System.out.println("Thanks for using your payment wallet");
menuContinue = false;
}
}
}
else{
System.out.println("Your account was not found please try again.");
}
scan.close();
}
}
| [
"[email protected]"
]
| |
9759627b24f71eb28732973dd7f82962957f7e8e | 89dedd7f3c7acc81d12e2bcb2e716f9af9e5fa04 | /chrome/android/javatests/src/org/chromium/chrome/browser/instantapps/InstantAppsHandlerTest.java | 32a7a0d45ee1fb206981b6a1e8eec502f75a1c9c | [
"BSD-3-Clause"
]
| permissive | bino7/chromium | 8d26f84a1b6e38a73d1b97fea6057c634eff68cb | 4666a6bb6fdcb1114afecf77bdaa239d9787b752 | refs/heads/master | 2022-12-22T14:31:53.913081 | 2016-09-06T10:05:11 | 2016-09-06T10:05:11 | 67,410,510 | 1 | 3 | BSD-3-Clause | 2022-12-17T03:08:52 | 2016-09-05T10:11:59 | null | UTF-8 | Java | false | false | 5,680 | java | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.instantapps;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.provider.Browser;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.IntentHandler;
/**
* Unit tests for {@link InstantAppsHandler}.
*/
public class InstantAppsHandlerTest extends InstrumentationTestCase {
private TestInstantAppsHandler mHandler;
private Context mContext;
private static final Uri URI = Uri.parse("http://sampleurl.com/foo");
private Intent createViewIntent() {
return new Intent(Intent.ACTION_VIEW, URI);
}
@Override
public void setUp() throws Exception {
super.setUp();
mContext = getInstrumentation().getTargetContext();
mHandler = new TestInstantAppsHandler();
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("applink.app_link_enabled", true);
editor.putBoolean("applink.chrome_default_browser", true);
editor.apply();
}
@Override
public void tearDown() throws Exception {
ContextUtils.getAppSharedPreferences().edit().clear().apply();
super.tearDown();
}
@SmallTest
public void testInstantAppsDisabled_disabledByFlag() {
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("applink.app_link_enabled", false);
editor.apply();
assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), true));
}
@SmallTest
public void testInstantAppsDisabled_incognito() {
Intent i = createViewIntent();
i.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
}
@SmallTest
public void testInstantAppsDisabled_doNotLaunch() {
Intent i = createViewIntent();
i.putExtra("com.google.android.gms.instantapps.DO_NOT_LAUNCH_INSTANT_APP", true);
assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
}
@SmallTest
public void testInstantAppsDisabled_dataReductionProxy() {
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("BANDWIDTH_REDUCTION_PROXY_ENABLED", true);
editor.apply();
assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
}
@SmallTest
public void testInstantAppsDisabled_mainIntent() {
Intent i = new Intent(Intent.ACTION_MAIN);
assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
}
@SmallTest
public void testInstantAppsDisabled_intentOriginatingFromChrome() {
Intent i = createViewIntent();
i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
Intent signedIntent = createViewIntent();
signedIntent.setPackage(mContext.getPackageName());
IntentHandler.addTrustedIntentExtras(signedIntent, mContext);
assertFalse(mHandler.handleIncomingIntent(mContext, signedIntent, false));
}
@SmallTest
public void testChromeNotDefault() {
SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("applink.chrome_default_browser", false);
editor.apply();
assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
// Even if Chrome is not default, launch Instant Apps for CustomTabs since those never
// show disambiguation dialogs.
Intent cti = createViewIntent()
.putExtra("android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS", true);
assertTrue(mHandler.handleIncomingIntent(mContext, cti, true));
}
@SmallTest
public void testInstantAppsEnabled() {
Intent i = createViewIntent();
assertTrue(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, false));
// Check that identical intent wouldn't be enabled for CustomTab flow.
assertFalse(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, true));
// Add CustomTab specific extra and check it's now enabled.
i.putExtra("android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS", true);
assertTrue(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, true));
}
@SmallTest
public void testNfcIntent() {
Intent i = new Intent(NfcAdapter.ACTION_NDEF_DISCOVERED);
i.setData(Uri.parse("http://instantapp.com/"));
assertTrue(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, false));
}
static class TestInstantAppsHandler extends InstantAppsHandler {
@Override
protected boolean tryLaunchingInstantApp(Context context, Intent intent,
boolean isCustomTabsIntent, Intent fallbackIntent) {
return true;
}
}
}
| [
"[email protected]"
]
| |
be2d6af37fe2b13ff05fe024e5c071bdf71e804c | 1aa874fae7d42c6ccc1a85986b4e2d503ba789ba | /AndroidTest/src/main/java/com/android/test/AppConfig.java | 17f3e96c7a8df819380c3928918eccfec23cf4c9 | []
| no_license | szn0212/AndroidBase | c8751c0c01cd3b679c7b214fdf911c9a1038e2cd | c1e85d24853be203716f454a541c51e09d994bd1 | refs/heads/master | 2021-01-18T05:56:09.366983 | 2015-12-08T09:23:49 | 2015-12-08T09:23:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 682 | java | package com.android.test;
/**
* 应用程序配置类:用于信息保存及设置
* Created by Administrator on 2015/10/12 0012.
*/
public class AppConfig {
/**
* handler的回调
*/
public static final int REQUEST_GET_FAIL = 1001;
public static final int REQUEST_GET_SUCCESS = 1002;
public static final int REQUEST_POST_FAIL = 1003;
public static final int REQUEST_POST_SUCCESS = 1004;
public static final int REQUEST_POST_FAIL_FOR_BEAN = 1005;
public static final int REQUEST_POST_SUCCESS_FOR_BEAN = 1006;
public static final int REQUEST_GET_FAIL_FOR_BEAN = 1007;
public static final int REQUEST_GET_SUCCESS_FOR_BEAN = 1008;
}
| [
"[email protected]"
]
| |
a0df53ba47846cf2626a13bbd18254c232f99605 | 6c999e4df3392c39f18ce0d09ad190dfe4251794 | /app/src/main/java/com/czp/searchmlist/SearchOldDataAdapter.java | 5cf17ff493cfc01eee590a36ad5d370da40c94d4 | []
| no_license | xiaoshaoxiaoshao/zheliyou | 9ed30bc901275375c234d5a3be7c223d4ce4665f | 18df5409426e5e09a3dd15e5d6678e28e3e1897e | refs/heads/master | 2023-01-15T00:08:08.355780 | 2020-11-09T00:37:53 | 2020-11-09T00:37:53 | 309,902,764 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,371 | java | package com.czp.searchmlist;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import edu.zjff.shzj.R;
/**
* Created by liuyunming on 2016/7/3.
*/
public class SearchOldDataAdapter extends BaseAdapter {
private Context context;
private ArrayList<String> list = new ArrayList<String>();
public SearchOldDataAdapter(Context context,ArrayList<String> strs) {
this.context =context;
list= strs;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
ViewHolder holder = null;
if (view == null) {
holder = new ViewHolder();
view = View.inflate(context, R.layout.search_olddata_item, null);
holder.tv = (TextView) view.findViewById(R.id.text);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.tv.setText(list.get(i));
return view;
}
public class ViewHolder{
TextView tv;
}
}
| [
"[email protected]"
]
| |
a073e77a220319cf2f231aed8cc99ca5110bd16c | e75be673baeeddee986ece49ef6e1c718a8e7a5d | /submissions/blizzard/Corpus/eclipse.pde.ui/976.java | 9fe90df068abbce7d57b0cbedf0a60525e80d6ba | [
"MIT"
]
| permissive | zhendong2050/fse18 | edbea132be9122b57e272a20c20fae2bb949e63e | f0f016140489961c9e3c2e837577f698c2d4cf44 | refs/heads/master | 2020-12-21T11:31:53.800358 | 2018-07-23T10:10:57 | 2018-07-23T10:10:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,478 | java | /*******************************************************************************
* Copyright (c) 2007, 2013 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.pde.api.tools.internal.provisional.scanner;
import org.eclipse.osgi.util.NLS;
public class ScannerMessages extends NLS {
//$NON-NLS-1$
private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.internal.provisional.scanner.ScannerMessages";
public static String ApiDescriptionManager_0;
public static String ApiDescriptionManager_1;
public static String ApiDescriptionManager_2;
public static String ApiDescriptionManager_3;
public static String ApiDescriptionManager_4;
public static String ComponentXMLScanner_0;
public static String ComponentXMLScanner_1;
public static String ComponentXMLScanner_2;
public static String ComponentXMLScanner_3;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, ScannerMessages.class);
}
private ScannerMessages() {
}
}
| [
"[email protected]"
]
| |
a08ec35d7aaf9499dd90112a001270830e731d37 | b8feb3f548b9200bff2cc16d8c690d55ef6e4e1c | /src/easy/FindLuckyIntegerinanArray.java | a85b2f16be7ac611e00372e3d18c68f88d16fb75 | []
| no_license | zangliguang/leetcode | ddb3a738722296d67b8d1627791e2135119bca9b | 258c35f30463588eb0599f6d1d3b080b7daeb3ea | refs/heads/master | 2023-04-29T07:42:35.807610 | 2023-04-15T07:07:44 | 2023-04-15T07:07:44 | 94,408,216 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 482 | java | package easy;
import java.lang.reflect.Array;
import java.util.Arrays;
/**
*1394 Find Lucky Integer in an Array
*/
public class FindLuckyIntegerinanArray {
public int findLucky(int[] arr) {
int[] mark=new int[500];
Arrays.fill(mark,0);
for (int i : arr) {
mark[i]++;
}
for (int i = mark.length - 1; i >= 0; i--) {
if(mark[i]==i){
return i;
}
}
return -1;
}
}
| [
"[email protected]"
]
| |
bd0137071a239e184dc6bf99cb635c4d72f6cb1a | b1049b017790e00211d6957ff06727f50e4bb182 | /src/main/java/net/alenzen/a2l/Unit.java | 026d688623c5d03aeae8081e9e6a507b9cac68b7 | [
"MIT",
"LicenseRef-scancode-public-domain"
]
| permissive | piotrkolo/A2LParser | 441d34e8d8845b4351e7a8e5a3fc878f6d7787c1 | e9df8c711da7aec536d8d4100485ebb5f8e53a89 | refs/heads/master | 2023-02-19T01:44:31.983648 | 2021-01-15T19:42:38 | 2021-01-15T19:42:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,749 | java | package net.alenzen.a2l;
import java.io.IOException;
public class Unit implements IA2LWriteable {
private String name;
private String longIdentifier;
private String display;
private Type type;
// optional parameters
private String unit_ref;
private SiExponents siExponents;
private UnitConversion unitConversion;
enum Type {
DERIVED, EXTENDED_SI
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLongIdentifier() {
return longIdentifier;
}
public void setLongIdentifier(String longIdentifier) {
this.longIdentifier = longIdentifier;
}
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public String getUnit_ref() {
return unit_ref;
}
public void setUnit_ref(String unit_ref) {
this.unit_ref = unit_ref;
}
public SiExponents getSiExponents() {
return siExponents;
}
public void setSiExponents(SiExponents siExponents) {
this.siExponents = siExponents;
}
public UnitConversion getUnitConversion() {
return unitConversion;
}
public void setUnitConversion(UnitConversion unitConversion) {
this.unitConversion = unitConversion;
}
@Override
public void writeTo(A2LWriter writer) throws IOException {
writer.writelnBeginSpaced("UNIT", name, A2LWriter.toA2LString(longIdentifier), A2LWriter.toA2LString(display), type.name());
writer.indent();
if(unit_ref != null) {
writer.writelnSpaced("REF_UNIT", unit_ref);
}
writer.write(siExponents);
writer.write(unitConversion);
writer.dedent();
writer.writelnEnd("UNIT");
}
}
| [
"[email protected]"
]
| |
77a7dabddba23bab240e0f59e761145eeaa43d2a | 8c8d5ff7dbdec05ec1b2d2cbd191fa894ab08d68 | /src/main/java/com/alipay/ams/cfg/AMSSettings.java | e0ce7c28bc93582a55c5c4041d6af3ffaa7414fc | [
"MIT"
]
| permissive | HeavenlyBuns/ams-java-sdk | b35417e2311188df7858fe69f8f8aa9060cf5007 | 7739f725f5013573cea4c51791470af971bbefce | refs/heads/master | 2021-02-12T02:53:14.018916 | 2020-02-28T09:02:03 | 2020-02-28T09:02:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,358 | java | /*
* The MIT License
* Copyright © 2019 Alipay.com Inc.
*
* 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 com.alipay.ams.cfg;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import com.alipay.ams.util.Logger;
import com.alipay.ams.util.SystemoutLogger;
/**
*
* @author guangling.zgl
* @version $Id: AMSSettings.java, v 0.1 2019年8月26日 下午6:32:56 guangling.zgl Exp $
*/
public class AMSSettings {
public static final String sdkVersion = "1.3.1.20200228";
//from config.properties start
public String clientId;
public String privateKey;
public String alipayPublicKey;
public String gatewayUrl;
//from config.properties end
//Max milliseconds to wait for a connection from the pool
public int apacheHttpConnectionRequestTimeout = 5000;
//Max milliseconds to wait for a new connection with Alipay gateway to be established
public int apacheHttpConnectTimeout = 5000;
//Max milliseconds to wait for response data
public int apacheHttpSocketTimeout = 5000;
public int apacheMaxPoolSize = 50;
public int[] inquiryInterval = new int[] { 2, 3, 3, 5, 5,
5, 5, 5, 5 };
public int[] cancelInterval = new int[] { 2, 3, 3, 5, 5 };
public boolean enableTelemetry = true;
public int maxInquiryCount = inquiryInterval.length;
public int maxCancelCount = cancelInterval.length;
public int maxOrderCodeRequestCount = 3;
public int maxEntryCodeRequestCount = 3;
public Logger logger = new SystemoutLogger();
public long jobListingDelayInMilliSeconds = 300;
public int corePoolSizeOfJobExecutor = 10;
public long lockAutoReleaseDelayInMilliSeconds = 300;
public int retryHandlePaymentSuccessDelayInSeconds = 3;
/**
* @param clientId
* @param privateKey
* @param alipayPublicKey
* @param gatewayUrl
*/
public AMSSettings(String clientId, String privateKey, String alipayPublicKey, String gatewayUrl) {
this.clientId = clientId;
this.privateKey = privateKey;
this.alipayPublicKey = alipayPublicKey;
this.gatewayUrl = gatewayUrl;
}
public AMSSettings() {
InputStream inputStream = null;
try {
Properties prop = new Properties();
String propFileName = "config.properties";
inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
if (inputStream != null) {
prop.load(inputStream);
this.clientId = prop.getProperty("clientId");
this.privateKey = prop.getProperty("privateKey");
this.alipayPublicKey = prop.getProperty("alipayPublicKey");
this.gatewayUrl = prop.getProperty("gatewayUrl");
} else {
throw new FileNotFoundException(
String
.format(
"property file '%s' not found in the classpath [src/main/resources/config.properties]",
propFileName));
}
} catch (IOException e) {
throw new IllegalStateException(e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
//
}
}
}
}
public boolean validate() {
return true;
}
/**
*
* @return
*/
public boolean isDevMode() {
return gatewayUrl.contains("dev.alipay.net") || gatewayUrl.contains(".alipaydev.com");
}
}
| [
"[email protected]"
]
| |
316ce609bf6e9a53893dd5e82ef46bc679abc0c7 | e106ed1b19e8bb93e788da4e895c2bf29e89809e | /src/main/java/com/ylink/ylpay/common/project/otcbb/constant/BillCheckStatus.java | 65b14e721cb28b93dae51561d294c46da73cad9e | []
| no_license | lf2035724/aucross-commons | ab691f93ac21bd2bdaa959fd492efd86d2591853 | d2977749da24db8dc1db4ea6f42624c95991d0b2 | refs/heads/master | 2020-06-13T11:39:31.064143 | 2016-12-02T11:20:57 | 2016-12-02T11:21:02 | 75,385,027 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,150 | java | /**
* 版权所有(C) 2013 证联融通
* 创建:jf.zhao 2013-5-14
*/
package com.ylink.ylpay.common.project.otcbb.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @author jf.zhao
* @date 2013-5-14
* @description:
*/
public enum BillCheckStatus {
NEW("00", "新建"),
WAIT("01", "等待"),
FAILURE("03", "失败"),
SUCCESS("02", "数据准备完成");
private String value;
private final String displayName;
public String getValue() {
return this.value;
}
public String getDisplayName() {
return this.displayName;
}
BillCheckStatus(String value, String displayName) {
this.value = value;
this.displayName = displayName;
}
private static Map<String, BillCheckStatus> valueMap = new HashMap<String, BillCheckStatus>();
static {
for (BillCheckStatus _enum : BillCheckStatus.values()) {
valueMap.put(_enum.value, _enum);
}
}
/**
* 枚举转换
*/
public static BillCheckStatus parseOf(String value) {
for (BillCheckStatus item : values())
if (item.getValue().equals(value))
return item;
throw new IllegalArgumentException("枚举值[" + value + "]不匹配!");
}
}
| [
"[email protected]"
]
| |
0050c2c5e7fc7376c7098a4b8f70de197baabb32 | 8758ee45523707953a64a7f62cbd3ee4b24a19a6 | /app/src/main/java/net/ddns/satsukies/bunkasae_card/TicketActivity.java | 3495e72b4f150516fbf8222fc42549686234dfbe | []
| no_license | satsukies/BunkasaE-Card | 201f8b31b6d53592ebad943062bd71e1247f042d | 58f3263271065406e4a23e618bfe2991dc329d4c | refs/heads/master | 2021-01-10T04:05:28.534616 | 2016-01-24T05:03:37 | 2016-01-24T05:03:37 | 49,352,847 | 0 | 0 | null | 2016-01-24T05:03:38 | 2016-01-10T04:10:43 | Java | UTF-8 | Java | false | false | 1,714 | java | package net.ddns.satsukies.bunkasae_card;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import com.squareup.otto.Subscribe;
import net.ddns.satsukies.bunkasae_card.api.GetAsyncTask;
import net.ddns.satsukies.bunkasae_card.model.Ticket;
import net.ddns.satsukies.bunkasae_card.pubsub.AsyncBus;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.ArrayList;
import butterknife.Bind;
import butterknife.ButterKnife;
public class TicketActivity extends AppCompatActivity {
@Bind(R.id.list)
ListView list;
ArrayList<Ticket> ticketList;
TicketAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ticket);
ButterKnife.bind(this);
ticketList = new ArrayList<>();
adapter = new TicketAdapter(this);
adapter.setTicketList(ticketList);
list.setAdapter(adapter);
Handler h = new Handler();
new GetAsyncTask(this).execute(h);
}
@Subscribe
public void fetchTickets(JSONArray array) {
try {
for (int x = 0; x < array.length(); x++) {
ticketList.add(new Ticket(array.getJSONObject(x)));
}
} catch (JSONException e) {
e.printStackTrace();
}
adapter.notifyDataSetChanged();
}
@Override
protected void onResume() {
super.onResume();
AsyncBus.get().register(this);
}
@Override
protected void onStop() {
super.onStop();
AsyncBus.get().unregister(this);
}
}
| [
"[email protected]"
]
| |
d937c731589b1ded631110771d81b7bbd9ba7cc4 | 0f21b35272ae2527ff1ab95a258378d3fb8418eb | /DataStructure-J/src/main/java/cn/shuaijunlan/nowcoder/$2017/$04/$27/App3.java | 22bfdeb62b8b185625a64758202d49a6486c3c8c | []
| no_license | ShuaiJunlan/java-learning | c1a92b41ba4ed1ff880e55a70330dd342dc6e8c6 | ae5cbbf146e6c059b5cd613bcd095d7855a00f8e | refs/heads/master | 2023-03-04T07:14:22.649266 | 2022-11-18T07:34:16 | 2022-11-18T07:34:16 | 162,292,537 | 4 | 0 | null | 2023-02-22T07:22:48 | 2018-12-18T13:29:13 | Java | UTF-8 | Java | false | false | 251 | java | package cn.shuaijunlan.nowcoder.$2017.$04.$27;
/**
* @author Junlan Shuai[[email protected]].
* @date Created on 20:39 2017/4/27.
*/
public class App3 {
public static void main(String[] args) {
System.out.print("6.00000");
}
}
| [
"[email protected]"
]
| |
e650de9aa6ec48d6757757ad7bba3adda77701a0 | fce5effe15b1adfb02c429f29b103763e25db261 | /Selenium Practice/src/SpiceJetPrac.java | 9446523182c75a2ea36141b3067ac37682c38cd6 | []
| no_license | Hemdeep01/selenium_automation | 9c78cd17456703c0645d71f18e624a17c1cb5bb7 | e322ff0618b78fef6d6f293bd7b5de089f341341 | refs/heads/master | 2020-04-18T14:32:31.071871 | 2019-03-26T17:56:43 | 2019-03-26T17:56:43 | 167,591,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,172 | java | import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
public class SpiceJetPrac {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\Hem\\Desktop\\SELENIUM\\chromedriver.exe" );
WebDriver driver= new ChromeDriver();
driver.get("https://www.spicejet.com/");
driver.findElement(By.id("divpaxinfo")).click();
Thread.sleep(2000L);
for(int i=1;i<4;i++)
{
driver.findElement(By.id("hrefIncAdt")).click();
}
driver.findElement(By.id("btnclosepaxoption")).click();
Select s=new Select(driver.findElement(By.id("ctl00_mainContent_DropDownListCurrency")));
s.selectByValue("INR");
Thread.sleep(2000L);
s.selectByIndex(2);
Thread.sleep(2000L);
s.selectByVisibleText("AED");
Thread.sleep(2000L);
driver.findElement(By.id("ctl00_mainContent_ddl_originStation1_CTXT")).click();
driver.findElement(By.xpath("//a[@value='HYD']")).click();
driver.findElement(By.xpath("(//a[@value='MAA'])[2]")).click();
}
}
| [
"Hem@LAPTOP-5MU2HV3U"
]
| Hem@LAPTOP-5MU2HV3U |
5ba29b09b67d9cd06501301623aa9d97cbdfa333 | 946989180102b8a47ce1f134fe162e3235ea0000 | /src/main/java/com/seokjin/Example.java | 43067ad1ef575fa169dc0dd375b51173d892c323 | []
| no_license | seokjin-mobigen/repo | f02ef54d03ded84c06fd104b3ae37e43e3ac220c | e59f7531a8cb37f98e2e8fc30d4ed33cf1ecde91 | refs/heads/master | 2023-01-05T18:23:32.192191 | 2020-11-06T05:37:57 | 2020-11-06T05:37:57 | 310,498,557 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package com.seokjin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class Example {
@RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(Example.class, args);
}
}
| [
"[email protected]"
]
| |
a7fa54d6943885f2ea09f3665ec3307465cc7e68 | 70cbaeb10970c6996b80a3e908258f240cbf1b99 | /WiFi万能钥匙dex1-dex2jar.jar.src/com/linksure/apservice/integration/a/a.java | 90a2c501c5438308e3a6a3248a262240a8a34912 | []
| no_license | nwpu043814/wifimaster4.2.02 | eabd02f529a259ca3b5b63fe68c081974393e3dd | ef4ce18574fd7b1e4dafa59318df9d8748c87d37 | refs/heads/master | 2021-08-28T11:11:12.320794 | 2017-12-12T03:01:54 | 2017-12-12T03:01:54 | 113,553,417 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 25,691 | java | package com.linksure.apservice.integration.a;
import com.bluefay.b.h;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class a
{
private static final ConcurrentHashMap<String, b> a = new ConcurrentHashMap();
public static void a(String paramString1, String paramString2, a parama)
{
if (a(paramString2)) {
throw new RuntimeException("saveFolder must be not empty");
}
b localb = (b)a.get(paramString1);
if ((localb == null) || (!localb.a()))
{
paramString2 = new b(paramString1, paramString2, parama);
paramString2.start();
a.put(paramString1, paramString2);
}
for (;;)
{
return;
h.a("already download for url:%S", new Object[] { paramString1 });
localb.a(parama);
}
}
static boolean a(String paramString)
{
if ((paramString == null) || (paramString.length() == 0)) {}
for (boolean bool = true;; bool = false) {
return bool;
}
}
public static abstract interface a
{
public abstract void a(int paramInt);
public abstract void a(boolean paramBoolean, String paramString);
}
private static final class b
extends Thread
{
private List<a.a> a;
private File b;
private String c;
private boolean d = false;
private String e;
private String f;
private AtomicBoolean g = new AtomicBoolean(false);
public b(String paramString1, String paramString2, a.a parama)
{
this.c = paramString1;
this.g.set(true);
this.e = paramString2;
this.f = null;
this.a = new ArrayList();
this.a.add(parama);
}
private String a(HttpURLConnection paramHttpURLConnection)
{
int i = 0;
Object localObject = paramHttpURLConnection.getHeaderField(i);
if (localObject != null) {
if ("Content-Disposition".equalsIgnoreCase(paramHttpURLConnection.getHeaderFieldKey(i)))
{
localObject = Pattern.compile(".*filename=(.*)").matcher((CharSequence)localObject);
if (((Matcher)localObject).find())
{
paramHttpURLConnection = new String(((Matcher)localObject).group(1).getBytes("iso-8859-1"), "utf-8").replaceAll("\"", "").replace("'", "").trim();
h.a("-----found file name %s from Content-Disposition", new Object[] { paramHttpURLConnection });
}
}
}
for (;;)
{
return paramHttpURLConnection;
i++;
break;
paramHttpURLConnection = paramHttpURLConnection.getURL().toString();
h.a("final url:" + paramHttpURLConnection, new Object[0]);
if (!this.c.equals(paramHttpURLConnection))
{
localObject = paramHttpURLConnection.substring(paramHttpURLConnection.lastIndexOf('/') + 1);
if (!a.a((String)localObject))
{
i = ((String)localObject).indexOf("?");
paramHttpURLConnection = (HttpURLConnection)localObject;
if (i != -1) {
paramHttpURLConnection = ((String)localObject).substring(0, i);
}
localObject = paramHttpURLConnection.trim();
paramHttpURLConnection = (HttpURLConnection)localObject;
if (!a.a((String)localObject)) {
continue;
}
}
}
paramHttpURLConnection = URLDecoder.decode(this.c, "utf-8");
localObject = paramHttpURLConnection.substring(paramHttpURLConnection.lastIndexOf('/') + 1);
if ((localObject == null) || ("".equals(((String)localObject).trim())))
{
paramHttpURLConnection = UUID.randomUUID().toString();
h.a("-----random file name " + paramHttpURLConnection, new Object[0]);
}
else
{
i = ((String)localObject).indexOf("?");
paramHttpURLConnection = (HttpURLConnection)localObject;
if (i != -1) {
paramHttpURLConnection = ((String)localObject).substring(0, i);
}
localObject = paramHttpURLConnection.trim();
h.a("-----found file name " + (String)localObject + " from url " + this.c, new Object[0]);
paramHttpURLConnection = (HttpURLConnection)localObject;
if (((String)localObject).equals(""))
{
h.a("-----file name \"" + (String)localObject + "\" is invalidate,do random UUID----", new Object[0]);
paramHttpURLConnection = UUID.randomUUID().toString();
h.a("-----random file name " + paramHttpURLConnection, new Object[0]);
}
}
}
}
private void a(int paramInt1, int paramInt2)
{
if (this.a == null) {}
for (;;)
{
return;
paramInt1 = paramInt2 * 100 / paramInt1;
synchronized (this.a)
{
Iterator localIterator = this.a.iterator();
if (localIterator.hasNext()) {
((a.a)localIterator.next()).a(paramInt1);
}
}
}
}
private void a(boolean paramBoolean, String paramString)
{
if (this.a == null) {}
for (;;)
{
return;
synchronized (this.a)
{
Iterator localIterator = this.a.iterator();
if (localIterator.hasNext()) {
((a.a)localIterator.next()).a(paramBoolean, paramString);
}
}
this.a.clear();
}
}
private static void b(HttpURLConnection paramHttpURLConnection)
{
Object localObject2 = new LinkedHashMap();
Object localObject1;
for (int i = 0;; i++)
{
localObject1 = paramHttpURLConnection.getHeaderField(i);
if (localObject1 == null) {
break;
}
((Map)localObject2).put(paramHttpURLConnection.getHeaderFieldKey(i), localObject1);
}
localObject2 = ((Map)localObject2).entrySet().iterator();
if (((Iterator)localObject2).hasNext())
{
localObject1 = (Map.Entry)((Iterator)localObject2).next();
if (((Map.Entry)localObject1).getKey() != null) {}
for (paramHttpURLConnection = (String)((Map.Entry)localObject1).getKey() + ":";; paramHttpURLConnection = "")
{
h.a(paramHttpURLConnection + (String)((Map.Entry)localObject1).getValue(), new Object[0]);
break;
}
}
}
public final void a(a.a parama)
{
try
{
if (this.a == null)
{
ArrayList localArrayList = new java/util/ArrayList;
localArrayList.<init>();
this.a = localArrayList;
}
this.a.add(parama);
return;
}
finally {}
}
public final boolean a()
{
return this.g.get();
}
/* Error */
public final void run()
{
// Byte code:
// 0: aconst_null
// 1: astore 7
// 3: ldc_w 259
// 6: iconst_1
// 7: anewarray 126 java/lang/Object
// 10: dup
// 11: iconst_0
// 12: aload_0
// 13: getfield 35 com/linksure/apservice/integration/a/a$b:c Ljava/lang/String;
// 16: aastore
// 17: invokestatic 131 com/bluefay/b/h:a (Ljava/lang/String;[Ljava/lang/Object;)V
// 20: new 261 java/io/File
// 23: astore 4
// 25: aload 4
// 27: aload_0
// 28: getfield 40 com/linksure/apservice/integration/a/a$b:e Ljava/lang/String;
// 31: invokespecial 262 java/io/File:<init> (Ljava/lang/String;)V
// 34: aload 4
// 36: invokevirtual 265 java/io/File:exists ()Z
// 39: ifne +9 -> 48
// 42: aload 4
// 44: invokevirtual 268 java/io/File:mkdirs ()Z
// 47: pop
// 48: aload 4
// 50: invokevirtual 265 java/io/File:exists ()Z
// 53: ifne +129 -> 182
// 56: new 270 java/lang/RuntimeException
// 59: astore 4
// 61: new 142 java/lang/StringBuilder
// 64: astore 5
// 66: aload 5
// 68: ldc_w 272
// 71: invokespecial 147 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 74: aload 4
// 76: aload 5
// 78: aload_0
// 79: getfield 40 com/linksure/apservice/integration/a/a$b:e Ljava/lang/String;
// 82: invokevirtual 151 java/lang/StringBuilder:append (Ljava/lang/String;)Ljava/lang/StringBuilder;
// 85: invokevirtual 152 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 88: invokespecial 273 java/lang/RuntimeException:<init> (Ljava/lang/String;)V
// 91: aload 4
// 93: athrow
// 94: astore 8
// 96: aconst_null
// 97: astore 5
// 99: aconst_null
// 100: astore 4
// 102: aload 5
// 104: astore 7
// 106: aload 4
// 108: astore 6
// 110: ldc_w 275
// 113: aload 8
// 115: invokestatic 278 com/bluefay/b/h:a (Ljava/lang/String;Ljava/lang/Exception;)V
// 118: aload 4
// 120: ifnull +8 -> 128
// 123: aload 4
// 125: invokevirtual 283 java/io/InputStream:close ()V
// 128: aload 5
// 130: ifnull +8 -> 138
// 133: aload 5
// 135: invokevirtual 286 java/io/FileOutputStream:close ()V
// 138: aload_0
// 139: getfield 288 com/linksure/apservice/integration/a/a$b:b Ljava/io/File;
// 142: ifnonnull +628 -> 770
// 145: aconst_null
// 146: astore 4
// 148: aload_0
// 149: aload_0
// 150: getfield 26 com/linksure/apservice/integration/a/a$b:d Z
// 153: aload 4
// 155: invokespecial 289 com/linksure/apservice/integration/a/a$b:a (ZLjava/lang/String;)V
// 158: aload_0
// 159: getfield 33 com/linksure/apservice/integration/a/a$b:g Ljava/util/concurrent/atomic/AtomicBoolean;
// 162: iconst_1
// 163: iconst_0
// 164: invokevirtual 293 java/util/concurrent/atomic/AtomicBoolean:compareAndSet (ZZ)Z
// 167: ifeq +14 -> 181
// 170: invokestatic 296 com/linksure/apservice/integration/a/a:a ()Ljava/util/concurrent/ConcurrentHashMap;
// 173: aload_0
// 174: getfield 35 com/linksure/apservice/integration/a/a$b:c Ljava/lang/String;
// 177: invokevirtual 302 java/util/concurrent/ConcurrentHashMap:remove (Ljava/lang/Object;)Ljava/lang/Object;
// 180: pop
// 181: return
// 182: new 137 java/net/URL
// 185: astore 4
// 187: aload 4
// 189: aload_0
// 190: getfield 35 com/linksure/apservice/integration/a/a$b:c Ljava/lang/String;
// 193: invokespecial 303 java/net/URL:<init> (Ljava/lang/String;)V
// 196: aload 4
// 198: invokevirtual 307 java/net/URL:openConnection ()Ljava/net/URLConnection;
// 201: checkcast 57 java/net/HttpURLConnection
// 204: astore 5
// 206: aload 5
// 208: sipush 5000
// 211: invokevirtual 310 java/net/HttpURLConnection:setConnectTimeout (I)V
// 214: aload 5
// 216: sipush 8000
// 219: invokevirtual 313 java/net/HttpURLConnection:setReadTimeout (I)V
// 222: aload 5
// 224: ldc_w 315
// 227: invokevirtual 318 java/net/HttpURLConnection:setRequestMethod (Ljava/lang/String;)V
// 230: aload 5
// 232: ldc_w 320
// 235: ldc_w 322
// 238: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 241: aload 5
// 243: ldc_w 328
// 246: ldc_w 330
// 249: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 252: aload 5
// 254: ldc_w 332
// 257: aload_0
// 258: getfield 35 com/linksure/apservice/integration/a/a$b:c Ljava/lang/String;
// 261: invokevirtual 333 java/lang/String:toString ()Ljava/lang/String;
// 264: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 267: aload 5
// 269: ldc_w 335
// 272: ldc_w 337
// 275: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 278: aload 5
// 280: ldc_w 339
// 283: ldc_w 341
// 286: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 289: aload 5
// 291: ldc_w 343
// 294: ldc_w 345
// 297: invokevirtual 326 java/net/HttpURLConnection:setRequestProperty (Ljava/lang/String;Ljava/lang/String;)V
// 300: aload 5
// 302: invokevirtual 348 java/net/HttpURLConnection:connect ()V
// 305: aload 5
// 307: invokestatic 350 com/linksure/apservice/integration/a/a$b:b (Ljava/net/HttpURLConnection;)V
// 310: aload_0
// 311: getfield 42 com/linksure/apservice/integration/a/a$b:f Ljava/lang/String;
// 314: invokestatic 164 com/linksure/apservice/integration/a/a:a (Ljava/lang/String;)Z
// 317: ifeq +23 -> 340
// 320: ldc_w 352
// 323: iconst_0
// 324: anewarray 126 java/lang/Object
// 327: invokestatic 131 com/bluefay/b/h:a (Ljava/lang/String;[Ljava/lang/Object;)V
// 330: aload_0
// 331: aload_0
// 332: aload 5
// 334: invokespecial 354 com/linksure/apservice/integration/a/a$b:a (Ljava/net/HttpURLConnection;)Ljava/lang/String;
// 337: putfield 42 com/linksure/apservice/integration/a/a$b:f Ljava/lang/String;
// 340: new 261 java/io/File
// 343: astore 4
// 345: aload 4
// 347: aload_0
// 348: getfield 40 com/linksure/apservice/integration/a/a$b:e Ljava/lang/String;
// 351: aload_0
// 352: getfield 42 com/linksure/apservice/integration/a/a$b:f Ljava/lang/String;
// 355: invokespecial 356 java/io/File:<init> (Ljava/lang/String;Ljava/lang/String;)V
// 358: aload_0
// 359: aload 4
// 361: putfield 288 com/linksure/apservice/integration/a/a$b:b Ljava/io/File;
// 364: new 142 java/lang/StringBuilder
// 367: astore 4
// 369: aload 4
// 371: ldc_w 358
// 374: invokespecial 147 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 377: aload 4
// 379: aload 5
// 381: invokevirtual 362 java/net/HttpURLConnection:getResponseCode ()I
// 384: invokevirtual 365 java/lang/StringBuilder:append (I)Ljava/lang/StringBuilder;
// 387: invokevirtual 152 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 390: iconst_0
// 391: anewarray 126 java/lang/Object
// 394: invokestatic 131 com/bluefay/b/h:a (Ljava/lang/String;[Ljava/lang/Object;)V
// 397: aload 5
// 399: invokevirtual 362 java/net/HttpURLConnection:getResponseCode ()I
// 402: sipush 200
// 405: if_icmpne +298 -> 703
// 408: aload 5
// 410: invokevirtual 369 java/net/HttpURLConnection:getInputStream ()Ljava/io/InputStream;
// 413: astore 4
// 415: aload 5
// 417: invokevirtual 372 java/net/HttpURLConnection:getContentLength ()I
// 420: istore_2
// 421: new 374 java/io/BufferedInputStream
// 424: astore 9
// 426: aload 9
// 428: aload 4
// 430: invokespecial 377 java/io/BufferedInputStream:<init> (Ljava/io/InputStream;)V
// 433: sipush 8192
// 436: newarray <illegal type>
// 438: astore 8
// 440: new 285 java/io/FileOutputStream
// 443: astore 5
// 445: aload 5
// 447: aload_0
// 448: getfield 288 com/linksure/apservice/integration/a/a$b:b Ljava/io/File;
// 451: invokespecial 380 java/io/FileOutputStream:<init> (Ljava/io/File;)V
// 454: aload 5
// 456: astore 7
// 458: aload 4
// 460: astore 6
// 462: aload 5
// 464: invokevirtual 384 java/io/FileOutputStream:getChannel ()Ljava/nio/channels/FileChannel;
// 467: astore 10
// 469: aload 5
// 471: astore 7
// 473: aload 4
// 475: astore 6
// 477: aload 10
// 479: lconst_0
// 480: invokevirtual 390 java/nio/channels/FileChannel:position (J)Ljava/nio/channels/FileChannel;
// 483: pop
// 484: iconst_0
// 485: istore_1
// 486: aload 5
// 488: astore 7
// 490: aload 4
// 492: astore 6
// 494: aload 9
// 496: aload 8
// 498: invokevirtual 394 java/io/BufferedInputStream:read ([B)I
// 501: istore_3
// 502: iload_3
// 503: iconst_m1
// 504: if_icmpeq +68 -> 572
// 507: aload 5
// 509: astore 7
// 511: aload 4
// 513: astore 6
// 515: aload_0
// 516: getfield 33 com/linksure/apservice/integration/a/a$b:g Ljava/util/concurrent/atomic/AtomicBoolean;
// 519: invokevirtual 252 java/util/concurrent/atomic/AtomicBoolean:get ()Z
// 522: ifeq +50 -> 572
// 525: aload 5
// 527: astore 7
// 529: aload 4
// 531: astore 6
// 533: aload 10
// 535: aload 8
// 537: iconst_0
// 538: iload_3
// 539: invokestatic 400 java/nio/ByteBuffer:wrap ([BII)Ljava/nio/ByteBuffer;
// 542: invokevirtual 404 java/nio/channels/FileChannel:write (Ljava/nio/ByteBuffer;)I
// 545: pop
// 546: iload_1
// 547: iload_3
// 548: iadd
// 549: istore_1
// 550: aload 5
// 552: astore 7
// 554: aload 4
// 556: astore 6
// 558: aload_0
// 559: iload_2
// 560: iload_1
// 561: invokespecial 406 com/linksure/apservice/integration/a/a$b:a (II)V
// 564: goto -78 -> 486
// 567: astore 8
// 569: goto -467 -> 102
// 572: aload 5
// 574: astore 7
// 576: aload 4
// 578: astore 6
// 580: aload 10
// 582: invokevirtual 407 java/nio/channels/FileChannel:close ()V
// 585: aload 5
// 587: astore 7
// 589: aload 4
// 591: astore 6
// 593: aload 5
// 595: invokevirtual 286 java/io/FileOutputStream:close ()V
// 598: aload 5
// 600: astore 7
// 602: aload 4
// 604: astore 6
// 606: aload 4
// 608: invokevirtual 283 java/io/InputStream:close ()V
// 611: aload 5
// 613: astore 7
// 615: aload 4
// 617: astore 6
// 619: new 142 java/lang/StringBuilder
// 622: astore 8
// 624: aload 5
// 626: astore 7
// 628: aload 4
// 630: astore 6
// 632: aload 8
// 634: ldc_w 409
// 637: invokespecial 147 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 640: aload 5
// 642: astore 7
// 644: aload 4
// 646: astore 6
// 648: aload 8
// 650: aload_0
// 651: getfield 288 com/linksure/apservice/integration/a/a$b:b Ljava/io/File;
// 654: invokevirtual 412 java/lang/StringBuilder:append (Ljava/lang/Object;)Ljava/lang/StringBuilder;
// 657: invokevirtual 152 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 660: iconst_0
// 661: anewarray 126 java/lang/Object
// 664: invokestatic 131 com/bluefay/b/h:a (Ljava/lang/String;[Ljava/lang/Object;)V
// 667: aload 5
// 669: astore 7
// 671: aload 4
// 673: astore 6
// 675: aload_0
// 676: iconst_1
// 677: putfield 26 com/linksure/apservice/integration/a/a$b:d Z
// 680: aload 4
// 682: ifnull +8 -> 690
// 685: aload 4
// 687: invokevirtual 283 java/io/InputStream:close ()V
// 690: aload 5
// 692: invokevirtual 286 java/io/FileOutputStream:close ()V
// 695: goto -557 -> 138
// 698: astore 4
// 700: goto -562 -> 138
// 703: new 270 java/lang/RuntimeException
// 706: astore 4
// 708: new 142 java/lang/StringBuilder
// 711: astore 6
// 713: aload 6
// 715: ldc_w 414
// 718: invokespecial 147 java/lang/StringBuilder:<init> (Ljava/lang/String;)V
// 721: aload 4
// 723: aload 6
// 725: aload 5
// 727: invokevirtual 362 java/net/HttpURLConnection:getResponseCode ()I
// 730: invokevirtual 365 java/lang/StringBuilder:append (I)Ljava/lang/StringBuilder;
// 733: invokevirtual 152 java/lang/StringBuilder:toString ()Ljava/lang/String;
// 736: invokespecial 273 java/lang/RuntimeException:<init> (Ljava/lang/String;)V
// 739: aload 4
// 741: athrow
// 742: astore 5
// 744: aconst_null
// 745: astore 4
// 747: aload 4
// 749: ifnull +8 -> 757
// 752: aload 4
// 754: invokevirtual 283 java/io/InputStream:close ()V
// 757: aload 7
// 759: ifnull +8 -> 767
// 762: aload 7
// 764: invokevirtual 286 java/io/FileOutputStream:close ()V
// 767: aload 5
// 769: athrow
// 770: aload_0
// 771: getfield 288 com/linksure/apservice/integration/a/a$b:b Ljava/io/File;
// 774: invokevirtual 417 java/io/File:getAbsolutePath ()Ljava/lang/String;
// 777: astore 4
// 779: goto -631 -> 148
// 782: astore 4
// 784: goto -94 -> 690
// 787: astore 4
// 789: goto -661 -> 128
// 792: astore 4
// 794: goto -656 -> 138
// 797: astore 4
// 799: goto -42 -> 757
// 802: astore 4
// 804: goto -37 -> 767
// 807: astore 5
// 809: goto -62 -> 747
// 812: astore 5
// 814: aload 6
// 816: astore 4
// 818: goto -71 -> 747
// 821: astore 8
// 823: aconst_null
// 824: astore 5
// 826: goto -724 -> 102
// Local variable table:
// start length slot name signature
// 0 829 0 this b
// 485 76 1 i int
// 420 140 2 j int
// 501 48 3 k int
// 23 663 4 localObject1 Object
// 698 1 4 localIOException1 java.io.IOException
// 706 72 4 localObject2 Object
// 782 1 4 localIOException2 java.io.IOException
// 787 1 4 localIOException3 java.io.IOException
// 792 1 4 localIOException4 java.io.IOException
// 797 1 4 localIOException5 java.io.IOException
// 802 1 4 localIOException6 java.io.IOException
// 816 1 4 localObject3 Object
// 64 662 5 localObject4 Object
// 742 26 5 localObject5 Object
// 807 1 5 localObject6 Object
// 812 1 5 localObject7 Object
// 824 1 5 localObject8 Object
// 108 707 6 localObject9 Object
// 1 762 7 localObject10 Object
// 94 20 8 localException1 Exception
// 438 98 8 arrayOfByte byte[]
// 567 1 8 localException2 Exception
// 622 27 8 localStringBuilder StringBuilder
// 821 1 8 localException3 Exception
// 424 71 9 localBufferedInputStream java.io.BufferedInputStream
// 467 114 10 localFileChannel java.nio.channels.FileChannel
// Exception table:
// from to target type
// 20 48 94 java/lang/Exception
// 48 94 94 java/lang/Exception
// 182 340 94 java/lang/Exception
// 340 415 94 java/lang/Exception
// 703 742 94 java/lang/Exception
// 462 469 567 java/lang/Exception
// 477 484 567 java/lang/Exception
// 494 502 567 java/lang/Exception
// 515 525 567 java/lang/Exception
// 533 546 567 java/lang/Exception
// 558 564 567 java/lang/Exception
// 580 585 567 java/lang/Exception
// 593 598 567 java/lang/Exception
// 606 611 567 java/lang/Exception
// 619 624 567 java/lang/Exception
// 632 640 567 java/lang/Exception
// 648 667 567 java/lang/Exception
// 675 680 567 java/lang/Exception
// 690 695 698 java/io/IOException
// 20 48 742 finally
// 48 94 742 finally
// 182 340 742 finally
// 340 415 742 finally
// 703 742 742 finally
// 685 690 782 java/io/IOException
// 123 128 787 java/io/IOException
// 133 138 792 java/io/IOException
// 752 757 797 java/io/IOException
// 762 767 802 java/io/IOException
// 415 454 807 finally
// 110 118 812 finally
// 462 469 812 finally
// 477 484 812 finally
// 494 502 812 finally
// 515 525 812 finally
// 533 546 812 finally
// 558 564 812 finally
// 580 585 812 finally
// 593 598 812 finally
// 606 611 812 finally
// 619 624 812 finally
// 632 640 812 finally
// 648 667 812 finally
// 675 680 812 finally
// 415 454 821 java/lang/Exception
}
}
}
/* Location: /Users/hanlian/Downloads/WiFi万能钥匙dex1-dex2jar.jar!/com/linksure/apservice/integration/a/a.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
]
| |
2f618b19fd33857cedff8d195768fec133d7c75a | 5a2b24d37003aab0f244007270cb5085aa7cb5c6 | /web_workspace/bookstore/src/com/bookstore/util/QueryUtil.java | 127aeddef79637f7e853bf805b5769465ab00942 | []
| no_license | asohee123/update | 1776f8f9372e12c06574515c56d1fdee51a5f663 | 128bafcec2eb45be3e4589fca6d56abfa696aa63 | refs/heads/master | 2022-11-04T20:59:23.485378 | 2020-07-13T08:58:56 | 2020-07-13T08:58:56 | 254,512,479 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | package com.bookstore.util;
import java.util.Properties;
public class QueryUtil {
// query.properties에 정의된 내용을 key, value의 쌍으로 보관하는 객체
private static Properties prop = new Properties();
static {
try {
prop.load(Class.forName("com.bookstore.util.QueryUtil").getResourceAsStream("query.properties"));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 지정된 이름의 쿼리문을 반환한다.
* @param name query.properties에 정의된 SQL의 이름
* @return sql 구문, 유효한 이름이 아닌 경우 null이 반환됨
*/
public static String getSQL(String name) {
return prop.getProperty(name);
}
}
| [
"[email protected]"
]
| |
50625a225510fe185d1feb76d005880a3bcd4267 | d9368906958abe94a69f68c15312686e7fedfc8a | /Day02/src/day02/OperatorCondition.java | c9c1860b96a42c24e43dfeff437157cd68196686 | []
| no_license | ywh2995/Java | 168f10d791e4623b478313fb11f11d996e206627 | 65888bbdde2687888362c6f6a1197b6ae013c1de | refs/heads/master | 2022-11-07T01:54:02.217224 | 2020-06-26T03:59:58 | 2020-06-26T03:59:58 | 275,069,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 518 | java | package day02;
public class OperatorCondition {
public static void main(String[] args) {
//랜덤한 double값을 발생시키는 기능 (0.0이상~ 1.0미만)
// System.out.println( Math.random());
// // 1 ~ 10까지 랜덤값
// double d = Math.random() * 10;
// int result = (int) d + 1; //1~10
// System.out.println(result);
int result = (int) (Math.random()*10)+1;
System.out.println(result);
String result2 = result % 3 == 0? "3의배수입니다" : "3의배수가 아닙니다.";
}
}
| [
"[email protected]"
]
| |
c5084a9d1ae537a0069a8d4fa67899dbec5efedf | f0b013a94722e88af36cf1f47890d190a86ca5ae | /src/com/davidsoft/natural/WordReader.java | 6bd99f48189cd55ecc7965a521cbca69a5cf4e71 | []
| no_license | daviddyn/SimpleChatSystem | ef557e0c7997cf5f497b204118b432bf17f45a94 | f66b373274640fd7280678a0f80b3b300665f3db | refs/heads/master | 2020-09-08T01:15:44.971133 | 2019-11-11T12:27:15 | 2019-11-11T12:27:15 | 220,968,442 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 754 | java | package com.davidsoft.natural;
/**
* Abstract word reader.
*/
public interface WordReader {
/**
* 读入下一个单词,使指针向后移动。
*
* @return 接下来的单词。
*/
String nextWord();
/**
* 预览下一个单词,指针不向后移动。
*
* @return 接下来的单词。
*/
String peekWord();
/**
* 跳过指定数量的单词。
*
* @param wordCount 几个
* @return 实际上跳过了几个单词。
*/
int skipWords(int wordCount);
/**
* 是否存在下一个单词。
*
* @return {@code true} if there are words remain, {@code false} otherwise.
*/
boolean hasNext();
}
| [
"[email protected]"
]
| |
0b747a66695485fdb14417453f4338836edff29d | ef691cc212ddbf4277beed2e5ec85094303b256b | /app/src/main/java/com/app/CustomViews/AutoResizeTextureView.java | 1bb6f70485fd840c81a7c7f42ba95c6c7c10fed8 | []
| no_license | bajmorse/Candid | 8213a143265ff30ec6e5b10139c99316fb0d55a5 | ab18042c52b73f54ca4b89d3248079734fcbe381 | refs/heads/master | 2021-01-17T18:04:54.901321 | 2016-07-08T18:55:33 | 2016-07-08T18:55:33 | 61,393,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,457 | java | package com.app.CustomViews;
import android.content.Context;
import android.util.AttributeSet;
import android.view.TextureView;
/**
* Created by brent on 2016-06-14.
*/
public class AutoResizeTextureView extends TextureView {
// TileSize ratio
private int mRatioWidth = 0;
private int mRatioHeight = 0;
public AutoResizeTextureView(Context context) {
this(context, null);
}
public AutoResizeTextureView(Context context, AttributeSet set) {
this(context, set, 0);
}
public AutoResizeTextureView(Context context, AttributeSet set, int defStyle) {
super(context, set, defStyle);
}
public void setAspectRatio(final int width, final int height) {
if (width < 0 || height < 0) throw new IllegalArgumentException("TileSize cannot be negative");
mRatioHeight = height;
mRatioWidth = width;
requestLayout();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Get width and height
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
// Set aspect ratio
if (mRatioHeight == 0 || mRatioWidth == 0) {
setMeasuredDimension(width, height);
} else {
setMeasuredDimension(width, width * mRatioHeight/mRatioWidth);
}
}
}
| [
"[email protected]"
]
| |
3992cd93861627b8302f760b0d5d21c3e73c559e | 01ad1eb39324a400f5bd1831d1721628c06a4fa3 | /app/src/main/java/com/vimalinc/hieg/webview/Webview10.java | 3789bea37fd8196a713ff747d8457a102284d0e4 | [
"Apache-2.0"
]
| permissive | vimalcvs/Hindi-to-English-Translation | 0699198858f88030bbb682a31737bfeee659b33c | 3eee8c8db762e48abd1504a164daa9af5b1199e5 | refs/heads/master | 2020-06-13T03:42:45.931687 | 2019-06-30T14:13:18 | 2019-06-30T14:13:18 | 194,522,755 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,709 | java | package com.vimalinc.hieg.webview;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.vimalinc.hieg.Aboutme;
import com.vimalinc.hieg.Notification;
import com.vimalinc.hieg.R;
public class Webview10 extends AppCompatActivity {
private WebView webView,webView2;
ProgressDialog progressDialog;
private InterstitialAd mInterstitialAd = null;
@SuppressLint("MissingPermission")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
AdView mAdView = findViewById(R.id.ad_view);
AdRequest adRequest1 = new AdRequest.Builder().build();
mAdView.loadAd(adRequest1);
mInterstitialAd= new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
init2();
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_down_fast);
webView2.startAnimation(animation);
String message = getIntent().getStringExtra("key").toString();
setTitle(message);
Bundle extras = getIntent().getExtras();
String value = "file:///android_asset/www/1.html";
if (extras != null) {
value = extras.getString("keyHTML");
}
webView = (WebView) findViewById(R.id.kamal);
webView.loadUrl(value);
init();
}
private void init() {
webView = (WebView) findViewById(R.id.kamal);
webView.setBackgroundColor(0);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
progressDialog = new ProgressDialog(Webview10.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.show();
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
try {
progressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.homemain, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_about:
Intent i = new Intent(Webview10.this, Aboutme.class);
startActivity(i);
return true;
case R.id.notification:
Intent i1 = new Intent(Webview10.this, Notification.class);
startActivity(i1);
return true;
case R.id.action_share:
String msg = "हिंदी से English में translate करना सीखें";
String appUrl = "https://play.google.com/store/apps/details?id=" + getPackageName();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, msg + "\n\nDownload the app now\n" + appUrl);
startActivity(intent);
return true;
case R.id.action_exit:
AlertDialog.Builder builder = new AlertDialog.Builder(Webview10.this);
builder.setTitle(R.string.app_name);
builder.setIcon(R.mipmap.ic_launcher);
builder.setMessage("Do you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
finish();
}
});
}
else{
super.onBackPressed();
}
}
public void init2() {
webView2=(WebView) findViewById(R.id.kamal);
}
} | [
"[email protected]"
]
| |
e9c178b84a03f98da53fc3d20fd2b16ccece968d | b8573985216f71cfe44bb26467948a69aeee3cea | /src/model/bean/HoaDonBan.java | c518d949a1e3d3019162dcffce154057982315d8 | []
| no_license | hoainam031095/ShopQuanAo_Java_Servlet | e6b3690435acd5aef5e3fd5047773752d9e80d6b | 6455a2f72e9abcdfeeb5ea3b6fffb66db0526c4d | refs/heads/master | 2020-04-11T07:48:02.443850 | 2019-01-22T10:48:57 | 2019-01-22T10:48:57 | 161,622,313 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,026 | java | package model.bean;
public class HoaDonBan {
private String maHD;
private String maTK;
private String tenNguoiNhan;
private String soDienThoai;
private int maTinhThanh;
private String diaChi;
private String ngayBan;
private int trangThai;
public HoaDonBan() {
super();
}
public HoaDonBan(String maHD, String maTK, String tenNguoiNhan, String soDienThoai, int maTinhThanh, String diaChi,
String ngayBan, int trangThai) {
super();
this.maHD = maHD;
this.maTK = maTK;
this.tenNguoiNhan = tenNguoiNhan;
this.soDienThoai = soDienThoai;
this.maTinhThanh = maTinhThanh;
this.diaChi = diaChi;
this.ngayBan = ngayBan;
this.trangThai = trangThai;
}
public String getMaHD() {
return maHD;
}
public void setMaHD(String maHD) {
this.maHD = maHD;
}
public String getMaTK() {
return maTK;
}
public void setMaTK(String maTK) {
this.maTK = maTK;
}
public String getTenNguoiNhan() {
return tenNguoiNhan;
}
public void setTenNguoiNhan(String tenNguoiNhan) {
this.tenNguoiNhan = tenNguoiNhan;
}
public String getSoDienThoai() {
return soDienThoai;
}
public void setSoDienThoai(String soDienThoai) {
this.soDienThoai = soDienThoai;
}
public int getMaTinhThanh() {
return maTinhThanh;
}
public void setMaTinhThanh(int maTinhThanh) {
this.maTinhThanh = maTinhThanh;
}
public String getDiaChi() {
return diaChi;
}
public void setDiaChi(String diaChi) {
this.diaChi = diaChi;
}
public String getNgayBan() {
return ngayBan;
}
public void setNgayBan(String ngayBan) {
this.ngayBan = ngayBan;
}
public int getTrangThai() {
return trangThai;
}
public void setTrangThai(int trangThai) {
this.trangThai = trangThai;
}
@Override
public String toString() {
return "HoaDonBan [maHD=" + maHD + ", maTK=" + maTK + ", tenNguoiNhan=" + tenNguoiNhan + ", soDienThoai="
+ soDienThoai + ", maTinhThanh=" + maTinhThanh + ", diaChi=" + diaChi + ", ngayBan=" + ngayBan
+ ", trangThai=" + trangThai + "]";
}
}
| [
"[email protected]"
]
| |
be3c1e5203afcc4c19ae5e685bb2b3f7697e63d1 | 18d36c2adddce511ef9dc9cc5cfde5826750000a | /src/fr/upmc/requestdispatcher/utils/RequestExecutionInformations.java | 68bd9f1876991c4fd6b7bf3b1ec7600c577b9f4b | []
| no_license | MorvanL/ALASCA | 9ce9283c4b2515fa518941acf9243b9160fa8ae6 | 4a2a3e4e9af18ef692dc7575d3db4ba0747f18d6 | refs/heads/master | 2021-05-06T22:47:42.760915 | 2018-01-09T11:07:51 | 2018-01-09T11:07:51 | 101,300,354 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,571 | java | package fr.upmc.requestdispatcher.utils;
/**
* The class <code>RequestExecutionInformations</code> implements just
* a container for many informations about the executions of a request.
*
* <pre>
* invariant true
* </pre>
*
* <p>Created on : 18 novembre 2017</p>
*
* @author <a href="mailto:[email protected]">Morvan Lassauzay</a>
* @version $Name$ -- $Revision$ -- $Date$
*/
public class RequestExecutionInformations {
/** URI of request */
private String requestURI;
/** The time which the request dispatcher receive this request */
private long arrivalTime;
/** URI of Vm on which the request is executing */
private String vmURI;
/**
* Create a new RequestExecutionInformations
*
* @param requestURI URI of request
* @param arrivalTime The time which the request dispatcher receive this request
* @param vmURI URI of Vm on which the request is executing
* @throws Exception
*/
public RequestExecutionInformations(
String requestURI,
long arrivalTime,
String vmURI
) throws Exception
{
this.requestURI = requestURI;
this.arrivalTime = arrivalTime;
this.vmURI = vmURI;
}
/**
* Get the arrival time of request
*
* @return arrivalTime
*/
public long getArrivalTime() {
return arrivalTime;
}
/**
* Get the VM URI
*
* @return uriVM
*/
public String getVmUri() {
return vmURI;
}
/**
* Get the Request URI
*
* @return requestURI
*/
public String getRequestUri() {
return requestURI;
}
}
| [
"[email protected]"
]
| |
2173e46389ab59780dcae0337e39cf8fae45e4ef | 6cf678294f01479fedf2dea46f513163d927b9e9 | /src/main/java/com/luccas/buscaperto/model/thumbnail/Thumbnail.java | 38bf074c4079e66d91941554af415b15623a71d8 | []
| no_license | leandrovisky/Buscaperto | c7f31b110b386906af1614cb8188044fca5a5146 | 084f14fad086a58075bfe0c74c6c4d613f8ed59d | refs/heads/master | 2022-02-03T18:51:35.268181 | 2019-02-01T20:51:53 | 2019-02-01T20:51:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 278 | java | package com.luccas.buscaperto.model.thumbnail;
import java.io.Serializable;
public class Thumbnail implements Serializable {
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
| [
"[email protected]"
]
| |
08c598b8760632afc1650ca7d5e7e98460adcc1b | cc31c336d08ff96ca7485f2fd65113b7ab7a3aa4 | /clientzipkin8989/src/main/java/com/example/demo/Clientzipkin8989Application.java | 57ad5a68699297b95b0847bb4962200b1413ab9e | []
| no_license | charlesion/springclouds | 9b6f0d871e1f78afcbde76a83e243f7bb537be49 | 6c58914e479afd3fc32fbab26de540026b37b76f | refs/heads/master | 2021-01-23T06:39:04.124563 | 2017-06-02T08:12:54 | 2017-06-02T08:13:08 | 93,032,413 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,257 | java | package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.logging.Level;
import java.util.logging.Logger;
@SpringBootApplication
@RestController
public class Clientzipkin8989Application {
public static void main(String[] args) {
SpringApplication.run(Clientzipkin8989Application.class, args);
}
private static final Logger LOG = Logger.getLogger(Clientzipkin8989Application.class.getName());
@RequestMapping("/hello8989")
public String home(){
LOG.log(Level.INFO, "hello8989 is being called");
return "hi i'm hello8989!";
}
@RequestMapping("/to8988")
public String info(){
LOG.log(Level.INFO, "calling trace to8988");
return restTemplate.getForObject("http://localhost:8988/hello8988",String.class);
}
@Autowired
private RestTemplate restTemplate;
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
}
}
| [
"[email protected]"
]
| |
23f73a87877734bd54181468955b7e802bcc011f | 238d07946ac7b4823e17ec23d014be0ce23b925d | /app/src/main/java/com/example/prmtptr/exa_1202154292_modul6/viewholder/PostViewHolder.java | db9f5b5c7d25b72a34cc1b246aa3063334f1f26e | []
| no_license | prmtptr/EXA_1202154292_MODUL6 | c4e1b30a98c8c68d61d2040be80031088cb31fe1 | 4e894e7c606d889e5bc9d650d741750bfee4c28f | refs/heads/master | 2020-03-07T18:46:17.721960 | 2018-04-01T16:51:03 | 2018-04-01T16:51:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,301 | java | package com.example.prmtptr.exa_1202154292_modul6.viewholder;
/**
* Created by USER on 4/1/2018.
*/
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.prmtptr.exa_1202154292_modul6.R;
import com.example.prmtptr.exa_1202154292_modul6.model.Post;
public class PostViewHolder extends RecyclerView.ViewHolder {
public TextView titleView;
public TextView authorView;
public ImageView starView;
public TextView numStarsView;
public TextView bodyView;
public PostViewHolder(View itemView) {
super(itemView);
titleView = itemView.findViewById(R.id.post_title);
authorView = itemView.findViewById(R.id.post_author);
starView = itemView.findViewById(R.id.star);
numStarsView = itemView.findViewById(R.id.post_num_stars);
bodyView = itemView.findViewById(R.id.post_body);
}
public void bindToPost(Post post, View.OnClickListener starClickListener) {
titleView.setText(post.title);
authorView.setText(post.author);
numStarsView.setText(String.valueOf(post.starCount));
bodyView.setText(post.body);
starView.setOnClickListener(starClickListener);
}
}
| [
"[email protected]"
]
| |
8f2f2b954105b629a359fb4397eded077cafc304 | f3908f58ef6b207e76181251ad1ac4fe3ebd4e3a | /test/ejercicio1/Estado_CaracteresTest.java | e667f828ccb8d1e4b5b46664429ba9eb365ba90f | [
"MIT"
]
| permissive | beltranaceves/Java--CSV-Parser | 9f9bbf6577f17878b14103649aaba9b396647ef7 | 9adad8802d24732840afea91fc8bbb0e8687b8ed | refs/heads/main | 2023-03-12T08:42:40.376686 | 2021-03-02T15:06:38 | 2021-03-02T15:06:38 | 343,811,512 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 740 | 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 ejercicio1;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Beltrán
*/
public class Estado_CaracteresTest {
public Estado_CaracteresTest() {
}
@Test (expected = IllegalArgumentException.class) //Faltan comillas
public void testCSV4() {
String entrada = "\"";
CSV interprete = new CSV();
interprete.Interpretar(entrada);
}
}
| [
"[email protected]"
]
| |
9af75fea784248321b7eff3d9a40e29dc4f13209 | 489a2712df8ade052ebacd243f4cc96d81a716b6 | /app/src/main/java/com/evasler/dokkanbase/roomentinties/card_invincible_form_card_relation.java | 4028d5333ead309eabe448d271cb5af0185e7e5f | []
| no_license | Evasler/DokkanBase | d74ae746591e6e3f242b504014452e80a96970d4 | 3e13ad4a73bb81b597ba84763350148130973946 | refs/heads/master | 2020-09-02T09:13:13.731391 | 2020-02-02T22:19:50 | 2020-02-02T22:19:50 | 219,187,544 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 757 | java | package com.evasler.dokkanbase.roomentinties;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity
public class card_invincible_form_card_relation {
@NonNull
@PrimaryKey
private String card_id;
@NonNull
private String invincible_form_card_id;
@NonNull
public String getCard_id() {
return card_id;
}
@NonNull
public String getInvincible_form_card_id() {
return invincible_form_card_id;
}
public void setCard_id(@NonNull String card_id) {
this.card_id = card_id;
}
public void setInvincible_form_card_id(@NonNull String invincible_form_card_id) {
this.invincible_form_card_id = invincible_form_card_id;
}
}
| [
"[email protected]"
]
| |
ddcae09484c0b7a43120acc6730fbdb0569412b7 | afd8e1a90a2686d8dea5dfcc1a0f4c1d355f239d | /src/main/java/net/bitnine/agensbrowser/bundle/util/TokenUtil.java | 57e2321acc2ca1f00f28c4b6562f3dfe0e6389ed | []
| no_license | lydon-GH/agensgraph-web | ba468c9a3bb6805c273d96a183e387259754ef5b | 19b993445d816ea40d5796dd9f675efca05e62d7 | refs/heads/main | 2023-02-23T21:54:02.484585 | 2021-01-30T03:15:31 | 2021-01-30T03:15:31 | 333,812,631 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,921 | java | //
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package net.bitnine.agensbrowser.bundle.util;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import net.bitnine.agensbrowser.bundle.message.ClientDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mobile.device.Device;
import org.springframework.stereotype.Component;
@Component
public class TokenUtil implements Serializable {
private static final long serialVersionUID = -3301605591108950415L;
static final String CLAIM_KEY_USERNAME = "sub";
static final String CLAIM_KEY_USERIP = "addr";
static final String CLAIM_KEY_AUDIENCE = "audience";
static final String CLAIM_KEY_CREATED = "created";
private static final String AUDIENCE_UNKNOWN = "unknown";
private static final String AUDIENCE_WEB = "web";
private static final String AUDIENCE_MOBILE = "mobile";
private static final String AUDIENCE_TABLET = "tablet";
@Value("${agens.jwt.secret}")
private String secret;
@Value("${agens.jwt.expiration}")
private Long expiration;
public TokenUtil() {
}
public String getUserNameFromToken(String token) {
String userName;
try {
Claims claims = this.getClaimsFromToken(token);
userName = claims.getSubject();
} catch (Exception var4) {
userName = null;
}
return userName;
}
public String getUserIpFromToken(String token) {
String userIp;
try {
Claims claims = this.getClaimsFromToken(token);
userIp = new String((String)claims.get("addr"));
} catch (Exception var4) {
userIp = null;
}
return userIp;
}
public Date getCreatedDateFromToken(String token) {
Date created;
try {
Claims claims = this.getClaimsFromToken(token);
created = new Date((Long)claims.get("created"));
} catch (Exception var4) {
created = null;
}
return created;
}
public Date getExpirationDateFromToken(String token) {
Date expiration;
try {
Claims claims = this.getClaimsFromToken(token);
expiration = claims.getExpiration();
} catch (Exception var4) {
expiration = null;
}
return expiration;
}
public String getAudienceFromToken(String token) {
String audience;
try {
Claims claims = this.getClaimsFromToken(token);
audience = (String)claims.get("audience");
} catch (Exception var4) {
audience = null;
}
return audience;
}
private Claims getClaimsFromToken(String token) {
Claims claims;
try {
claims = (Claims)Jwts.parser().setSigningKey(this.secret).parseClaimsJws(token).getBody();
} catch (Exception var4) {
claims = null;
}
return claims;
}
private Date generateExpirationDate() {
return new Date(System.currentTimeMillis() + this.expiration * 1000L);
}
private Boolean isTokenExpired(String token) {
Date expiration = this.getExpirationDateFromToken(token);
return expiration.before(new Date());
}
private Boolean isCreatedBeforeLastPasswordReset(Date created, Date lastPasswordReset) {
return lastPasswordReset != null && created.before(lastPasswordReset);
}
private static final String generateAudience(Device device) {
String audience = "unknown";
if (device.isNormal()) {
audience = "web";
} else if (device.isTablet()) {
audience = "tablet";
} else if (device.isMobile()) {
audience = "mobile";
}
return audience;
}
private Boolean ignoreTokenExpiration(String token) {
String audience = this.getAudienceFromToken(token);
return "tablet".equals(audience) || "mobile".equals(audience);
}
public String generateToken(ClientDto client) {
Map<String, Object> claims = new HashMap();
claims.put("sub", client.getUserName());
claims.put("addr", client.getUserIp());
claims.put("audience", generateAudience(client.getDevice()));
claims.put("created", new Date());
return this.generateToken((Map)claims);
}
String generateToken(Map<String, Object> claims) {
return Jwts.builder().setClaims(claims).setExpiration(this.generateExpirationDate()).signWith(SignatureAlgorithm.HS512, this.secret).compact();
}
public Boolean canTokenBeRefreshed(String token, Date lastPasswordReset) {
Date created = this.getCreatedDateFromToken(token);
return !this.isCreatedBeforeLastPasswordReset(created, lastPasswordReset) && (!this.isTokenExpired(token) || this.ignoreTokenExpiration(token));
}
public String refreshToken(String token) {
String refreshedToken;
try {
Claims claims = this.getClaimsFromToken(token);
claims.put("created", new Date());
refreshedToken = this.generateToken((Map)claims);
} catch (Exception var4) {
refreshedToken = null;
}
return refreshedToken;
}
public Boolean validateToken(String token, ClientDto client) {
String userName = this.getUserNameFromToken(token);
String userIp = this.getUserIpFromToken(token);
String audience = this.getAudienceFromToken(token);
return client.getUserName().equals(userName) && client.getUserIp().equals(userIp) && generateAudience(client.getDevice()).equals(audience) && !this.isTokenExpired(token) ? true : false;
}
}
| [
"[email protected]"
]
| |
13425387e2b1d72fbcd67910ff40baf9afe72fb0 | 60f0fc7858bfb99af178147733767df5cf9f2e66 | /weatherservice/src/main/java/au/origin/weather/weatherservice/service/WeatherService.java | 12ab37dc0b9ba7df56da559511e622879cced171 | []
| no_license | dilmimg/weather-service | 28c73a2145b6d1b2fe4554b6cbc094cb2e602a20 | f8526b79f1e4cdb6f04dea6540cac3fab7eab285 | refs/heads/master | 2023-01-09T12:02:22.508597 | 2019-08-09T07:26:58 | 2019-08-09T07:26:58 | 201,260,528 | 0 | 0 | null | 2023-01-05T21:52:17 | 2019-08-08T13:08:18 | TypeScript | UTF-8 | Java | false | false | 1,092 | java | package au.origin.weather.weatherservice.service;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import au.origin.weather.weatherservice.dao.WeatherDao;
import au.origin.weather.weatherservice.entity.Weather;
import au.origin.weather.weatherservice.model.CityTemperature;
import au.origin.weather.weatherservice.model.WeatherDetails;
@Service
public class WeatherService {
@Autowired
private WeatherDao weatherDao;
public WeatherDetails getWeatherDetails(){
return convertToWeatherDetails(this.weatherDao.findAll());
}
private WeatherDetails convertToWeatherDetails(List<Weather> weatherList) {
WeatherDetails weatherDetails = new WeatherDetails();
List<CityTemperature> cityTemperatureList = weatherList.stream()
.map(weather -> new CityTemperature(weather.getCity(),Integer.toString(weather.getTemperature())))
.collect(Collectors.toList());
weatherDetails.setCities(cityTemperatureList);
return weatherDetails;
}
}
| [
"[email protected]"
]
| |
a8bc346d390a506d0ff521aef1a18ecd39f1a354 | c54fc6065f38e14ddf8b37b415791f851a17284f | /LottieSample/src/main/java/com/airbnb/lottie/samples/FullScreenActivity.java | 5fed70f9c26c27e23f1bf78af68a20f930c90385 | [
"Apache-2.0"
]
| permissive | Yuanyz/lottie-android | 1e4addf85ff3550db94df7ff63ace017b13b2201 | 9e8e9bb7fc048edec4f871da3530e69d3e394e56 | refs/heads/master | 2020-12-03T01:45:07.946613 | 2017-06-30T02:30:53 | 2017-06-30T02:30:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 518 | java | package com.airbnb.lottie.samples;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
/**
* To have a full screen animation, make an animation that is wider than the screen and set the
* scaleType to centerCrop.
*/
public class FullScreenActivity extends AppCompatActivity {
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_full_screen);
}
}
| [
"[email protected]"
]
| |
53326817825887fcc6d1bc8e0fc4965cc33cb5b5 | bb9e0ee59a674c3707f5076d3834bc7e08ccf2c6 | /account-service/src/main/java/com/foo/domain/Account.java | 7f3c81012d09a865da209a3a1e1bc5145120d358 | []
| no_license | mtShaikh/spring-microservice | e4faace0b76829764aef0bebcbefa641c8b120af | c895e5329c1637669e7e748106235142e70e8aea | refs/heads/master | 2020-03-16T06:28:55.346687 | 2018-06-20T12:16:30 | 2018-06-20T12:16:30 | 132,555,758 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 952 | java | package com.foo.domain;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Account {
@Id
private String Id;
private String number;
private int balance;
private String customerId;
public String getId() {
return Id;
}
public void setId(String id) {
this.Id = id;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public int getBalance() {
return balance;
}
public void setBalance(int balance) {
this.balance = balance;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
@Override
public String toString() {
return "Account [id=" + Id + ", number=" + number + ", customerId=" + customerId + "]";
}
}
| [
"[email protected]"
]
| |
ec36b92cfab9d2cd08b8ab3bb1a2acdaea0eae13 | 86827d1a1c1f8b8c110cec422dbff294a0f1d5a5 | /baladex-core/src/main/java/com/denism/core/generic/GenericDAO.java | 18b85c58369c6b0e87d60f255fcf1e22b8bbaf4c | []
| no_license | DenisSMoreira/baladex | 30ed174327493aa8af21a1eceb34ea7b9ff9d054 | 3934ca1698faf3144cfcd999027e25eb4e456686 | refs/heads/master | 2019-07-29T17:21:33.027231 | 2015-05-28T19:30:20 | 2015-05-28T19:30:20 | 32,752,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 730 | java | /**
*
*/
package com.denism.core.generic;
import java.io.Serializable;
import java.util.List;
import org.hibernate.HibernateException;
/**
* @author denism
*
*/
public interface GenericDAO<T, ID extends Serializable> {
/**
*
* @param entity
* @return
* @throws HibernateException
*/
void save(T entity);
/**
*
* @param entity
* @return
* @throws HibernateException
*/
void update(T entity);
/**
*
* @param entity
* @return
* @throws HibernateException
*/
void merge(T entity);
/**
*
* @param entity
* @throws HibernateException
*/
void remove(T entity);
/**
*
* @return
*/
List<T> findAll();
/**
*
* @param id
* @return
*/
T findById(ID id);
}
| [
"[email protected]"
]
| |
c2ccc1e9a177ae91ec4b417f7632ad75df7661eb | fd3f67368e7177cd5e8aed9e38a81fbfb9a1bbc8 | /components/event-receiver/event-input-adapters/org.wso2.carbon.event.input.adapter.email/src/main/java/org/wso2/carbon/event/input/adapter/email/internal/util/EmailEventAdapterConstants.java | 7420cc668f9cc6806e5043bc12969b9583a8f617 | [
"Apache-2.0"
]
| permissive | ayash/carbon-analytics-common | 1a3ed2f6a9cf8e62ba569595db4d1465449580da | 7722d5d7b6423d0a56f192b3e383fabd245cf2b6 | refs/heads/master | 2021-01-18T11:38:06.851127 | 2015-05-15T10:04:56 | 2015-05-15T10:04:56 | 32,130,853 | 0 | 0 | null | 2015-03-13T05:20:37 | 2015-03-13T05:20:37 | null | UTF-8 | Java | false | false | 3,030 | java | /*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.wso2.carbon.event.input.adapter.email.internal.util;
public final class EmailEventAdapterConstants {
private EmailEventAdapterConstants() {
}
public static final String ADAPTER_TYPE_EMAIL = "email";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_ADDRESS = "transport.mail.Address";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_ADDRESS_HINT = "transport.mail.Address.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL = "transport.mail.Protocol";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL_HINT = "transport.mail.Protocol.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_POLL_INTERVAL = "transport.PollInterval";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_POLL_INTERVAL_HINT = "transport.PollInterval.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL_HOST = "mail.protocol.host";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL_HOST_HINT = "mail.protocol.host.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL_PORT = "mail.protocol.port";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PROTOCOL_PORT_HINT = "mail.protocol.port.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_USERNAME = "mail.protocol.user";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_USERNAME_HINT = "mail.protocol.user.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PASSWORD = "mail.protocol.password";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_PASSWORD_HINT = "mail.protocol.password.hint";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_SOCKET_FACTORY_CLASS = "mail.protocol.socketFactory.class";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_SOCKET_FACTORY_FALLBACK =
"mail.protocol.socketFactory.fallback";
public static final String ADAPTER_CONF_RECEIVING_EMAIL_TRANSPORT_NAME = "mailto";
public static final String ADAPTER_MESSAGE_RECEIVING_EMAIL_SUBJECT = "email.in.subject";
public static final String ADAPTER_MESSAGE_RECEIVING_EMAIL_SUBJECT_HINT = "email.in.subject.hint";
public static final String BROKER_CONF_EMAIL_PROTOCOL = "transport.mail.Protocol";
public static final int AXIS_TIME_INTERVAL_IN_MILLISECONDS = 10000;
}
| [
"shortyrules1990"
]
| shortyrules1990 |
fd55552a1977574883cfc57d3eca2c1e13fefa54 | 2e590ef886718e01d7ec58beff00a28d7aa9a366 | /source-code/java/dv/src/gov/nasa/kepler/dv/io/DvGhostDiagnosticResults.java | eb3dafdaa9547d12af51e84dc222c70f55341e14 | [
"LicenseRef-scancode-warranty-disclaimer"
]
| no_license | adam-sweet/kepler-pipeline | 95a6cbc03dd39a8289b090fb85cdfc1eb5011fd9 | f58b21df2c82969d8bd3e26a269bd7f5b9a770e1 | refs/heads/master | 2022-06-07T21:22:33.110291 | 2020-05-06T01:12:08 | 2020-05-06T01:12:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,254 | java | /*
* Copyright 2017 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* This file is available under the terms of the NASA Open Source Agreement
* (NOSA). You should have received a copy of this agreement with the
* Kepler source code; see the file NASA-OPEN-SOURCE-AGREEMENT.doc.
*
* No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY
* WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY,
* INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE
* WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM
* INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR
* FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM
* TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
* CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT
* OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY
* OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
* FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES
* REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE,
* AND DISTRIBUTES IT "AS IS."
*
* Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS
* AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND
* SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF
* THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES,
* EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM
* PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT
* SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED
* STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY
* PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE
* REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL
* TERMINATION OF THIS AGREEMENT.
*/
package gov.nasa.kepler.dv.io;
import gov.nasa.spiffy.common.persistable.Persistable;
/**
* Ghost diagnostic results.
*
* @author Bill Wohler
*/
public class DvGhostDiagnosticResults implements Persistable {
private DvStatistic coreApertureCorrelationStatistic = new DvStatistic();
private DvStatistic haloApertureCorrelationStatistic = new DvStatistic();
/**
* Creates a {@link DvGhostDiagnosticResults}. For use only by
* serialization, mock objects and Hibernate.
*/
public DvGhostDiagnosticResults() {
}
/**
* Creates a new immutable {@link DvGhostDiagnosticResults} object.
*/
public DvGhostDiagnosticResults(
DvStatistic coreApertureCorrelationStatistic,
DvStatistic haloApertureCorrelationStatistic) {
this.coreApertureCorrelationStatistic = coreApertureCorrelationStatistic;
this.haloApertureCorrelationStatistic = haloApertureCorrelationStatistic;
}
public DvStatistic getCoreApertureCorrelationStatistic() {
return coreApertureCorrelationStatistic;
}
public DvStatistic getHaloApertureCorrelationStatistic() {
return haloApertureCorrelationStatistic;
}
}
| [
"[email protected]"
]
| |
5d1d8c71507a69ca2e4e2391bb8e4bb6bcbf4116 | 492c60c4a4e075c09263b163245b21b985292454 | /src/br/com/caelum/tarefas/controller/TarefasController.java | 1bb9340c10790d85cc46202a55060d29acda4447 | []
| no_license | Daciano0/terefa | 3369e790fb51f4ff8d611c5041378d3f8ad3df00 | a0347dbf114991c64cc19f17d795cd0ba62ca1f0 | refs/heads/master | 2020-04-04T17:57:36.056391 | 2018-11-05T01:46:50 | 2018-11-05T01:46:50 | 156,143,903 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 470 | java | package br.com.caelum.tarefas.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class TarefasController {
@RequestMapping("adicionaTarefa")
public String adiciona(Tarefa tarefa) {
JdbcTarefaDao dao = new JdbcTarefaDao();
dao.adiciona(tarefa);
return "tarefa/adicionada";
}
@RequestMapping("novaTarefa")
public String form() {
return "tarefa/formulario";
}
} | [
"Daciano0"
]
| Daciano0 |
c3dd3ccc5a6fd8cf563be3317edef564dbb85816 | cf4fd132a0185c7a559677d08199aa26a514842f | /bus project/BusManagementSystem/src/java/hiber/HQL/Student.java | eb340e662ede9ad84d25b70257cc84118a459975 | []
| no_license | aloksingh321/busproject | 52d9a0ba29658ae560c6293869f44b4ef156a9c9 | 5e6175bd24e85806cec268a32674ae3d719cee75 | refs/heads/master | 2020-04-21T08:12:17.856214 | 2019-05-04T13:47:00 | 2019-05-04T13:47:00 | 169,412,757 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,405 | 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 hiber.HQL;
//package hiberannotation;
import hiber.*;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
*
* @author ALOK SINGH
*/
@Entity
@Table (name="student1")
public class Student {
@Id
@GeneratedValue
private int id;
@Column (name="stu_name")
private String name;
// @Transient
private int marks;
Student()
{
super();
}
Student(int id,String name,int marks)
{
this.id = id;
this.name= name;
this.marks = marks;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
@Override
public String toString()
{
return id+"name:- "+name+"marks:- "+marks ;
}
}
| [
"[email protected]"
]
| |
0f712afdfe54d6d531fd9cb47659c7ca8145c295 | 2f92dfff9b9929b64e645fdc254815d06bf2b8d2 | /src/main/lee/code/code_171__Excel_Sheet_Column_Number/MainTest.java | 2bcdcc81fb2793d219cff7c208a3fa7e241f6bbf | [
"MIT"
]
| permissive | code543/leetcodequestions | fc5036d63e4c3e1b622fe73552fb33c039e63fb0 | 44cbfe6718ada04807b6600a5d62b9f0016d4ab2 | refs/heads/master | 2020-04-05T19:43:15.530768 | 2018-12-07T04:09:07 | 2018-12-07T04:09:07 | 157,147,529 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 810 | java | package lee.code.code_171__Excel_Sheet_Column_Number;
import java.util.*;
import lee.util.*;
/**
*
*
* 171.Excel Sheet Column Number
*
* difficulty: Easy
* @see https://leetcode.com/problems/excel-sheet-column-number/description/
* @see description_171.md
* @Similiar Topics
* -->Math https://leetcode.com//tag/math
* @Similiar Problems
* -->Excel Sheet Column Title https://leetcode.com//problems/excel-sheet-column-title
* Run solution from Unit Test:
* @see lee.codetest.code_171__Excel_Sheet_Column_Number.CodeTest
* Run solution from Main Judge Class:
* @see lee.code.code_171__Excel_Sheet_Column_Number.C171_MainClass
*
*/
/**
testcase:"A"
*/
public class MainTest {
public static void main(String[] args) {
//new Solution().titleToNumber(Strings);
}
}
| [
"[email protected]"
]
| |
87013a42362b6dd15e746cc04b77a6ac86a6f0d2 | 17a4911416d54113e4c6eeaeb87c9bc1d9c69cd7 | /src/Client/Main.java | 4c2c37f033d7ac63d2c8e71fc6d51d3f3acb3bed | []
| no_license | alenoe/it_Projekt | 84440cc452ecee59c1d0ae675cdddd7a89f9f8b0 | bab426cec0aa7331a68d5db4752cb4ac26b7c785 | refs/heads/master | 2021-01-10T14:24:30.072555 | 2015-11-25T08:09:23 | 2015-11-25T08:09:23 | 46,416,393 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,107 | java | package Client;
import java.net.URL;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
public class Main extends Application {
@Override
public void start(final Stage stage) throws Exception {
final URL fxmlUrl = getClass().getResource(
"Login.fxml");
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlUrl);
fxmlLoader.setController(new Client_Controller());
final Parent root = fxmlLoader.load();
stage.setScene(new Scene(root, 450, 250));
stage.setTitle("King_of_Tokyo");
stage.show();
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
Platform.exit(); // ends any JavaFX activities
System.exit(0); // end all activities (our server task) - not good code
}
});
}
public static void main(final String[] args) {
launch(args);
}
}
| [
"[email protected]"
]
| |
bf16ee1605a1f74da5365d6850559c2046dadbef | 10624bd5ce0eced734fa473a41c29abbfd43191b | /lisamap/src/main/java/srs/DataSource/Table/DBFHeaderInfo.java | ee0fa2ddf0b9f0cddb507cc238c510b75725eb03 | []
| no_license | bqzfli/lisamap | 08802991f504bc989b0f371baa2b6f0b977d0f52 | 50c5bbc1770d8839851efcb42112b9d9955891e2 | refs/heads/master | 2020-12-30T11:53:01.006984 | 2018-12-07T09:01:09 | 2018-12-07T09:01:09 | 91,436,379 | 4 | 2 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package srs.DataSource.Table;
/**
文件头信息结构
*/
public final class DBFHeaderInfo{
public byte FileType;
public byte Year;
public byte Month;
public byte Day;
public int RecordCount;
public short HeaderLength;
public short RecordLength;
public int FieldCount;
public DBFHeaderInfo clone(){
DBFHeaderInfo varCopy = new DBFHeaderInfo();
varCopy.FileType = this.FileType;
varCopy.Year = this.Year;
varCopy.Month = this.Month;
varCopy.Day = this.Day;
varCopy.RecordCount = this.RecordCount;
varCopy.HeaderLength = this.HeaderLength;
varCopy.RecordLength = this.RecordLength;
varCopy.FieldCount = this.FieldCount;
return varCopy;
}
public void setFileType(byte value){
this.FileType=value;
}
};
| [
"[email protected]"
]
| |
e656f13eef0bfdcd8a60e4b7a7b125f636d60a0c | f2454d625017a7e6d30a967cd445dd96e85cddff | /EISParent/EIS5-3/eis-business/business-knowledgeCenter/src/main/java/com/ecspace/business/knowledgeCenter/administrator/dao/FileInfoDao.java | ac1a8dbaf941d12fb6ebb9e109da178e7ca8022a | []
| no_license | stationone/EIS | a9cbc1f2740abeef67df50da8c1d2eb03a3c1aeb | ba8491a16131e847b06fe34a661c6262acb1cd69 | refs/heads/master | 2022-12-23T20:02:10.799115 | 2020-01-19T08:21:24 | 2020-01-19T08:21:24 | 224,360,333 | 0 | 0 | null | 2022-12-16T04:37:35 | 2019-11-27T06:27:36 | JavaScript | UTF-8 | Java | false | false | 1,119 | java | package com.ecspace.business.knowledgeCenter.administrator.dao;
import com.ecspace.business.knowledgeCenter.administrator.pojo.FileInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
/**
* @author zhangch
* @date 2019/11/19 0019 下午 15:35
*/
@Repository
public interface FileInfoDao extends ElasticsearchRepository<FileInfo, String> {
Page<FileInfo> findByMenuId(String menuId, Pageable pageable);
@Override
Optional<FileInfo> findById(String id);
List<FileInfo> findByMenuId(String menuId);
Optional<FileInfo> findByHashCode(String hashCode);
Page<FileInfo> findByMenuIdAndStatus(String menuId, Integer status, Pageable pageable);
Page<FileInfo> findByMenuIdAndStatusIn(String menuId,Integer[] status,Pageable pageable);
Page<FileInfo> findByStatus(Integer status, Pageable pageable);
}
| [
"[email protected]"
]
| |
5b0514d0d653bf44892b48658ceaee65451b6260 | 8968de104d7f7bb80f0183ff2236b55d9ace3a23 | /app/src/main/java/com/example/eitstudent/act_login2.java | a360ff5a7979020b2e61881dd620100d6f889690 | []
| no_license | Alexandraa72/Android-eit | 681462195d5009b4e856d222bd6144cde9856b80 | bc43c7bf29550341cf6861d0a0ccfb6ce8412bb3 | refs/heads/master | 2023-03-13T20:28:34.963996 | 2021-03-04T04:30:54 | 2021-03-04T04:30:54 | 344,348,483 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package com.example.eitstudent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class act_login2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_act_login2);
}
} | [
"[email protected]"
]
| |
a7497500b60248781faf81cabc79b40ccefb6c03 | f57ea83ee086f489aef641f993aba52411120939 | /Client/DesktopSysinfoDisplay/src/info/talsemgeest/desktopsysinfodisplay/MainActivity.java | 3423d8020556fad362d0b5017401dbab8f21883c | [
"Apache-2.0"
]
| permissive | talsemgeest/desktopsysinfodisplay | bb0c0689ba48f350e9ca4f3638659155b98ba2ad | 610551ae995127562fed7e1e18f3d2021a23d71c | refs/heads/master | 2016-09-05T16:32:14.181793 | 2014-08-20T00:13:08 | 2014-08-20T00:13:08 | 23,130,116 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,664 | java | package info.talsemgeest.desktopsysinfodisplay;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.support.v4.widget.DrawerLayout;
public class MainActivity extends Activity implements
NavigationDrawerFragment.NavigationDrawerCallbacks {
/**
* Fragment managing the behaviors, interactions and presentation of the
* navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
public final static String PORT = "info.talsemgeest.desktopsysinfodisplay.PORT";
public final static String IP = "info.talsemgeest.desktopsysinfodisplay.IP";
public final static String DEMO = "info.talsemgeest.desktopsysinfodisplay.DEMO";
/**
* Used to store the last screen title. For use in
* {@link #restoreActionBar()}.
*/
private CharSequence mTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
.findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout));
}
@Override
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getFragmentManager();
//If demo is selected, enable demo mode
if (position == 1) {
Intent intent = new Intent(this, SysinfoGraphActivity.class);
intent.putExtra(DEMO, true);
startActivity(intent);
} else {
fragmentManager
.beginTransaction()
.replace(R.id.container,
PlaceholderFragment.newInstance(position + 1))
.commit();
}
}
public void onSectionAttached(int number) {
switch (number) {
case 1:
mTitle = getString(R.string.title_section1);
break;
case 2:
mTitle = getString(R.string.title_section2);
break;
}
}
public void restoreActionBar() {
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) {
// Only show items in the action bar relevant to this screen
// if the drawer is not showing. Otherwise, let the drawer
// decide what to show in the action bar.
getMenuInflater().inflate(R.menu.main, menu);
restoreActionBar();
return true;
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_connect,
container, false);
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
((MainActivity) activity).onSectionAttached(getArguments().getInt(
ARG_SECTION_NUMBER));
}
}
/**
* Connects to server,
*/
public void connectToServer(View view) {
Intent intent = new Intent(this, SysinfoGraphActivity.class);
//Add info to intent and start activity.
EditText ipBox = (EditText) findViewById(R.id.ip_input);
String ip = ipBox.getText().toString();
EditText portBox = (EditText) findViewById(R.id.port_input);
String port = portBox.getText().toString();
intent.putExtra(IP, ip);
intent.putExtra(PORT, port);
intent.putExtra(DEMO, false);
startActivity(intent);
}
}
| [
"[email protected]"
]
| |
6528b90ca8e3171bed2c9728b8514d9dfca33546 | b609d4545cf56311a9f376d33501ffe7a4931872 | /src/main/java/com/esdo/bepilot/Model/Response/MissionDetailResponse.java | 39f4233e6cee7aed16bbeb0524066dd5c25e25b6 | []
| no_license | bridgecrew-perf7/deploy4-2 | e2bb546441ee3f0881c6666a1afdaf1bddac76f9 | 18d823c5ed6ad79b91bdf59cfe5def538934b2b0 | refs/heads/main | 2023-09-04T17:53:14.257833 | 2021-11-19T04:15:23 | 2021-11-19T04:15:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 315 | java | package com.esdo.bepilot.Model.Response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MissionDetailResponse {
private Long id;
private Long missionId;
private Long userId;
private String status;
}
| [
""
]
| |
34bb671abad84daba6fe16d5dfbe6d49dc046c31 | 493133e7f2cb57f76dbb7035a4bd2bab95adcd41 | /src/java/im/hdy/dao/SenderDao.java | d45b9d61b07bffa16b3b45e93e85072c990c5672 | []
| no_license | egdw/campus_manager | eee7e92a7a1b36771e5e7d675133b52421c391ca | f4375d4c378d361677649d96d4c4b8337b5f187d | refs/heads/master | 2020-12-03T08:01:16.922752 | 2017-07-13T08:52:36 | 2017-07-13T08:52:36 | 95,648,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 829 | java | package im.hdy.dao;
import im.hdy.model.SenderEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* Created by hdy on 2017/6/27.
*/
public interface SenderDao extends PagingAndSortingRepository<SenderEntity, Long>, JpaSpecificationExecutor<SenderEntity> {
@Modifying
@Query("update SenderEntity s set s.senderIscomplete = ?1 where s.senderId = ?2")
public int addSenderSuccess(Integer senderIscomplete, Long senderId);
@Modifying
@Query("update SenderEntity s set s.senderIscomplete = ?1 where s.senderId = ?2")
public int addSenderCancle(Integer senderIscomplete, Long senderId);
}
| [
"[email protected]"
]
| |
cc46d4c20c164b2db4929e1eecac21fefc40313a | 7951b011669b2347cad79d74811df5c0e7f812e4 | /Andrey/src/task1/Wheel.java | d6b7a73a41e1f491571716a2dce80c3f0958e9cd | []
| no_license | gorobec/ACO18TeamProject | 77c18e12cefb4eda3186dc6f7b84aed14040a691 | ae48c849915c8cb41aab637d001d2b492cc53432 | refs/heads/master | 2021-01-11T15:20:56.092695 | 2017-02-18T14:22:11 | 2017-02-18T14:22:11 | 80,338,687 | 1 | 1 | null | 2017-02-22T20:10:45 | 2017-01-29T09:48:23 | Java | UTF-8 | Java | false | false | 404 | java | package task1;
/**
* Created by Sherlock on 26.01.2017.
*/
public class Wheel {
private int wheelDiameters;
public Wheel(int wheelDiameters) {
this.wheelDiameters = wheelDiameters;
}
public double getWheelDiameters() {
return wheelDiameters;
}
@Override
public String toString() {
return String.format("Diameter: %f", wheelDiameters);
}
}
| [
"[email protected]"
]
| |
1f82fbf1d5f7610b266b0037410bb3dc7507a9ae | 76dc5c84dc9bfe17e401d1bc7349edf062c1ad25 | /src/test/java/com/test/github/mobileweb/screens/GitHubSelendroidScreen.java | 8e0641cce2d146aeaea98ea325c468b8e92f85d1 | []
| no_license | priyankshah217/ImageCompareFrameworkTest | cbd57f730e2b4c8066e393b78f98810ae3c8a25d | 7b37ea635ff1cc71540354632a06a21880addaf1 | refs/heads/master | 2020-05-19T17:36:48.492011 | 2014-11-10T07:13:02 | 2014-11-10T07:13:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 575 | java | package com.test.github.mobileweb.screens;
import io.appium.java_client.android.AndroidDriver;
import com.test.utils.AbstractScreen;
public class GitHubSelendroidScreen extends AbstractScreen {
public GitHubSelendroidScreen(AndroidDriver driver) {
super(driver);
// TODO Auto-generated constructor stub
loadPage();
}
@Override
public String getScreenName() {
// TODO Auto-generated method stub
return getClass().getSimpleName();
}
@Override
public AbstractScreen clickOnLink(String linkName) {
// TODO Auto-generated method stub
return null;
}
}
| [
"[email protected]"
]
| |
74058d8158d64dac53a28160f4994fcf711f0e42 | 94362ff275a56b8e23a4d19031286dcafda9d4b5 | /src/com/rpstms/java/kata2/Propiedades.java | 7f882d7fd5cc722c22c5b4e3168e710303740eb3 | []
| no_license | Bach6CNA/Kata2 | e0a503d815807026744163c00ef0cdefab2b69be | 75488e1693141f74f25a37ff27a62b0f5e37dcda | refs/heads/master | 2021-01-18T21:15:09.703729 | 2015-08-27T01:03:19 | 2015-08-27T01:03:19 | 41,457,621 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 360 | 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.rpstms.java.kata2;
/**
*
* @author richpolis
*/
public interface Propiedades {
public double getPerimetro();
public double getArea();
}
| [
"[email protected]"
]
| |
d654a47302bdfdd03c7330d54baac85354be59c6 | bb6ec86d3321a9eff2465fc932820ade4ecfa1eb | /xc-service-search/src/main/java/com/xuecheng/search/SearchApplication.java | 82756c68d55b6834215c8af30ed031b2cb719ef4 | []
| no_license | fengyinhan/XC_PROJIECT | 30ce608246b3dd090f7fb52c6a0a486d29c46419 | 4d9af7607be3c1b450d2d3f1cd65d543f39225ef | refs/heads/master | 2022-12-04T20:28:18.044205 | 2019-08-22T11:36:31 | 2019-08-22T11:36:31 | 203,778,607 | 0 | 0 | null | 2022-11-24T06:26:49 | 2019-08-22T11:11:52 | Java | UTF-8 | Java | false | false | 1,020 | java | package com.xuecheng.search;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
/**
* @author Administrator
* @version 1.0
**/
@SpringBootApplication
@EnableDiscoveryClient
@EntityScan("com.xuecheng.framework.domain.search")//扫描实体类
@ComponentScan(basePackages={"com.xuecheng.api"})//扫描接口
@ComponentScan(basePackages={"com.xuecheng.search"})//扫描本项目下的所有类
@ComponentScan(basePackages={"com.xuecheng.framework"})//扫描common下的所有类
public class SearchApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SearchApplication.class, args);
}
}
| [
"[email protected]"
]
| |
13da8b94bf8aa66e97a33378163727055e3ef8ce | 1cc95169a5c225a1e8001afbef0aab7faf0b065f | /UMPLE/Generert kode for domenemodell/Java/VoteConfirmedPage.java | 04b3a703931f975f6ba851107f636cbc03d65007 | []
| no_license | jhoffis/2019-DAT109-Modelldrevet-utvikling-26 | 3142e7bc25c8db52f4209b289a9260b73a4367f7 | eaf1eb0f610b0404488646958c6930333aeebc28 | refs/heads/master | 2020-05-19T21:18:31.003770 | 2019-05-07T11:58:16 | 2019-05-07T11:58:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,922 | java | /*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.29.1.4450.6749b7105 modeling language!*/
// line 20 "model.ump"
// line 54 "model.ump"
public class VoteConfirmedPage
{
//------------------------
// MEMBER VARIABLES
//------------------------
//VoteConfirmedPage Attributes
private String userMessage;
//VoteConfirmedPage Associations
private Vote vote;
//------------------------
// CONSTRUCTOR
//------------------------
public VoteConfirmedPage(String aUserMessage, Vote aVote)
{
userMessage = aUserMessage;
if (aVote == null || aVote.getVoteConfirmedPage() != null)
{
throw new RuntimeException("Unable to create VoteConfirmedPage due to aVote");
}
vote = aVote;
}
public VoteConfirmedPage(String aUserMessage, int aWeightForVote, Stand aStandForVote, DatabaseHandler aDatabaseHandlerForVote, UserVerification aUserVerificationForVote)
{
userMessage = aUserMessage;
vote = new Vote(aWeightForVote, this, aStandForVote, aDatabaseHandlerForVote, aUserVerificationForVote);
}
//------------------------
// INTERFACE
//------------------------
public boolean setUserMessage(String aUserMessage)
{
boolean wasSet = false;
userMessage = aUserMessage;
wasSet = true;
return wasSet;
}
public String getUserMessage()
{
return userMessage;
}
/* Code from template association_GetOne */
public Vote getVote()
{
return vote;
}
public void delete()
{
Vote existingVote = vote;
vote = null;
if (existingVote != null)
{
existingVote.delete();
}
}
public String toString()
{
return super.toString() + "["+
"userMessage" + ":" + getUserMessage()+ "]" + System.getProperties().getProperty("line.separator") +
" " + "vote = "+(getVote()!=null?Integer.toHexString(System.identityHashCode(getVote())):"null");
}
} | [
"[email protected]"
]
| |
8a1f31c72991243e6f319d832dc4907469f0c6fa | b92df83c414250ffcc3b8c8259cd29958af6e1f7 | /cardgameblackjack/src/main/java/com/cardtech/game/blackjack/BJPlayerStrategy.java | 20a40d55eefd0ac7a56100c5c0d56e8bdff01d8c | []
| no_license | rrodini/workspace-cardgames | b79d86e914429a7252ab1a6a3d545f7d981a895f | 11a257925a04e9e36e71bfe26ff3e28531c734e8 | refs/heads/master | 2023-01-21T07:09:26.732958 | 2022-12-31T14:01:48 | 2022-12-31T14:01:48 | 5,660,317 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,772 | java | package com.cardtech.game.blackjack;
import static com.cardtech.game.blackjack.BJHandValue.Firmness.*;
import static com.cardtech.game.blackjack.BJResponse.*;
import com.cardtech.core.Card;
/**
* PlayerStrategy is the fixed strategy of a player taken from the Wikipedia article on blackjack.
* Note: same strategy was found on other blackjack websites.
*/
public class BJPlayerStrategy implements BJStrategy {
/* These tables implement the player strategy found here: */
/* https://en.wikipedia.org/wiki/Blackjack */
final int [][] hardHandResponse = {
/* Dealer's face-up card. */
/* 2 3 4 5 6 7 8 9 10 A */
/* player hand */
/* 0 - 17-20 */ { S , S , S , S , S , S , S , S , S , S },
/* 1 - 16 */ { S , S , S , S , S , H , H , SU, SU, SU },
/* 2 - 15 */ { S , S , S , S , S , H , H , H , SU, H },
/* 3 - 13-14 */ { S , S , S , S , S , H , H , H , H , H },
/* 4 - 12 */ { H , H , S , S , S , H , H , H , H , H },
/* 5 - 11 */ { DH, DH, DH, DH, DH, DH, DH, DH, DH, DH },
/* 6 - 10 */ { DH, DH, DH, DH, DH, DH, DH, DH, H , H },
/* 7 - 9 */ { H , DH, DH, DH, DH, H , H , H , H , H },
/* 8 - 5-8 */ { H , H , H , H , H , H , H , H , H , H },
};
final int [][] softHandResponse = {
/* Dealer's face-up card. */
/* 2 3 4 5 6 7 8 9 10 A */
/* player hand */
/* 0 - A,9 */ { S , S , S , S , S , S , S , S , S , S },
/* 1 - A,8 */ { S , S , S , S , DS, S , S , S , S , S },
/* 2 - A,7 */ { DS, DS, DS, DS, DS, S , S , H , H , H },
/* 3 - A,6 */ { H , DH, DH, DH, DH, H , H , H , H , H },
/* 4 - A,4-A,5 */ { H , H , DH, DH, DH, H , H , H , H , H },
/* 5 - A,2-A,3 */ { H , H , H , DH, DH, H , H , H , H , H },
};
final int [][] splitHandResponse = {
/* Dealer's face-up card. */
/* 2 3 4 5 6 7 8 9 10 A */
/* player hand */
/* 0 - A-A */ { SP, SP, SP, SP, SP, SP, SP, SP, SP, SP },
/* 1 - 10,10 */ { S , S , S , S , S , S , S , S , S , S },
/* 2 - 9-9 */ { SP, SP, SP, SP, SP, S , SP, SP, S , S },
/* 3 - 8-8 */ { SP, SP, SP, SP, SP, SP, SP, SP, SP, SP },
/* 4 - 7-7 */ { SP, SP, SP, SP, SP, SP, H , H , H , H },
/* 5 - 6-6 */ { SP, SP, SP, SP, SP, H , H , H , H , H },
/* 6 - 5-5 */ { DH, DH, DH, DH, DH, DH, DH, DH, H , H },
/* 7 - 4-4 */ { H , H , H , SP, SP, H , H , H , H , H },
/* 8 - 2-2,3-3 */ { SP, SP, SP, SP, SP, SP, H , H , H , H },
};
/**
* hit gives a response to the dealer's question regarding HIT or STAND.
* The response depends on the player's cards and the dealer's up card.
* @param playerHand player's hand.
* @param dealerHand dealer's hand.
* @return See BJResponse values.
*/
@Override
public int hit(BJPlayerHand playerHand, BJDealerHand dealerHand) {
BJHandValue playerHandValue = BJHandEvaluator.evaluate(playerHand);
//System.out.printf("player hand: %s\n", playerHandValue.toString());
int response = -1;
int j = indexFromDealerHand(dealerHand);
if (playerHand.getCardCount() == 2 &&
playerHand.getCard(0).getValue() == playerHand.getCard(1).getValue()) {
// use splitHandResponse table
int i = splitIndexFromPlayerHand(playerHand);
//System.out.printf("split indices i: %d, j: %d\n", i, j);
response = splitHandResponse[i][j];
} else if (playerHandValue.getFirmness() == HARD_HAND) {
// use hardHandResponse table
int i = hardIndexFromPlayerHand(playerHandValue.getLowValue()); // low value == high value
//System.out.printf("hard indices i: %d, j: %d\n", i, j);
response = hardHandResponse[i][j];
} else if (playerHandValue.getFirmness() == SOFT_HAND) {
int i = softIndexFromPlayerHand(playerHandValue.getLowValue()-playerHandValue.getAceCount());
//System.out.printf("soft indices i: %d, j: %d\n", i, j);
response = softHandResponse[i][j];
} else {
throw new IllegalStateException("player's hand value is invalid: " + playerHandValue.toString());
}
response = mapResponse(response);
return response;
}
/**
* mapResponse collapses some of the responses in order to simplify the implementation
* as there is no DOUBLE or SURRENDER implemented.
* @param response one of STAND, HIT, DOUBLE/STAND, DOUBLE/HIT, SURRENDER, or SPLIT
* @return one of STAND, HIT, or SPLIT
*/
private int mapResponse(int response) {
switch (response) {
case S: case H: case SP:
break;
case DS:
response = S;
break;
case DH: case SU:
response = H;
break;
}
return response;
}
private int splitIndexFromPlayerHand(BJPlayerHand pHand) {
Card dupCard = pHand.getCard(0);
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
int [] map = {-1, -1, 8, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 0};
return map[dupCard.getValue()];
}
private int hardIndexFromPlayerHand(int total) {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
int [] map = {-1, -1, -1, -1, -1, 8, 8, 8, 8, 7, 6, 5, 4, 3, 3, 2, 1, 0, 0, 0, 0};
return map[total];
}
private int softIndexFromPlayerHand(int lowMin) {
// 0 1 2 3 4 5 6 7 8 9
int [] map = {-1, -1, 5, 5, 4, 4, 3, 2, 1, 0};
return map[lowMin];
}
private int indexFromDealerHand(BJDealerHand dHand) {
Card upCard = dHand.getUpCard();
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
int [] map = {-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 9};
return map[upCard.getValue()];
}
}
| [
"[email protected]"
]
| |
de67675aa725328a609dfc5184a8f339f1eea515 | 0fca0b41c531431cbbcb111269a34a4088a9e8ba | /src/prob6/RectTriangle.java | f9bd3e6501573346083450f61b2565c457c67102 | []
| no_license | hornedlizard/practice05 | 38ad657cddd0d5140d6b304db0bb88d78dfba9c5 | f5073d9f50d6b8f0b99c8a938a6ba56c85d053f3 | refs/heads/master | 2021-04-27T13:29:14.195892 | 2018-02-22T12:09:10 | 2018-02-22T12:09:10 | 122,440,673 | 0 | 0 | null | 2018-02-22T06:41:11 | 2018-02-22T06:41:11 | null | UTF-8 | Java | false | false | 391 | java | package prob6;
public class RectTriangle extends Shape {
public RectTriangle(double w, double h) {
setWidth(w);
setHeight(h);
}
@Override
public double getArea() {
return (getWidth() * getHeight()) / 2;
}
@Override
public double getPerimeter() {
return getWidth()+getHeight()+Math.sqrt(Math.pow(getWidth(), 2)+Math.pow(getHeight(), 2));
}
}
| [
"BIT@DESKTOP-A70PMGU"
]
| BIT@DESKTOP-A70PMGU |
f8b61cced426d4cfab6766d0da5c2f339951da17 | 499016637b856134fb2939f74b4ebf66542c82aa | /Algorithm/028_Implement_strStr/Solution.java | e1839d24ba1eb2c2c275ae4b958938916dc87d12 | []
| no_license | renchunxiao/Leecode | 460555cd0ccaf9fbb1717a76d95ab734c6beb47b | 1b98bfdda238d613b601c5524931628b5f34cab3 | refs/heads/master | 2020-05-22T04:15:26.049794 | 2016-10-08T11:58:01 | 2016-10-08T11:58:01 | 64,671,872 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,009 | java | public class Solution {
public int strStr(String haystack, String needle) {
if (haystack == null || needle == null) {
return -1;
}
if (needle.length() > haystack.length()) {
return -1;
}
if (needle.length() == 0) {
return 0;
}
int olength = haystack.length();
int nlength = needle.length();
int index = -1;
A:for (int i = 0; i < olength; i++) {
if (haystack.charAt(i) != needle.charAt(0)) {
continue;
} else {
index = i;
if (i + nlength > olength) {
return -1;
}
for (int j = 1; j < nlength; j++) {
if (needle.charAt(j) != haystack.charAt(i + j)) {
index = -1;
continue A;
}
}
return index;
}
}
return index;
}
}
| [
"[email protected]"
]
| |
cd0b38bd3c0a80964f392a4d834a6f054c7ce775 | 69ca230138d587d43d867079c80e1c88c8d5678c | /net.colloquia/src/net/colloquia/datamodel/entities/ColloquiaComponent.java | e3750e5c672391b120d269f606d6ce35124a133a | []
| no_license | Phillipus/colloquia | cc6138c44e02425407a5986cfe1b1ad0ca93bb21 | d1dcc5440ae9fb621a853fc8d43f7fad48c3da0d | refs/heads/master | 2022-12-04T17:57:31.197534 | 2020-08-31T21:51:50 | 2020-08-31T21:51:50 | 281,718,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,131 | java | package net.colloquia.datamodel.entities;
import java.util.*;
import net.colloquia.datamodel.*;
import net.colloquia.prefs.*;
import net.colloquia.util.*;
import net.colloquia.xml.*;
import org.jdom.*;
/**
* This is the ancestor of all Colloquia entities
*/
public abstract class ColloquiaComponent
implements XML, PropertyTableModel
{
// Entity types
public static final int PERSON = 0;
public static final int RESOURCE = 1;
public static final int ASSIGNMENT = 2;
public static final int ACTIVITY = 3;
public static final int GROUP = 4;
public static final int PERSON_GROUP = 5;
public static final int RESOURCE_GROUP = 6;
public static final int ACTIVITY_GROUP = 7;
public static final int TEMPLATE_GROUP = 8;
// This is for internal use, it's not saved
private int entityType;
private String guid;
// For convenience / debugging
public String name;
// Instances of Groups that this component is a member of
protected Vector memberGroups = new Vector();
// Common Keys to main properties
public static final String NAME = "name";
public static final String GUID = "guid";
public static final String DATE_CREATED = "date_created";
public static final String DATE_MODIFIED = "date_modified";
public static final String SUBMITTER = "submitter";
public static final String LOCAL_FILE = "local_file";
public static final String URL = "url";
public static final String PHYSICAL_LOCATION = "physical_location";
public static final String EXTERNAL_BROWSER = "external_browser";
/**
* Constructor for new Component with an existing GUID
* We don't always want to generate a GUID - opening, copying already have them
* If GUID is null, a new GUID will be generated
*/
protected ColloquiaComponent(String name, String GUID, int entityType) {
initComponent(name, entityType);
if(GUID == null) setGUID(generateGUID());
else setGUID(GUID);
}
/**
* Init for a new Component
*/
private void initComponent(String name, int entityType) {
setName(name, false);
this.entityType = entityType;
setPropertyDate(DATE_CREATED, Utils.getNow());
setPropertyDate(DATE_MODIFIED, getPropertyDate(DATE_CREATED));
setSubmitter("ME", false);
}
// Properties
protected Hashtable properties = new Hashtable();
public Hashtable getProperties() { return properties; } // getTableData
public void setProperties(Hashtable set) { properties = set; } // setTableData
/**
* Put a property in the property table
* @param key
* @param value
* @param update If true, reset this Resource's timestamp to now
*/
public void putProperty(String key, String value, boolean update) { // setTableElement
if(key == null || value == null) return;
if(key.equals("")) return;
key = key.toLowerCase();
// 'Me' - for backward compat
if(value.equalsIgnoreCase("me")) value = value.toUpperCase();
// For debugging
if(key.equals(NAME)) name = value;
if(key.equals(GUID)) guid = value;
properties.put(key, value);
//* update means set Date Modified
if(update) setTimeStamp(key);
}
public String getProperty(String key) {
String value = (String)properties.get(key.toLowerCase());
return value == null ? "" : value;
}
public void removeProperty(String key, boolean update) {
properties.remove(key.toLowerCase());
//* update means set Date Modified
if(update) setTimeStamp(key);
}
// =========================== TABLE STUFF ===============================
public int getTableRowCount() {
return getTableFieldValues().size();
}
public String getTableRowName(int row) {
if(row >= getTableFieldValues().size()) return "";
FieldValue fv = (FieldValue)getTableFieldValues().elementAt(row);
return fv.friendlyName;
}
public String getTableRowValue(int row) {
String key = getTableRowKey(row);
return getProperty(key);
}
public String getTableRowKey(int row) {
if(row >= getTableFieldValues().size()) return "";
FieldValue fv = (FieldValue)getTableFieldValues().elementAt(row);
return fv.key;
}
public FieldValue getTableFieldValue(int row) {
if(row >= getTableFieldValues().size()) return null;
return (FieldValue)getTableFieldValues().elementAt(row);
}
/**
* Factory method for creating a component
*/
public static ColloquiaComponent createComponent(String name, String GUID, int type) {
switch(type) {
// PERSON
case PERSON:
return new Person(name, GUID);
// RESOURCE
case RESOURCE:
return new Resource(name, GUID);
// RESOURCE GROUP
case RESOURCE_GROUP:
return new ResourceGroup(name, GUID);
// ACTIVITY
case ACTIVITY:
return new Activity(name, GUID);
// ASSIGNMENT
case ASSIGNMENT:
return new Assignment(name, GUID);
// GROUP
case GROUP:
return new Group(name, GUID);
// Activity GROUP
case ACTIVITY_GROUP:
return new ActivityGroup(name, GUID);
// PERSON GROUP
case PERSON_GROUP:
return new PersonGroup(name, GUID);
default:
return null;
}
}
//========================== CONVENIENCE ==================================
public int getType() {
return entityType;
}
public void setName(String name, boolean update) {
putProperty(NAME, name, update);
}
public String getName() {
return getProperty(NAME);
}
public void rename(String newName) {
if(newName != null) {
// Save old name
String oldName = getName();
// Trim spaces and check for empty string
newName = newName.trim();
if(newName.length() == 0) return;
// Same as before?
if(oldName.equals(newName)) return;
// Set to this new name
setName(newName, true);
}
}
public void setGUID(String id) {
putProperty(GUID, id, false);
}
public String getGUID() {
return getProperty(GUID);
}
public void setTimeStamp(String key) {
if(key.equalsIgnoreCase(SUBMITTER)) return;
else if(key.equalsIgnoreCase(LOCAL_FILE)) return;
else setTimeStamp();
}
public void setTimeStamp() {
setPropertyDate(DATE_MODIFIED, Utils.getNow());
}
public void setPropertyDate(String propertyName, Date date) {
putProperty(propertyName, String.valueOf(date.getTime()), false);
}
public Date getPropertyDate(String propertyName) {
String val = getProperty(propertyName);
if(val.equals("")) return null;
else return new Date(Long.parseLong(val));
}
public void setURL(String set, boolean update) {
putProperty(URL, set, update);
}
public String getURL() {
return getProperty(URL);
}
public String getLocalFile() {
return getProperty(LOCAL_FILE);
}
public void setLocalFile(String set, boolean update) {
putProperty(LOCAL_FILE, set, update);
}
public String getSubmitter() {
return getProperty(SUBMITTER);
}
public void setSubmitter(String set, boolean update) {
if(set.equalsIgnoreCase("ME")) set = set.toUpperCase();
putProperty(SUBMITTER, set, update);
}
/** Returns true if this is mine */
public boolean isMine() {
return getSubmitter().equalsIgnoreCase("ME");
}
/**
* Returns true if person e-mail matches this submitter's e-mail
*/
public boolean isSubmitter(Person person) {
if(person == null) return false;
return isSubmitter(person.getEmailAddress());
}
/**
* Returns true if e-mail matches this submitter's e-mail
*/
public boolean isSubmitter(String eMail) {
if(eMail == null) return false;
String submitter = getSubmitter();
return submitter.equalsIgnoreCase(eMail);
}
public void setExternalBrowser(boolean value, boolean update) {
if(value) putProperty(EXTERNAL_BROWSER, "true", update);
else removeProperty(EXTERNAL_BROWSER, update);
}
public boolean isExternalBrowser() {
String val = getProperty(EXTERNAL_BROWSER);
return val.toLowerCase().equals("true");
}
public abstract ColloquiaComponent copy();
public abstract SentComponent getSentComponent();
/**
* Update this with the values of tc's properties
*/
public void updateProperties(ColloquiaComponent tc) {
Hashtable props = tc.getProperties();
Enumeration e = props.keys();
while(e.hasMoreElements()) {
String key = (String)e.nextElement();
String value = (String)props.get(key);
if(!key.equalsIgnoreCase(GUID)) putProperty(key, value, false);
}
}
public Vector getMemberGroups() {
return memberGroups;
}
public void addMemberGroup(ColloquiaContainer parentGroup) {
// New one - so add GUID to central bank
if(getInstanceCount() == 0) DataModel.addGUID(this);
if(!memberGroups.contains(parentGroup)) memberGroups.addElement(parentGroup);
}
public void removeMemberGroup(ColloquiaContainer parentGroup) {
memberGroups.removeElement(parentGroup);
// Gone!
if(getInstanceCount() == 0) DataModel.removeGUID(this);
}
public int getInstanceCount() {
return memberGroups.size();
}
/**
* Returns a Vector of all Activities that this component is a member of
*/
public Vector getActivities() {
Vector v = new Vector();
for(int i = 0; i < memberGroups.size(); i++) {
ColloquiaContainer group = (ColloquiaContainer)memberGroups.elementAt(i);
if(group instanceof Activity) v.addElement(group);
}
return v;
}
// Over-ridden so tree displays object name
public String toString() { return getName(); }
/**
* Write this Component in XML Format as a String of XML properties
*/
public void write2XML(XMLWriter writer) throws XMLWriteException {
// Properties
Hashtable props = getProperties();
Enumeration e = props.keys();
while(e.hasMoreElements()) {
String tag = (String)e.nextElement();
String value = (String)props.get(tag);
writer.write(new XMLTag(tag, value));
}
}
public void write2Element(Element parent) {
// Properties
Hashtable props = getProperties();
Enumeration e = props.keys();
while(e.hasMoreElements()) {
String tag = (String)e.nextElement();
String value = (String)props.get(tag);
// Do we really want to save these as attributes???
if(tag.equalsIgnoreCase(GUID) || tag.equalsIgnoreCase(NAME)) {
parent.setAttribute(tag, value);
continue;
}
Element element = new Element(tag);
element.setText(value);
parent.addContent(element);
}
}
/**
* XML implementation
*/
public void unMarshallXML(XMLReader reader) throws XMLReadException {
String line;
XMLTag xmlTag;
while((line = reader.readLine()) != null) {
xmlTag = XMLTag.getXMLTag(line);
if(xmlTag != null) putProperty(xmlTag.tag, xmlTag.value, false);
}
}
/**
* Generates a pseudo-random key ID for a ColloquiaComponent
*/
public static String generateGUID() {
int num1, num2;
String guid, hash;
Random rand;
// Get hashCode from user's e-mail address
UserPrefs prefs = UserPrefs.getUserPrefs();
String myEmailAddress = prefs.getProperty(UserPrefs.EMAIL_ADDRESS);
if(myEmailAddress.length() != 0) {
num1 = myEmailAddress.hashCode();
}
// If no hashCode, generate number
else {
rand = new Random();
num1 = rand.nextInt();
}
if(num1 < 0) num1 *= -1; // remove sign
hash = String.valueOf(num1 + "-");
// Loop while generated key already exists
do {
try { Thread.sleep(25); } catch(InterruptedException ex) {}
rand = new Random();
num2 = rand.nextInt();
if(num2 < 0) num2 *= -1;
guid = hash + String.valueOf(num2);
} while(DataModel.containsGUID(guid));
return guid;
}
/**
* Copy the text files associated with this to newCopy
* Over-ride please!
*/
public void copyTextFiles(ColloquiaComponent newCopy) {
}
}
| [
"[email protected]"
]
| |
fab1bcf728651ef765a767933341c6f8eb967868 | 63726a49e4b0719645d8ddf9898df726a274a654 | /gulimall-ware/src/main/java/com/xl/gulimall/ware/entity/WareOrderTaskEntity.java | 30e58f68a057372beff2d502dccc7bd0ffa9cd36 | [
"Apache-2.0"
]
| permissive | bug10086/gulimall | d2ab2616cf111b5eb5bb2c6e1460a61edd901fd3 | efaadd555ca89895e8b77838d32308b070253136 | refs/heads/main | 2023-04-18T02:16:53.449546 | 2021-05-04T14:59:37 | 2021-05-04T14:59:37 | 353,539,563 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,262 | java | package com.xl.gulimall.ware.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 库存工作单
*
* @author xilieao
* @email [email protected]
* @date 2021-04-01 20:24:05
*/
@Data
@TableName("wms_ware_order_task")
public class WareOrderTaskEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* order_id
*/
private Long orderId;
/**
* order_sn
*/
private String orderSn;
/**
* 收货人
*/
private String consignee;
/**
* 收货人电话
*/
private String consigneeTel;
/**
* 配送地址
*/
private String deliveryAddress;
/**
* 订单备注
*/
private String orderComment;
/**
* 付款方式【 1:在线付款 2:货到付款】
*/
private Integer paymentWay;
/**
* 任务状态
*/
private Integer taskStatus;
/**
* 订单描述
*/
private String orderBody;
/**
* 物流单号
*/
private String trackingNo;
/**
* create_time
*/
private Date createTime;
/**
* 仓库id
*/
private Long wareId;
/**
* 工作单备注
*/
private String taskComment;
}
| [
"[email protected]"
]
| |
c53d4ad51d4b71e2ca43b3e58d5605a7648b1e37 | 2f5e04627603dd4dcac2b2db43e0b3c4ad86d2c9 | /src/main/java/com/game/dto/ScrapedData.java | 79467cd24e1a65b4a1d7831e5ff3b5fae146a324 | []
| no_license | pratikranjane94/ApkDownloaderSeleniumWithFileProgres | 60e948a499a1c243d68a6e8d08a46f2a7ae7470d | d065a5b85d1a73707f1ec0c1faf59a50969d2909 | refs/heads/master | 2021-01-12T12:50:25.248739 | 2017-01-10T10:38:24 | 2017-01-10T10:38:24 | 69,022,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,110 | java | package com.game.dto;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table
public class ScrapedData {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int key;
@Column
private int id;
@Column
private int no;
@Column
private String fileName;
@Column
private String dlTitle;
@Column
private String dlGenre;
@Column
private String dlSize;
@Column
private String dlVersion;
@Column
private String dlPublishDate;
@Column
private String downloadLink;
@Embedded
private PlayStoreData playStoreData;
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getNo() {
return no;
}
public void setNo(int no) {
this.no = no;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getDlTitle() {
return dlTitle;
}
public void setDlTitle(String dlTitle) {
this.dlTitle = dlTitle;
}
public String getDlGenre() {
return dlGenre;
}
public void setDlGenre(String dlGenre) {
this.dlGenre = dlGenre;
}
public String getDlSize() {
return dlSize;
}
public void setDlSize(String dlSize) {
this.dlSize = dlSize;
}
public String getDlVersion() {
return dlVersion;
}
public void setDlVersion(String dlVersion) {
this.dlVersion = dlVersion;
}
public String getDlPublishDate() {
return dlPublishDate;
}
public void setDlPublishDate(String dlPublishDate) {
this.dlPublishDate = dlPublishDate;
}
public String getDownloadLink() {
return downloadLink;
}
public void setDownloadLink(String downloadLink) {
this.downloadLink = downloadLink;
}
public PlayStoreData getPlayStoreData() {
return playStoreData;
}
public void setPlayStoreData(PlayStoreData playStoreData) {
this.playStoreData = playStoreData;
}
}
| [
"[email protected]"
]
| |
8647addb91261793ef5cb99102a4459b1aadb3c2 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_6377668744314880_0/java/kongbomb/C.java | 43af5033fac79c0575ecf74048d2ea80564e3b9e | []
| no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | Java | false | false | 2,244 | java | package running;
import org.psjava.algo.geometry.convexhull.ConvexHullAlgorithm;
import org.psjava.ds.array.Array;
import org.psjava.ds.array.DynamicArray;
import org.psjava.ds.geometry.Point2D;
import org.psjava.ds.geometry.Polygon2D;
import org.psjava.ds.numbersystrem.LongNumberSystem;
import org.psjava.ds.set.Set;
import org.psjava.ds.set.SetFromIterable;
import org.psjava.formula.geometry.StraightOrder;
import org.psjava.goods.GoodConvexHullAlgorithm;
import org.psjava.util.SubSetIterable;
import org.psjava.util.ZeroTo;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Scanner;
public class C implements Runnable {
public static final ConvexHullAlgorithm CONVEX_HULL_ALGORITHM = GoodConvexHullAlgorithm.getInstance();
public static final LongNumberSystem NS = LongNumberSystem.getInstance();
@Override
public void run() {
Scanner in = new Scanner(System.in);
int casen = in.nextInt();
for(int casei : ZeroTo.get(casen)) {
System.out.println("Case #" + (casei + 1) + ": ");
int n = in.nextInt();
DynamicArray<Point2D<Long>> points = DynamicArray.create();
for(int i : ZeroTo.get(n))
points.addToLast(Point2D.create(in.nextLong(), in.nextLong()));
for(Point2D<Long> p : points) {
int min = n-1;
for (Iterable<Point2D<Long>> sub : SubSetIterable.create(points)) {
Set<Point2D<Long>> subset = SetFromIterable.create(sub);
int candidate = n - subset.size();
if(subset.size() > 0 && candidate < min) {
Polygon2D<Long> convexHull = CONVEX_HULL_ALGORITHM.calc(subset, NS);
if(isOnHull(p, convexHull))
min = candidate;
}
}
System.out.println(min);
}
}
}
private boolean isOnHull(Point2D<Long> p, Polygon2D<Long> convexHull) {
Array<Point2D<Long>> points = convexHull.getCCWOrderPoints();
for(int k : ZeroTo.get(points.size()))
if (StraightOrder.is(points.get(k), p, points.get((k + 1) % points.size()), NS))
return true;
return false;
}
public static void main(String[] args) throws Exception {
System.setIn(new BufferedInputStream(new FileInputStream("solutions/running-io/C-small-attempt2.in")));
new C().run();
}
}
| [
"[email protected]"
]
| |
f39d4c185e1c50c2acb2638307ed1ebb8b48e719 | bd2cbb655bded01b9f9ed83725d05133d56a329c | /agric_service/src/main/java/com/ywc/agric/service/impl/CheckItemServiceImpl.java | 8c8a3ab1e8528a3e9c0302c97895a874425996d3 | []
| no_license | yangweichao666/Agricultural_cooperative_mis_1.1 | 2c4f86fa869bc5f3441fb94335aebe4fc9326177 | 09fb86f49c5d8a2de70c7d036bd75757166413a4 | refs/heads/master | 2023-05-05T02:02:50.946891 | 2021-04-13T03:37:03 | 2021-04-13T03:37:03 | 356,122,893 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,673 | java | package com.ywc.agric.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.StringUtil;
import com.ywc.agric.constant.MessageConstant;
import com.ywc.agric.dao.CheckItemDao;
import com.ywc.agric.entity.PageResult;
import com.ywc.agric.entity.QueryPageBean;
import com.ywc.agric.exception.HealthException;
import com.ywc.agric.pojo.CheckItem;
import com.ywc.agric.service.CheckItemService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @Author YWC
* @Date 2021/3/18 11:29
* interfaceClass 发布到zookeeper上的接口
*/
//此注解用于发布服务
@Service(interfaceClass = CheckItemService.class)
public class CheckItemServiceImpl implements CheckItemService {
//自动装配
@Autowired
private CheckItemDao checkItemDao;
@Override
public List<CheckItem> findAll() {
return checkItemDao.findAll();
}
@Override
public void add(CheckItem checkItem) {
checkItemDao.add(checkItem);
}
@Override
public PageResult findPage(QueryPageBean queryPageBean) {
//第二种方法mybatis拦截器
PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
//模糊查询拼接%
//判断是否存在查询条件
if (!StringUtil.isEmpty(queryPageBean.getQueryString())){
queryPageBean.setQueryString("%"+queryPageBean.getQueryString()+"%");
}
//进行查询
Page<CheckItem> page= checkItemDao.findByCondition(queryPageBean.getQueryString());
//将page的内容封装到PageResult
PageResult<CheckItem> checkItemPageResult = new PageResult<>(page.getTotal(), page.getResult());
return checkItemPageResult;
}
@Override
public void deleteById(int id) throws HealthException {
//检查次检查项是否被检查组使用
//检查id是否在t_checkgroup_checkitem表中
int cout=checkItemDao.findCountByCheckItem(id);
if (cout>0){
//上抛异常
throw new HealthException(MessageConstant.DELETE_CHECKITEM_FAIL);
}
checkItemDao.deleteById(id);
}
/**
* 查询检查项
* @param id
* @return
* @throws HealthException
*/
@Override
public CheckItem findById(int id) throws HealthException {
return checkItemDao.findById(id);
}
/**
* 编辑
* @param checkItem
*/
@Override
public void update(CheckItem checkItem) {
checkItemDao.update(checkItem);
}
}
| [
"1098551672@qqcom"
]
| 1098551672@qqcom |
6411749a6634f52900fa48cf7c38c63935e6bc40 | 9a78879d081aee74f4e69e95adf226819af2dc9b | /easysend/src/main/java/it/av/es/model/BasicEntity.java | 923d8e7fea24512e050b643eaa6039e62bb6ca67 | [
"Apache-2.0"
]
| permissive | alessandro-vincelli/easy-send | 40679323e6107f24a7f9aa699409b10b872268bf | ebf254c86fc33569358513823821e71574048625 | refs/heads/master | 2020-05-17T04:23:07.896921 | 2013-08-05T16:31:33 | 2013-08-05T16:31:33 | 32,913,958 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,470 | java | package it.av.es.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.GenericGenerator;
@MappedSuperclass
public class BasicEntity implements Serializable {
@Id
@GenericGenerator(name = "generator", strategy = "uuid", parameters = {})
@GeneratedValue(generator = "generator")
@Column(updatable = false, length = 36)
// @DocumentId
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public BasicEntity() {
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BasicEntity other = (BasicEntity) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
// @Override
// public String toString() {
// return ToStringBuilder.reflectionToString(this);
// }
}
| [
"[email protected]@6de8a768-92d9-1753-a867-ca14e03499b6"
]
| [email protected]@6de8a768-92d9-1753-a867-ca14e03499b6 |
71a8b3edf359035a05287f4f4070ea88195ba3ca | 8b89b70dbad7f1f1871c9ae6ae8681acde645fe6 | /android/app/src/main/java/com/babylonjsdemo/MainApplication.java | 0b001f3f2eda03ef13a93a6f30d5975f34b46512 | []
| no_license | Bulisor/BabylonjsDemo | 13bc1375848dcfc63fb2a9326fc219f5b8fac3d0 | 9d06ed54cbcc5f87316b95336cf213232d691e08 | refs/heads/master | 2022-06-30T04:53:17.484482 | 2022-06-11T17:16:01 | 2022-06-11T17:16:01 | 206,096,712 | 7 | 4 | null | 2022-06-11T17:16:02 | 2019-09-03T14:24:30 | JavaScript | UTF-8 | Java | false | false | 1,983 | java | package com.babylonjsdemo;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.swmansion.reanimated.ReanimatedPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.babylonjsdemo.generated.BasePackageList;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import org.unimodules.adapters.react.ReactAdapterPackage;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.Package;
import org.unimodules.core.interfaces.SingletonModule;
import expo.modules.constants.ConstantsPackage;
import expo.modules.permissions.PermissionsPackage;
import expo.modules.filesystem.FileSystemPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(
new BasePackageList().getPackageList(),
Arrays.<SingletonModule>asList()
);
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReanimatedPackage(),
new RNGestureHandlerPackage(),
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
| [
"[email protected]"
]
| |
0aa59ca1821ff67ee31a2aa93022931aa68f4dcf | eace11a5735cfec1f9560e41a9ee30a1a133c5a9 | /CMT/cptiscas/程序变异体的backup/改名前/FineGrainedHeap/RCXC_remove7/FineGrainedHeap.java | e257b84bb6edf1bf4409cd1337a5eff4e8e58d5a | []
| no_license | phantomDai/mypapers | eb2fc0fac5945c5efd303e0206aa93d6ac0624d0 | e1aa1236bbad5d6d3b634a846cb8076a1951485a | refs/heads/master | 2021-07-06T18:27:48.620826 | 2020-08-19T12:17:03 | 2020-08-19T12:17:03 | 162,563,422 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,547 | java | /*
* FineGrainedHeap.java
*
* Created on March 10, 2007, 10:45 AM
*
* From "Multiprocessor Synchronization and Concurrent Data Structures",
* by Maurice Herlihy and Nir Shavit.
* Copyright 2007 Elsevier Inc. All rights reserved.
*/
package mutants.FineGrainedHeap.RCXC_remove7;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Heap with fine-grained locking and arbitrary priorities.
* @param T type manged by heap
* @author mph
*/
public class FineGrainedHeap<T> implements PQueue<T> {
private static int ROOT = 1;
private static int NO_ONE = -1;
private Lock heapLock;
int next;
HeapNode<T>[] heap;
/**
* Constructor
* @param capacity maximum number of items heap can hold
*/
@SuppressWarnings(value = "unchecked")
public FineGrainedHeap(int capacity) {
heapLock = new ReentrantLock();
next = ROOT;
heap = (HeapNode<T>[]) new HeapNode[capacity + 1];
for (int i = 0; i < capacity + 1; i++) {
heap[i] = new HeapNode<T>();
}
}
/**
* Add item to heap.
* @param item Uninterpreted item.
* @param priority item priority
*/
public void add(T item, int priority) {
heapLock.lock();
int child = next++;
heap[child].lock();
heapLock.unlock();
heap[child].init(item, priority);
heap[child].unlock();
while (child > ROOT) {
int parent = child / 2;
heap[parent].lock();
heap[child].lock();
int oldChild = child;
try {
if (heap[parent].tag == Status.AVAILABLE && heap[child].amOwner()) {
if (heap[child].score < heap[parent].score) {
swap(child, parent);
child = parent;
} else {
heap[child].tag = Status.AVAILABLE;
heap[child].owner = NO_ONE;
return;
}
} else if (!heap[child].amOwner()) {
child = parent;
}
} finally {
heap[oldChild].unlock();
heap[parent].unlock();
}
}
if (child == ROOT) {
heap[ROOT].lock();
if (heap[ROOT].amOwner()) {
heap[ROOT].tag = Status.AVAILABLE;
heap[child].owner = NO_ONE;
}
heap[ROOT].unlock();
}
}
/**
* Returns and removes lowest-priority item in heap.
* @return lowest-priority item.
*/
public T removeMin() {
heapLock.lock();
int bottom = --next;
heap[bottom].lock();
heap[ROOT].lock();
heapLock.unlock();
if (heap[ROOT].tag == Status.EMPTY) {
heap[ROOT].unlock();
heap[bottom].lock();
return null;
}
T item = heap[ROOT].item;
heap[ROOT].tag = Status.EMPTY;
swap(bottom, ROOT);
heap[bottom].owner = NO_ONE;
heap[bottom].unlock();
if (heap[ROOT].tag == Status.EMPTY) {
heap[ROOT].unlock();
return item;
}
int child = 0;
int parent = ROOT;
while (parent < heap.length / 2) {
int left = parent * 2;
int right = (parent * 2) + 1;
heap[left].lock();
heap[right].lock();
if (heap[left].tag == Status.EMPTY) {
heap[right].unlock();
heap[left].unlock();
break;
} else if (heap[right].tag == Status.EMPTY || heap[left].score < heap[right].score) {
heap[right].unlock();
child = left;
} else {
heap[left].unlock();
child = right;
}
if (heap[child].score < heap[parent].score) {
swap(parent, child);
heap[parent].unlock();
parent = child;
} else {
//heap[child].unlock();
break;
}
}
heap[parent].unlock();
return item;
}
private void swap(int i, int j) {
int _owner = heap[i].owner;
heap[i].owner = heap[j].owner;
heap[j].owner = _owner;
T _item = heap[i].item;
heap[i].item = heap[j].item;
heap[j].item = _item;
int _priority = heap[i].score;
heap[i].score = heap[j].score;
heap[j].score = _priority;
Status _tag = heap[i].tag;
heap[i].tag = heap[j].tag;
heap[j].tag = _tag;
}
public void sanityCheck() {
int stop = next;
for (int i = ROOT; i < stop; i++) {
int left = i * 2;
int right = (i * 2) + 1;
if (left < stop && heap[left].score < heap[i].score) {
System.out.println("Heap property violated:");
System.out.printf("\theap[%d] = %d, left child heap[%d] = %d\n", i, heap[i].score, left, heap[left].score);
}
if (right < stop && heap[right].score < heap[i].score) {
System.out.println("Heap property violated:");
System.out.printf("\theap[%d] = %d, right child heap[%d] = %d\n", i, heap[i].score, right, heap[right].score);
}
}
}
private static enum Status {
EMPTY, AVAILABLE, BUSY
}
private static class HeapNode<S> {
Status tag;
int score;
S item;
int owner;
Lock lock;
/**
* initialize node
* @param myItem
* @param myPriority
*/
public void init(S myItem, int myPriority) {
item = myItem;
score = myPriority;
tag = Status.BUSY;
owner = ThreadID.get();
}
public HeapNode() {
tag = Status.EMPTY;
lock = new ReentrantLock();
}
public void lock() {
lock.lock();
}
public void unlock() {
lock.unlock();
}
public boolean amOwner() {
switch (tag) {
case EMPTY:
return false;
case AVAILABLE:
return false;
case BUSY:
return owner == ThreadID.get();
}
return false; // not reached
}
}
} | [
"[email protected]"
]
| |
6073cd38669d456b30022e0b08e0ff0e02009e5e | de9625ac294f4078ed752bf83273fefdba64131d | /src/main/java/ua/logos/domain/filter/SimpleFilter.java | f220ea8589a7075823a68f826966e5b98b2e16de | []
| no_license | ShvedovIllia/SpringBootRest | fb39854203944afa606cd039b075be05ffd38a3d | f5ab168b219b91c610533e324fdfc7e6f9dba6cc | refs/heads/master | 2020-03-24T17:28:38.474906 | 2018-08-15T16:22:27 | 2018-08-15T16:22:27 | 142,857,766 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 170 | java | package ua.logos.domain.filter;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class SimpleFilter {
private String search;
}
| [
"[email protected]"
]
| |
ca1f8468e1ac45b1ca58deddddaf6005f6319f55 | b8194fee4ddf498b2c1bd302ec4ba9466746250d | /build/Android/Debug/app/src/main/java/com/fuse/R.java | 514eac67b7da0c9e7b9d57276bfc788d6f45dfff | []
| no_license | color0e/Fabric_Fuse_Project | e49e7371c9579d80c9ec96c1f2d3a90de7b52149 | 9b20a0347e5249315cf7af587e04234ec611c6be | refs/heads/master | 2020-03-30T16:49:34.363764 | 2018-10-03T16:26:28 | 2018-10-03T16:26:28 | 151,428,896 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 534 | java | package com.fuse;
import java.lang.reflect.Field;
public final class R
{
public static int get(String path)
{
try {
int lastDot = path.lastIndexOf(".", path.length()-1);
Class<?> cls = Class.forName(com.apps.fabric.R.class.getName()+"$"+(((String)path.subSequence(0, lastDot)).replace('.','$')));
Field f = cls.getField((String)path.subSequence(lastDot+1, path.length()));
return f.getInt(null);
} catch (Exception e) {
return -1;
}
}
}
| [
"[email protected]"
]
| |
2aeea5522f379822c1cc2a004c59b56515f6d35a | baa079fced01056cffa8b48689974e11f240bf6c | /EmployeeDemo/src/main/java/com/societe/employeeDemo/service/EmployeeService.java | 10692e9ca70b2a5097081c809b2d4a09c989523a | []
| no_license | mdsbz/EmployeeDemo | 09ea55fd647a768e63e5a35d2dc2b74de63462e6 | 07035c3ac19ad4b1a55acedaf393c19e2f20a1b9 | refs/heads/master | 2020-09-19T20:14:06.568508 | 2019-11-26T22:31:18 | 2019-11-26T22:31:18 | 223,663,832 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 664 | java | /**
*
*/
package com.societe.employeeDemo.service;
import java.util.List;
import com.societe.employeeDemo.exception.ServiceException;
import com.societe.employeeDemo.request.EmployeeRequest;
import com.societe.employeeDemo.response.EmployeeResponse;
/**
* @author Md Sbz
*
*/
public interface EmployeeService {
/**
*
* @return
* @throws ServiceException
*/
public List<EmployeeResponse> getEmployee() throws ServiceException;
/**
*
* @param employeeRequest
* @return
* @throws ServiceException
*/
public EmployeeResponse addEmployee(EmployeeRequest employeeRequest) throws ServiceException;
}
| [
"Md [email protected]"
]
| |
5505c07c3dd8a236c787efa97be416e5f032c7e8 | d19bb66aa81341fca790445d81d44c77a09843b2 | /com.suppresswarnings.android/app/build/generated/source/apt/debug/com/suppresswarnings/android/MainActivity_ViewBinding.java | 0eaf0bdfb0d5f1d06638c1a67f198b4d5f119654 | []
| no_license | outermanjiaming/suppresswarnings | 46e63673b7e742cd5360934be087a7c091c89977 | 252dae3dacab054c932f28793c06bf75641f26ca | refs/heads/master | 2022-05-30T01:09:53.492484 | 2020-09-11T10:31:41 | 2020-09-11T10:31:41 | 114,127,904 | 7 | 6 | null | 2022-05-20T20:51:05 | 2017-12-13T14:02:31 | Java | UTF-8 | Java | false | false | 2,125 | java | // Generated code from Butter Knife. Do not modify!
package com.suppresswarnings.android;
import android.support.annotation.CallSuper;
import android.support.annotation.UiThread;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import butterknife.Unbinder;
import butterknife.internal.DebouncingOnClickListener;
import butterknife.internal.Utils;
import com.suppresswarnings.android.view.MyWebview;
import java.lang.IllegalStateException;
import java.lang.Override;
public class MainActivity_ViewBinding<T extends MainActivity> implements Unbinder {
protected T target;
private View view2131296258;
@UiThread
public MainActivity_ViewBinding(final T target, View source) {
this.target = target;
View view;
target.webview = Utils.findRequiredViewAsType(source, R.id.webview, "field 'webview'", MyWebview.class);
view = Utils.findRequiredView(source, R.id.btn_control, "field 'control' and method 'onButterKnifeBtnClick'");
target.control = Utils.castView(view, R.id.btn_control, "field 'control'", Button.class);
view2131296258 = view;
view.setOnClickListener(new DebouncingOnClickListener() {
@Override
public void doClick(View p0) {
target.onButterKnifeBtnClick(p0);
}
});
target.warning = Utils.findRequiredViewAsType(source, R.id.tv_warning, "field 'warning'", TextView.class);
target.background = Utils.findRequiredViewAsType(source, R.id.background, "field 'background'", LinearLayout.class);
target.progressBar = Utils.findRequiredViewAsType(source, R.id.progressbar, "field 'progressBar'", ProgressBar.class);
}
@Override
@CallSuper
public void unbind() {
T target = this.target;
if (target == null) throw new IllegalStateException("Bindings already cleared.");
target.webview = null;
target.control = null;
target.warning = null;
target.background = null;
target.progressBar = null;
view2131296258.setOnClickListener(null);
view2131296258 = null;
this.target = null;
}
}
| [
"[email protected]"
]
| |
c6077889d55cec2a015f0b6a212fb5d2d573f8e2 | 55f5a80e35f64612a33f709b1e8c2b9feaf37ff6 | /Animals.java | f3a4c5feb760f730590419e30a91340713532e1f | []
| no_license | AweMike/123 | 035ad9fbc5caab7e3f82904222ed5e27f31d3ade | 29b303ace9e241aa1ed7b7a2143e2e265b27ca67 | refs/heads/main | 2023-06-20T01:14:42.328480 | 2021-07-18T04:47:04 | 2021-07-18T04:47:04 | 387,091,943 | 0 | 0 | null | null | null | null | WINDOWS-1251 | Java | false | false | 2,888 | java | package Animal;
public class Animals {
private String klass; //Класс животного
private String otr; // Отряд животного
private int age; //Возраст животного
private double ves; //Вес животного
private int kon; //Кол-во конечностей
private static boolean pit; //Питание (мясо или трава)
public void findfood() {
System.out.print("Ищет сено...");
}
public void eat() {
System.out.print("Медленно жует сено");
}
//Конструктор без параметров
public Animals() {
age= 15;
ves = 400.2;
klass = "Млекопитающее";
otr = "Парнокопытные";
kon = 4;
pit = pit;
}
//Конструктор1 класс
public Animals(String klass) {
this.klass = klass;
}
//Конструктор2 класс, отряд, питание
public Animals(String klass, String otr, boolean pit) {
this.klass = klass;
this.otr = otr;
this.pit = pit;
}
//Конструктор3 класс, отряд, вес, питание
public Animals(String klass, double ves, String otr, boolean pit) {
this.klass = klass;
this.ves = ves;
this.otr = otr;
this.pit = pit;
}
//Конструктор4 класс, отряд, возраст, питание
public Animals( String klass, int age, String otr, boolean pit) {
this.klass = klass;
this.age = age;
this.otr = otr;
this.pit = pit;
}
//Конструктор5 класс, отряд, вес, возраст, питание, кол-во конечностей
public Animals(String klass, String otr, int age, double ves,int kon) {
this.klass = klass;
this.otr = otr;
this.ves = ves;
this.age = age;
this.pit = true;
this.kon = kon;
}
//Вывод инфорамции о животном
public void show() {
String pitanie;
if (pit == true)
{ pitanie = "Трава";
}
else {
pitanie = "Мясо";
}
System.out.println
(" Класс: "+klass+
" Отряд: "+otr+
" Возраст : "+age+ " лет "+
" Вес "+ves+" кг"+
" Питание :" +pitanie+
" Кол-во конечностей: "+kon);
}
public static void main(String[] args)
{
Animals Anim1 = new Animals("Млекопитающий","Парнокопытный",10,400.1,4);
Anim1.show();
Animals cow = new Animals();
cow.findfood();
cow.eat();
}
}
| [
"[email protected]"
]
| |
087d7db6190207e3c00af166d0b826fcb0d6da28 | 214cdb4fdd67f9e0d2a4263090d2fc57e0706749 | /src/pr04/controlador/FactoriaAcciones.java | 68e35d3be617b72571f79ea15cbcb6dfc001cdbe | []
| no_license | ManuelRoman/ApFotPerdidoAjax | 63a8c08b2b00099378379d2201508ca33e108a45 | df6d38ed94ee3bac751748228b799ec3fb0df071 | refs/heads/master | 2021-01-23T01:17:11.082908 | 2017-06-19T22:13:18 | 2017-06-19T22:13:18 | 92,861,846 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,619 | java | package pr04.controlador;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
import pr04.modelo.acciones.AccionIndex;
import pr04.modelo.beans.BeanError;
import pr04.utilidades.LeePropiedades;
/**
* Instancia objetos de tipo Acción.
* Es una clase abstracta que impide que se puedan instanciar objetos de ella,
* pero permite que se obtengan clases derivadas.
* Se encarga de obtener los objetos Acción específicos para una determinada acción.
*/
public abstract class FactoriaAcciones {
/**
* Información de la lista de acciones disponibles
*/
private static HashMap<String, Accion> listaAcciones = null;
/**
* Devuelve objetos de tipo Accion en función del parámetro de acción proporcionado.
* @param accion Cadena que representa la acción que se desea llevar a cabo
* @return Objeto de tipo Accion, que encapsula el proceso a llevar a cabo.
*/
@SuppressWarnings("unchecked")
public static Accion creaAccion(String accion, String archivoAcciones) {
System.out.println("Acceso a creaAccion, acción: " + accion);
// Solo se accede la primera vez que se ejecuta la aplicación al archivo de propiedades
if (listaAcciones == null) {
System.out.println("Accede al archivo propiedades");
Properties propiedades = null;
try {
propiedades = LeePropiedades.getPropiedades(archivoAcciones);
} catch (FileNotFoundException e2) {
System.out.println("Archivo de acciones no encontrado: " + archivoAcciones);
e2.printStackTrace();
} catch (IOException e2) {
System.out.println("Error al leer del archivo de acciones: " + archivoAcciones);
e2.printStackTrace();
}
listaAcciones = new HashMap<String, Accion>();
Enumeration e = propiedades.keys();
while (e.hasMoreElements()) {
String clave = (String) e.nextElement();
String valorAccion = (String) propiedades.get(clave);
Class clase = null;
try {
clase = Class.forName(valorAccion);
Accion valor = (Accion) clase.newInstance();
listaAcciones.put(clave, valor);
} catch (ClassNotFoundException e1) {
System.out.println("Clase acción no encontrada: " + clave);
e1.printStackTrace();
} catch (InstantiationException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e1) {
e1.printStackTrace();
}
}
}
// Acción por defecto. Conduce a index.html.
Accion accionSeleccionada = new AccionIndex();
if (accion!= null){
accionSeleccionada = listaAcciones.get(accion);
}
return accionSeleccionada;
}
}
| [
"[email protected]"
]
| |
9b9baad86ca0393b8c54f2bd301e0f95fe407a66 | 20e4994a2ae22cba09d1d40bf535316f3a631994 | /cervicalcancer/src/main/java/zm/gov/moh/cervicalcancer/submodule/dashboard/patient/model/IRecyclerViewClickListener.java | df048f9bcef8c5a61fb5ea3c02c826cd2723e8c6 | []
| no_license | BlueCodeSystems/smartcerv | c7690918c55f9836f31e980c76f343b1f7a155c0 | 747b4f570eb82ecc69051c61dc07a0dfcb6ebbfa | refs/heads/master | 2021-06-21T10:27:54.936694 | 2020-02-13T10:20:34 | 2020-02-13T10:20:34 | 154,180,362 | 7 | 2 | null | 2020-12-18T12:33:09 | 2018-10-22T16:48:00 | Java | UTF-8 | Java | false | false | 189 | java | package zm.gov.moh.cervicalcancer.submodule.dashboard.patient.model;
import android.view.View;
public interface IRecyclerViewClickListener {
void onClick(View view, int position);
}
| [
"[email protected]"
]
| |
42cf09c4b2566a13a4a45ae6f7e11b546b5fa493 | 29be4bd35036de6d7c4dd4a94dbfe9b10197bd71 | /src/test/java/TestInterface1.java | 3f3b003eb97b36e18ae1941c2bc5d2d7eb85fa24 | []
| no_license | liuqingzhi/databaseQuery | 827d1820cad65faa6ffca77f28335dd1e499c6e8 | 136b8e57e948531cb0f4438a5d4b3a79db9fcc54 | refs/heads/master | 2020-06-04T14:11:09.543310 | 2014-09-20T05:19:34 | 2014-09-20T05:19:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 353 | java | /**
* 定义的测试接口,用来测试使用groovy来实现这个接口。
* @author 刘庆志
*
*/
public interface TestInterface1
{
/**
* 要实现的接口方法。
* @param src
* @param srcInteger
* @return
* @author 刘庆志
*/
public String printStr(String src,Integer srcInteger);
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.