blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
sequencelengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
35e6fabb3892f91b599737328bfb531874fbdc81 | 0c86373f4e1d2d6be389ecde55a9aa5e299ca26e | /src/main/java/fr/docapost/powwow/api/entities/IEnable.java | 44de5fa927c7b07cbded809063964bc4fbfd7d5b | [] | no_license | BacemKannou/powwow-team-back | 616817fc0b905903c3b1ca3b2e72c1edaca7e044 | e9af0c736eee6c2f07db085e53ccb619cc268f55 | refs/heads/main | 2023-06-24T19:22:48.985342 | 2021-07-26T12:06:07 | 2021-07-26T12:06:07 | 342,574,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133 | java | package fr.docapost.powwow.api.entities;
public interface IEnable {
boolean isDisabled();
void setDisabled(boolean var1);
} | [
"[email protected]"
] | |
34e200b73c317a31645c3c694a3248c0a3860d3f | ecd444441c2280b8449220e9d04cbd1d8f51cb20 | /shop/shop-common/src/main/java/com/lrving/App.java | a27959314d798da6ee8fb66944a92d6782620cec | [] | no_license | lrvinghang/shop | 4498ea4ebd37486fbdc1a70703f57f91d287ddf0 | 5e944c5794f97adeba0c8fdb1ccb95b1a7b09e03 | refs/heads/master | 2023-01-30T03:23:06.687853 | 2020-12-01T13:41:34 | 2020-12-01T13:41:34 | 317,495,348 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 173 | java | package com.lrving;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| [
"Qq1157026884"
] | Qq1157026884 |
94b598353e1c19ba6398ace57f3aef03d8ffc91d | cd44caad4aeec098a53c19f35bb46490ee45dac9 | /src/main/java/org/github/erolon/model/Matrix.java | 091e9e2a4b14a68c83e653b96cd7b5c88492f960 | [] | no_license | ESegundoRolon/ms-mutants-ml | 994511ea2a350eb70e6801498eb7ecb477117ccf | 06df6f650204c817358c579c1f2ccd32f7505f9e | refs/heads/master | 2021-05-09T11:33:47.317236 | 2018-10-29T20:34:01 | 2018-10-29T20:34:01 | 118,991,890 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,538 | java | package org.github.erolon.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Matrix {
private static final Logger LOGGER = LoggerFactory.getLogger(Matrix.class);
private char data[][];
public Matrix (int rows, int columns){data = new char[rows][columns];}
public Matrix (char data[][]){
this.data = new char[data.length][data[0].length];
IntStream.range(0, this.data.length).forEach(row ->
IntStream.range(0, data[0].length).forEach(column -> this.data[row][column] = data [row][column]));
}
public char[][] getData() { return data; }
/**
* Metodo para rotar una matrix en 90 grados sentido horario
* @return Matrix rotada
*/
public Matrix rotate() {
char[][] returnedData = new char[data.length][data.length];
LOGGER.debug("Antes de rotar: {}",Arrays.deepToString(data));
IntStream.range(0, data.length).forEach(row ->
IntStream.range(0, data.length).forEach( column -> returnedData[row][column] = data[data.length -1 - column][row]));
LOGGER.debug("Luego de rotar: {}",Arrays.deepToString(returnedData));
return new Matrix(returnedData);
}
/**
* Devuelve los caracteres de la diagonal principal en un string
* @return String
*/
public String getMainDiagonal( )
{
StringBuilder diagonal = new StringBuilder();
IntStream.range(0, this.data.length).forEach(row -> diagonal.append(String.valueOf(data[row][row]) ));
String result = diagonal.toString();
LOGGER.debug("Diagonal principal: {}", result );
return result;
}
/**
* Devuelve todas las diagonales excluyendo la principal
* @return String
*/
public String[] getDiagonals(){
List<String> diagonals = new ArrayList<String>();
for( int k = 0 ; k < data.length * 2 ; k++ ) {
StringBuilder diagonal = new StringBuilder();
for( int j = 0 ; j <= k ; j++ ) {
int i = k - j;
if( i < data.length && j < data.length ) {
diagonal.append( String.valueOf(data[i][j]) );
}
}
if(!diagonal.toString().isEmpty()){
LOGGER.debug("Agrego : {}",diagonal.toString());
diagonals.add(diagonal.toString());
}
}
//el primero y el anteultimo son los vertices superior izquierdo e inferior derecho
diagonals.remove(0);
diagonals.remove(diagonals.size()-1);
return diagonals.toArray(new String[0]);
}
}
| [
"[email protected]"
] | |
2e1e551d2dacb51bc87e300f26c0d96735babea9 | f219be2e958d0619fc0b0ccb5534a9d4989dfbba | /src/main/java/com/blame/googleearthnavigation/bean/SpotCoordinates.java | 8d1e93b4a84bde706cf2b8ca4e97dd3af6e0c216 | [] | no_license | pabloblazq/GoogleEarthNavigation | 6c170c571fb77c1d499e4bc0e8000951fed32e56 | 96239fba030734ea882c2c46ff8fb656e05c56de | refs/heads/master | 2022-05-29T23:21:39.959093 | 2019-10-09T06:34:26 | 2019-10-09T06:34:26 | 212,313,983 | 0 | 0 | null | 2022-05-20T21:10:53 | 2019-10-02T10:45:47 | Java | UTF-8 | Java | false | false | 546 | java | package com.blame.googleearthnavigation.bean;
public class SpotCoordinates extends Coordinates {
protected int groundAltitude;
public SpotCoordinates(double latitude, double longitude, int groundAltitude) {
super(latitude, longitude);
this.groundAltitude = groundAltitude;
}
public int getGroundAltitude() {
return groundAltitude;
}
@Override
public String toString() {
return "SpotCoordinates [groundAltitude=" + groundAltitude + ", latitude=" + latitude + ", longitude="
+ longitude + "]";
}
}
| [
"[email protected]"
] | |
183ced1e743087ab9d8f9caebfb363a34c09e9c6 | c7c714709a0b780d95d3d8a63fbfe66f50aae942 | /test/NullPointer_Demo.java | b5db6d800051b01d33a717df9afb757cfc1986ff | [] | no_license | mayurpawar0809/Edac_may2021 | 5f952fc1a90a4f1915e78c8ec4ec2dc0287dcf2c | 70846cbf5b49329ede3447dc3ec1ef8f31e720f7 | refs/heads/main | 2023-05-08T12:51:29.349777 | 2021-05-31T10:08:30 | 2021-05-31T10:08:30 | 365,246,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 356 | java |
/Java program to demonstrate NullPointerException
class NullPointer_Demo
{
public static void main(String args[])
{
try {
String a = null; //null value
System.out.println(a.charAt(0));
} catch(NullPointerException e) {
System.out.println("NullPointerException..");
}
}
} | [
"[email protected]"
] | |
dedf8954c4f7ba5f77c38cba1eee8ab917a655bd | f9d8b48eed19569d478bbce70eee2eeb544d8cf6 | /ripple-bouncycastle/src/main/java/org/ripple/bouncycastle/pqc/crypto/rainbow/RainbowKeyParameters.java | 33005bf62dda182396fa972f3d9f94db9317c859 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | moorecoin/MooreClient | 52e3e822f65d93fc4c7f817a936416bfdf060000 | 68949cf6d1a650dd8dd878f619a874888b201a70 | refs/heads/master | 2021-01-10T06:06:26.239954 | 2015-11-14T15:39:44 | 2015-11-14T15:39:44 | 46,180,336 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 529 | java | package org.ripple.bouncycastle.pqc.crypto.rainbow;
import org.ripple.bouncycastle.crypto.params.asymmetrickeyparameter;
public class rainbowkeyparameters
extends asymmetrickeyparameter
{
private int doclength;
public rainbowkeyparameters(
boolean isprivate,
int doclength)
{
super(isprivate);
this.doclength = doclength;
}
/**
* @return the doclength
*/
public int getdoclength()
{
return this.doclength;
}
}
| [
"[email protected]"
] | |
fd8489170521d679ce477e013591056f03160250 | 125464573b769e9ad7ab2cf18e7fb8554187937d | /src/d16127504_CA3/Config/Constants.java | c5233afb8efbef1251cebf0efbd424a21b6e3063 | [] | no_license | toporny/Ae_Department | 66fa26f94d70a2e94a68a08473d537d0e9dbfa9e | 80a0ea260cdf41f7841d0512bd5fc856c803db68 | refs/heads/master | 2022-12-02T17:29:45.272872 | 2020-08-07T13:23:24 | 2020-08-07T13:23:24 | 113,877,953 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package d16127504_CA3.Config;
public class Constants {
public final class Limits {
public static final int LIMIT_BIG = 1000;
public static final int LIMIT_SMALL = 20;
}
public final class DB {
public static final String AE_DEPARTAMENT_FILE = "ae_departament.sqlite";
}
}
| [
"[email protected]"
] | |
b97d25a274ce37a7b0fe8e85e0ecb8ff16556961 | 50e691c96a76226f9f14544be7c3797ee784ee1e | /project/src/helper/ConfirmDialogHelper.java | c15a6b156f9b06dfcde8de7ee6f03f34b9f4a7f1 | [] | no_license | nhidh99/uitOOAD | e573e3c20d25b70a9b0bf09b5ede754cff67746d | fe78a6e8304016801caffad5ad094aa2fe832dba | refs/heads/master | 2023-05-26T08:19:19.236440 | 2019-12-10T22:57:12 | 2019-12-10T22:57:12 | 212,252,982 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,103 | java | package helper;
import java.util.Optional;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Alert.AlertType;
public class ConfirmDialogHelper {
public static boolean confirm(String header) {
Alert dialog = new Alert(AlertType.CONFIRMATION);
dialog.setTitle("Xác nhận");
dialog.setHeaderText(header);
ButtonType yesButton = new ButtonType("Xác nhận");
ButtonType noButton = new ButtonType("Hủy bỏ");
dialog.getButtonTypes().setAll(yesButton, noButton);
Optional<ButtonType> result = dialog.showAndWait();
return result.get() == yesButton;
}
public static boolean confirm(String header, String content) {
Alert dialog = new Alert(AlertType.CONFIRMATION);
dialog.setTitle("Xác nhận");
dialog.setHeaderText(header);
dialog.setContentText(content);
ButtonType yesButton = new ButtonType("Xác nhận");
ButtonType noButton = new ButtonType("Hủy bỏ");
dialog.getButtonTypes().setAll(yesButton, noButton);
Optional<ButtonType> result = dialog.showAndWait();
return result.get() == yesButton;
}
} | [
"[email protected]"
] | |
6826e9915a718f2ba63ed04a10e7b93257bb196e | d2c4eaeac525966f09518727819bfac9dd219dc3 | /033_1_sharedpreferences/src/main/java/com/merdeev/sharedpreferences/MainActivity.java | 041e77c9a82145f72e4aeaa0fea9876846a19b04 | [] | no_license | RuslanMerdeev/StartAndroid | 92066646a605e94e22e06af55e1e0779587eeecf | 2bbf9cff3c6398b955711e6f22c647773e1f4d9f | refs/heads/master | 2021-01-20T21:08:48.628939 | 2017-09-18T11:30:20 | 2017-09-18T11:30:20 | 101,752,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,819 | java | package com.merdeev.sharedpreferences;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements OnClickListener {
EditText etText;
Button btnSave, btnLoad;
// SharedPreferences sPref;
final String SAVED_TEXT = "saved_text";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etText = (EditText) findViewById(R.id.etText);
btnSave = (Button) findViewById(R.id.btnSave);
btnLoad = (Button) findViewById(R.id.btnLoad);
btnSave.setOnClickListener(this);
btnLoad.setOnClickListener(this);
loadText();
}
@Override
public void onClick(View view) {
switch(view.getId()) {
case(R.id.btnSave):
saveText();
break;
case(R.id.btnLoad):
loadText();
break;
}
}
void saveText() {
SharedPreferences sPref = getPreferences(MODE_PRIVATE);
Editor ed = sPref.edit();
ed.putString(SAVED_TEXT,etText.getText().toString());
ed.commit();
Toast.makeText(this,"Text saved",Toast.LENGTH_SHORT).show();
}
void loadText() {
SharedPreferences sPref = getPreferences(MODE_PRIVATE);
String savedText = sPref.getString(SAVED_TEXT,"");
etText.setText(savedText);
Toast.makeText(this,"Text loaded",Toast.LENGTH_SHORT).show();
}
} | [
"[email protected]"
] | |
6977a3699b3e96c13b13ca9c7082c3c88a9e94f0 | 8ebc8f0d21d900c066350055a34c3e482c447b46 | /src/test/java/core/Promise.java | 894d3729207b75cad0456a7c8f0d97caf5dbaf9b | [] | no_license | EugenVideos/TestVideo | 7ee2020eafc63e5cebb6aa2d0c16c9d8db55ac4e | bb2a54d08f11c5f7439a5a005fe7b15e77d5cecb | refs/heads/master | 2020-03-12T12:19:18.060049 | 2018-04-22T23:11:53 | 2018-04-22T23:11:53 | 130,615,637 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 258 | java | package core;
import org.openqa.selenium.WebDriver;
public class Promise {
private final WebDriver driver;
Promise(WebDriver driver) {
this.driver = driver;
}
public Promise Error() {
return new Promise(driver);
}
}
| [
"[email protected]"
] | |
fba0913ea4825b6f5e1b270905008b927515df85 | c78b2de53978f3d244cb87f54fafc4115755c98b | /src/main/java/org/atos/epi/example/processors/PreProcessValidator.java | fe515fa1b4d9706f095edf7a2ac3958fa9497a3d | [] | no_license | belphegor666/wildfly-camel-template | 099ab086e0b7de3f5d8579c927e970f5d2771847 | 6cde89b2ddfa7aba54f5f1bfd18dfa5c581a5b4e | refs/heads/master | 2020-12-24T06:42:00.423811 | 2016-07-23T05:55:38 | 2016-07-23T05:55:38 | 64,001,265 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,287 | java | package org.atos.epi.example.processors;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ValidationException;
public class PreProcessValidator implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
final String HEADER_DATA = "data";
final String data = exchange.getIn().getHeader(HEADER_DATA).toString();
// We look for CAPITAL letters in the data
if(countUppercase(data) == 1) {
// There's only one capital, so we'll correct the data
exchange.getIn().setHeader(HEADER_DATA, "message repaired : "+data.toLowerCase());
exchange.getIn().setHeader("preValidMessage", true);
} else if (countUppercase(data) > 1) {
// There's more than one capital, so we'll declare the data invalid
exchange.getIn().setHeader(HEADER_DATA, "message invalid : "+data);
exchange.getIn().setHeader("preValidMessage", false);
throw new ValidationException(exchange, "invalid message");
} else {
exchange.getIn().setHeader(HEADER_DATA, "message valid : "+data);
exchange.getIn().setHeader("preValidMessage", true);
}
}
private int countUppercase(String s) {
int result = 0;
for (char c : s.toCharArray()) {
if (Character.isUpperCase(c)) result++;
}
return result;
}
}
| [
"[email protected]"
] | |
b7b3dbc1ef1996da670382332139f1827f3c9116 | 77c2be2c6c51e08a583d92afb9486c100256ac10 | /app/src/main/java/com/example/abhilash/jsonfetching/MainActivity.java | 50077003258b455875b966c2cbee67bdc7062204 | [] | no_license | AbhiCS002/jsonfetching | 950b7939ae55c2c712c089f1eefbf414dec6ef43 | bc74725def17b286e44a15c819a6facfcd333eb8 | refs/heads/master | 2020-03-10T00:19:37.174231 | 2018-04-11T10:52:45 | 2018-04-11T10:52:45 | 129,079,234 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,380 | java | package com.example.abhilash.jsonfetching;
/**
* Created by abhilash on 10/4/18.
*/
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.Toast;
import java.util.List;
public class MainActivity extends ListActivity implements FetchDataListener{
private ProgressDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
// show progress dialog
dialog = ProgressDialog.show(this, "", "Loading...");
String url = "http://10.0.2.2/areca.php";
FetchDataTask task = new FetchDataTask(this);
task.execute(url);
}
@Override
public void onFetchComplete(List<Application> data) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// create new adapter
ApplicationAdapter adapter = new ApplicationAdapter(this, data);
// set the adapter to list
setListAdapter(adapter);
}
@Override
public void onFetchFailure(String msg) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// show failure message
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
} | [
"4su14cs002"
] | 4su14cs002 |
b6bf4f10fccd3f20da05644363c8de3c22107a32 | 62b604d6da105a2b802d012208755b2454fe5d70 | /AlgorithmSimulator/src/algorithm/ExplorationWallerType3.java | 2e1548a5ef437428ee2ba17b2bcbe2e9c89cef0a | [] | no_license | shaojieyew/MDP_Simulator | edbed8bbbf586c082713cb34836bea9e9eee55ef | 5b458081d11f53282ac43a36fb6e176fc5ec224a | refs/heads/master | 2021-07-22T04:14:20.877081 | 2017-11-02T17:22:55 | 2017-11-02T17:22:55 | 102,107,184 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 35,056 | java | package algorithm;
/*follow left wall, with minimum rotation*/
import java.awt.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import Data.Map;
import Data.MapListener;
import Data.Position;
import Data.Robot;
import Data.RobotListener;
import Data.Vertex;
import RPiInterface.Message;
public class ExplorationWallerType3 extends Exploration {
public int [][] visited = new int[20][15];
public float checkEnvironementOf[];
int printCount=1;
public static boolean testTurnedLeft =false;
public static boolean testTurnedRight =false;
public static boolean newVisit =false;
public static float newVisitDirection =0;
public static boolean finishHuggingWall =false;
public static int[] positionBeforeStrayAway =null;
public static final int strayAwayDistanceThreshold =6;
public static final int strayAwayDifferences =3;
public void cleanUpVar(){
testTurnedLeft =false;
testTurnedRight =false;
newVisit =false;
newVisitDirection =0;
finishHuggingWall =false;
}
//from rpi
public ExplorationWallerType3(boolean isTerminate){
super(isTerminate);
}
//from simulator
public ExplorationWallerType3(){
super();
}
public ExplorationWallerType3(int startAtX, int startAtY){
super(startAtX,startAtY);
}
@Override
public void init() {
visited = new int[20][15];
float checkEnvironementOf[]={NORTH,SOUTH,EAST,WEST};
this.checkEnvironementOf =checkEnvironementOf;
}
public Message computeAction(){
float mapDiscoveredRate = m.getExploredRate();
long currentTimeStamp = System.currentTimeMillis();
long seconds = ((currentTimeStamp-Robot.getInstance().getExploringStartTime())/1000);
//set goal to termination/start point
if(waypointFound()&&endPointFound()&&(seconds>=getAutoTerminate_time()||isOkToTerminate()||mapDiscoveredRate>=getAutoTerminate_explore_rate())){
finishHuggingWall=true;
terminate();
}
Message message = null;
int currentX = Math.round(r.getPosX());
int currentY =Math.round(r.getPosY());
float direction = r.getDirection();
int result[] ;
updateVisitedList();
//if startpoint is not explored or goal is not startpoint/termination, continue to explore nearby blocks
if(!isOkToTerminate()||!startPointFound()){
int currentDirectionIndex = 0;
if(visited[currentY][currentX]==0){
if(!newVisit){
newVisit = true;
newVisitDirection = direction;
}
int count = 0;
int checkDirection = 0;
int toRotate = 360;
for(int i =currentDirectionIndex ; i<currentDirectionIndex+4 ; i++){
float directionToCheck = checkEnvironementOf[i%4];
int temp = howManyUndiscovered(currentX, currentY,directionToCheck);
//System.out.println(direction+" facing = "+directionToCheck+" , "+ temp);
float degree = degreeToRotateToDirection(direction, directionToCheck);
if(temp>count){
count = temp;
checkDirection = (int) directionToCheck;
toRotate = (int) degree;
}else{
if(temp==count){
if(Math.abs(degree)<toRotate){
//System.out.println(toRotate+" vs "+ degree);
checkDirection = (int) directionToCheck;
toRotate = (int) degree;
}
}
}
}
//System.out.println(checkDirection);
if(isAnyUndiscovered(currentX, currentY,checkDirection)){
float degree = rotateToDirection(direction,checkDirection);
int intDegree = Math.round(degree);
String movement= "R"+intDegree;
if(intDegree<0){
movement= "L"+(intDegree*-1);
}
message = new Message();
String []movments = {movement};
message.setMovements(movments);
int [] location = {currentX,currentY};
message.setRobotLocation(location);
message.setEndOfExploration(false);
message.setDirection(checkDirection);
//return message;
return message;
}
}
}
if(!finishHuggingWall){
float tempDirection = direction;
if(newVisit){
tempDirection= (int) newVisitDirection;
}
if(testTurnedLeft==true&&outofWallhugging(currentX,currentY,(int)tempDirection)){
finishHuggingWall=true;
}else{
if(positionBeforeStrayAway!=null){
result = getNextWallHugLocation(positionBeforeStrayAway[0],positionBeforeStrayAway[1],positionBeforeStrayAway[2]);
positionBeforeStrayAway=null;
}else{
result = getNextWallHugLocation(currentX,currentY,(int)tempDirection);
}
int count1 =whatTileCanBeDiscovered(result[0],result[1],false).size();
if(result[0]!=currentX||result[1]!=currentY){
int tempResult[] = getBestNextStop(result[0], result[1], strayAwayDistanceThreshold);
positionBeforeStrayAway=null;
if((result[0]!=tempResult[0]||result[1]!=tempResult[1])&&(tempResult[0]!=currentX||tempResult[1]!=currentY)){
int count2 =whatTileCanBeDiscovered(tempResult[0],tempResult[1],false).size();
if(count2-count1>strayAwayDifferences){
//int temp[]= {currentX,currentY,(int)tempDirection};
positionBeforeStrayAway = result;
result = tempResult;
}
}
}
if(result[0]==1&&result[1]==1&&positionBeforeStrayAway==null){
finishHuggingWall = true;
}
if(!finishHuggingWall){
if(result[0]==1&&result[1]==1&&isOkToTerminate()){
message = moveToLocation(currentX, currentY, direction, result[0],result[1],0);
message.setEndOfExploration(true);
destroy();
}else{
message = moveToLocation(currentX, currentY, direction, result[0],result[1],result[2]);
}
return message;
}
}
}
if(finishHuggingWall){
checkedVisited =new int[20][15];
result = getBestNextStop(currentX,currentY,10000);
if(currentX==result[0]&¤tY==result[1]&&(currentX!=1||currentY!=1)){
result[0]=1;
result[1]=1;
}
if(result[0]==1&&result[1]==1&&isOkToTerminate()){
message = moveToLocation(currentX, currentY, direction, result[0],result[1],0);
message.setEndOfExploration(true);
cleanUpVar();
destroy();
}else{
message = moveToLocation(currentX, currentY, direction, result[0],result[1]);
}
return message ;
}
return message;
}
@Override
public Message moveToLocation(int x1, int y1,float facing, int x2, int y2, int endDirection) {
Vertex s = m.getVertices()[y1][x1];
if(s==null){
////System.out.println("Error:"+x1+","+y1);
////System.out.println("Error:"+x1+","+y1);
return null;
}
Vertex[][] vertices = m.getVertices();
Vertex e =vertices[y2][x2];
DijkstraMinimunRotation d = new DijkstraMinimunRotation();
java.util.List<Vertex> path = d.computePaths(s, e,vertices);
ArrayList<String> instructions = new ArrayList<String>();
if(newVisit){
newVisit = false;
float degree = getDegreeBetweenTwoPoint(x1,y1,path.get(1).x,path.get(1).y);
////System.out.println(x1+","+y1+"=>"+","+path.get(1)+" - "+degree+" deg <-->"+newVisitDirection);
if(degree!=facing){
float degreeToMove = rotateToDirection(facing,newVisitDirection);
facing= newVisitDirection;
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ rotationCost;
instructions.add(rmovement);
}
}
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)x1,(int)y1,(int) facing,instructions,null);
}
float direction = facing;
int forwardCount = 0;
for(int i =0;i<path.size()-1;i++){
Vertex v1 =path.get(i);
Vertex v2 =path.get(i+1);
float degree = getDegreeBetweenTwoPoint(v1.x,v1.y,v2.x,v2.y);
if(degree!= direction)
{
if(forwardCount!=0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}
forwardCount=0;
//float degreeBetween= degreeToRotateToDirection(direction,degree);
float degreeToMove =rotateToDirection(direction,degree);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ rotationCost;
instructions.add(rmovement);
direction = degree;
}
forwardCount=forwardCount+10;
if(lastMovedBeforeCalibrate+forwardCount>=intervalForCalibrate){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}else{
if(i==path.size()-2){
if(forwardCount>0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}
}
}
}
if(direction!=endDirection){
float degreeToMove =rotateToDirection(direction,endDirection);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ rotationCost;
instructions.add(rmovement);
direction = endDirection;
}
String []movements = new String[instructions.size()];
int index=0;
for(String instruction: instructions){
movements[index] = instruction;
index++;
}
Message message = new Message();
message.setMovements(movements);
Vertex lastLocation = path.get(path.size()-1);
int [] location = {(int) lastLocation.x,(int) lastLocation.y};
message.setRobotLocation(location);
message.setEndOfExploration(false);
message.setDirection(direction);
return message;
}
//get Instructions To Location
@Override
public Message moveToLocation(int x1, int y1,float facing, int x2, int y2) {
ArrayList<String> instructions = new ArrayList<String>();
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)x1,(int)y1,(int) facing,instructions,null);
}
Vertex s = m.getVertices()[y1][x1];
if(s==null){
////System.out.println("Error:"+x1+","+y1);
////System.out.println("Error:"+x1+","+y1);
return null;
}
Vertex[][] vertices = m.getVertices();
Vertex e =vertices[y2][x2];
float direction = facing;
DijkstraMinimunRotation d = new DijkstraMinimunRotation();
java.util.List<Vertex> path = d.computePaths(s, e,vertices);
////System.out.println("Path to travel: "+path);
////System.out.println("I am facing "+direction);
int forwardCount = 0;
for(int i =0;i<path.size()-1;i++){
Vertex v1 =path.get(i);
Vertex v2 =path.get(i+1);
float degree = getDegreeBetweenTwoPoint(v1.x,v1.y,v2.x,v2.y);
if(degree!= direction)
{
if(forwardCount!=0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}
forwardCount=0;
//float degreeBetween= degreeToRotateToDirection(direction,degree);
float degreeToMove =rotateToDirection(direction,degree);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ rotationCost;
instructions.add(rmovement);
direction = degree;
}
forwardCount=forwardCount+10;
if(lastMovedBeforeCalibrate+forwardCount>=intervalForCalibrate){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}else{
if(i==path.size()-2){
if(forwardCount>0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
lastMovedBeforeCalibrate = lastMovedBeforeCalibrate+ forwardCount;
if(lastMovedBeforeCalibrate>=intervalForCalibrate){
instructions = addCalibrationCommand((int)v2.x,(int)v2.y,(int) direction,instructions,null);
}
forwardCount=0;
}
}
}
}
String []movements = new String[instructions.size()];
int index=0;
for(String instruction: instructions){
movements[index] = instruction;
index++;
}
Message message = new Message();
message.setMovements(movements);
Vertex lastLocation = path.get(path.size()-1);
int [] location = {(int) lastLocation.x,(int) lastLocation.y};
message.setRobotLocation(location);
message.setEndOfExploration(false);
message.setDirection(direction);
return message;
}
public boolean allPossiblePathExplored(int x,int y){
int visitedCheck [][] = new int[20][15];
Vertex v = m.getVertices()[y][x];
// BFS uses Queue data structure
Queue queue = new LinkedList();
queue.add(v);
visitedCheck[y][x] = 1;
while(!queue.isEmpty()) {
Vertex node = (Vertex)queue.remove();
if(visited[(int) node.getY()][(int) node.getX()]==0){
return false;
}
Vertex child=null;
if(node.adjacencies.size()>0)
for(int i =0;i<node.adjacencies.size();i++){
child = node.adjacencies.get(i);
if(visitedCheck[(int) child.getY()][(int) child.getX()]==0){
visitedCheck[(int) child.getY()][(int) child.getX()]=1;
queue.add(child);
}
}
}
return true;
}
private int[] getNextWallHugLocation( int x, int y,int direction){
int robotsNorth = (int) ((NORTH+direction)%360);
int robotsEast = (int) ((EAST+direction)%360);
int robotsWest = (int) ((WEST+direction)%360);
int nMoveable = isDirectionMoveable(robotsNorth, x, y);
int wMoveable = isDirectionMoveable(robotsWest, x, y);
int previousBlocked = getLeftBlocks(direction,x, y);
int [] result = {x,y,direction};
if(visited[y][x]==0||(x==1 && y==1&&endPointFound())){
return result;
}
if(allPossiblePathExplored(x,y)){
int [] result1 = {1,1,0};
return result1;
}
int steps = (nMoveable<previousBlocked)?nMoveable:previousBlocked;
if(testTurnedLeft&&nMoveable!=0){
testTurnedLeft=false;
//r.moveForward(10*nMoveable);
result= computeForwardLocation(direction, x, y, steps);
result=getNextWallHugLocation(result[0],result[1],direction);
}else{
if(wMoveable!=0){
testTurnedLeft=true;
result=getNextWallHugLocation(result[0],result[1],robotsWest);
}else{
if(steps!=0){
if(testTurnedRight){
testTurnedRight=false;
}
result= computeForwardLocation(direction, x, y, steps);
result=getNextWallHugLocation(result[0],result[1],direction);
}else{
testTurnedRight=true;
result=getNextWallHugLocation(result[0],result[1],robotsEast);
}
}
}
return result;
}
private Message moveToLocation1(int x1, int y1,float facing, int x2, int y2, int endDirection) {
Vertex s = m.getVertices()[y1][x1];
if(s==null){
//System.out.println("Error:"+x1+","+y1);
//System.out.println("Error:"+x1+","+y1);
return null;
}
Vertex[][] vertices = m.getVertices();
Vertex e =vertices[y2][x2];
DijkstraMinimunRotation d = new DijkstraMinimunRotation();
java.util.List<Vertex> path = d.computePaths(s, e,vertices);
ArrayList<String> instructions = new ArrayList<String>();
if(newVisit){
newVisit = false;
float degree = 0;
if(path.size()>1){
degree = getDegreeBetweenTwoPoint(x1,y1,path.get(1).x,path.get(1).y);
}
if(degree!=facing){
float degreeToMove = rotateToDirection(facing,newVisitDirection);
facing= newVisitDirection;
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
instructions.add(rmovement);
}
}
float direction = facing;
int forwardCount = 0;
for(int i =0;i<path.size()-1;i++){
Vertex v1 =path.get(i);
Vertex v2 =path.get(i+1);
float degree = getDegreeBetweenTwoPoint(v1.x,v1.y,v2.x,v2.y);
if(degree!= direction)
{
if(forwardCount!=0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
}
forwardCount=0;
//float degreeBetween= degreeToRotateToDirection(direction,degree);
float degreeToMove =rotateToDirection(direction,degree);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
instructions.add(rmovement);
direction = degree;
}
forwardCount=forwardCount+10;
if(i==path.size()-2){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
}
}
if(direction!=endDirection){
float degreeToMove =rotateToDirection(direction,endDirection);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
instructions.add(rmovement);
direction = endDirection;
}
String []movements = new String[instructions.size()];
int index=0;
for(String instruction: instructions){
movements[index] = instruction;
index++;
}
Message message = new Message();
message.setMovements(movements);
Vertex lastLocation = path.get(path.size()-1);
int [] location = {(int) lastLocation.x,(int) lastLocation.y};
message.setRobotLocation(location);
message.setEndOfExploration(false);
message.setDirection(direction);
return message;
}
//get Instructions To Location
private Message moveToLocation1(int x1, int y1,float facing, int x2, int y2) {
ArrayList<String> instructions = new ArrayList<String>();
Vertex s = m.getVertices()[y1][x1];
if(s==null){
//System.out.println("Error:"+x1+","+y1);
//System.out.println("Error:"+x1+","+y1);
return null;
}
Vertex[][] vertices = m.getVertices();
Vertex e =vertices[y2][x2];
float direction = facing;
DijkstraMinimunRotation d = new DijkstraMinimunRotation();
java.util.List<Vertex> path = d.computePaths(s, e,vertices);
//System.out.println("Path to travel: "+path);
//System.out.println("I am facing "+direction);
int forwardCount = 0;
for(int i =0;i<path.size()-1;i++){
Vertex v1 =path.get(i);
Vertex v2 =path.get(i+1);
float degree = getDegreeBetweenTwoPoint(v1.x,v1.y,v2.x,v2.y);
if(degree!= direction)
{
if(forwardCount!=0){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
}
forwardCount=0;
//float degreeBetween= degreeToRotateToDirection(direction,degree);
float degreeToMove =rotateToDirection(direction,degree);
int intDegree = Math.round(degreeToMove);
String rmovement= "R"+intDegree;
if(intDegree<0){
rmovement= "L"+(intDegree*-1);
}
instructions.add(rmovement);
direction = degree;
}
forwardCount=forwardCount+10;
if(i==path.size()-2){
instructions.add("F"+forwardCount);
r.moveForward(forwardCount);
}
}
String []movements = new String[instructions.size()];
int index=0;
for(String instruction: instructions){
movements[index] = instruction;
index++;
}
Message message = new Message();
message.setMovements(movements);
Vertex lastLocation = path.get(path.size()-1);
int [] location = {(int) lastLocation.x,(int) lastLocation.y};
message.setRobotLocation(location);
message.setEndOfExploration(false);
message.setDirection(direction);
return message;
}
private int[] getBestNextStop(int inX, int inY, int maxHop) {
int currentX = Math.round(r.getPosX());
int currentY =Math.round(r.getPosY());
float direction = r.getDirection();
ArrayList<Position> canExplore= whatTileCanBeDiscovered(currentX,currentY,false);
float degree = getDegreeBetweenTwoPoint(currentX,currentY,currentX,currentY);
int degreeBetween =0;
//if(currentX!=1 || currentY!=1){
degreeBetween = (int) degreeToRotateToDirection(direction,degree);
//}
int result[] = {currentX,currentY,canExplore.size(),0};
return getBestNextStopRecursive(inX, inY, maxHop, result);
}
//BFS, check all nodes
private int checkedVisited[][]= new int[20][15];
private int[] getBestNextStopRecursive(int inX, int inY, int maxHop, int[] inDefault) {
int currentX = (int) r.getPosX();
int currentY = (int) r.getPosY();
Vertex v = m.getVertices()[inY][inX];
if(v==null){
return inDefault;
}
ArrayList<Vertex> neighbours = v.adjacencies;
int []optimised=inDefault;
for(Vertex nextNode: neighbours){
int x = (int) nextNode.x;
int y = (int) nextNode.y;
if(checkedVisited[y][x]==0){
checkedVisited[y][x]=1;
ArrayList<Position> canExplore= whatTileCanBeDiscovered(x,y,false);
if(canExplore.size()>0&&canExplore.size()<=3){
canExplore =whatTileCanBeDiscovered(x,y,true);
}
int squareAway = getDistanceAway(currentX,currentY,x,y);
if(squareAway<0){
//System.out.println("alert");
}
int result[] = {x,y,canExplore.size(),squareAway};
if(maxHop==1){
return result;
}else{
int result1[] =getBestNextStopRecursive(x,y,maxHop-1,inDefault);
result = calculateScoreOfVertexAndCompare(result1,result);
}
optimised = calculateScoreOfVertexAndCompare(result,optimised);
}
}
return optimised;
}
//greedy heuristic
private int[] calculateScoreOfVertexAndCompare(int[] place1, int[] place2){
float mapDiscoveredRate = m.getExploredRate();
float exploreMoreWeightage = 1; //explore_score:1-36
int nearByWeightage = 0; //score: 1-28
float endLocationWeightage = 1; //score: 1-28
float startWeightage = 0; //score: 1-28
int distanceWeightage = 1;
boolean isAllPossibleNodeVisited = allPossibleNodeVisited();
//if end point found
if(m.getExploredTiles()[18][13]==1||isAllPossibleNodeVisited){
endLocationWeightage=0;
//if map discovered rate 90% or more
if(mapDiscoveredRate>0.7){
startWeightage = 0;
exploreMoreWeightage=1;
distanceWeightage=1;
}
//if map discovered rate is 100%
if(mapDiscoveredRate>=getAutoTerminate_explore_rate()||isAllPossibleNodeVisited){
startWeightage = 1000000;
exploreMoreWeightage=0;
distanceWeightage=0;
terminate();
}
}
//check termiation or timeout
long currentTimeStamp = System.currentTimeMillis();
long seconds = ((currentTimeStamp-Robot.getInstance().getExploringStartTime())/1000);
if(seconds>=getAutoTerminate_time()||isOkToTerminate()||mapDiscoveredRate>=getAutoTerminate_explore_rate()){
startWeightage = 1000000;
exploreMoreWeightage=0;
distanceWeightage=0;
terminate();
}
/*
int x1 = place1[0];
int y1 = place1[1];
int x2 = place2[0];
int y2 = place2[1];
//compare to find mutual undiscovered tiles
ArrayList<Position> canExplore1 =whatTileCanBeDiscovered(x1,y1,false);
ArrayList<Position> canExplore2 =whatTileCanBeDiscovered(x2,y2,false);
float totalCount = (canExplore1.size()<canExplore2.size())?canExplore1.size():canExplore2.size();
float similarCount = 0;
if(totalCount>0){
boolean breakAll=false;
for(Position s1: canExplore1){
for(Position s2: canExplore2){
if(s1.equals(s2)){
similarCount++;
if((similarCount/totalCount)>0.5){
distanceWeightage=0;
breakAll=true;
break;
}
}
}
if(breakAll){
break;
}
}
}
//if mutually exclusive then visit the nearer one
if((totalCount!=0&&(similarCount==0))){
distanceWeightage=10;
exploreMoreWeightage=0;
}
*/
//get score of 2 location and compare
float score1=0;
float score2=0;
score1=calculateScore( place1, distanceWeightage, startWeightage, nearByWeightage, endLocationWeightage, exploreMoreWeightage);
score2=calculateScore( place2, distanceWeightage, startWeightage, nearByWeightage, endLocationWeightage, exploreMoreWeightage);
if(startWeightage>0){
if(place1[0]==1&&place1[1]==1){
score2=0;
score1=1;
}
if(place2[0]==1&&place2[1]==1){
score1=0;
score2=1;
}
}else{
if(score1==score2){
if(getStartingX()<=6){
if(place1[0]>place2[0]){
score1=0;
score2=1;
}else{
score1=1;
score2=0;
}
}else{
if(place1[0]<place2[0]){
score1=0;
score2=1;
}else{
score1=1;
score2=0;
}
}
}
}
//if(place1[2]!=0)
//////System.out.println("\t ("+(place1[0])+","+place1[1]+")"+"- score:" +score1 +" \ttotal explorable:"+ place1[2]+" \t distance:"+ place1[3]);
//if(place2[2]!=0)
//////System.out.println("\t ("+(place2[0])+","+place2[1]+")"+"- score:" +score2+" \ttotal explorable:"+ place2[2]+" \t distance:"+ place1[3]);
int []result;
if(score1>score2){
result = place1;
}else{
if(score1==score2){
result = place1;
}else{
result = place2;
}
}
return result;
}
int visitedTemp [][] = new int[20][15];
private int getTotalUnexploredTileConnected(Position pos){
visitedTemp = new int[20][15];
visitedTemp[pos.getPosY()][pos.getPosX()]=1;
int x = pos.getPosX();
int y = pos.getPosY();
return getTotalUnexploredTileConnected(x,y, 1);
}
private int getTotalUnexploredTileConnected(int x, int y, int count){
int xTop = x;
int yTop = y+1;
int xBottom = x;
int yBottom = y-1;
int xLeft = x-1;
int yLeft = y;
int xRight = x+1;
int yRight = y;
if(xTop>=0&&xTop<15&&yTop>=0&&yTop<20&&m.getExploredTiles()[yTop][xTop]==0&&visitedTemp[yTop][xTop]!=1){
visitedTemp[yTop][xTop]=1;
count = getTotalUnexploredTileConnected(xTop, yTop ,count+1);
}
if(xBottom>=0&&xBottom<15&&yBottom>=0&&yBottom<20&&m.getExploredTiles()[yBottom][xBottom]==0&&visitedTemp[yBottom][xBottom]!=1){
visitedTemp[yBottom][xBottom]=1;
count = getTotalUnexploredTileConnected(xBottom, yBottom ,count+1);
}
if(xLeft>=0&&xLeft<15&&yLeft>=0&&yLeft<20&&m.getExploredTiles()[yLeft][xLeft]==0&&visitedTemp[yLeft][xLeft]!=1){
visitedTemp[yLeft][xLeft]=1;
count = getTotalUnexploredTileConnected(xLeft, yLeft ,count+1);
}
if(xRight>=0&&xRight<15&&yRight>=0&&yRight<20&&m.getExploredTiles()[yRight][xRight]==0&&visitedTemp[yRight][xRight]!=1){
visitedTemp[yRight][xRight]=1;
count = getTotalUnexploredTileConnected(xRight, yRight ,count+1);
}
return count;
}
private float calculateScore(int place2[], int distanceWeightage,float startWeightage, float nearByWeightage, float endLocationWeightage, float exploreMoreWeightage){
//int x = place[0];
//int y = place[0];
float leanXDirection = 1;
float leanYDirection=1;
int[] endLocation = {13,18};
int[] startLocation = {1,1};
float score=0;
if(visited[place2[1]][place2[0]]==0 || ((visited[place2[1]][place2[0]]==1)&&(place2[0]==1&&place2[1]==1)&&startWeightage>0)){
int exploreSquareCount2 = place2[2];
int distanceAway2 = 300-(place2[3]);
int squareAway2 = 29-(Math.abs(place2[0]-endLocation[0])+Math.abs(place2[1]-endLocation[1]));
int nearBySquareAway2 = (int) (29-(Math.abs(place2[0]-r.getPosX())+Math.abs(place2[1]-r.getPosY())));
int startSquareAway2 = (int) (29-(Math.abs(place2[0]-startLocation[1])+Math.abs(place2[1]-startLocation[1])));
if(exploreSquareCount2==0){
score=0;
}else{
score =(distanceAway2*distanceWeightage)+ (startSquareAway2)*startWeightage +(nearBySquareAway2)*nearByWeightage + (squareAway2)*endLocationWeightage + exploreSquareCount2*exploreMoreWeightage;
}
}
return score;
}
private int getDistanceAway(int x1, int y1, int x2, int y2) {
Vertex[][]vertices = m.getVertices();
Vertex v1 = vertices[y1][x1];
Vertex v2 = vertices[y2][x2];
java.util.List<Vertex> path = null;
if(v1!=null&&v2!=null){
DijkstraMinimunRotation d = new DijkstraMinimunRotation();
path=d.computePaths(v1, v2,vertices);
}
if(path!=null&&path.size()>0){
return path.size()-1;
}
return Math.abs(x1-x2)+Math.abs(y1-y2);
}
//update the visited list
private void updateVisitedList(){
for(int x1=1;x1<14;x1++){
for(int y1=1;y1<19;y1++){
if(visited[y1][x1]==0){
if(!isAnyUndiscovered(x1,y1,NORTH)&&!isAnyUndiscovered(x1,y1,SOUTH)&&!isAnyUndiscovered(x1,y1,EAST)&&!isAnyUndiscovered(x1,y1,WEST)){
visited[y1][x1]=1;
}
}
}
}
}
//update the visited list
private boolean allPossibleNodeVisited(){
for(int x1=1;x1<14;x1++){
for(int y1=1;y1<19;y1++){
if(visited[y1][x1]==0){
Vertex v = m.getVertices()[y1][x1];
if(v!=null){
return false;
}
}
}
}
return true;
}
//get number of tiles that are unexplored in a location
private ArrayList<Position> whatTileCanBeDiscovered(int x, int y, boolean firstLayer){
ArrayList<Position> arrays=new ArrayList<Position>();
float[] allDirection = {NORTH,SOUTH,EAST,WEST};
for(float dir: allDirection){
Position[][] lineOfSensors = r.getSensorSimulator().getLineOfSensor(x, y, dir);
for(int i =0;i<3;i++){
Position[] sensors = lineOfSensors[i];
for(Position sensor:sensors){
int count = 0;
if(sensor!=null&&sensor.getPosY()>=0&&(sensor.getPosY())<20&&(sensor.getPosX())>=0&&(sensor.getPosX())<15){
if(m.getExploredTiles()[sensor.getPosY()][(sensor.getPosX())]==0){
arrays.add(new Position(sensor.getPosX(),sensor.getPosY()));
count++;
}else{
if(m.getObstacles()[sensor.getPosY()][(sensor.getPosX())]==1){
break;
}
}
}else{
break;
}
if(firstLayer&&count==1){
break;
}
}
}
}
return arrays;
}
public int isDirectionMoveable(float direction, int x, int y){
int[][]obstacles = m.getObstacles();
int[][]explored = m.getExploredTiles();
int maxMoveable = 3;
int dir = (int)direction;
switch (dir){
case 0:
for(int i =0;i<maxMoveable;i++){
if(y+2+i>=20){
return i;
}
if(explored[y+2+i][x+1]==0||(explored[y+2+i][x+1]==1&&obstacles[y+2+i][x+1]==1)){
return i;
}
if(explored[y+2+i][x]==0||(explored[y+2+i][x]==1&&obstacles[y+2+i][x]==1)){
return i;
}
if(explored[y+2+i][x-1]==0||(explored[y+2+i][x-1]==1&&obstacles[y+2+i][x-1]==1)){
return i;
}
}
break;
case 90:
for(int i =0;i<maxMoveable;i++){
if(x+2+i>=15){
return i;
}
if(explored[y-1][x+i+2]==0||(explored[y-1][x+i+2]==1&&obstacles[y-1][x+i+2]==1)){
return i;
}
if(explored[y][x+i+2]==0||(explored[y][x+i+2]==1&&obstacles[y][x+i+2]==1)){
return i;
}
if(explored[y+1][x+i+2]==0||(explored[y+1][x+i+2]==1&&obstacles[y+1][x+i+2]==1)){
return i;
}
}
break;
case 180:
for(int i =0;i<maxMoveable;i++){
if(y-2-i<0){
return i;
}
if(explored[y-2-i][x-1]==0||(explored[y-2-i][x-1]==1&&obstacles[y-2-i][x-1]==1)){
return i;
}
if(explored[y-2-i][x]==0||(explored[y-2-i][x]==1&&obstacles[y-2-i][x]==1)){
return i;
}
if(explored[y-2-i][x+1]==0||(explored[y-2-i][x+1]==1&&obstacles[y-2-i][x+1]==1)){
return i;
}
}
break;
case 270:
for(int i =0;i<maxMoveable;i++){
if(x-2-i<0){
return i;
}
if(explored[y+1][x-i-2]==0||(explored[y+1][x-i-2]==1&&obstacles[y+1][x-i-2]==1)){
return i;
}
if(explored[y][x-i-2]==0||(explored[y][x-i-2]==1&&obstacles[y][x-i-2]==1)){
return i;
}
if(explored[y-1][x-i-2]==0||(explored[y-1][x-i-2]==1&&obstacles[y-1][x-i-2]==1)){
return i;
}
}
break;
}
return maxMoveable;
}
public int getLeftBlocks(float direction, int x, int y){
int[][]obstacles = m.getObstacles();
int[][]explored = m.getExploredTiles();
int dir = (int)direction;
switch (dir){
case 0:
if(x-2<0){
return 3;
}
if(explored[y+1][x-2]==0||(explored[y+1][x-2]==1&&obstacles[y+1][x-2]==1)){
return 3;
}
if(explored[y][x-2]==0||(explored[y][x-2]==1&&obstacles[y][x-2]==1)){
return 2;
}
if(explored[y-1][x-2]==0||(explored[y-1][x-2]==1&&obstacles[y-1][x-2]==1)){
return 1;
}
break;
case 90:
if(y+2>=20){
return 3;
}
if(explored[y+2][x+1]==0||(explored[y+2][x+1]==1&&obstacles[y+2][x+1]==1)){
return 3;
}
if(explored[y+2][x]==0||(explored[y+2][x]==1&&obstacles[y+2][x]==1)){
return 2;
}
if(explored[y+2][x-1]==0||(explored[y+2][x-1]==1&&obstacles[y+2][x-1]==1)){
return 1;
}
break;
case 180:
if(x+2>=15){
return 3;
}
if(explored[y-1][x+2]==0||(explored[y-1][x+2]==1&&obstacles[y-1][x+2]==1)){
return 3;
}
if(explored[y][x+2]==0||(explored[y][x+2]==1&&obstacles[y][x+2]==1)){
return 2;
}
if(explored[y+1][x+2]==0||(explored[y+1][x+2]==1&&obstacles[y+1][x+2]==1)){
return 1;
}
break;
case 270:
if(y-2<0){
return 3;
}
if(explored[y-2][x-1]==0||(explored[y-2][x-1]==1&&obstacles[y-2][x-1]==1)){
return 3;
}
if(explored[y-2][x]==0||(explored[y-2][x]==1&&obstacles[y-2][x]==1)){
return 2;
}
if(explored[y-2][x+1]==0||(explored[y-2][x+1]==1&&obstacles[y-2][x+1]==1)){
return 1;
}
break;
}
return 3;
}
@Override
public void updateRobot() {
}
@Override
public void onRobotStop() {
}
@Override
public void onRobotStartExploring() {
// TODO Auto-generated method stub
}
@Override
public void onRobotStopExploring() {
// TODO Auto-generated method stub
}
@Override
public String geType() {
return ExplorationFactory.EX_WALL3;
}
}
| [
"[email protected]"
] | |
9a13d88d0cdd449c54a6c9dca25552ff8f362368 | 2e35704669539202c1adcafa26b3d510fad08220 | /projewski-exchange-binance/src/main/java/pl/projewski/bitcoin/exchange/binance/api/v1/MaxNumOrdersFilter.java | a24125d6c95cc6741a05bb2ff6713c7a91cf1db9 | [
"MIT"
] | permissive | rojekabc/projewski-bitcoin | 760c56642e74622a35ba6b5c6c258afae511bd34 | 35cce313d26d9074138e70870c109f32ca4043f0 | refs/heads/master | 2022-11-25T01:27:26.586592 | 2022-05-23T19:02:26 | 2022-05-23T19:02:26 | 116,667,279 | 2 | 1 | MIT | 2022-11-16T01:59:42 | 2018-01-08T11:16:41 | Java | UTF-8 | Java | false | false | 310 | java | package pl.projewski.bitcoin.exchange.binance.api.v1;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class MaxNumOrdersFilter extends Filter {
private long limit;
public MaxNumOrdersFilter() {
super(FilterType.MAX_NUM_ORDERS);
}
}
| [
"[email protected]"
] | |
edf00391b4d0f1a7bf3b29beb3e27c5710dd16c2 | 01df6a626cc4de3461d3554e2895df9fdda15d03 | /src/Chapter6/P6.java | d65f9bf4151a7a476f3386c3ae288ae6212a013f | [] | no_license | Vivanio/JavaProgrammingOne | b3b076c5f529a8203167fd1ea47d0c43e32d62ae | 66439813ab06b91bef1cf75b10ee98568985fb07 | refs/heads/master | 2021-05-13T11:47:26.007662 | 2018-01-16T18:53:55 | 2018-01-16T18:53:55 | 117,139,854 | 0 | 0 | null | 2018-01-16T18:53:56 | 2018-01-11T18:52:16 | Java | UTF-8 | Java | false | false | 3,478 | java | package Chapter6;
import java.util.Scanner;
//import java.lang.Character;
/**
*
* Converting the prices of money
*
* @author Donavon Mithchell
*/
public class P6 {
/**
* Main Method
*
* @param args arguments from command line prompt
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean stop = false;
//String finish;
char yeet = ' ';
double dollar, euro, pound, yen;
System.out.println("How much is a Euro compared to a dollar");
euro = input.nextDouble();
System.out.println("How much is a Pound Sterling compared to a dollar");
pound = input.nextDouble();
System.out.println("How much is a Yen compared to dollar");
yen = input.nextDouble();
System.out.println("How many US dollars do you want to convert?");
dollar = input.nextDouble();
Banker(dollar, yen, euro, pound, yeet);
}
public static double Banker(double home, double anime, double queen, double sword, char stopper) {
//System.out.print("Enter \"E\" to buy Euros, \"P\" to buy Pounds or \"Y\" to buy Yen :");
//Scanner input = new Scanner(System.in);
String holder;
double yo;
boolean stop = false;
while (stop != true) {
System.out.print("Enter \"E\" to buy Euros, \"P\" to buy Pounds or \"Y\" to buy Yen :");
Scanner input = new Scanner(System.in);
//String holder;
if (home < 100.0) {
yo = home;
home = home * 0.9;
} else {
yo = home;
home = home * 0.95;
}
holder = input.next();
stopper = holder.charAt(0);
if (stopper == 'E' || stopper == 'e') {
queen = home * queen;
System.out.printf("For %.2f dollars, you can buy %.2f Euros", yo, queen);
queen = queen / home;
} else {
if (stopper == 'P' || stopper == 'p') {
sword = home * sword;
System.out.printf("For %.2f dollars, you can buy %.2f Pound Sterlings", yo, sword);
sword = sword / home;
} else {
if (stopper == 'y' || stopper == 'Y') {
anime = home * anime;
System.out.printf("For %.2f dollars, you can buy %.2f Yen", yo, anime);
anime = anime / home;
}
}
}
//stopper = holder.charAt(0);
while (!holder.equals("no") && !holder.equals("No") && !holder.equals("yes") && !holder.equals("Yes")) {
System.out.println();
System.out.print("Do you want to continue? (answer Yes or No) :");
holder = input.next();
if (holder.equals("no") || holder.equals("No")) {
stop = true;
}
if (holder.equals("yes") || holder.equals("Yes")) {
System.out.println();
System.out.println("How many US dollars do you want to convert?");
home = input.nextDouble();
}
//System.out.println("2");
}
}
return home;
}
}
| [
"[email protected]"
] | |
8943666ab9cf3dc7d80b599188db8e4ecf6b602f | 3b3c922225e688b2ab9340f337e1a4a94c98a5c4 | /src/main/java/eon/hg/fileserver/controller/ManageController.java | 5af9fc19ec0ab95f10c6b15594553951351f2dba | [] | no_license | aeonj/eon-fileserver | 0e5d6d71424d0686f386e242d9896aaadede85f4 | ed9b279c4d7761603bbcea3815f8edefd9455f80 | refs/heads/master | 2022-12-11T01:43:08.334451 | 2020-05-09T02:12:55 | 2020-05-09T02:12:55 | 232,266,315 | 0 | 0 | null | 2022-12-06T00:41:11 | 2020-01-07T07:18:59 | JavaScript | UTF-8 | Java | false | false | 4,977 | java | package eon.hg.fileserver.controller;
import eon.hg.fileserver.authorization.annotation.Authorization;
import eon.hg.fileserver.model.App;
import eon.hg.fileserver.model.WarningData;
import eon.hg.fileserver.model.WarningUser;
import eon.hg.fileserver.service.ManageService;
import eon.hg.fileserver.util.body.PageBody;
import eon.hg.fileserver.util.body.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/manage")
public class ManageController {
@Autowired
private ManageService manageService;
@Authorization
@GetMapping("/app/list")
public PageBody appList(int page,int limit) {
return PageBody.success().addPageInfo(manageService.loadAppList(),page,manageService.loadAppList().size());
}
@Authorization
@PostMapping("/app/insert")
public ResultBody appInsert(App app) {
App vf = manageService.getAppByAppNo(app.getApp_no());
if (vf!=null) {
return ResultBody.failed("应用编号已经存在了");
}
manageService.insertApp(app);
return ResultBody.success();
}
@Authorization
@PostMapping("/app/update")
public ResultBody appUpdate(App app) {
App vf = manageService.getAppByAppNo(app.getApp_no());
if (vf!=null && vf.getId()!=app.getId()) {
return ResultBody.failed("应用编号已经存在了");
}
manageService.updateApp(app);
return ResultBody.success();
}
@Authorization
@PostMapping("/app/delete")
public ResultBody appDelete(App app) {
manageService.deleteApp(app);
return ResultBody.success();
}
@Authorization
@PostMapping("/app/batchdel")
public ResultBody appBatchDelete(@RequestBody List<App> apps) {
manageService.batchDeleteApp(apps);
return ResultBody.success();
}
@Authorization
@GetMapping("/warning/data/list")
public PageBody warningDataList(int page,int limit) {
return PageBody.success().addPageInfo(manageService.loadWarningDataList(),page,manageService.loadWarningDataList().size());
}
@Authorization
@PostMapping("/warning/data/insert")
public ResultBody warningDataInsert(WarningData obj) {
WarningData vf = manageService.getWarningDataByIpAddr(obj.getWdIpAddr());
if (vf!=null) {
return ResultBody.failed("服务器IP已经存在了");
}
manageService.insertWarningData(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/data/update")
public ResultBody warningDataUpdate(WarningData obj) {
WarningData vf = manageService.getWarningDataByIpAddr(obj.getWdIpAddr());
if (vf!=null && vf.getId()!=obj.getId()) {
return ResultBody.failed("服务器IP已经存在了");
}
manageService.updateWarningData(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/data/delete")
public ResultBody warningDataDelete(WarningData obj) {
manageService.deleteWarningData(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/data/batchdel")
public ResultBody warningDataBatchDelete(@RequestBody List<WarningData> objs) {
manageService.batchDeleteWarningData(objs);
return ResultBody.success();
}
@Authorization
@GetMapping("/warning/user/list")
public PageBody warningUserList(int page,int limit) {
return PageBody.success().addPageInfo(manageService.loadWarningUserList(),page,manageService.loadWarningUserList().size());
}
@Authorization
@PostMapping("/warning/user/insert")
public ResultBody warningUserInsert(WarningUser obj) {
WarningUser vf = manageService.getWarningUserByName(obj.getName());
if (vf!=null) {
return ResultBody.failed("用户名已经存在了");
}
manageService.insertWarningUser(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/user/update")
public ResultBody warningUserUpdate(WarningUser obj) {
WarningUser vf = manageService.getWarningUserByName(obj.getName());
if (vf!=null && vf.getId()!=obj.getId()) {
return ResultBody.failed("用户名已经存在了");
}
manageService.updateWarningUser(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/user/delete")
public ResultBody warningUserDelete(WarningUser obj) {
manageService.deleteWarningUser(obj);
return ResultBody.success();
}
@Authorization
@PostMapping("/warning/user/batchdel")
public ResultBody warningUserBatchDelete(@RequestBody List<WarningUser> objs) {
manageService.batchDeleteWarningUser(objs);
return ResultBody.success();
}
}
| [
"[email protected]"
] | |
9be61dbc78001935787b7ed394b81da0f7f374ec | 923886346a534a8ae1f92d54b44a462d9ddae1d4 | /tenant-app/src/main/java/com/krushidj/tenantapp/controller/AdminController.java | efc8851379dd23a3bb57cfce9df8f86316cb5c10 | [] | no_license | kd-api/tenant-api | c1ad7f7671aa9b39d38d6732a3f1a2889b5db799 | bb2b4e2bde21c83bb7061a6dc75a167493b76f94 | refs/heads/master | 2020-06-19T10:59:18.666076 | 2019-07-28T23:39:31 | 2019-07-28T23:39:31 | 196,685,287 | 0 | 0 | null | 2019-07-28T23:45:27 | 2019-07-13T06:09:00 | Java | UTF-8 | Java | false | false | 2,414 | java | package com.krushidj.tenantapp.controller;
import com.krushidj.tenantapp.entity.LoginEntity;
import com.krushidj.tenantapp.entity.Product;
import com.krushidj.tenantapp.entity.ProductTypeDesc;
import com.krushidj.tenantapp.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class AdminController {
@Autowired
private AdminService adminService;
// here method for user
@RequestMapping(value = "/user", method = RequestMethod.POST)
public void create(@RequestBody LoginEntity entity) {
adminService.create(entity);
}
@RequestMapping(value = "/findBPh", method = RequestMethod.GET)
List<LoginEntity> findPhoneNumberByUser(@RequestParam("phoneQuery") String phoneQuery) {
return adminService.findPhoneNumberByUser(phoneQuery);
}
// here crud methods for product which is usefull for specific type.
// which is usefull for manuplate and crud operation on UI side.
@RequestMapping(value = "/product", method = RequestMethod.POST)
void saveProduct(@RequestBody Product product) {
adminService.saveProduct(product);
}
@RequestMapping(value = "/product", method = RequestMethod.GET)
List<Product> findAllProduct() {
return adminService.findAllProduct();
}
// here crud methods for product char id which is usefull for specific type.
// which is usefull for manuplate and crud operation on UI side.
@RequestMapping(value = "/productCharType", method = RequestMethod.POST)
void saveproductCharType(@RequestBody ProductTypeDesc productTypeDesc) {
adminService.saveProductType(productTypeDesc);
}
@RequestMapping(value = "/productCharType", method = RequestMethod.GET)
boolean isAvailableproductCharType(@RequestParam("name") String name) {
return adminService.isAvailable(name);
}
@RequestMapping(value = "/productCharType", method = RequestMethod.PUT)
void updateproductCharType(@RequestBody ProductTypeDesc productTypeDesc) {
adminService.updateProductType(productTypeDesc);
}
@RequestMapping(value = "/productCharTypeAll", method = RequestMethod.GET)
List<ProductTypeDesc> getAllproductCharType() {
return adminService.getAll();
}
}
| [
"[email protected]"
] | |
fa68cad5ebca98f56f36bb36c733caa854cc12bb | a4835aa8e975e5f671df2391069a5f3608456a6b | /app/src/main/java/com/shailesh/mybusappdagger2/ui/splash/Splash_Activity.java | 9c7b63aa31f53962577736e134f70cc0cacb44bc | [] | no_license | Shailesh2323Patil/MyBusApp | 3a333ee96bbb80077ddad2582bd4b462ef27c77c | 57c86f2aa8e5b4271dd8fdc80a2bcc00a405716c | refs/heads/master | 2023-03-31T09:33:10.542249 | 2021-04-01T10:00:56 | 2021-04-01T10:00:56 | 353,653,412 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,054 | java | package com.shailesh.mybusappdagger2.ui.splash;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import dagger.android.support.DaggerAppCompatActivity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.shailesh.mybusappdagger2.ApiResponceResource;
import com.shailesh.mybusappdagger2.BuildConfig;
import com.shailesh.mybusappdagger2.R;
import com.shailesh.mybusappdagger2.databinding.ActivitySplashBinding;
import com.shailesh.mybusappdagger2.model.AppVersion;
import com.shailesh.mybusappdagger2.ui.login.Login_Activity;
import com.shailesh.mybusappdagger2.util.CallIntent;
import com.shailesh.mybusappdagger2.util.PrintMessage;
import com.shailesh.mybusappdagger2.util.dialog.DialogBox_NoInternetConnection;
import com.shailesh.mybusappdagger2.util.no_internet_connection.CheckInternetConnection;
import com.shailesh.mybusappdagger2.util.progress_dialog.ProgressDialogCustom;
import com.shailesh.mybusappdagger2.util.shared_preference.SharedPreferenceStorage;
import com.shailesh.mybusappdagger2.view_model.ViewModelProviderFactory;
import javax.inject.Inject;
public class Splash_Activity extends DaggerAppCompatActivity
{
private static final Integer internetConnectivity = 181;
@Inject
SharedPreferenceStorage sharedPreferenceStorage;
@Inject
ViewModelProviderFactory providerFactory;
@Inject
ProgressDialogCustom progressDialogCustom;
Splash_ViewModel viewModel;
ActivitySplashBinding binding;
private static int SPLASH_SCREEN_TIME_OUT = 2000;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
// //This method is used so that your splash activity
// //can cover the entire screen.
viewModel = new ViewModelProvider(this,providerFactory).get(Splash_ViewModel.class);
// Making notification bar transparent
if (Build.VERSION.SDK_INT >= 21)
{
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
binding = DataBindingUtil.setContentView(Splash_Activity.this, R.layout.activity_splash);
changeStatusBarColor();
new Handler().postDelayed(new Runnable() {
@Override
public void run()
{
String version_code = BuildConfig.VERSION_NAME;
viewModel.apiSplash(version_code);
}
}, SPLASH_SCREEN_TIME_OUT);
onSetObservables();
dialogNoInternet();
}
/**
* Making notification bar transparent
*/
private void changeStatusBarColor()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
}
@Override
protected void onStart()
{
super.onStart();
}
@Override
protected void onStop()
{
super.onStop();
}
private void dialogNoInternet()
{
if(CheckInternetConnection.isConnectionToInternet(this) == false)
{
DialogBox_NoInternetConnection.dialogOkMessage(this);
}
}
private void onSetObservables()
{
// App Version
viewModel.mutableAppVersion.observe(this, new Observer<ApiResponceResource<AppVersion>>() {
@Override
public void onChanged(ApiResponceResource<AppVersion> appVersionApiResponceResource)
{
switch (appVersionApiResponceResource.status)
{
case LOADING:
progressDialogCustom.showProgressBar(true);
break;
case AUTHENTICATED:
{
progressDialogCustom.showProgressBar(false);
AppVersion appVersion = appVersionApiResponceResource.data;
Boolean stable_version = appVersion.getStable_version();
if(stable_version)
{
String userId = sharedPreferenceStorage.getInformation(sharedPreferenceStorage.userId);
String authToken = sharedPreferenceStorage.getInformation(sharedPreferenceStorage.authToken);
if(userId.equals("") && authToken.equals(""))
{
Intent intent = new Intent(Splash_Activity.this, Login_Activity.class);
startActivity(intent);
finish();
}
else
{
CallIntent.callDashboard(Splash_Activity.this,"1");
}
}
else
{
dialogAppUpdate(Splash_Activity.this,getString(R.string.app_update),appVersion.getDescription(),appVersion.getUrl());
}
}
break;
case ERROR:
progressDialogCustom.showProgressBar(false);
PrintMessage.showErrorMessage(Splash_Activity.this,appVersionApiResponceResource.message,binding.idLayRoot);
break;
}
}
});
}
public static void dialogAppUpdate(final Context context,
final String title,
final String message,
final String url)
{
try
{
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_ok_message);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.setCancelable(false);
final TextView id_txt_title = dialog.findViewById(R.id.id_txt_title);
final TextView id_txt_message = dialog.findViewById(R.id.id_txt_message);
final Button id_btn_ok = dialog.findViewById(R.id.id_btn_ok);
id_txt_title.setText(title);
id_txt_message.setText(message);
id_btn_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
try
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.setPackage("com.android.vending");
context.startActivity(intent);
}
catch (Exception e)
{
String packageName = BuildConfig.APPLICATION_ID;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
context.startActivity(intent);
}
}
});
dialog.show();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
037b7b0df339d95443c7dc3e3d2c4588c432b4e4 | f2360d8132bdc4e8c2863f3a7f3ea18989538ee8 | /src/day50_inheritance03/FullTimeEmployee.java | 51ec547a0c01bcb2823c0f4635c4a26bad183beb | [] | no_license | SungHunBaek/java-project | 1d176184fc72e472661923a859f31766968fbe28 | cc720d79e559dc32a1c613afab9e9d4fb5e36834 | refs/heads/master | 2020-05-27T02:50:25.693321 | 2019-06-29T21:28:02 | 2019-06-29T21:28:02 | 188,456,995 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 246 | java | package day50_inheritance03;
public class FullTimeEmployee extends Employee{
@Override
public void calculatePay(int hours, double rate) {
double total = (hours*rate) * 1.05;
System.out.println("FullTimeEmployee total pay: " + total);
}
}
| [
"[email protected]"
] | |
9f2b67a35f82d7121d3dac1ef6c72dd204830c7e | f6cb132b079e1d17c61c4999afdf5dd6fd183479 | /src/main/java/com/zking/erp/base/controller/ReturnorderdetailController.java | a91f4ed34f1355bb382e6a269402b001d8471deb | [] | no_license | 1729979349/erp | e8812d92f04fb1b7eb2776a6d47de98ce6654edd | 7e5351b256848672129217eaf6519f8cfb503ce0 | refs/heads/master | 2023-02-22T09:32:49.323136 | 2021-01-20T13:31:38 | 2021-01-20T13:31:38 | 328,337,278 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 249 | java | package com.zking.erp.base.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/returnorderdetail")
public class ReturnorderdetailController {
}
| [
"[email protected]"
] | |
6daca2716047ee6789b94a10750a5243dc489f27 | ab52bb58aab8104c26db2a6690ec1986ac37dd62 | /main6/envoy/src/java/com/globalsight/everest/request/reimport/ReimporterException.java | e7cc8de22211d9f06b67a830fe734dd951438a60 | [] | no_license | tingley/globalsight | 32ae49ac08c671d9166bd0d6cdaa349d9e6b4438 | 47d95929f4e9939ba8bbbcb5544de357fef9aa8c | refs/heads/master | 2021-01-19T07:23:33.073276 | 2020-10-19T19:42:22 | 2020-10-19T19:42:22 | 14,053,692 | 7 | 6 | null | null | null | null | UTF-8 | Java | false | false | 3,103 | java | /**
* Copyright 2009 Welocalize, Inc.
*
* 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.globalsight.everest.request.reimport;
/*
* Copyright (c) 2001 GlobalSight Corporation. All rights reserved.
*
* THIS DOCUMENT CONTAINS TRADE SECRET DATA WHICH IS THE PROPERTY OF
* GLOBALSIGHT CORPORATION. THIS DOCUMENT IS SUBMITTED TO RECIPIENT
* IN CONFIDENCE. INFORMATION CONTAINED HEREIN MAY NOT BE USED, COPIED
* OR DISCLOSED IN WHOLE OR IN PART EXCEPT AS PERMITTED BY WRITTEN
* AGREEMENT SIGNED BY AN OFFICER OF GLOBALSIGHT CORPORATION.
*
* THIS MATERIAL IS ALSO COPYRIGHTED AS AN UNPUBLISHED WORK UNDER
* SECTIONS 104 AND 408 OF TITLE 17 OF THE UNITED STATES CODE.
* UNAUTHORIZED USE, COPYING OR OTHER REPRODUCTION IS PROHIBITED
* BY LAW.
*/
//globalsight
import com.globalsight.util.GeneralException;
/**
* This exception is thrown for any exception that is related to the
* internal working of the reimport component.
*/
public class ReimporterException extends GeneralException
{
// Reimport related messages are stored in the following property file
final static String PROPERTY_FILE_NAME = "ReimporterException";
// error in looking up other components
static final String MSG_FAILED_TO_FIND_JOB_HANDLER = "FailedToFindJobHandler";
static final String MSG_FAILED_TO_FIND_REQUEST_HANDLER = "FailedToFindRequestHandler";
static final String MSG_FAILED_TO_FIND_WORKFLOW_SERVER = "FailedToFindWorkflowServer";
static final String MSG_FAILED_TO_FIND_USER_MANAGER = "FailedToFindUserManager";
// arguments: 1: the request id
static final String MSG_FAILED_TO_DELAY_REIMPORT = "FailedToDelayReimport";
static final String MSG_FAILED_TO_FIND_JOB_OF_PAGE = "FailedToFindJobOfPage";
// this is one is only used on start-up
static final String MSG_FAILED_TO_LOAD_ALL_DELAYED_IMPORTS = "FailedToLoadAndStartImportingAllDelayedRequests";
// arguments: 1 - job id, 2 - job name, 3 - the previous page id, 4 - the external page id,
static final String MSG_FAILED_TO_CANCEL_JOB_OF_PREVIOUS_PAGE = "FailedToCancelJobOfPreviousPage";
/*
*
*/
public ReimporterException(String p_messageKey, String[] p_messageArguments, Exception p_originalException)
{
super(p_messageKey, p_messageArguments, p_originalException, PROPERTY_FILE_NAME);
}
/**
* Constructor where only the original exception is passed.
*/
public ReimporterException(Exception p_originalException)
{
super(p_originalException);
}
}
| [
"[email protected]"
] | |
0e9c254d173411aef9e32295987918dbc0f3500a | 89f04a8514ebd1d577deba5cb282b38fecbe01c6 | /library/src/main/java/com/mendeley/api/callbacks/folder/GetFoldersCallback.java | 1fa0efcda3b3a26dd6008a6a518ed196aa50cdcd | [
"Apache-2.0"
] | permissive | thirdiron/mendeley-android-sdk | c41b012dea0b4fa1fefda6caec14306a32a5712b | 16a79cca2afe84544f16f56baf709ba1fdf18b0b | refs/heads/master | 2021-01-15T21:07:38.665693 | 2016-01-07T22:57:05 | 2016-01-07T22:57:05 | 31,038,580 | 0 | 0 | null | 2015-02-19T21:45:28 | 2015-02-19T21:45:28 | null | UTF-8 | Java | false | false | 381 | java | package com.mendeley.api.callbacks.folder;
import com.mendeley.api.exceptions.MendeleyException;
import com.mendeley.api.model.Folder;
import com.mendeley.api.params.Page;
import java.util.List;
public interface GetFoldersCallback {
public void onFoldersReceived(List<Folder> folders, Page next);
public void onFoldersNotReceived(MendeleyException mendeleyException);
}
| [
"[email protected]"
] | |
d8277c7ce5f7669779de31fb3036a012ddd00a81 | 26ba1561e1804f90752535a7d5b498570312ed55 | /src/regex/bdNameFormat.java | ceb7db5e56b2b571187f653db04723e212bfaa0c | [] | no_license | nazrul-avash/JavaSE-Practise | 2ec84e0af492a315ddbbf168757d607038247e80 | 7ebe2c9ac033779efed6f52e693015c4b152aa38 | refs/heads/master | 2020-07-28T21:47:52.341769 | 2019-09-19T12:33:34 | 2019-09-19T12:33:34 | 209,549,243 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 653 | 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 prac;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Lenovo
*/
public class bdNameFormat {
public static void main(String afgs[]){
String s="a.m.m pfosy";
String regex="^[a-zA-Z]+ ?((\\.|-| )[a-zA-Z]+)*?$";
Pattern pat=Pattern.compile(regex);
Matcher match=pat.matcher(s);
if(match.matches()){
System.out.println("hallelujah");
}
else{
System.out.println("aint no bdeshi");
}
}
}
| [
"[email protected]"
] | |
90f6c8d5fd3c2cc74b0267ff313ff1d2dd75ecf6 | 3192b7a984ed59da652221d11bc2bdfaa1aede00 | /code/src/main/java/com/cmcu/mcc/five/dto/FiveOaRulelawexamineDto.java | d5ad62506ac274d45a4119c4adbcb4f0d1559c4e | [] | no_license | shanghaif/-wz- | e6f5eca1511f6d68c0cd6eb3c0f118e340d9ff50 | c7d6e8a000fbc4b6d8fed44cd5ffe483be45440c | refs/heads/main | 2023-06-08T22:35:30.125549 | 2021-04-30T07:03:21 | 2021-04-30T07:03:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 612 | java | package com.cmcu.mcc.five.dto;
import com.cmcu.mcc.five.entity.FiveOaRulelawexamine;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;
@Getter
@Setter
public class FiveOaRulelawexamineDto extends FiveOaRulelawexamine {
private String processName;
private String operateUserLogin;
private String attendUser;
private String finishTime;
public static FiveOaRulelawexamineDto adapt(FiveOaRulelawexamine item) {
FiveOaRulelawexamineDto dto = new FiveOaRulelawexamineDto();
BeanUtils.copyProperties(item, dto);
return dto;
}
}
| [
"[email protected]"
] | |
feb057e78df69f4e98ce37371b62655217214160 | ff14516865af602115f8366aad2913945fd60bf1 | /src/main/java/com/dithec/workshopmongo/domain/Post.java | 1c04fe27cb78c5729877722feac37dacb0a5b8e4 | [] | no_license | DinaelMiranda/spring-boot-mongodb | 9998d53e867f68fe31a1769767e0bcf153377c96 | be24d2cc922f7af484bb3149f9622b7608ef6b76 | refs/heads/master | 2023-03-24T00:09:41.567910 | 2021-03-29T19:15:37 | 2021-03-29T19:15:37 | 351,857,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,093 | java | package com.dithec.workshopmongo.domain;
import com.dithec.workshopmongo.dto.AuthorDTO;
import com.dithec.workshopmongo.dto.CommentDTO;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import javax.xml.crypto.Data;
import javax.xml.stream.events.Comment;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Document
public class Post implements Serializable {
@Id
private String id;
private Date data;
private String title;
private String body;
private AuthorDTO author;
private List<CommentDTO> comments = new ArrayList<>();
public Post() {
}
public Post(String id, Date data, String title, String body, AuthorDTO author) {
this.id = id;
this.data = data;
this.title = title;
this.body = body;
this.author = author;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getData() {
return data;
}
public void setData(Date data) {
this.data = data;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public AuthorDTO getAuthor() {
return author;
}
public void setAuthor(AuthorDTO author) {
this.author = author;
}
public List<CommentDTO> getComments() {
return comments;
}
public void setComments(List<CommentDTO> comments) {
this.comments = comments;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Post post = (Post) o;
return id.equals(post.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
| [
"[email protected]"
] | |
7dc8de239ce5502d50a9d24a54f3f08cf19121bc | a4a0979dd18d16d9a53d7f26f39044dda2a48f78 | /app/src/main/java/com/example/apple/lingyongqian/xianjindai/activity/WebViewActivity.java | e49ced0bd62575727dc0e3f95a84b03819f38c06 | [] | no_license | doubletan/51lingyongqian | 29ba57467c2cbd6820ae0eabcfeabae6415c7bd8 | 6c7e5301eafa1aaf7aa2333577a0e42a49999032 | refs/heads/master | 2021-08-22T13:49:46.949842 | 2017-11-30T10:30:48 | 2017-11-30T10:30:48 | 112,590,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,850 | java | package com.example.apple.lingyongqian.xianjindai.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.example.apple.lingyongqian.R;
import com.example.apple.lingyongqian.xianjindai.biz.update.UpdateService;
import com.example.apple.lingyongqian.xianjindai.util.DeviceUtil;
import com.umeng.analytics.MobclickAgent;
import cn.pedant.SweetAlert.SweetAlertDialog;
public class WebViewActivity extends Activity {
private WebView myWebView;
private ProgressBar bar;
private String myUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
// 初始化控件
initViews();
}
private void initViews() {
myWebView = (WebView) findViewById(R.id.my_web);
bar = (ProgressBar) findViewById(R.id.common_web_bar);
Intent intent = getIntent();
myUrl = intent.getStringExtra("url");
// 设置WebView属性,能够执行Javascript脚本
myWebView.getSettings().setJavaScriptEnabled(true);// 是否允许执行js,默认为false。设置true时,会提醒可能造成XSS漏洞
// 有些网页webview不能加载
myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);// 设置js可以直接打开窗口,如window.open(),默认为false
myWebView.getSettings().setSupportZoom(true);// 是否可以缩放,默认true
myWebView.getSettings().setBuiltInZoomControls(true);// 是否显示缩放按钮,默认false
myWebView.getSettings().setUseWideViewPort(true);// 设置此属性,可任意比例缩放。大视图模式
myWebView.getSettings().setLoadWithOverviewMode(true);// 和setUseWideViewPort(true)一起解决网页自适应问题
myWebView.getSettings().setAppCacheEnabled(true);// 是否使用缓存
myWebView.getSettings().setDomStorageEnabled(true);// DOM Storage
// myWebView.getSettings().setUseWideViewPort(true);
// myWebView.getSettings().setDatabaseEnabled(true);
// myWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
// myWebView.getSettings().setBlockNetworkImage(true);
// myWebView.getSettings().setAllowFileAccess(true);
// myWebView.getSettings().setSaveFormData(false);
// myWebView.getSettings().setLoadsImagesAutomatically(true);
/**
* 设置获取位置
*/
//启用数据库
myWebView.getSettings().setDatabaseEnabled(true);
//设置定位的数据库路径
String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
myWebView.getSettings().setGeolocationDatabasePath(dir);
//启用地理定位
myWebView.getSettings().setGeolocationEnabled(true);
//开启DomStorage缓存
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setWebChromeClient(new WebChromeClient() {
//加载进度
@Override
public void onProgressChanged(WebView view, int newProgress) {
// TODO 自动生成的方法存根
if (newProgress == 100) {
bar.setVisibility(View.GONE);//加载完网页进度条消失
} else {
bar.setVisibility(View.VISIBLE);//开始加载网页时显示进度条
bar.setProgress(newProgress);//设置进度值
}
}
//获取位置
@Override
public void onGeolocationPermissionsShowPrompt(String origin,GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
super.onGeolocationPermissionsShowPrompt(origin, callback);
}
});
myWebView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(final String url, String userAgent, String contentDisposition, String mimetype,
long contentLength) {
if (url.endsWith(".apk")) {//判断是否是.apk结尾的文件路径
if (DeviceUtil.isWifiAvailable(WebViewActivity.this)) {
UpdateService.Builder.create(url).build(WebViewActivity.this);
} else {
final AlertDialog alertDialog = new AlertDialog.Builder(WebViewActivity.this).create();
alertDialog.setCancelable(false);
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
Window window = alertDialog.getWindow();
window.setContentView(R.layout.integral_exchange_tips1);
TextView tv1 = (TextView) window.findViewById(R.id.integral_exchange_tips1_tv);
tv1.setText("亲,您现在是非wifi状态下,确定要下载吗?");
RelativeLayout rl2 = (RelativeLayout) window.findViewById(R.id.integral_exchange_tips1_rl1);
RelativeLayout rl3 = (RelativeLayout) window.findViewById(R.id.integral_exchange_tips1_rl2);
rl2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.dismiss();
}
});
rl3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UpdateService.Builder.create(url).build(WebViewActivity.this);
alertDialog.dismiss();
}
});
}
}
}
});
myWebView.setWebViewClient(new MyWebViewClient());
if (!DeviceUtil.IsNetWork(this)){
new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
.setTitleText("网络异常,请检查网络")
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
finish();
}
})
.show();
}else{
myWebView.loadUrl(myUrl);
}
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("platformapi/startapp")) {
try {
Intent intent;
intent = Intent.parseUri(url,
Intent.URI_INTENT_SCHEME);
intent.addCategory("android.intent.category.BROWSABLE");
intent.setComponent(null);
// intent.setSelector(null);
startActivity(intent);
} catch (Exception e) {
Toast.makeText(WebViewActivity.this, "请安装最新版支付宝", Toast.LENGTH_SHORT).show();
}
} else if (url.contains("weixin://wap/pay?")) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (Exception e) {
Toast.makeText(WebViewActivity.this, "请安装最新版微信", Toast.LENGTH_SHORT).show();
}
} else if (url.contains("mqqapi://forward/url?")) {
try {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} catch (Exception e) {
Toast.makeText(WebViewActivity.this, "请安装最新版QQ", Toast.LENGTH_SHORT).show();
}
} else if (!(url.contains("http://") || url.contains("https://"))) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} else {
view.loadUrl(url);
}
return true;
}
}
public void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
public void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {
myWebView.goBack(); // goBack()表示返回WebView的上一页面
return true;
} else if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
}
return false;
}
@Override
protected void onDestroy() {
super.onDestroy();
myWebView.destroy();
}
}
| [
"[email protected]"
] | |
dcb2b83d6a1201c9affda2097ff0729611722ea9 | 7df40f6ea2209b7d48979465fd8081ec2ad198cc | /TOOLS/server/com/sun/xml/bind/v2/model/core/LeafInfo.java | 20c18e41e2d50de047c165c48569d57fb58a6be6 | [
"IJG"
] | permissive | warchiefmarkus/WurmServerModLauncher-0.43 | d513810045c7f9aebbf2ec3ee38fc94ccdadd6db | 3e9d624577178cd4a5c159e8f61a1dd33d9463f6 | refs/heads/master | 2021-09-27T10:11:56.037815 | 2021-09-19T16:23:45 | 2021-09-19T16:23:45 | 252,689,028 | 0 | 0 | null | 2021-09-19T16:53:10 | 2020-04-03T09:33:50 | Java | UTF-8 | Java | false | false | 280 | java | package com.sun.xml.bind.v2.model.core;
public interface LeafInfo<T, C> extends MaybeElement<T, C> {}
/* Location: C:\Users\leo\Desktop\server.jar!\com\sun\xml\bind\v2\model\core\LeafInfo.class
* Java compiler version: 5 (49.0)
* JD-Core Version: 1.1.3
*/ | [
"[email protected]"
] | |
f2ae1f8ae9516916b861a0c0cc8ed1c352fd3a8b | 58fd1157f6a79613fad78f474ac6d0f8db871af9 | /packages/furo-specs/build/java/taskmanager/UpdateExperimentServiceRequestOrBuilder.java | 97abb10658e70befd62ce3926f427b0721348424 | [
"MIT"
] | permissive | btopro/FuroBaseComponents | 2118939cd22c11bff319d37e74515082e360dc82 | 264b24209f2c65a6a269c50625938e78f83e5cae | refs/heads/master | 2022-03-22T15:22:08.251192 | 2019-11-13T12:19:02 | 2019-11-13T12:19:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | true | 846 | java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: __bundled/BundledService.proto
package taskmanager;
public interface UpdateExperimentServiceRequestOrBuilder extends
// @@protoc_insertion_point(interface_extends:taskmanager.UpdateExperimentServiceRequest)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string exp = 1;</code>
*/
java.lang.String getExp();
/**
* <code>string exp = 1;</code>
*/
com.google.protobuf.ByteString
getExpBytes();
/**
* <code>.experiment.Experiment data = 2;</code>
*/
boolean hasData();
/**
* <code>.experiment.Experiment data = 2;</code>
*/
experiment.ExperimentOuterClass.Experiment getData();
/**
* <code>.experiment.Experiment data = 2;</code>
*/
experiment.ExperimentOuterClass.ExperimentOrBuilder getDataOrBuilder();
}
| [
"[email protected]"
] | |
49b725d63bdf478a33de2b6114f2f36a49ccdc40 | f4b08701ccf4acd17b09ec429452100d4977ce18 | /antlr3/gunit/target/generated-sources/antlr3/org/antlr/gunit/swingui/parsers/StGUnitParser.java | 20877a839eb353154abec6bedd95425012d8f8b4 | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause"
] | permissive | rhacking/antlr3-haxe | 139fb2d3decd2a1aeccc256dc1a64d304b1ec9e6 | 08ea8a8caafe4b2aa2cf8bcdaffb5899bd11e72e | refs/heads/master | 2020-06-26T14:34:38.760084 | 2017-07-12T21:15:06 | 2017-07-12T21:15:06 | 97,026,169 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,543 | java | // $ANTLR 3.5.3-SNAPSHOT org/antlr/gunit/swingui/parsers/StGUnit.g 2017-06-11 18:43:44
package org.antlr.gunit.swingui.parsers;
import org.antlr.gunit.swingui.model.*;
import org.antlr.gunit.swingui.runner.*;
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
@SuppressWarnings("all")
public class StGUnitParser extends Parser {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "ACTION", "AST", "CHAR_LITERAL",
"DOC_COMMENT", "ESC", "EXT", "FAIL", "ML_COMMENT", "ML_STRING", "NESTED_ACTION",
"NESTED_AST", "NESTED_RETVAL", "OK", "RETVAL", "RULE_REF", "SL_COMMENT",
"STRING", "STRING_LITERAL", "TOKEN_REF", "WS", "XDIGIT", "'->'", "':'",
"';'", "'@header'", "'gunit'", "'returns'", "'walks'"
};
public static final int EOF=-1;
public static final int T__25=25;
public static final int T__26=26;
public static final int T__27=27;
public static final int T__28=28;
public static final int T__29=29;
public static final int T__30=30;
public static final int T__31=31;
public static final int ACTION=4;
public static final int AST=5;
public static final int CHAR_LITERAL=6;
public static final int DOC_COMMENT=7;
public static final int ESC=8;
public static final int EXT=9;
public static final int FAIL=10;
public static final int ML_COMMENT=11;
public static final int ML_STRING=12;
public static final int NESTED_ACTION=13;
public static final int NESTED_AST=14;
public static final int NESTED_RETVAL=15;
public static final int OK=16;
public static final int RETVAL=17;
public static final int RULE_REF=18;
public static final int SL_COMMENT=19;
public static final int STRING=20;
public static final int STRING_LITERAL=21;
public static final int TOKEN_REF=22;
public static final int WS=23;
public static final int XDIGIT=24;
// delegates
public Parser[] getDelegates() {
return new Parser[] {};
}
// delegators
public StGUnitParser(TokenStream input) {
this(input, new RecognizerSharedState());
}
public StGUnitParser(TokenStream input, RecognizerSharedState state) {
super(input, state);
}
@Override public String[] getTokenNames() { return StGUnitParser.tokenNames; }
@Override public String getGrammarFileName() { return "org/antlr/gunit/swingui/parsers/StGUnit.g"; }
public TestSuiteAdapter adapter ;;
// $ANTLR start "gUnitDef"
// org/antlr/gunit/swingui/parsers/StGUnit.g:52:1: gUnitDef : 'gunit' name= id ( 'walks' id )? ';' ( header )? ( suite )* ;
public final void gUnitDef() throws RecognitionException {
ParserRuleReturnScope name =null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:53:2: ( 'gunit' name= id ( 'walks' id )? ';' ( header )? ( suite )* )
// org/antlr/gunit/swingui/parsers/StGUnit.g:53:4: 'gunit' name= id ( 'walks' id )? ';' ( header )? ( suite )*
{
match(input,29,FOLLOW_29_in_gUnitDef68);
pushFollow(FOLLOW_id_in_gUnitDef72);
name=id();
state._fsp--;
adapter.setGrammarName((name!=null?input.toString(name.start,name.stop):null));
// org/antlr/gunit/swingui/parsers/StGUnit.g:54:6: ( 'walks' id )?
int alt1=2;
int LA1_0 = input.LA(1);
if ( (LA1_0==31) ) {
alt1=1;
}
switch (alt1) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:54:7: 'walks' id
{
match(input,31,FOLLOW_31_in_gUnitDef82);
pushFollow(FOLLOW_id_in_gUnitDef84);
id();
state._fsp--;
}
break;
}
match(input,27,FOLLOW_27_in_gUnitDef88);
// org/antlr/gunit/swingui/parsers/StGUnit.g:55:3: ( header )?
int alt2=2;
int LA2_0 = input.LA(1);
if ( (LA2_0==28) ) {
alt2=1;
}
switch (alt2) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:55:3: header
{
pushFollow(FOLLOW_header_in_gUnitDef93);
header();
state._fsp--;
}
break;
}
// org/antlr/gunit/swingui/parsers/StGUnit.g:55:11: ( suite )*
loop3:
while (true) {
int alt3=2;
int LA3_0 = input.LA(1);
if ( (LA3_0==RULE_REF||LA3_0==TOKEN_REF) ) {
alt3=1;
}
switch (alt3) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:55:11: suite
{
pushFollow(FOLLOW_suite_in_gUnitDef96);
suite();
state._fsp--;
}
break;
default :
break loop3;
}
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "gUnitDef"
// $ANTLR start "header"
// org/antlr/gunit/swingui/parsers/StGUnit.g:58:1: header : '@header' ACTION ;
public final void header() throws RecognitionException {
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:59:2: ( '@header' ACTION )
// org/antlr/gunit/swingui/parsers/StGUnit.g:59:4: '@header' ACTION
{
match(input,28,FOLLOW_28_in_header108);
match(input,ACTION,FOLLOW_ACTION_in_header110);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "header"
// $ANTLR start "suite"
// org/antlr/gunit/swingui/parsers/StGUnit.g:62:1: suite : (parserRule= RULE_REF ( 'walks' RULE_REF )? |lexerRule= TOKEN_REF ) ':' ( test )+ ;
public final void suite() throws RecognitionException {
Token parserRule=null;
Token lexerRule=null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:2: ( (parserRule= RULE_REF ( 'walks' RULE_REF )? |lexerRule= TOKEN_REF ) ':' ( test )+ )
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:4: (parserRule= RULE_REF ( 'walks' RULE_REF )? |lexerRule= TOKEN_REF ) ':' ( test )+
{
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:4: (parserRule= RULE_REF ( 'walks' RULE_REF )? |lexerRule= TOKEN_REF )
int alt5=2;
int LA5_0 = input.LA(1);
if ( (LA5_0==RULE_REF) ) {
alt5=1;
}
else if ( (LA5_0==TOKEN_REF) ) {
alt5=2;
}
else {
NoViableAltException nvae =
new NoViableAltException("", 5, 0, input);
throw nvae;
}
switch (alt5) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:6: parserRule= RULE_REF ( 'walks' RULE_REF )?
{
parserRule=(Token)match(input,RULE_REF,FOLLOW_RULE_REF_in_suite127);
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:26: ( 'walks' RULE_REF )?
int alt4=2;
int LA4_0 = input.LA(1);
if ( (LA4_0==31) ) {
alt4=1;
}
switch (alt4) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:63:27: 'walks' RULE_REF
{
match(input,31,FOLLOW_31_in_suite130);
match(input,RULE_REF,FOLLOW_RULE_REF_in_suite132);
}
break;
}
adapter.startRule((parserRule!=null?parserRule.getText():null));
}
break;
case 2 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:65:5: lexerRule= TOKEN_REF
{
lexerRule=(Token)match(input,TOKEN_REF,FOLLOW_TOKEN_REF_in_suite154);
adapter.startRule((lexerRule!=null?lexerRule.getText():null));
}
break;
}
match(input,26,FOLLOW_26_in_suite168);
// org/antlr/gunit/swingui/parsers/StGUnit.g:69:3: ( test )+
int cnt6=0;
loop6:
while (true) {
int alt6=2;
switch ( input.LA(1) ) {
case RULE_REF:
{
int LA6_2 = input.LA(2);
if ( ((LA6_2 >= EXT && LA6_2 <= FAIL)||LA6_2==OK||LA6_2==25||LA6_2==30) ) {
alt6=1;
}
}
break;
case TOKEN_REF:
{
int LA6_3 = input.LA(2);
if ( ((LA6_3 >= EXT && LA6_3 <= FAIL)||LA6_3==OK||LA6_3==25||LA6_3==30) ) {
alt6=1;
}
}
break;
case ML_STRING:
case STRING:
{
alt6=1;
}
break;
}
switch (alt6) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:69:3: test
{
pushFollow(FOLLOW_test_in_suite172);
test();
state._fsp--;
}
break;
default :
if ( cnt6 >= 1 ) break loop6;
EarlyExitException eee = new EarlyExitException(6, input);
throw eee;
}
cnt6++;
}
adapter.endRule();
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "suite"
// $ANTLR start "test"
// org/antlr/gunit/swingui/parsers/StGUnit.g:73:1: test : input expect ;
public final void test() throws RecognitionException {
ITestCaseInput input1 =null;
ITestCaseOutput expect2 =null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:74:2: ( input expect )
// org/antlr/gunit/swingui/parsers/StGUnit.g:74:4: input expect
{
pushFollow(FOLLOW_input_in_test188);
input1=input();
state._fsp--;
pushFollow(FOLLOW_expect_in_test190);
expect2=expect();
state._fsp--;
adapter.addTestCase(input1, expect2);
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
}
// $ANTLR end "test"
// $ANTLR start "expect"
// org/antlr/gunit/swingui/parsers/StGUnit.g:78:1: expect returns [ITestCaseOutput out] : ( OK | FAIL | 'returns' RETVAL | '->' output | '->' AST );
public final ITestCaseOutput expect() throws RecognitionException {
ITestCaseOutput out = null;
Token RETVAL3=null;
Token AST5=null;
ParserRuleReturnScope output4 =null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:79:2: ( OK | FAIL | 'returns' RETVAL | '->' output | '->' AST )
int alt7=5;
switch ( input.LA(1) ) {
case OK:
{
alt7=1;
}
break;
case FAIL:
{
alt7=2;
}
break;
case 30:
{
alt7=3;
}
break;
case 25:
{
int LA7_4 = input.LA(2);
if ( (LA7_4==AST) ) {
alt7=5;
}
else if ( (LA7_4==ACTION||LA7_4==ML_STRING||LA7_4==STRING) ) {
alt7=4;
}
else {
int nvaeMark = input.mark();
try {
input.consume();
NoViableAltException nvae =
new NoViableAltException("", 7, 4, input);
throw nvae;
} finally {
input.rewind(nvaeMark);
}
}
}
break;
default:
NoViableAltException nvae =
new NoViableAltException("", 7, 0, input);
throw nvae;
}
switch (alt7) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:79:4: OK
{
match(input,OK,FOLLOW_OK_in_expect210);
out = TestSuiteAdapter.createBoolOutput(true);
}
break;
case 2 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:80:4: FAIL
{
match(input,FAIL,FOLLOW_FAIL_in_expect219);
out = TestSuiteAdapter.createBoolOutput(false);
}
break;
case 3 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:81:4: 'returns' RETVAL
{
match(input,30,FOLLOW_30_in_expect227);
RETVAL3=(Token)match(input,RETVAL,FOLLOW_RETVAL_in_expect229);
out = TestSuiteAdapter.createReturnOutput((RETVAL3!=null?RETVAL3.getText():null));
}
break;
case 4 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:82:4: '->' output
{
match(input,25,FOLLOW_25_in_expect236);
pushFollow(FOLLOW_output_in_expect238);
output4=output();
state._fsp--;
out = TestSuiteAdapter.createStdOutput((output4!=null?input.toString(output4.start,output4.stop):null));
}
break;
case 5 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:83:4: '->' AST
{
match(input,25,FOLLOW_25_in_expect245);
AST5=(Token)match(input,AST,FOLLOW_AST_in_expect247);
out = TestSuiteAdapter.createAstOutput((AST5!=null?AST5.getText():null));
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return out;
}
// $ANTLR end "expect"
// $ANTLR start "input"
// org/antlr/gunit/swingui/parsers/StGUnit.g:86:1: input returns [ITestCaseInput in] : ( STRING | ML_STRING | fileInput );
public final ITestCaseInput input() throws RecognitionException {
ITestCaseInput in = null;
Token STRING6=null;
Token ML_STRING7=null;
String fileInput8 =null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:87:2: ( STRING | ML_STRING | fileInput )
int alt8=3;
switch ( input.LA(1) ) {
case STRING:
{
alt8=1;
}
break;
case ML_STRING:
{
alt8=2;
}
break;
case RULE_REF:
case TOKEN_REF:
{
alt8=3;
}
break;
default:
NoViableAltException nvae =
new NoViableAltException("", 8, 0, input);
throw nvae;
}
switch (alt8) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:87:4: STRING
{
STRING6=(Token)match(input,STRING,FOLLOW_STRING_in_input264);
in = TestSuiteAdapter.createStringInput((STRING6!=null?STRING6.getText():null));
}
break;
case 2 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:88:4: ML_STRING
{
ML_STRING7=(Token)match(input,ML_STRING,FOLLOW_ML_STRING_in_input273);
in = TestSuiteAdapter.createMultiInput((ML_STRING7!=null?ML_STRING7.getText():null));
}
break;
case 3 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:89:4: fileInput
{
pushFollow(FOLLOW_fileInput_in_input280);
fileInput8=fileInput();
state._fsp--;
in = TestSuiteAdapter.createFileInput(fileInput8);
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return in;
}
// $ANTLR end "input"
public static class output_return extends ParserRuleReturnScope {
};
// $ANTLR start "output"
// org/antlr/gunit/swingui/parsers/StGUnit.g:92:1: output : ( STRING | ML_STRING | ACTION );
public final StGUnitParser.output_return output() throws RecognitionException {
StGUnitParser.output_return retval = new StGUnitParser.output_return();
retval.start = input.LT(1);
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:93:2: ( STRING | ML_STRING | ACTION )
// org/antlr/gunit/swingui/parsers/StGUnit.g:
{
if ( input.LA(1)==ACTION||input.LA(1)==ML_STRING||input.LA(1)==STRING ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
retval.stop = input.LT(-1);
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return retval;
}
// $ANTLR end "output"
// $ANTLR start "fileInput"
// org/antlr/gunit/swingui/parsers/StGUnit.g:98:1: fileInput returns [String path] : id ( EXT )? ;
public final String fileInput() throws RecognitionException {
String path = null;
Token EXT10=null;
ParserRuleReturnScope id9 =null;
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:99:2: ( id ( EXT )? )
// org/antlr/gunit/swingui/parsers/StGUnit.g:99:4: id ( EXT )?
{
pushFollow(FOLLOW_id_in_fileInput319);
id9=id();
state._fsp--;
path = (id9!=null?input.toString(id9.start,id9.stop):null);
// org/antlr/gunit/swingui/parsers/StGUnit.g:99:27: ( EXT )?
int alt9=2;
int LA9_0 = input.LA(1);
if ( (LA9_0==EXT) ) {
alt9=1;
}
switch (alt9) {
case 1 :
// org/antlr/gunit/swingui/parsers/StGUnit.g:99:28: EXT
{
EXT10=(Token)match(input,EXT,FOLLOW_EXT_in_fileInput324);
path += (EXT10!=null?EXT10.getText():null);
}
break;
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return path;
}
// $ANTLR end "fileInput"
public static class id_return extends ParserRuleReturnScope {
};
// $ANTLR start "id"
// org/antlr/gunit/swingui/parsers/StGUnit.g:102:1: id : ( TOKEN_REF | RULE_REF );
public final StGUnitParser.id_return id() throws RecognitionException {
StGUnitParser.id_return retval = new StGUnitParser.id_return();
retval.start = input.LT(1);
try {
// org/antlr/gunit/swingui/parsers/StGUnit.g:102:5: ( TOKEN_REF | RULE_REF )
// org/antlr/gunit/swingui/parsers/StGUnit.g:
{
if ( input.LA(1)==RULE_REF||input.LA(1)==TOKEN_REF ) {
input.consume();
state.errorRecovery=false;
}
else {
MismatchedSetException mse = new MismatchedSetException(null,input);
throw mse;
}
}
retval.stop = input.LT(-1);
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return retval;
}
// $ANTLR end "id"
// Delegated rules
public static final BitSet FOLLOW_29_in_gUnitDef68 = new BitSet(new long[]{0x0000000000440000L});
public static final BitSet FOLLOW_id_in_gUnitDef72 = new BitSet(new long[]{0x0000000088000000L});
public static final BitSet FOLLOW_31_in_gUnitDef82 = new BitSet(new long[]{0x0000000000440000L});
public static final BitSet FOLLOW_id_in_gUnitDef84 = new BitSet(new long[]{0x0000000008000000L});
public static final BitSet FOLLOW_27_in_gUnitDef88 = new BitSet(new long[]{0x0000000010440002L});
public static final BitSet FOLLOW_header_in_gUnitDef93 = new BitSet(new long[]{0x0000000000440002L});
public static final BitSet FOLLOW_suite_in_gUnitDef96 = new BitSet(new long[]{0x0000000000440002L});
public static final BitSet FOLLOW_28_in_header108 = new BitSet(new long[]{0x0000000000000010L});
public static final BitSet FOLLOW_ACTION_in_header110 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_RULE_REF_in_suite127 = new BitSet(new long[]{0x0000000084000000L});
public static final BitSet FOLLOW_31_in_suite130 = new BitSet(new long[]{0x0000000000040000L});
public static final BitSet FOLLOW_RULE_REF_in_suite132 = new BitSet(new long[]{0x0000000004000000L});
public static final BitSet FOLLOW_TOKEN_REF_in_suite154 = new BitSet(new long[]{0x0000000004000000L});
public static final BitSet FOLLOW_26_in_suite168 = new BitSet(new long[]{0x0000000000541000L});
public static final BitSet FOLLOW_test_in_suite172 = new BitSet(new long[]{0x0000000000541002L});
public static final BitSet FOLLOW_input_in_test188 = new BitSet(new long[]{0x0000000042010400L});
public static final BitSet FOLLOW_expect_in_test190 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_OK_in_expect210 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_FAIL_in_expect219 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_30_in_expect227 = new BitSet(new long[]{0x0000000000020000L});
public static final BitSet FOLLOW_RETVAL_in_expect229 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_25_in_expect236 = new BitSet(new long[]{0x0000000000101010L});
public static final BitSet FOLLOW_output_in_expect238 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_25_in_expect245 = new BitSet(new long[]{0x0000000000000020L});
public static final BitSet FOLLOW_AST_in_expect247 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_STRING_in_input264 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_ML_STRING_in_input273 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_fileInput_in_input280 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_id_in_fileInput319 = new BitSet(new long[]{0x0000000000000202L});
public static final BitSet FOLLOW_EXT_in_fileInput324 = new BitSet(new long[]{0x0000000000000002L});
}
| [
"[email protected]"
] | |
7e6be4ca69d8bf79997a0cafb17dfd1860b02a8e | e26451c8da43b9cc40a0a66f2b8614f30e8290df | /FindMyOrderCourier/app/src/androidTest/java/com/example/stahi/findmyordercourier/ExampleInstrumentedTest.java | fdb27a00ea484f4264c6af2acfede80332300fed | [] | no_license | AlexandruStahie/FindMyOrder | a1d1a9692b5cf97c4d2f399d6ee044bd2017006f | 1e1af55bbfb3e3b51a8859aafe6859e785e87bb2 | refs/heads/master | 2020-05-02T15:43:54.386321 | 2019-03-27T18:24:56 | 2019-03-27T18:24:56 | 177,622,824 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 756 | java | package com.example.stahi.findmyordercourier;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.stahi.findmyordercourier", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
bd297dccaeaace5a778056b6ae5e8eb384e13854 | 8f9a26c52b8a073e882a9169639a441379dd6162 | /app/src/main/java/com/guoxun/pajs/widget/BaseEditText.java | 324e4f7748873def7245111156f49f5b0721068c | [] | no_license | JayGengi/quick_coding | 7043686d2fdd3daa49d86cda10c7c9d527530e8b | 20e535d129b85cb68506c9269cd5846985463e2e | refs/heads/master | 2021-07-18T03:36:26.964367 | 2020-05-25T03:09:06 | 2020-05-25T03:09:06 | 159,299,147 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,568 | java | package com.guoxun.pajs.widget;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.appcompat.widget.AppCompatEditText;
import com.guoxun.pajs.R;
/**
* Created by JayGengi on 2017/5/12.
*/
public class BaseEditText extends AppCompatEditText implements View.OnFocusChangeListener,TextWatcher{
//EditText右侧的删除按钮
private Drawable mClearDrawable;
private boolean hasFoucs;
private boolean clearVisible = true;
private boolean isShowNull = true;
public static Typeface baseTypeface;
//"fonts/base.ttf"
public static void typeface(Context context,String pathName) {
try{
if(!"".equals(pathName)&&pathName!=null){
baseTypeface = Typeface.createFromAsset(context.getAssets(),pathName);
}
}catch (Exception e){
e.printStackTrace();
}
}
public BaseEditText(Context context) {
this(context, null);
}
public BaseEditText(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.editTextStyle);
}
public BaseEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
// 获取EditText的DrawableRight,假如没有设置就使用默认的图片,获取图片的顺序是左上右下(0,1,2,3,)
mClearDrawable = getCompoundDrawables()[2];
if (mClearDrawable == null) {
mClearDrawable = getResources().getDrawable(
R.mipmap.edit_delete);
}
ViewTreeObserver vto = getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
mClearDrawable.setBounds(-10, 0, (int)(getHeight()*0.5f),(int)(getHeight()*0.5f)+10);
// 默认设置隐藏图标
setClearIconVisible(false);
}
});
// mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(),
// mClearDrawable.getIntrinsicHeight());
// 默认设置隐藏图标
setClearIconVisible(false);
// 设置焦点改变的监听
setOnFocusChangeListener(this);
// 设置输入框里面内容发生改变的监听
addTextChangedListener(this);
if(baseTypeface!=null){
setTypeface(baseTypeface);
}
}
public void setText(String content){
if(content==null){
if(isShowNull){
content="null";
}
}
super.setText(content);
}
/* @说明:isInnerWidth, isInnerHeight为ture,触摸点在删除图标之内,则视为点击了删除图标
* event.getX() 获取相对应自身左上角的X坐标
* event.getY() 获取相对应自身左上角的Y坐标
* getWidth() 获取控件的宽度
* getHeight() 获取控件的高度
* getTotalPaddingRight() 获取删除图标左边缘到控件右边缘的距离
* getPaddingRight() 获取删除图标右边缘到控件右边缘的距离
* isInnerWidth:
* getWidth() - getTotalPaddingRight() 计算删除图标左边缘到控件左边缘的距离
* getWidth() - getPaddingRight() 计算删除图标右边缘到控件左边缘的距离
* isInnerHeight:
* distance 删除图标顶部边缘到控件顶部边缘的距离
* distance + height 删除图标底部边缘到控件顶部边缘的距离
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (getCompoundDrawables()[2] != null) {
int x = (int) event.getX();
int y = (int) event.getY();
Rect rect = getCompoundDrawables()[2].getBounds();
int height = rect.height();
int distance = (getHeight() - height) / 2;
boolean isInnerWidth = x > (getWidth() - getTotalPaddingRight()) && x < (getWidth() - getPaddingRight());
boolean isInnerHeight = y > distance && y < (distance + height);
if (isInnerWidth && isInnerHeight) {
this.setText("");
}
}
}
return super.onTouchEvent(event);
}
/**
* 当ClearEditText焦点发生变化的时候,
* 输入长度为零,隐藏删除图标,否则,显示删除图标
*/
@Override
public void onFocusChange(View v, boolean hasFocus) {
this.hasFoucs = hasFocus;
if (hasFocus) {
setSelection(getText().length());//将光标移动到最后
if(clearVisible){
setClearIconVisible(getText().length() > 0);
}
} else {
setClearIconVisible(false);
}
}
protected void setClearIconVisible(boolean visible) {
Drawable right = visible ? mClearDrawable : null;
setCompoundDrawables(getCompoundDrawables()[0],
getCompoundDrawables()[1], right, getCompoundDrawables()[3]);
}
@Override
public void onTextChanged(CharSequence s, int start, int count, int after) {
if (hasFoucs) {
if(clearVisible){
setClearIconVisible(s.length() > 0);
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
public boolean isClearVisible() {
return clearVisible;
}
public void setClearVisible(boolean clearVisible) {
this.clearVisible = clearVisible;
}
public boolean isShowNull() {
return isShowNull;
}
public void setShowNull(boolean showNull) {
isShowNull = showNull;
}
} | [
"[email protected]"
] | |
f504212f74ab35e98b493d4aac8b4707f4c2d85a | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/jdbi/testing/137/LoggableSetObjectArgument.java | 5c62b1de69dc40d1f009eafb6fea74a352992aac | [] | no_license | ASSERT-KTH/synthetic-checkstyle-error-dataset | 40e8d1e0a7ebe7f7711def96a390891a6922f7bd | 40c057e1669584bfc6fecf789b5b2854660222f3 | refs/heads/master | 2023-03-18T12:50:55.410343 | 2019-01-25T09:54:39 | 2019-01-25T09:54:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,380 | java | /*
* 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.jdbi.v3.core.argument.internal.strategies;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.jdbi.v3.core.statement.StatementContext;
// TODO unify with ObjectArgument?
public class LoggableSetObjectArgument<T> extends AbstractLoggableArgument<T> {
private final Integer sqlType;
public LoggableSetObjectArgument(T value) {
super(value);
this.sqlType = null;
}
public LoggableSetObjectArgument(T value, int sqlType) {
super(value);
this.sqlType = sqlType;
}
@Override
public void apply(int pos, PreparedStatement stmt, StatementContext ctx) throws SQLException {
if (sqlType == null) {
stmt.setObject(pos, value);
} else {
stmt.setObject(pos, value, sqlType);
}
}
}
| [
"[email protected]"
] | |
f12273d4a9b42019a9bcd3296513c24a30a06eb5 | 83b3391975c4f673cb39e4486ce4abf07e2fb7ac | /Spring4MVC/src/main/java/com/websystique/springmvc/dao/CoursesDao.java | 4efc5e662080b6471520249928a6f8329dcb02e0 | [
"Apache-2.0"
] | permissive | ReaKar/Thesis-Spring4MVC | b6258e5ed22d3e441779ca67592eef302b5d7577 | 26cd5fa6a894c08e2f6b975e0076a38a0d8970f6 | refs/heads/master | 2021-05-07T06:23:22.945615 | 2017-11-22T23:20:58 | 2017-11-22T23:20:58 | 111,748,613 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 417 | java | package com.websystique.springmvc.dao;
import java.util.List;
import com.websystique.springmvc.model.Courses;
public interface CoursesDao {
Courses findById(int idCourse);
Courses findByTitle(String title);
void save(Courses course);
void deleteById(int idCourse);
void activeCourse(int idCourse);
List<Courses> findAllCourses();
List<Courses> findAll();
List<Courses> findActiveCourses();
}
| [
"[email protected]"
] | |
dc5bba513f6e2a27bbcb1094461fba478434199c | f0d067319947746e76a39cc2b1deee1ac989224e | /FinalTest/src/FrontController/BoardFrontController.java | 1d53245fd3bec941e9ac98977c822769d5a1018b | [] | no_license | gudals6676/Jsp-Servlet | bec5f0d27eed6cfc82129b34cba149906e9355d0 | 1cd92b75d591b1af75c6d12702fa9a2b63889fb8 | refs/heads/main | 2023-05-31T10:56:11.452612 | 2021-07-02T00:09:18 | 2021-07-02T00:09:18 | 368,399,764 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,889 | java | package FrontController;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.LoginDAOMybatis;
import web.Controller;
@WebServlet("*.go") //전체 매핑
// FrontController 패턴
public class BoardFrontController extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// 1.클라이언트가 어떤요청을 했는지 알아보는 것
request.setCharacterEncoding("utf-8");
String reqUrl = request.getRequestURI();
System.out.println(reqUrl);
String reqPath = request.getContextPath(); // /MVC02
System.out.println(reqPath);
String command = reqUrl.substring(reqPath.length()); // 앞에 MVC02 점프하고 뒷부분만 출력
System.out.println(command);
// 2.요청에따른 분기작업(if~ else if~)
LoginDAOMybatis dao = new LoginDAOMybatis();
String view = null;
Controller controller = null;
// HandlerMapping(핸들러매핑)
HandlerMapping mappings = new HandlerMapping();
controller = mappings.getController(command);
//------------------분기작업-------------------------
view = controller.requestHandler(request, response);
if (view!=null) {
if(view.indexOf("redirect:/")!=-1) { //-1은 없는것
response.sendRedirect(view.split(":/")[1]); //redirect:/list.do
//System.out.println(view.split(":/")[1]+1);
}else { // ViewResolver
//RequestDispatcher rd = request.getRequestDispatcher(ViewResolver.makeUrl(view));//"/WEB-INF/views/Boardlist.jsp";
//rd.forward(request, response);
}
}
}
}
| [
"[email protected]"
] | |
ba2e906a223bfa551244bfedc2091ea7184f921c | 10dce27ab81a96732ae53ae12477f347fa2dc59a | /src/main/java/program/DrawUtils.java | 53aa341f5b40ec13a1df1fc4d2b854e92961504c | [] | no_license | mrkobold/puzzlesolver | 7c18fb551aa9e7f948458851704c5c200f6696d6 | 8a4585bc775d391f11769b63a46764d26996ec93 | refs/heads/master | 2022-09-30T14:14:19.622820 | 2020-06-08T12:29:00 | 2020-06-08T12:29:00 | 258,164,531 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 934 | java | package program;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.awt.Color;
import java.awt.Graphics;
public class DrawUtils {
static void showImage(int[][] pixels) throws InterruptedException {
int height = pixels.length;
int width = pixels[0].length;
JFrame frame = new JFrame("preview");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(pixels[0].length + 100, pixels.length + 100);
frame.setVisible(true);
Graphics g = frame.getGraphics();
Thread.sleep(100);
g.fillRect(0, 0, width, height);
g.setColor(Color.WHITE);
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
if (pixels[row][col] == 255) {
g.drawLine(col + 20, row + 60, col + 20, row + 60);
}
}
}
}
}
| [
"[email protected]"
] | |
0bbc104ff918b2318a4f3a00a5feac315b941d39 | b755a269f733bc56f511bac6feb20992a1626d70 | /qiyun-user/user-mapper/src/main/java/com/qiyun/mapper2/Member2Mapper.java | 7ecdfd762ee820ffcad9966b3d4348ac7e1f6f83 | [] | no_license | yysStar/dubbo-zookeeper-SSM | 55df313b58c78ab2eaa3d021e5bb201f3eee6235 | e3f85dea824159fb4c29207cc5c9ccaecf381516 | refs/heads/master | 2022-12-21T22:50:33.405116 | 2020-05-09T09:20:41 | 2020-05-09T09:20:41 | 125,301,362 | 2 | 0 | null | 2022-12-16T10:51:09 | 2018-03-15T02:27:17 | Java | UTF-8 | Java | false | false | 6,272 | java | package com.qiyun.mapper2;
import com.qiyun.common.GoldCard2;
import com.qiyun.dto.MemberWalletLine2DTO;
import com.qiyun.dto.SuperGodDTO;
import com.qiyun.model.MemberWalletLine;
import com.qiyun.model.PayMember;
import com.qiyun.model2.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
public interface Member2Mapper {
int updateUserToWrite(String userName, Date tobeWriteTime);
int countByExample(Member2Query example);
int deleteByExample(Member2Query example);
int deleteByPrimaryKey(Integer id);
int insert(Member2 record);
int insertSelective(Member2 record);
List<Member2> selectByExample(Member2Query example);
Member2 selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") Member2 record, @Param("example") Member2Query example);
int updateByExample(@Param("record") Member2 record, @Param("example") Member2Query example);
int updateByPrimaryKeySelective(Member2 record);
int updateByPrimaryKey(Member2 record);
Member2 selectByAccount(String account);
Member2 selectByMobile(String mobile);
Member2 selectByMobileOrAccount(String account);
List<PayMember> getPayMember();
int findAccountNum(String accountId);
int findActiveNum(String account);
Map findPayNum(String account);
/**
* 获取超级大神数据
*
* @param account
* @return
*/
SuperGodDTO getSuperGod(String account);
SuperGodDTO getSuperGodN(String account);
String getAgentCode(String account);
int findMemberNote(Map<String, Object> map);
int addMemberNote(Map<String, Object> map);
int updateMemberNote(Map<String, Object> map);
List<Map> findSalesMoneyInfo(Map account);
List<Map> findAccountWall(Map minCount);
List<Map> findRechargeWall(Map<String, Object> map);
int checkCertNo(String certNo);
int checkMobile(String mobile);
int checkName(String memberName);
int memberToAgent(Map paramMap);
List<Map> memberMoveLogs();
List<Map> findMemberPlan(Map map);
Member2 getByUsername(String account);
List<Member2> getRobotList();
List<Map> findSaleDatas(Map<String, Object> map);
List<Map> findMemberAssociation(Map map);
List<Map> findMemberMove(Map map);
List<Map> findMemberWalletLine(Map map);
List<Map> findRechargeLine(Map<String, String> mapParam);
List<Map> findRechargeUnderLine(Map<String, String> mapParam);
List<Map> findFinancialCashInfo(Map map);
List<Map> findSaleInfo();
List<Map> findFinancialMoneyInfo(Map isMonth);
List<Map<String, Object>> getMemberByAgent(Map<String, Object> map);
List<Map> findselfBuy( Map mapParams);
int findfollowBuy(Map s);
String findCommision(Map s);
List<Map> findRechargeAndWitdrawlInfo(String account);
Map findRoleByAccount(String account);
List<Map<String, Object>> findAllParentModel(@Param("model_id") Integer id);
int addUser(Map<String,Object> map);
List<Map<String,Object>> findChildModel(Map<String,Object> map);
List<Map> findAllRole(Map<String, Object> map);
List<Map> findAllUserAndRole(@Param("user_id")Integer id);
int addPermission(Map<String,Object> map);
int addParentModel(Map<String,Object> map);
int addRole(Map<String,Object> map);
int updatePermission(Map<String,Object> map);
void updateChildPermission(Map map);
String findModelName(String s);
Map findChildModelName(@Param(value = "children") Integer children, @Param(value = "role_id") int role_id);
int updateStatus(Map map);
int addMemberToAgent(Map map);
int memberMoveAudit(Map map);
int updateUserInfo(Map<String,Object> map);
int updateChildModelInfo(Map<String,Object> map);
int findAccountNumBy(Map mapParams);
int findActiveNumBy(Map mapParams);
Map findPayNumBy(Map mapParams);
List<Map> findChildModelByParent(Integer parentModelId);
Member2 selectByPlanNo(int planNo);
int delUser(Integer user_id);
int updateMemberToQD(Integer member_id, String account, Date date, Integer transType, String active_code);
List findAllAgentAndQD(@Param("account") String account);
void addAgentToQD(@Param("qd_id") String qd_id, @Param("agent_id") Integer agent_id);
int findDrawsNums(String account);
int updateDrawsNum(int i, String account);
int addGoldCard(GoldCard2 goldCard2);
List<GoldCard2> findGoldCard(@Param(value = "account") String account,@Param(value = "startTime") String startTime,@Param(value = "endTime") String endTime);
int addActivity(Map<String,Object> mapParams);
List<Map> findAllActivity();
int updateActivity(Map<String,Object> mapParams);
int resetDrawsNum();
int updateGoldCard(GoldCard2 goldCard2);
int incrementDrawsNum(int i, String account);
List<Map> findMemberWalletLineByAccount(@Param("allInfo")Map account, @Param("listParam")List<Integer> list);
MemberAgent2 findAgetInfo(String account);
void upgradeAgentToQD(String account);
void updateMemberSourceId(@Param(value = "provider") String provider, @Param(value = "memberId") int i,@Param(value = "sourceId") Integer sourceId);
List<MemberWalletLine2> findRobotConsume();
Map findchildRole(Map map1);
void updateChild(Map<String,Object> map);
Map findAdminUser(Map<String,Object> map);
int updateParentModel(Map<String,Object> map);
int insetQDToUser(String user_account, String s);
int delQDToUser(String user_account, String s);
List<String> findQDByLoginAccount(String loginAccount);
int memberToWrite(String account,Date time);
int memberToNoWrite(String account,Date time);
List<Map>findAllMemberBy(Map<String,Object> map);
List<Member2> getBeforeOneMonth(Date date);
List<String> findMemberByAccount(String agentAccount);
List<Map> findMemberPlanByMember(List account);
List<Member2> selectByUserName(String member);
List<Map> findDlInfoByQD(@Param("qdList") List<String> accounts, @Param("dlAccount") String agentName);
void updateMemberInfoBack(Map<String,Object> paramMap);
} | [
"[email protected]"
] | |
83ca8d3301fbb98d16ddbb7df479527d0dde6c75 | 855b4041b6a7928988a41a5f3f7e7c7ae39565e4 | /hk-core/src/main/java/com/hk/svr/pub/BatchIdx.java | e5ed8c23f56ea5a06be59df11e2051d054a32bdf | [] | no_license | mestatrit/newbyakwei | 60dca96c4c21ae5fcf6477d4627a0eac0f76df35 | ea9a112ac6fcbc2a51dbdc79f417a1d918aa4067 | refs/heads/master | 2021-01-10T06:29:50.466856 | 2013-03-07T08:09:58 | 2013-03-07T08:09:58 | 36,559,185 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 166 | java | package com.hk.svr.pub;
import org.apache.lucene.document.Document;
public interface BatchIdx {
public int getSize();
public Document getDocument(int i);
} | [
"[email protected]"
] | |
750056bd1aeb7b0883dd8704026e1a159f0a0237 | 6b6f7ef9e654f722fe1fe4196b4997262ee40f5f | /frameworks/base/core/java/android/content/ContentProvider.java | e654f007a2d3c60e71f1d426e358d73b2e8e75cb | [] | no_license | lilang-wu/P3Android | b0b02c55790ce57fbe99c6dbe3f7f151764b465e | 6c120a98920136beb0bfbfaef3ef51a1b429afb4 | refs/heads/master | 2021-09-24T21:41:21.510166 | 2018-10-15T05:47:05 | 2018-10-15T05:47:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 84,149 | java | /*
* Copyright (C) 2006 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 android.content;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.content.pm.PackageManager.PERMISSION_MOCKED;
import android.app.AppOpsManager;
import android.content.pm.PathPermission;
import android.content.pm.ProviderInfo;
import android.content.res.AssetFileDescriptor;
import android.content.res.Configuration;
import android.database.Cursor;
import android.database.SQLException;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.ICancellationSignal;
import android.os.OperationCanceledException;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
import android.text.TextUtils;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
/**
* Content providers are one of the primary building blocks of Android applications, providing
* content to applications. They encapsulate data and provide it to applications through the single
* {@link ContentResolver} interface. A content provider is only required if you need to share
* data between multiple applications. For example, the contacts data is used by multiple
* applications and must be stored in a content provider. If you don't need to share data amongst
* multiple applications you can use a database directly via
* {@link android.database.sqlite.SQLiteDatabase}.
*
* <p>When a request is made via
* a {@link ContentResolver} the system inspects the authority of the given URI and passes the
* request to the content provider registered with the authority. The content provider can interpret
* the rest of the URI however it wants. The {@link UriMatcher} class is helpful for parsing
* URIs.</p>
*
* <p>The primary methods that need to be implemented are:
* <ul>
* <li>{@link #onCreate} which is called to initialize the provider</li>
* <li>{@link #query} which returns data to the caller</li>
* <li>{@link #insert} which inserts new data into the content provider</li>
* <li>{@link #update} which updates existing data in the content provider</li>
* <li>{@link #delete} which deletes data from the content provider</li>
* <li>{@link #getType} which returns the MIME type of data in the content provider</li>
* </ul></p>
*
* <p class="caution">Data access methods (such as {@link #insert} and
* {@link #update}) may be called from many threads at once, and must be thread-safe.
* Other methods (such as {@link #onCreate}) are only called from the application
* main thread, and must avoid performing lengthy operations. See the method
* descriptions for their expected thread behavior.</p>
*
* <p>Requests to {@link ContentResolver} are automatically forwarded to the appropriate
* ContentProvider instance, so subclasses don't have to worry about the details of
* cross-process calls.</p>
*
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about using content providers, read the
* <a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>
* developer guide.</p>
*/
public abstract class ContentProvider implements ComponentCallbacks2 {
private static final String TAG = "ContentProvider";
/*
* Note: if you add methods to ContentProvider, you must add similar methods to
* MockContentProvider.
*/
private Context mContext = null;
private int mMyUid;
// Since most Providers have only one authority, we keep both a String and a String[] to improve
// performance.
private String mAuthority;
private String[] mAuthorities;
private String mReadPermission;
private String mWritePermission;
private PathPermission[] mPathPermissions;
private boolean mExported;
private boolean mNoPerms;
private boolean mSingleUser;
private final ThreadLocal<String> mCallingPackage = new ThreadLocal<String>();
private Transport mTransport = new Transport();
/**
* Construct a ContentProvider instance. Content providers must be
* <a href="{@docRoot}guide/topics/manifest/provider-element.html">declared
* in the manifest</a>, accessed with {@link ContentResolver}, and created
* automatically by the system, so applications usually do not create
* ContentProvider instances directly.
*
* <p>At construction time, the object is uninitialized, and most fields and
* methods are unavailable. Subclasses should initialize themselves in
* {@link #onCreate}, not the constructor.
*
* <p>Content providers are created on the application main thread at
* application launch time. The constructor must not perform lengthy
* operations, or application startup will be delayed.
*/
public ContentProvider() {
}
/**
* Constructor just for mocking.
*
* @param context A Context object which should be some mock instance (like the
* instance of {@link android.test.mock.MockContext}).
* @param readPermission The read permision you want this instance should have in the
* test, which is available via {@link #getReadPermission()}.
* @param writePermission The write permission you want this instance should have
* in the test, which is available via {@link #getWritePermission()}.
* @param pathPermissions The PathPermissions you want this instance should have
* in the test, which is available via {@link #getPathPermissions()}.
* @hide
*/
public ContentProvider(
Context context,
String readPermission,
String writePermission,
PathPermission[] pathPermissions) {
mContext = context;
mReadPermission = readPermission;
mWritePermission = writePermission;
mPathPermissions = pathPermissions;
}
/**
* Given an IContentProvider, try to coerce it back to the real
* ContentProvider object if it is running in the local process. This can
* be used if you know you are running in the same process as a provider,
* and want to get direct access to its implementation details. Most
* clients should not nor have a reason to use it.
*
* @param abstractInterface The ContentProvider interface that is to be
* coerced.
* @return If the IContentProvider is non-{@code null} and local, returns its actual
* ContentProvider instance. Otherwise returns {@code null}.
* @hide
*/
public static ContentProvider coerceToLocalContentProvider(
IContentProvider abstractInterface) {
if (abstractInterface instanceof Transport) {
return ((Transport)abstractInterface).getContentProvider();
}
return null;
}
/**
* Binder object that deals with remoting.
*
* @hide
*/
class Transport extends ContentProviderNative {
AppOpsManager mAppOpsManager = null;
int mReadOp = AppOpsManager.OP_NONE;
int mWriteOp = AppOpsManager.OP_NONE;
ContentProvider getContentProvider() {
return ContentProvider.this;
}
@Override
public String getProviderName() {
return getContentProvider().getClass().getName();
}
@Override
public Cursor query(String callingPkg, Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder,
ICancellationSignal cancellationSignal) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return rejectQuery(uri, projection, selection, selectionArgs, sortOrder,
CancellationSignal.fromTransport(cancellationSignal));
}
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.query(
uri, projection, selection, selectionArgs, sortOrder,
CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
}
}
@Override
public String getType(Uri uri) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
return ContentProvider.this.getType(uri);
}
@Override
public Uri insert(String callingPkg, Uri uri, ContentValues initialValues) {
validateIncomingUri(uri);
int userId = getUserIdFromUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return rejectInsert(uri, initialValues);
}
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.insert(uri, initialValues), userId);
} finally {
setCallingPackage(original);
}
}
@Override
public int bulkInsert(String callingPkg, Uri uri, ContentValues[] initialValues) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.bulkInsert(uri, initialValues);
} finally {
setCallingPackage(original);
}
}
@Override
public ContentProviderResult[] applyBatch(String callingPkg,
ArrayList<ContentProviderOperation> operations)
throws OperationApplicationException {
int numOperations = operations.size();
final int[] userIds = new int[numOperations];
for (int i = 0; i < numOperations; i++) {
ContentProviderOperation operation = operations.get(i);
Uri uri = operation.getUri();
validateIncomingUri(uri);
userIds[i] = getUserIdFromUri(uri);
if (userIds[i] != UserHandle.USER_CURRENT) {
// Removing the user id from the uri.
operation = new ContentProviderOperation(operation, true);
operations.set(i, operation);
}
if (operation.isReadOperation()) {
if (enforceReadPermission(callingPkg, uri)
!= AppOpsManager.MODE_ALLOWED) {
throw new OperationApplicationException("App op not allowed", 0);
}
}
if (operation.isWriteOperation()) {
if (enforceWritePermission(callingPkg, uri)
!= AppOpsManager.MODE_ALLOWED) {
throw new OperationApplicationException("App op not allowed", 0);
}
}
}
final String original = setCallingPackage(callingPkg);
try {
ContentProviderResult[] results = ContentProvider.this.applyBatch(operations);
for (int i = 0; i < results.length ; i++) {
if (userIds[i] != UserHandle.USER_CURRENT) {
// Adding the userId to the uri.
results[i] = new ContentProviderResult(results[i], userIds[i]);
}
}
return results;
} finally {
setCallingPackage(original);
}
}
@Override
public int delete(String callingPkg, Uri uri, String selection, String[] selectionArgs) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.delete(uri, selection, selectionArgs);
} finally {
setCallingPackage(original);
}
}
@Override
public int update(String callingPkg, Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return 0;
}
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.update(uri, values, selection, selectionArgs);
} finally {
setCallingPackage(original);
}
}
@Override
public ParcelFileDescriptor openFile(
String callingPkg, Uri uri, String mode, ICancellationSignal cancellationSignal)
throws FileNotFoundException {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, mode);
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openFile(
uri, mode, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
}
}
@Override
public AssetFileDescriptor openAssetFile(
String callingPkg, Uri uri, String mode, ICancellationSignal cancellationSignal)
throws FileNotFoundException {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, mode);
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openAssetFile(
uri, mode, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
}
}
@Override
public Bundle call(String callingPkg, String method, String arg, Bundle extras) {
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.call(method, arg, extras);
} finally {
setCallingPackage(original);
}
}
@Override
public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
return ContentProvider.this.getStreamTypes(uri, mimeTypeFilter);
}
@Override
public AssetFileDescriptor openTypedAssetFile(String callingPkg, Uri uri, String mimeType,
Bundle opts, ICancellationSignal cancellationSignal) throws FileNotFoundException {
validateIncomingUri(uri);
uri = getUriWithoutUserId(uri);
enforceFilePermission(callingPkg, uri, "r");
final String original = setCallingPackage(callingPkg);
try {
return ContentProvider.this.openTypedAssetFile(
uri, mimeType, opts, CancellationSignal.fromTransport(cancellationSignal));
} finally {
setCallingPackage(original);
}
}
@Override
public ICancellationSignal createCancellationSignal() {
return CancellationSignal.createTransport();
}
@Override
public Uri canonicalize(String callingPkg, Uri uri) {
validateIncomingUri(uri);
int userId = getUserIdFromUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return null;
}
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.canonicalize(uri), userId);
} finally {
setCallingPackage(original);
}
}
@Override
public Uri uncanonicalize(String callingPkg, Uri uri) {
validateIncomingUri(uri);
int userId = getUserIdFromUri(uri);
uri = getUriWithoutUserId(uri);
if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
return null;
}
final String original = setCallingPackage(callingPkg);
try {
return maybeAddUserId(ContentProvider.this.uncanonicalize(uri), userId);
} finally {
setCallingPackage(original);
}
}
private void enforceFilePermission(String callingPkg, Uri uri, String mode)
throws FileNotFoundException, SecurityException {
if (mode != null && mode.indexOf('w') != -1) {
if (enforceWritePermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
throw new FileNotFoundException("App op not allowed");
}
} else {
if (enforceReadPermission(callingPkg, uri) != AppOpsManager.MODE_ALLOWED) {
throw new FileNotFoundException("App op not allowed");
}
}
}
private int enforceReadPermission(String callingPkg, Uri uri) throws SecurityException {
enforceReadPermissionInner(uri);
if (mReadOp != AppOpsManager.OP_NONE) {
return mAppOpsManager.noteOp(mReadOp, Binder.getCallingUid(), callingPkg);
}
return AppOpsManager.MODE_ALLOWED;
}
private int enforceWritePermission(String callingPkg, Uri uri) throws SecurityException {
enforceWritePermissionInner(uri);
if (mWriteOp != AppOpsManager.OP_NONE) {
return mAppOpsManager.noteOp(mWriteOp, Binder.getCallingUid(), callingPkg);
}
return AppOpsManager.MODE_ALLOWED;
}
}
boolean checkUser(int pid, int uid, Context context) {
return UserHandle.getUserId(uid) == context.getUserId()
|| mSingleUser
|| context.checkPermission(INTERACT_ACROSS_USERS, pid, uid)
== PERMISSION_GRANTED;
}
/** {@hide} */
protected void enforceReadPermissionInner(Uri uri) throws SecurityException {
final Context context = getContext();
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
String missingPerm = null;
if (UserHandle.isSameApp(uid, mMyUid)) {
return;
}
if (mExported && checkUser(pid, uid, context)) {
final String componentPerm = getReadPermission();
if (componentPerm != null) {
/**change by Dongyang Wu
* @date: 6-04
*/
int permStuts = context.checkPermission(componentPerm, pid, uid);
if ( permStuts == PERMISSION_GRANTED || permStuts == PERMISSION_MOCKED) {
return;
} else {
missingPerm = componentPerm;
}
}
// track if unprotected read is allowed; any denied
// <path-permission> below removes this ability
boolean allowDefaultRead = (componentPerm == null);
final PathPermission[] pps = getPathPermissions();
if (pps != null) {
final String path = uri.getPath();
for (PathPermission pp : pps) {
final String pathPerm = pp.getReadPermission();
if (pathPerm != null && pp.match(path)) {
if (context.checkPermission(pathPerm, pid, uid) == PERMISSION_GRANTED) {
return;
} else {
// any denied <path-permission> means we lose
// default <provider> access.
allowDefaultRead = false;
missingPerm = pathPerm;
}
}
}
}
// if we passed <path-permission> checks above, and no default
// <provider> permission, then allow access.
if (allowDefaultRead) return;
}
// last chance, check against any uri grants
if (context.checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_READ_URI_PERMISSION)
== PERMISSION_GRANTED) {
return;
}
final String failReason = mExported
? " requires " + missingPerm + ", or grantUriPermission()"
: " requires the provider be exported, or grantUriPermission()";
throw new SecurityException("Permission Denial: reading "
+ ContentProvider.this.getClass().getName() + " uri " + uri + " from pid=" + pid
+ ", uid=" + uid + failReason);
}
/** {@hide} */
protected void enforceWritePermissionInner(Uri uri) throws SecurityException {
final Context context = getContext();
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
String missingPerm = null;
if (UserHandle.isSameApp(uid, mMyUid)) {
return;
}
if (mExported && checkUser(pid, uid, context)) {
final String componentPerm = getWritePermission();
if (componentPerm != null) {
if (context.checkPermission(componentPerm, pid, uid) == PERMISSION_GRANTED) {
return;
} else {
missingPerm = componentPerm;
}
}
// track if unprotected write is allowed; any denied
// <path-permission> below removes this ability
boolean allowDefaultWrite = (componentPerm == null);
final PathPermission[] pps = getPathPermissions();
if (pps != null) {
final String path = uri.getPath();
for (PathPermission pp : pps) {
final String pathPerm = pp.getWritePermission();
if (pathPerm != null && pp.match(path)) {
if (context.checkPermission(pathPerm, pid, uid) == PERMISSION_GRANTED) {
return;
} else {
// any denied <path-permission> means we lose
// default <provider> access.
allowDefaultWrite = false;
missingPerm = pathPerm;
}
}
}
}
// if we passed <path-permission> checks above, and no default
// <provider> permission, then allow access.
if (allowDefaultWrite) return;
}
// last chance, check against any uri grants
if (context.checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
== PERMISSION_GRANTED) {
return;
}
final String failReason = mExported
? " requires " + missingPerm + ", or grantUriPermission()"
: " requires the provider be exported, or grantUriPermission()";
throw new SecurityException("Permission Denial: writing "
+ ContentProvider.this.getClass().getName() + " uri " + uri + " from pid=" + pid
+ ", uid=" + uid + failReason);
}
/**
* Retrieves the Context this provider is running in. Only available once
* {@link #onCreate} has been called -- this will return {@code null} in the
* constructor.
*/
public final Context getContext() {
return mContext;
}
/**
* Set the calling package, returning the current value (or {@code null})
* which can be used later to restore the previous state.
*/
private String setCallingPackage(String callingPackage) {
final String original = mCallingPackage.get();
mCallingPackage.set(callingPackage);
return original;
}
/**
* Return the package name of the caller that initiated the request being
* processed on the current thread. The returned package will have been
* verified to belong to the calling UID. Returns {@code null} if not
* currently processing a request.
* <p>
* This will always return {@code null} when processing
* {@link #getType(Uri)} or {@link #getStreamTypes(Uri, String)} requests.
*
* @see Binder#getCallingUid()
* @see Context#grantUriPermission(String, Uri, int)
* @throws SecurityException if the calling package doesn't belong to the
* calling UID.
*/
public final String getCallingPackage() {
final String pkg = mCallingPackage.get();
if (pkg != null) {
mTransport.mAppOpsManager.checkPackage(Binder.getCallingUid(), pkg);
}
return pkg;
}
/**
* Change the authorities of the ContentProvider.
* This is normally set for you from its manifest information when the provider is first
* created.
* @hide
* @param authorities the semi-colon separated authorities of the ContentProvider.
*/
protected final void setAuthorities(String authorities) {
if (authorities != null) {
if (authorities.indexOf(';') == -1) {
mAuthority = authorities;
mAuthorities = null;
} else {
mAuthority = null;
mAuthorities = authorities.split(";");
}
}
}
/** @hide */
protected final boolean matchesOurAuthorities(String authority) {
if (mAuthority != null) {
return mAuthority.equals(authority);
}
if (mAuthorities != null) {
int length = mAuthorities.length;
for (int i = 0; i < length; i++) {
if (mAuthorities[i].equals(authority)) return true;
}
}
return false;
}
/**
* Change the permission required to read data from the content
* provider. This is normally set for you from its manifest information
* when the provider is first created.
*
* @param permission Name of the permission required for read-only access.
*/
protected final void setReadPermission(String permission) {
mReadPermission = permission;
}
/**
* Return the name of the permission required for read-only access to
* this content provider. This method can be called from multiple
* threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*/
public final String getReadPermission() {
return mReadPermission;
}
/**
* Change the permission required to read and write data in the content
* provider. This is normally set for you from its manifest information
* when the provider is first created.
*
* @param permission Name of the permission required for read/write access.
*/
protected final void setWritePermission(String permission) {
mWritePermission = permission;
}
/**
* Return the name of the permission required for read/write access to
* this content provider. This method can be called from multiple
* threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*/
public final String getWritePermission() {
return mWritePermission;
}
/**
* Change the path-based permission required to read and/or write data in
* the content provider. This is normally set for you from its manifest
* information when the provider is first created.
*
* @param permissions Array of path permission descriptions.
*/
protected final void setPathPermissions(PathPermission[] permissions) {
mPathPermissions = permissions;
}
/**
* Return the path-based permissions required for read and/or write access to
* this content provider. This method can be called from multiple
* threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*/
public final PathPermission[] getPathPermissions() {
return mPathPermissions;
}
/** @hide */
public final void setAppOps(int readOp, int writeOp) {
if (!mNoPerms) {
mTransport.mReadOp = readOp;
mTransport.mWriteOp = writeOp;
}
}
/** @hide */
public AppOpsManager getAppOpsManager() {
return mTransport.mAppOpsManager;
}
/**
* Implement this to initialize your content provider on startup.
* This method is called for all registered content providers on the
* application main thread at application launch time. It must not perform
* lengthy operations, or application startup will be delayed.
*
* <p>You should defer nontrivial initialization (such as opening,
* upgrading, and scanning databases) until the content provider is used
* (via {@link #query}, {@link #insert}, etc). Deferred initialization
* keeps application startup fast, avoids unnecessary work if the provider
* turns out not to be needed, and stops database errors (such as a full
* disk) from halting application launch.
*
* <p>If you use SQLite, {@link android.database.sqlite.SQLiteOpenHelper}
* is a helpful utility class that makes it easy to manage databases,
* and will automatically defer opening until first use. If you do use
* SQLiteOpenHelper, make sure to avoid calling
* {@link android.database.sqlite.SQLiteOpenHelper#getReadableDatabase} or
* {@link android.database.sqlite.SQLiteOpenHelper#getWritableDatabase}
* from this method. (Instead, override
* {@link android.database.sqlite.SQLiteOpenHelper#onOpen} to initialize the
* database when it is first opened.)
*
* @return true if the provider was successfully loaded, false otherwise
*/
public abstract boolean onCreate();
/**
* {@inheritDoc}
* This method is always called on the application main thread, and must
* not perform lengthy operations.
*
* <p>The default content provider implementation does nothing.
* Override this method to take appropriate action.
* (Content providers do not usually care about things like screen
* orientation, but may want to know about locale changes.)
*/
public void onConfigurationChanged(Configuration newConfig) {
}
/**
* {@inheritDoc}
* This method is always called on the application main thread, and must
* not perform lengthy operations.
*
* <p>The default content provider implementation does nothing.
* Subclasses may override this method to take appropriate action.
*/
public void onLowMemory() {
}
public void onTrimMemory(int level) {
}
/**
* @hide
* Implementation when a caller has performed a query on the content
* provider, but that call has been rejected for the operation given
* to {@link #setAppOps(int, int)}. The default implementation
* rewrites the <var>selection</var> argument to include a condition
* that is never true (so will always result in an empty cursor)
* and calls through to {@link #query(android.net.Uri, String[], String, String[],
* String, android.os.CancellationSignal)} with that.
*/
public Cursor rejectQuery(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder,
CancellationSignal cancellationSignal) {
// The read is not allowed... to fake it out, we replace the given
// selection statement with a dummy one that will always be false.
// This way we will get a cursor back that has the correct structure
// but contains no rows.
if (selection == null || selection.isEmpty()) {
selection = "'A' = 'B'";
} else {
selection = "'A' = 'B' AND (" + selection + ")";
}
return query(uri, projection, selection, selectionArgs, sortOrder, cancellationSignal);
}
/**
* Implement this to handle query requests from clients.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
* <p>
* Example client call:<p>
* <pre>// Request a specific record.
* Cursor managedCursor = managedQuery(
ContentUris.withAppendedId(Contacts.People.CONTENT_URI, 2),
projection, // Which columns to return.
null, // WHERE clause.
null, // WHERE clause value substitution
People.NAME + " ASC"); // Sort order.</pre>
* Example implementation:<p>
* <pre>// SQLiteQueryBuilder is a helper class that creates the
// proper SQL syntax for us.
SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
// Set the table we're querying.
qBuilder.setTables(DATABASE_TABLE_NAME);
// If the query ends in a specific record number, we're
// being asked for a specific record, so set the
// WHERE clause in our query.
if((URI_MATCHER.match(uri)) == SPECIFIC_MESSAGE){
qBuilder.appendWhere("_id=" + uri.getPathLeafId());
}
// Make the query.
Cursor c = qBuilder.query(mDb,
projection,
selection,
selectionArgs,
groupBy,
having,
sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;</pre>
*
* @param uri The URI to query. This will be the full URI sent by the client;
* if the client is requesting a specific record, the URI will end in a record number
* that the implementation should parse and add to a WHERE or HAVING clause, specifying
* that _id value.
* @param projection The list of columns to put into the cursor. If
* {@code null} all columns are included.
* @param selection A selection criteria to apply when filtering rows.
* If {@code null} then all rows are included.
* @param selectionArgs You may include ?s in selection, which will be replaced by
* the values from selectionArgs, in order that they appear in the selection.
* The values will be bound as Strings.
* @param sortOrder How the rows in the cursor should be sorted.
* If {@code null} then the provider is free to define the sort order.
* @return a Cursor or {@code null}.
*/
public abstract Cursor query(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder);
/**
* Implement this to handle query requests from clients with support for cancellation.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
* <p>
* Example client call:<p>
* <pre>// Request a specific record.
* Cursor managedCursor = managedQuery(
ContentUris.withAppendedId(Contacts.People.CONTENT_URI, 2),
projection, // Which columns to return.
null, // WHERE clause.
null, // WHERE clause value substitution
People.NAME + " ASC"); // Sort order.</pre>
* Example implementation:<p>
* <pre>// SQLiteQueryBuilder is a helper class that creates the
// proper SQL syntax for us.
SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
// Set the table we're querying.
qBuilder.setTables(DATABASE_TABLE_NAME);
// If the query ends in a specific record number, we're
// being asked for a specific record, so set the
// WHERE clause in our query.
if((URI_MATCHER.match(uri)) == SPECIFIC_MESSAGE){
qBuilder.appendWhere("_id=" + uri.getPathLeafId());
}
// Make the query.
Cursor c = qBuilder.query(mDb,
projection,
selection,
selectionArgs,
groupBy,
having,
sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;</pre>
* <p>
* If you implement this method then you must also implement the version of
* {@link #query(Uri, String[], String, String[], String)} that does not take a cancellation
* signal to ensure correct operation on older versions of the Android Framework in
* which the cancellation signal overload was not available.
*
* @param uri The URI to query. This will be the full URI sent by the client;
* if the client is requesting a specific record, the URI will end in a record number
* that the implementation should parse and add to a WHERE or HAVING clause, specifying
* that _id value.
* @param projection The list of columns to put into the cursor. If
* {@code null} all columns are included.
* @param selection A selection criteria to apply when filtering rows.
* If {@code null} then all rows are included.
* @param selectionArgs You may include ?s in selection, which will be replaced by
* the values from selectionArgs, in order that they appear in the selection.
* The values will be bound as Strings.
* @param sortOrder How the rows in the cursor should be sorted.
* If {@code null} then the provider is free to define the sort order.
* @param cancellationSignal A signal to cancel the operation in progress, or {@code null} if none.
* If the operation is canceled, then {@link OperationCanceledException} will be thrown
* when the query is executed.
* @return a Cursor or {@code null}.
*/
public Cursor query(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder,
CancellationSignal cancellationSignal) {
return query(uri, projection, selection, selectionArgs, sortOrder);
}
/**
* Implement this to handle requests for the MIME type of the data at the
* given URI. The returned MIME type should start with
* <code>vnd.android.cursor.item</code> for a single record,
* or <code>vnd.android.cursor.dir/</code> for multiple items.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>Note that there are no permissions needed for an application to
* access this information; if your content provider requires read and/or
* write permissions, or is not exported, all applications can still call
* this method regardless of their access permissions. This allows them
* to retrieve the MIME type for a URI when dispatching intents.
*
* @param uri the URI to query.
* @return a MIME type string, or {@code null} if there is no type.
*/
public abstract String getType(Uri uri);
/**
* Implement this to support canonicalization of URIs that refer to your
* content provider. A canonical URI is one that can be transported across
* devices, backup/restore, and other contexts, and still be able to refer
* to the same data item. Typically this is implemented by adding query
* params to the URI allowing the content provider to verify that an incoming
* canonical URI references the same data as it was originally intended for and,
* if it doesn't, to find that data (if it exists) in the current environment.
*
* <p>For example, if the content provider holds people and a normal URI in it
* is created with a row index into that people database, the cananical representation
* may have an additional query param at the end which specifies the name of the
* person it is intended for. Later calls into the provider with that URI will look
* up the row of that URI's base index and, if it doesn't match or its entry's
* name doesn't match the name in the query param, perform a query on its database
* to find the correct row to operate on.</p>
*
* <p>If you implement support for canonical URIs, <b>all</b> incoming calls with
* URIs (including this one) must perform this verification and recovery of any
* canonical URIs they receive. In addition, you must also implement
* {@link #uncanonicalize} to strip the canonicalization of any of these URIs.</p>
*
* <p>The default implementation of this method returns null, indicating that
* canonical URIs are not supported.</p>
*
* @param url The Uri to canonicalize.
*
* @return Return the canonical representation of <var>url</var>, or null if
* canonicalization of that Uri is not supported.
*/
public Uri canonicalize(Uri url) {
return null;
}
/**
* Remove canonicalization from canonical URIs previously returned by
* {@link #canonicalize}. For example, if your implementation is to add
* a query param to canonicalize a URI, this method can simply trip any
* query params on the URI. The default implementation always returns the
* same <var>url</var> that was passed in.
*
* @param url The Uri to remove any canonicalization from.
*
* @return Return the non-canonical representation of <var>url</var>, return
* the <var>url</var> as-is if there is nothing to do, or return null if
* the data identified by the canonical representation can not be found in
* the current environment.
*/
public Uri uncanonicalize(Uri url) {
return url;
}
/**
* @hide
* Implementation when a caller has performed an insert on the content
* provider, but that call has been rejected for the operation given
* to {@link #setAppOps(int, int)}. The default implementation simply
* returns a dummy URI that is the base URI with a 0 path element
* appended.
*/
public Uri rejectInsert(Uri uri, ContentValues values) {
// If not allowed, we need to return some reasonable URI. Maybe the
// content provider should be responsible for this, but for now we
// will just return the base URI with a dummy '0' tagged on to it.
// You shouldn't be able to read if you can't write, anyway, so it
// shouldn't matter much what is returned.
return uri.buildUpon().appendPath("0").build();
}
/**
* Implement this to handle requests to insert a new row.
* As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
* after inserting.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
* @param uri The content:// URI of the insertion request. This must not be {@code null}.
* @param values A set of column_name/value pairs to add to the database.
* This must not be {@code null}.
* @return The URI for the newly inserted item.
*/
public abstract Uri insert(Uri uri, ContentValues values);
/**
* Override this to handle requests to insert a set of new rows, or the
* default implementation will iterate over the values and call
* {@link #insert} on each of them.
* As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
* after inserting.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* @param uri The content:// URI of the insertion request.
* @param values An array of sets of column_name/value pairs to add to the database.
* This must not be {@code null}.
* @return The number of values that were inserted.
*/
public int bulkInsert(Uri uri, ContentValues[] values) {
int numValues = values.length;
for (int i = 0; i < numValues; i++) {
insert(uri, values[i]);
}
return numValues;
}
/**
* Implement this to handle requests to delete one or more rows.
* The implementation should apply the selection clause when performing
* deletion, allowing the operation to affect multiple rows in a directory.
* As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
* after deleting.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>The implementation is responsible for parsing out a row ID at the end
* of the URI, if a specific row is being deleted. That is, the client would
* pass in <code>content://contacts/people/22</code> and the implementation is
* responsible for parsing the record number (22) when creating a SQL statement.
*
* @param uri The full URI to query, including a row ID (if a specific record is requested).
* @param selection An optional restriction to apply to rows when deleting.
* @return The number of rows affected.
* @throws SQLException
*/
public abstract int delete(Uri uri, String selection, String[] selectionArgs);
/**
* Implement this to handle requests to update one or more rows.
* The implementation should update all rows matching the selection
* to set the columns according to the provided values map.
* As a courtesy, call {@link ContentResolver#notifyChange(android.net.Uri ,android.database.ContentObserver) notifyChange()}
* after updating.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* @param uri The URI to query. This can potentially have a record ID if this
* is an update request for a specific record.
* @param values A set of column_name/value pairs to update in the database.
* This must not be {@code null}.
* @param selection An optional filter to match rows to update.
* @return the number of rows affected.
*/
public abstract int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs);
/**
* Override this to handle requests to open a file blob.
* The default implementation always throws {@link FileNotFoundException}.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>This method returns a ParcelFileDescriptor, which is returned directly
* to the caller. This way large data (such as images and documents) can be
* returned without copying the content.
*
* <p>The returned ParcelFileDescriptor is owned by the caller, so it is
* their responsibility to close it when done. That is, the implementation
* of this method should create a new ParcelFileDescriptor for each call.
* <p>
* If opened with the exclusive "r" or "w" modes, the returned
* ParcelFileDescriptor can be a pipe or socket pair to enable streaming
* of data. Opening with the "rw" or "rwt" modes implies a file on disk that
* supports seeking.
* <p>
* If you need to detect when the returned ParcelFileDescriptor has been
* closed, or if the remote process has crashed or encountered some other
* error, you can use {@link ParcelFileDescriptor#open(File, int,
* android.os.Handler, android.os.ParcelFileDescriptor.OnCloseListener)},
* {@link ParcelFileDescriptor#createReliablePipe()}, or
* {@link ParcelFileDescriptor#createReliableSocketPair()}.
*
* <p class="note">For use in Intents, you will want to implement {@link #getType}
* to return the appropriate MIME type for the data returned here with
* the same URI. This will allow intent resolution to automatically determine the data MIME
* type and select the appropriate matching targets as part of its operation.</p>
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.
* You may also want to support other common columns if you have additional meta-data
* to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
* in {@link android.provider.MediaStore.MediaColumns}.</p>
*
* @param uri The URI whose file is to be opened.
* @param mode Access mode for the file. May be "r" for read-only access,
* "rw" for read and write access, or "rwt" for read and write access
* that truncates any existing file.
*
* @return Returns a new ParcelFileDescriptor which you can use to access
* the file.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the file.
*
* @see #openAssetFile(Uri, String)
* @see #openFileHelper(Uri, String)
* @see #getType(android.net.Uri)
* @see ParcelFileDescriptor#parseMode(String)
*/
public ParcelFileDescriptor openFile(Uri uri, String mode)
throws FileNotFoundException {
throw new FileNotFoundException("No files supported by provider at "
+ uri);
}
/**
* Override this to handle requests to open a file blob.
* The default implementation always throws {@link FileNotFoundException}.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>This method returns a ParcelFileDescriptor, which is returned directly
* to the caller. This way large data (such as images and documents) can be
* returned without copying the content.
*
* <p>The returned ParcelFileDescriptor is owned by the caller, so it is
* their responsibility to close it when done. That is, the implementation
* of this method should create a new ParcelFileDescriptor for each call.
* <p>
* If opened with the exclusive "r" or "w" modes, the returned
* ParcelFileDescriptor can be a pipe or socket pair to enable streaming
* of data. Opening with the "rw" or "rwt" modes implies a file on disk that
* supports seeking.
* <p>
* If you need to detect when the returned ParcelFileDescriptor has been
* closed, or if the remote process has crashed or encountered some other
* error, you can use {@link ParcelFileDescriptor#open(File, int,
* android.os.Handler, android.os.ParcelFileDescriptor.OnCloseListener)},
* {@link ParcelFileDescriptor#createReliablePipe()}, or
* {@link ParcelFileDescriptor#createReliableSocketPair()}.
*
* <p class="note">For use in Intents, you will want to implement {@link #getType}
* to return the appropriate MIME type for the data returned here with
* the same URI. This will allow intent resolution to automatically determine the data MIME
* type and select the appropriate matching targets as part of its operation.</p>
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.
* You may also want to support other common columns if you have additional meta-data
* to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
* in {@link android.provider.MediaStore.MediaColumns}.</p>
*
* @param uri The URI whose file is to be opened.
* @param mode Access mode for the file. May be "r" for read-only access,
* "w" for write-only access, "rw" for read and write access, or
* "rwt" for read and write access that truncates any existing
* file.
* @param signal A signal to cancel the operation in progress, or
* {@code null} if none. For example, if you are downloading a
* file from the network to service a "rw" mode request, you
* should periodically call
* {@link CancellationSignal#throwIfCanceled()} to check whether
* the client has canceled the request and abort the download.
*
* @return Returns a new ParcelFileDescriptor which you can use to access
* the file.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the file.
*
* @see #openAssetFile(Uri, String)
* @see #openFileHelper(Uri, String)
* @see #getType(android.net.Uri)
* @see ParcelFileDescriptor#parseMode(String)
*/
public ParcelFileDescriptor openFile(Uri uri, String mode, CancellationSignal signal)
throws FileNotFoundException {
return openFile(uri, mode);
}
/**
* This is like {@link #openFile}, but can be implemented by providers
* that need to be able to return sub-sections of files, often assets
* inside of their .apk.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>If you implement this, your clients must be able to deal with such
* file slices, either directly with
* {@link ContentResolver#openAssetFileDescriptor}, or by using the higher-level
* {@link ContentResolver#openInputStream ContentResolver.openInputStream}
* or {@link ContentResolver#openOutputStream ContentResolver.openOutputStream}
* methods.
* <p>
* The returned AssetFileDescriptor can be a pipe or socket pair to enable
* streaming of data.
*
* <p class="note">If you are implementing this to return a full file, you
* should create the AssetFileDescriptor with
* {@link AssetFileDescriptor#UNKNOWN_LENGTH} to be compatible with
* applications that cannot handle sub-sections of files.</p>
*
* <p class="note">For use in Intents, you will want to implement {@link #getType}
* to return the appropriate MIME type for the data returned here with
* the same URI. This will allow intent resolution to automatically determine the data MIME
* type and select the appropriate matching targets as part of its operation.</p>
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.</p>
*
* @param uri The URI whose file is to be opened.
* @param mode Access mode for the file. May be "r" for read-only access,
* "w" for write-only access (erasing whatever data is currently in
* the file), "wa" for write-only access to append to any existing data,
* "rw" for read and write access on any existing data, and "rwt" for read
* and write access that truncates any existing file.
*
* @return Returns a new AssetFileDescriptor which you can use to access
* the file.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the file.
*
* @see #openFile(Uri, String)
* @see #openFileHelper(Uri, String)
* @see #getType(android.net.Uri)
*/
public AssetFileDescriptor openAssetFile(Uri uri, String mode)
throws FileNotFoundException {
ParcelFileDescriptor fd = openFile(uri, mode);
return fd != null ? new AssetFileDescriptor(fd, 0, -1) : null;
}
/**
* This is like {@link #openFile}, but can be implemented by providers
* that need to be able to return sub-sections of files, often assets
* inside of their .apk.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* <p>If you implement this, your clients must be able to deal with such
* file slices, either directly with
* {@link ContentResolver#openAssetFileDescriptor}, or by using the higher-level
* {@link ContentResolver#openInputStream ContentResolver.openInputStream}
* or {@link ContentResolver#openOutputStream ContentResolver.openOutputStream}
* methods.
* <p>
* The returned AssetFileDescriptor can be a pipe or socket pair to enable
* streaming of data.
*
* <p class="note">If you are implementing this to return a full file, you
* should create the AssetFileDescriptor with
* {@link AssetFileDescriptor#UNKNOWN_LENGTH} to be compatible with
* applications that cannot handle sub-sections of files.</p>
*
* <p class="note">For use in Intents, you will want to implement {@link #getType}
* to return the appropriate MIME type for the data returned here with
* the same URI. This will allow intent resolution to automatically determine the data MIME
* type and select the appropriate matching targets as part of its operation.</p>
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.</p>
*
* @param uri The URI whose file is to be opened.
* @param mode Access mode for the file. May be "r" for read-only access,
* "w" for write-only access (erasing whatever data is currently in
* the file), "wa" for write-only access to append to any existing data,
* "rw" for read and write access on any existing data, and "rwt" for read
* and write access that truncates any existing file.
* @param signal A signal to cancel the operation in progress, or
* {@code null} if none. For example, if you are downloading a
* file from the network to service a "rw" mode request, you
* should periodically call
* {@link CancellationSignal#throwIfCanceled()} to check whether
* the client has canceled the request and abort the download.
*
* @return Returns a new AssetFileDescriptor which you can use to access
* the file.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the file.
*
* @see #openFile(Uri, String)
* @see #openFileHelper(Uri, String)
* @see #getType(android.net.Uri)
*/
public AssetFileDescriptor openAssetFile(Uri uri, String mode, CancellationSignal signal)
throws FileNotFoundException {
return openAssetFile(uri, mode);
}
/**
* Convenience for subclasses that wish to implement {@link #openFile}
* by looking up a column named "_data" at the given URI.
*
* @param uri The URI to be opened.
* @param mode The file mode. May be "r" for read-only access,
* "w" for write-only access (erasing whatever data is currently in
* the file), "wa" for write-only access to append to any existing data,
* "rw" for read and write access on any existing data, and "rwt" for read
* and write access that truncates any existing file.
*
* @return Returns a new ParcelFileDescriptor that can be used by the
* client to access the file.
*/
protected final ParcelFileDescriptor openFileHelper(Uri uri,
String mode) throws FileNotFoundException {
Cursor c = query(uri, new String[]{"_data"}, null, null, null);
int count = (c != null) ? c.getCount() : 0;
if (count != 1) {
// If there is not exactly one result, throw an appropriate
// exception.
if (c != null) {
c.close();
}
if (count == 0) {
throw new FileNotFoundException("No entry for " + uri);
}
throw new FileNotFoundException("Multiple items at " + uri);
}
c.moveToFirst();
int i = c.getColumnIndex("_data");
String path = (i >= 0 ? c.getString(i) : null);
c.close();
if (path == null) {
throw new FileNotFoundException("Column _data not found.");
}
int modeBits = ParcelFileDescriptor.parseMode(mode);
return ParcelFileDescriptor.open(new File(path), modeBits);
}
/**
* Called by a client to determine the types of data streams that this
* content provider supports for the given URI. The default implementation
* returns {@code null}, meaning no types. If your content provider stores data
* of a particular type, return that MIME type if it matches the given
* mimeTypeFilter. If it can perform type conversions, return an array
* of all supported MIME types that match mimeTypeFilter.
*
* @param uri The data in the content provider being queried.
* @param mimeTypeFilter The type of data the client desires. May be
* a pattern, such as */* to retrieve all possible data types.
* @return Returns {@code null} if there are no possible data streams for the
* given mimeTypeFilter. Otherwise returns an array of all available
* concrete MIME types.
*
* @see #getType(Uri)
* @see #openTypedAssetFile(Uri, String, Bundle)
* @see ClipDescription#compareMimeTypes(String, String)
*/
public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
return null;
}
/**
* Called by a client to open a read-only stream containing data of a
* particular MIME type. This is like {@link #openAssetFile(Uri, String)},
* except the file can only be read-only and the content provider may
* perform data conversions to generate data of the desired type.
*
* <p>The default implementation compares the given mimeType against the
* result of {@link #getType(Uri)} and, if they match, simply calls
* {@link #openAssetFile(Uri, String)}.
*
* <p>See {@link ClipData} for examples of the use and implementation
* of this method.
* <p>
* The returned AssetFileDescriptor can be a pipe or socket pair to enable
* streaming of data.
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.
* You may also want to support other common columns if you have additional meta-data
* to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
* in {@link android.provider.MediaStore.MediaColumns}.</p>
*
* @param uri The data in the content provider being queried.
* @param mimeTypeFilter The type of data the client desires. May be
* a pattern, such as */*, if the caller does not have specific type
* requirements; in this case the content provider will pick its best
* type matching the pattern.
* @param opts Additional options from the client. The definitions of
* these are specific to the content provider being called.
*
* @return Returns a new AssetFileDescriptor from which the client can
* read data of the desired type.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the data.
* @throws IllegalArgumentException Throws IllegalArgumentException if the
* content provider does not support the requested MIME type.
*
* @see #getStreamTypes(Uri, String)
* @see #openAssetFile(Uri, String)
* @see ClipDescription#compareMimeTypes(String, String)
*/
public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts)
throws FileNotFoundException {
if ("*/*".equals(mimeTypeFilter)) {
// If they can take anything, the untyped open call is good enough.
return openAssetFile(uri, "r");
}
String baseType = getType(uri);
if (baseType != null && ClipDescription.compareMimeTypes(baseType, mimeTypeFilter)) {
// Use old untyped open call if this provider has a type for this
// URI and it matches the request.
return openAssetFile(uri, "r");
}
throw new FileNotFoundException("Can't open " + uri + " as type " + mimeTypeFilter);
}
/**
* Called by a client to open a read-only stream containing data of a
* particular MIME type. This is like {@link #openAssetFile(Uri, String)},
* except the file can only be read-only and the content provider may
* perform data conversions to generate data of the desired type.
*
* <p>The default implementation compares the given mimeType against the
* result of {@link #getType(Uri)} and, if they match, simply calls
* {@link #openAssetFile(Uri, String)}.
*
* <p>See {@link ClipData} for examples of the use and implementation
* of this method.
* <p>
* The returned AssetFileDescriptor can be a pipe or socket pair to enable
* streaming of data.
*
* <p class="note">For better interoperability with other applications, it is recommended
* that for any URIs that can be opened, you also support queries on them
* containing at least the columns specified by {@link android.provider.OpenableColumns}.
* You may also want to support other common columns if you have additional meta-data
* to supply, such as {@link android.provider.MediaStore.MediaColumns#DATE_ADDED}
* in {@link android.provider.MediaStore.MediaColumns}.</p>
*
* @param uri The data in the content provider being queried.
* @param mimeTypeFilter The type of data the client desires. May be
* a pattern, such as */*, if the caller does not have specific type
* requirements; in this case the content provider will pick its best
* type matching the pattern.
* @param opts Additional options from the client. The definitions of
* these are specific to the content provider being called.
* @param signal A signal to cancel the operation in progress, or
* {@code null} if none. For example, if you are downloading a
* file from the network to service a "rw" mode request, you
* should periodically call
* {@link CancellationSignal#throwIfCanceled()} to check whether
* the client has canceled the request and abort the download.
*
* @return Returns a new AssetFileDescriptor from which the client can
* read data of the desired type.
*
* @throws FileNotFoundException Throws FileNotFoundException if there is
* no file associated with the given URI or the mode is invalid.
* @throws SecurityException Throws SecurityException if the caller does
* not have permission to access the data.
* @throws IllegalArgumentException Throws IllegalArgumentException if the
* content provider does not support the requested MIME type.
*
* @see #getStreamTypes(Uri, String)
* @see #openAssetFile(Uri, String)
* @see ClipDescription#compareMimeTypes(String, String)
*/
public AssetFileDescriptor openTypedAssetFile(
Uri uri, String mimeTypeFilter, Bundle opts, CancellationSignal signal)
throws FileNotFoundException {
return openTypedAssetFile(uri, mimeTypeFilter, opts);
}
/**
* Interface to write a stream of data to a pipe. Use with
* {@link ContentProvider#openPipeHelper}.
*/
public interface PipeDataWriter<T> {
/**
* Called from a background thread to stream data out to a pipe.
* Note that the pipe is blocking, so this thread can block on
* writes for an arbitrary amount of time if the client is slow
* at reading.
*
* @param output The pipe where data should be written. This will be
* closed for you upon returning from this function.
* @param uri The URI whose data is to be written.
* @param mimeType The desired type of data to be written.
* @param opts Options supplied by caller.
* @param args Your own custom arguments.
*/
public void writeDataToPipe(ParcelFileDescriptor output, Uri uri, String mimeType,
Bundle opts, T args);
}
/**
* A helper function for implementing {@link #openTypedAssetFile}, for
* creating a data pipe and background thread allowing you to stream
* generated data back to the client. This function returns a new
* ParcelFileDescriptor that should be returned to the caller (the caller
* is responsible for closing it).
*
* @param uri The URI whose data is to be written.
* @param mimeType The desired type of data to be written.
* @param opts Options supplied by caller.
* @param args Your own custom arguments.
* @param func Interface implementing the function that will actually
* stream the data.
* @return Returns a new ParcelFileDescriptor holding the read side of
* the pipe. This should be returned to the caller for reading; the caller
* is responsible for closing it when done.
*/
public <T> ParcelFileDescriptor openPipeHelper(final Uri uri, final String mimeType,
final Bundle opts, final T args, final PipeDataWriter<T> func)
throws FileNotFoundException {
try {
final ParcelFileDescriptor[] fds = ParcelFileDescriptor.createPipe();
AsyncTask<Object, Object, Object> task = new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... params) {
func.writeDataToPipe(fds[1], uri, mimeType, opts, args);
try {
fds[1].close();
} catch (IOException e) {
Log.w(TAG, "Failure closing pipe", e);
}
return null;
}
};
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Object[])null);
return fds[0];
} catch (IOException e) {
throw new FileNotFoundException("failure making pipe");
}
}
/**
* Returns true if this instance is a temporary content provider.
* @return true if this instance is a temporary content provider
*/
protected boolean isTemporary() {
return false;
}
/**
* Returns the Binder object for this provider.
*
* @return the Binder object for this provider
* @hide
*/
public IContentProvider getIContentProvider() {
return mTransport;
}
/**
* Like {@link #attachInfo(Context, android.content.pm.ProviderInfo)}, but for use
* when directly instantiating the provider for testing.
* @hide
*/
public void attachInfoForTesting(Context context, ProviderInfo info) {
attachInfo(context, info, true);
}
/**
* After being instantiated, this is called to tell the content provider
* about itself.
*
* @param context The context this provider is running in
* @param info Registered information about this content provider
*/
public void attachInfo(Context context, ProviderInfo info) {
attachInfo(context, info, false);
}
private void attachInfo(Context context, ProviderInfo info, boolean testing) {
/*
* We may be using AsyncTask from binder threads. Make it init here
* so its static handler is on the main thread.
*/
AsyncTask.init();
mNoPerms = testing;
/*
* Only allow it to be set once, so after the content service gives
* this to us clients can't change it.
*/
if (mContext == null) {
mContext = context;
if (context != null) {
mTransport.mAppOpsManager = (AppOpsManager) context.getSystemService(
Context.APP_OPS_SERVICE);
}
mMyUid = Process.myUid();
if (info != null) {
setReadPermission(info.readPermission);
setWritePermission(info.writePermission);
setPathPermissions(info.pathPermissions);
mExported = info.exported;
mSingleUser = (info.flags & ProviderInfo.FLAG_SINGLE_USER) != 0;
setAuthorities(info.authority);
}
ContentProvider.this.onCreate();
}
}
/**
* Override this to handle requests to perform a batch of operations, or the
* default implementation will iterate over the operations and call
* {@link ContentProviderOperation#apply} on each of them.
* If all calls to {@link ContentProviderOperation#apply} succeed
* then a {@link ContentProviderResult} array with as many
* elements as there were operations will be returned. If any of the calls
* fail, it is up to the implementation how many of the others take effect.
* This method can be called from multiple threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*
* @param operations the operations to apply
* @return the results of the applications
* @throws OperationApplicationException thrown if any operation fails.
* @see ContentProviderOperation#apply
*/
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
throws OperationApplicationException {
final int numOperations = operations.size();
final ContentProviderResult[] results = new ContentProviderResult[numOperations];
for (int i = 0; i < numOperations; i++) {
results[i] = operations.get(i).apply(this, results, i);
}
return results;
}
/**
* Call a provider-defined method. This can be used to implement
* interfaces that are cheaper and/or unnatural for a table-like
* model.
*
* <p class="note"><strong>WARNING:</strong> The framework does no permission checking
* on this entry into the content provider besides the basic ability for the application
* to get access to the provider at all. For example, it has no idea whether the call
* being executed may read or write data in the provider, so can't enforce those
* individual permissions. Any implementation of this method <strong>must</strong>
* do its own permission checks on incoming calls to make sure they are allowed.</p>
*
* @param method method name to call. Opaque to framework, but should not be {@code null}.
* @param arg provider-defined String argument. May be {@code null}.
* @param extras provider-defined Bundle argument. May be {@code null}.
* @return provider-defined return value. May be {@code null}, which is also
* the default for providers which don't implement any call methods.
*/
public Bundle call(String method, String arg, Bundle extras) {
return null;
}
/**
* Implement this to shut down the ContentProvider instance. You can then
* invoke this method in unit tests.
*
* <p>
* Android normally handles ContentProvider startup and shutdown
* automatically. You do not need to start up or shut down a
* ContentProvider. When you invoke a test method on a ContentProvider,
* however, a ContentProvider instance is started and keeps running after
* the test finishes, even if a succeeding test instantiates another
* ContentProvider. A conflict develops because the two instances are
* usually running against the same underlying data source (for example, an
* sqlite database).
* </p>
* <p>
* Implementing shutDown() avoids this conflict by providing a way to
* terminate the ContentProvider. This method can also prevent memory leaks
* from multiple instantiations of the ContentProvider, and it can ensure
* unit test isolation by allowing you to completely clean up the test
* fixture before moving on to the next test.
* </p>
*/
public void shutdown() {
Log.w(TAG, "implement ContentProvider shutdown() to make sure all database " +
"connections are gracefully shutdown");
}
/**
* Print the Provider's state into the given stream. This gets invoked if
* you run "adb shell dumpsys activity provider <provider_component_name>".
*
* @param fd The raw file descriptor that the dump is being sent to.
* @param writer The PrintWriter to which you should dump your state. This will be
* closed for you after you return.
* @param args additional arguments to the dump request.
*/
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
writer.println("nothing to dump");
}
/** @hide */
private void validateIncomingUri(Uri uri) throws SecurityException {
String auth = uri.getAuthority();
int userId = getUserIdFromAuthority(auth, UserHandle.USER_CURRENT);
if (userId != UserHandle.USER_CURRENT && userId != mContext.getUserId()) {
throw new SecurityException("trying to query a ContentProvider in user "
+ mContext.getUserId() + " with a uri belonging to user " + userId);
}
if (!matchesOurAuthorities(getAuthorityWithoutUserId(auth))) {
String message = "The authority of the uri " + uri + " does not match the one of the "
+ "contentProvider: ";
if (mAuthority != null) {
message += mAuthority;
} else {
message += mAuthorities;
}
throw new SecurityException(message);
}
}
/** @hide */
public static int getUserIdFromAuthority(String auth, int defaultUserId) {
if (auth == null) return defaultUserId;
int end = auth.lastIndexOf('@');
if (end == -1) return defaultUserId;
String userIdString = auth.substring(0, end);
try {
return Integer.parseInt(userIdString);
} catch (NumberFormatException e) {
Log.w(TAG, "Error parsing userId.", e);
return UserHandle.USER_NULL;
}
}
/** @hide */
public static int getUserIdFromAuthority(String auth) {
return getUserIdFromAuthority(auth, UserHandle.USER_CURRENT);
}
/** @hide */
public static int getUserIdFromUri(Uri uri, int defaultUserId) {
if (uri == null) return defaultUserId;
return getUserIdFromAuthority(uri.getAuthority(), defaultUserId);
}
/** @hide */
public static int getUserIdFromUri(Uri uri) {
return getUserIdFromUri(uri, UserHandle.USER_CURRENT);
}
/**
* Removes userId part from authority string. Expects format:
* [email protected]
* If there is no userId in the authority, it symply returns the argument
* @hide
*/
public static String getAuthorityWithoutUserId(String auth) {
if (auth == null) return null;
int end = auth.lastIndexOf('@');
return auth.substring(end+1);
}
/** @hide */
public static Uri getUriWithoutUserId(Uri uri) {
if (uri == null) return null;
Uri.Builder builder = uri.buildUpon();
builder.authority(getAuthorityWithoutUserId(uri.getAuthority()));
return builder.build();
}
/** @hide */
public static boolean uriHasUserId(Uri uri) {
if (uri == null) return false;
return !TextUtils.isEmpty(uri.getUserInfo());
}
/** @hide */
public static Uri maybeAddUserId(Uri uri, int userId) {
if (uri == null) return null;
if (userId != UserHandle.USER_CURRENT
&& ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
if (!uriHasUserId(uri)) {
//We don't add the user Id if there's already one
Uri.Builder builder = uri.buildUpon();
builder.encodedAuthority("" + userId + "@" + uri.getEncodedAuthority());
return builder.build();
}
}
return uri;
}
}
| [
"[email protected]"
] | |
fde9cb4eb6d76f18a5e6a95e1533a1d40ccc0359 | edb6910171402be6db714fa7a702aceeb80779bb | /src-test/src/org/openbravo/test/pricelist/data/PriceListTestData7.java | a982f430ebb3c8658730cb8127ce388a26f6f054 | [
"Apache-2.0"
] | permissive | eid101/InjazErp | 2e87b9f0f66fcb5c8b3db251496968f9029c6b7f | 6d7c69a9d3a6023e093ab0d7b356983fdee1e4c8 | refs/heads/master | 2021-05-09T20:04:10.687300 | 2018-01-24T01:39:46 | 2018-01-24T01:39:46 | 118,670,797 | 0 | 0 | Apache-2.0 | 2018-08-29T03:51:21 | 2018-01-23T21:15:39 | Java | UTF-8 | Java | false | false | 3,418 | java | /*
*************************************************************************
* The contents of this file are subject to the Openbravo Public License
* Version 1.1 (the "License"), being the Mozilla Public License
* Version 1.1 with a permitted attribution clause; you may not use this
* file except in compliance with the License. You may obtain a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2017 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
*/
package org.openbravo.test.pricelist.data;
import java.math.BigDecimal;
import java.util.HashMap;
/**
* Data used for Test: Price List Schema with Fixed Price or Cost Based, an entire Product Category
* and base Price List.
*
* @author Mark
*
*/
public class PriceListTestData7 extends PriceListTestData {
@Override
public void initialize() {
// Define the rule to be applied when the price list be generated
PriceListSchemaLineTestData ruleLine = new PriceListSchemaLineTestData();
ruleLine.setProductCategoryId(PriceListTestConstants.DISTRIBUTION_GOODS_PRODUCT_CATEGORY);
ruleLine.setBaseListPriceValue(PriceListTestConstants.REFLIST_VALUE_FIXED_PRICE_OR_COST_BASED);
ruleLine.setFixedListPrice(new BigDecimal("11.73"));
ruleLine.setListPriceMargin(new BigDecimal("10"));
ruleLine
.setBaseStandardPriceValue(PriceListTestConstants.REFLIST_VALUE_FIXED_PRICE_OR_COST_BASED);
ruleLine.setFixedStandardPrice(new BigDecimal("9.65"));
ruleLine.setUnitPriceMargin(new BigDecimal("10"));
// Add lines
setTestPriceListRulesData(new PriceListSchemaLineTestData[] { ruleLine });
/**
* This Map will be used to verify Product Prices values after test is executed. Map has the
* following structure: <Product name, [Unit Price Expected, List Price Expected]>
*/
HashMap<String, String[]> productPriceLines = new HashMap<String, String[]>();
productPriceLines.put(PriceListTestConstants.LAPTOP_PRODUCT_NAME, new String[] { "11.00",
"11.73" });
productPriceLines.put(PriceListTestConstants.SOCCER_BALL_PRODUCT_NAME, new String[] { "11.00",
"11.73" });
productPriceLines.put(PriceListTestConstants.T_SHIRTS_PRODUCT_NAME, new String[] { "11.00",
"11.73" });
productPriceLines.put(PriceListTestConstants.TENNIS_BALL_PRODUCT_NAME, new String[] { "11.00",
"11.73" });
setExpectedProductPrices(productPriceLines);
// Price List Header
setOrganizationId(PriceListTestConstants.SPAIN_ORGANIZATION_ID);
setPriceListName(PriceListTestConstants.PRICE_LIST_NAME);
setCurrencyId(PriceListTestConstants.EUR_CURRENCY_ID);
setSalesPrice(true);
// This will be a Price list Based on Cost
setBasedOnCost(true);
setPriceIncludesTax(false);
// Price List Version
setBasePriceListVersionId(PriceListTestConstants.CUSTOMER_B_PRICE_LIST_VERSION_ID);
}
}
| [
"[email protected]"
] | |
aff7d4ce42deaf3ab670d7039bc1b444da23609a | 47665b453015388da7f2336d95bc08c48f567252 | /InterfaceA.java | e3e3eb12c5d78c86c738914744e9efd752cfbccc | [] | no_license | JasonLi2/ReflectiveSerialization | 786c10d5d9a8074b40d4bbc3489752afc804b596 | fcba618dfddfd16537eade189d333f37b2de5a5b | refs/heads/main | 2023-02-05T17:18:37.970935 | 2020-12-14T21:38:38 | 2020-12-14T21:38:38 | 321,479,135 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 239 | java | public interface InterfaceA extends InterfaceB {
public void func1(int a, double b, boolean c, String s) throws Exception;
public int func2(String s) throws Exception, ArithmeticException, IllegalMonitorStateException;
}
| [
"[email protected]"
] | |
be46d7c98ae287102cbb9b6cab86543dc06033b9 | 883b7801d828a0994cae7367a7097000f2d2e06a | /python/experiments/projects/benetech-ServiceNet/real_error_dataset/1/22/OrganizationRepository.java | ed70e522562fa6702439681cebcb0568ad3fee4b | [] | no_license | pombredanne/styler | 9c423917619912789289fe2f8982d9c0b331654b | f3d752d2785c2ab76bacbe5793bd8306ac7961a1 | refs/heads/master | 2023-07-08T05:55:18.284539 | 2020-11-06T05:09:47 | 2020-11-06T05:09:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,303 | java | package org.benetech.servicenet.repository;
import org.benetech.servicenet.domain.Organization;
import org.benetech.servicenet.domain.UserProfile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
/**
* Spring Data repository for the Organization entity.
*/
@Repository
public interface OrganizationRepository extends JpaRepository<Organization, UUID> {
@Query("SELECT org FROM Organization org WHERE org.account.id = :ownerId")
List<Organization> findAllWithOwnerId(@Param("ownerId") UUID ownerId);
@Query("SELECT org FROM Organization org WHERE :userProfile MEMBER OF org.userProfiles")
List<Organization> findAllWithUserProfile(@Param("userProfile") UserProfile userProfile);
@Query("SELECT org FROM Organization org WHERE org.account.id = :ownerId")
Page<Organization> findAllWithOwnerId(@Param("ownerId") UUID ownerId, Pageable pageable);
@Query("SELECT org FROM Organization org "
+ "LEFT JOIN FETCH org.account "
+ "LEFT JOIN FETCH org.locations")
List<Organization> findAllWithEagerAssociations();
@Query("SELECT org FROM Organization org "
+ "LEFT JOIN FETCH org.account "
+ "LEFT JOIN FETCH org.locations "
+ "WHERE org.id = :id")
Organization findOneWithEagerAssociations(@Param("id") UUID id);
@Query("SELECT org FROM Organization org " +
"LEFT JOIN FETCH org.contacts " +
"WHERE org.externalDbId = :externalDbId AND org.account.name = :providerName")
Optional<Organization> findOneWithEagerAssociationsByExternalDbIdAndProviderName(@Param("externalDbId")
String externalDbId,
@Param("providerName")
String providerName);
List<Organization> findAllByIdOrExternalDbId(UUID id, String externalDbId);
@Query("SELECT org FROM Organization org WHERE org.account.name != :providerName AND org.active = True")
List<Organization> findAllByProviderNameNot(@Param("providerName") String providerName);
@Query("SELECT org FROM Organization org WHERE org.id NOT IN :ids "
+ "AND org.account.name != :providerName AND org.active = True")
List<Organization> findAllByProviderNameNotAnAndIdNotIn(@Param("providerName") String providerName,
@Param("ids") List<UUID> ids);
Page<Organization> findAll(Pageable pageable);
@Query("SELECT org FROM Organization org "
+ "LEFT JOIN FETCH org.account "
+ "LEFT JOIN FETCH org.locations locs "
+ "LEFT JOIN FETCH org.services srvs "
+ "LEFT JOIN FETCH org.contacts "
+ "LEFT JOIN FETCH org.phones "
+ "LEFT JOIN FETCH org.programs "
+ "LEFT JOIN FETCH locs.regularSchedule lRS "
+ "LEFT JOIN FETCH lRS.openingHours "
+ "LEFT JOIN FETCH locs.holidaySchedules "
+ "LEFT JOIN FETCH locs.langs "
+ "LEFT JOIN FETCH locs.accessibilities "
+ "LEFT JOIN FETCH srvs.regularSchedule sRS "
+ "LEFT JOIN FETCH sRS.openingHours "
+ "LEFT JOIN FETCH srvs.holidaySchedules "
+ "LEFT JOIN FETCH srvs.funding "
+ "LEFT JOIN FETCH srvs.eligibility "
+ "LEFT JOIN FETCH srvs.docs "
+ "LEFT JOIN FETCH srvs.paymentsAccepteds "
+ "LEFT JOIN FETCH srvs.langs "
+ "LEFT JOIN FETCH srvs.taxonomies "
+ "LEFT JOIN FETCH srvs.phones "
+ "LEFT JOIN FETCH srvs.contacts "
+ "WHERE org.id = :id OR "
+ "org.externalDbId = :externalDbId OR "
+ "locs.id = :id OR "
+ "locs.externalDbId = :externalDbId OR "
+ "srvs.id = :id OR "
+ "srvs.externalDbId = :externalDbId")
Organization findOneWithAllEagerAssociationsByIdOrExternalDbId(@Param("id") UUID id, @Param("externalDbId") String externalDbId);
}
| [
"[email protected]"
] | |
f94e6d5e44432de5b172ced8113828ff2bdcf668 | ba780d92d577527fdf370e656b70b2bf29c220e8 | /src/main/java/part2/Client.java | 71303a6284c3a2cadfeb2a25e049fdd7d516c220 | [] | no_license | ShuLi1023/TP2_RMI | 6d3d44e64d9eaf3b207037546469d6c338d5993d | 348fd574f351f0b010a426f0e655cbd6050e090e | refs/heads/master | 2023-01-08T05:03:17.441638 | 2020-11-03T11:39:12 | 2020-11-03T11:39:12 | 306,367,953 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,591 | java | package part2;
import part2.entity.Exam;
import part2.entity.Student;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
public static void main(String[] args) {
try{
Registry registry = LocateRegistry.getRegistry(1888);
PromotionInterface p = (PromotionInterface) registry.lookup( "rmi://localhost:1888/Server" );
Student student1 = new Student("A",27,001);
Student student2 = new Student("B",28,002);
p.add_student(student1);
p.add_student(student2);
p.get_student("A").add_exam(new Exam("Math",90,0.7));
p.get_student("A").add_exam(new Exam("English",80,0.5));
p.get_student("A").add_exam(new Exam("French",85,0.4));
p.get_student("B").add_exam(new Exam("Math",95,0.7));
p.get_student("B").add_exam(new Exam("English",85,0.5));
System.out.println("avg score of A: " + p.get_student("A").calculate_average());
System.out.println("avg score of B: " + p.get_student("B").calculate_average());
System.out.println("exams of A: " + p.get_student("A").print_exams());
System.out.println("exams of B: " + p.get_student("B").print_exams());
System.out.println("promotion score: " + p.promotion_score());
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
d55ccf2309c619ef8c787d16db1c1ca955e39ca4 | af90f8f0a96944c76b0c3b040ddd6318e0bbbb9e | /app/src/main/java/pondthaitay/googlemapapi/exercises/template/frangment/CustomPresenter.java | e3f97fcdb6ff6aad73b73d3b2b367f559c2bcc4d | [] | no_license | jedsada-gh/GoogleMapAPI-Exercises | 5f32548382e47e29859dbe26ce4d8e4a5ae6a5cd | 9ec12320694660f509e40e48d18ba86d9cea41e9 | refs/heads/master | 2023-05-25T03:00:48.985934 | 2017-05-25T13:41:07 | 2017-05-25T13:41:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 552 | java | package pondthaitay.googlemapapi.exercises.template.frangment;
import javax.inject.Inject;
import pondthaitay.googlemapapi.exercises.ui.base.BasePresenter;
class CustomPresenter extends BasePresenter<CustomInterface.View>
implements CustomInterface.Presenter {
@Inject
CustomPresenter() {
super();
}
@Override
public void onViewCreate() {
}
@Override
public void onViewDestroy() {
}
@Override
public void onViewStart() {
}
@Override
public void onViewStop() {
}
}
| [
"[email protected]"
] | |
0c96b6841212a142823db4b5af2ef9c2c9406f40 | 33cdce4283fac44f5faccd16e840633995b8b6e1 | /app/src/main/java/com/apps/realtimetrackersample/LocationTracker.java | 598c7ee897eec8b94f0599e5088044b974e8c66b | [] | no_license | SaumyaSNayak/RealTimeTrackerSample | 9bac8878aad04f1dc2fccc7e6ce9a04e2aac262f | 5642c27931c7f58ae5fd77b422c73efba2bbe6f6 | refs/heads/master | 2020-03-18T18:11:35.120959 | 2018-05-27T19:43:13 | 2018-05-27T19:43:13 | 135,076,339 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,067 | java | package com.apps.realtimetrackersample;
import android.Manifest;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import java.util.ArrayList;
public class LocationTracker extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
private LatLng locationMarker;
private ArrayList<LatLng> path = new ArrayList<LatLng>();
public LocationTracker() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
requestLocationUpdates();
return super.onStartCommand(intent, flags, startId);
}
private void requestLocationUpdates() {
final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationRequest request = new LocationRequest();
request.setInterval(2000);
request.setFastestInterval(2000);
request.setSmallestDisplacement(1F);
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(this);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
|| !manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
return;
} else {
client.requestLocationUpdates(request, new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
Location location = locationResult.getLastLocation();
locationMarker = new LatLng(location.getLatitude(), location.getLongitude());
Intent intent = new Intent("LatLong");
Bundle bundle = new Bundle();
bundle.putParcelable("Location", locationMarker);
intent.putExtra("Location", bundle);
LocalBroadcastManager.getInstance(LocationTracker.this).sendBroadcast(intent);
path.add(locationMarker);
}
}, null);
}
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onConnected(@Nullable Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
}
| [
"[email protected]"
] | |
dcef8f80ee3b42d53005e57a971fe3f86ce32ec6 | 4b21fdfbf29aad643285b7167058d42dbfc576a4 | /xiao_AI_intelligent/framework/it/sauronsoftware/jave/Encoder.java | 5999cd729518aaad77ca928010e1bcb00c731339 | [] | no_license | KB-ROBOT/kb-robot | ff249ec9b9f3ba63db338cafa20db9e2c1cb2f93 | 3227cfebdd7530d4d009626dc9d7a1636c4544e6 | refs/heads/master | 2020-05-21T20:06:56.746789 | 2017-03-27T09:53:02 | 2017-03-27T09:53:02 | 64,918,724 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 29,495 | java | /*
* JAVE - A Java Audio/Video Encoder (based on FFMPEG)
*
* Copyright (C) 2008-2009 Carlo Pelliccia (www.sauronsoftware.it)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.sauronsoftware.jave;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Main class of the package. Instances can encode audio and video streams.
*
* @author Carlo Pelliccia
*/
public class Encoder {
/**
* This regexp is used to parse the ffmpeg output about the supported
* formats.
*/
private static final Pattern FORMAT_PATTERN = Pattern
.compile("^\\s*([D ])([E ])\\s+([\\w,]+)\\s+.+$");
/**
* This regexp is used to parse the ffmpeg output about the included
* encoders/decoders.
*/
private static final Pattern ENCODER_DECODER_PATTERN = Pattern.compile(
"^\\s*([D ])([E ])([AVS]).{3}\\s+(.+)$", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the ongoing encoding
* process.
*/
private static final Pattern PROGRESS_INFO_PATTERN = Pattern.compile(
"\\s*(\\w+)\\s*=\\s*(\\S+)\\s*", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the size of a video
* stream.
*/
private static final Pattern SIZE_PATTERN = Pattern.compile(
"(\\d+)x(\\d+)", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the frame rate value
* of a video stream.
*/
private static final Pattern FRAME_RATE_PATTERN = Pattern.compile(
"([\\d.]+)\\s+(?:fps|tb\\(r\\))", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the bit rate value
* of a stream.
*/
private static final Pattern BIT_RATE_PATTERN = Pattern.compile(
"(\\d+)\\s+kb/s", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the sampling rate of
* an audio stream.
*/
private static final Pattern SAMPLING_RATE_PATTERN = Pattern.compile(
"(\\d+)\\s+Hz", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the channels number
* of an audio stream.
*/
private static final Pattern CHANNELS_PATTERN = Pattern.compile(
"(mono|stereo)", Pattern.CASE_INSENSITIVE);
/**
* This regexp is used to parse the ffmpeg output about the success of an
* encoding operation.
*/
private static final Pattern SUCCESS_PATTERN = Pattern.compile(
"^\\s*video\\:\\S+\\s+audio\\:\\S+\\s+global headers\\:\\S+.*$",
Pattern.CASE_INSENSITIVE);
/**
* The locator of the ffmpeg executable used by this encoder.
*/
private FFMPEGLocator locator;
/**
* It builds an encoder using a {@link DefaultFFMPEGLocator} instance to
* locate the ffmpeg executable to use.
*/
public Encoder() {
this.locator = new DefaultFFMPEGLocator();
}
/**
* It builds an encoder with a custom {@link FFMPEGLocator}.
*
* @param locator
* The locator picking up the ffmpeg executable used by the
* encoder.
*/
public Encoder(FFMPEGLocator locator) {
this.locator = locator;
}
/**
* Returns a list with the names of all the audio decoders bundled with the
* ffmpeg distribution in use. An audio stream can be decoded only if a
* decoder for its format is available.
*
* @return A list with the names of all the included audio decoders.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getAudioDecoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
String audioVideoFlag = matcher.group(3);
if ("D".equals(decoderFlag)
&& "A".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a list with the names of all the audio encoders bundled with the
* ffmpeg distribution in use. An audio stream can be encoded using one of
* these encoders.
*
* @return A list with the names of all the included audio encoders.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getAudioEncoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
String audioVideoFlag = matcher.group(3);
if ("E".equals(encoderFlag)
&& "A".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a list with the names of all the video decoders bundled with the
* ffmpeg distribution in use. A video stream can be decoded only if a
* decoder for its format is available.
*
* @return A list with the names of all the included video decoders.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getVideoDecoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
String audioVideoFlag = matcher.group(3);
if ("D".equals(decoderFlag)
&& "V".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a list with the names of all the video encoders bundled with the
* ffmpeg distribution in use. A video stream can be encoded using one of
* these encoders.
*
* @return A list with the names of all the included video encoders.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getVideoEncoders() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = ENCODER_DECODER_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
String audioVideoFlag = matcher.group(3);
if ("E".equals(encoderFlag)
&& "V".equals(audioVideoFlag)) {
String name = matcher.group(4);
res.add(name);
}
} else {
break;
}
} else if (line.trim().equals("Codecs:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a list with the names of all the file formats supported at
* encoding time by the underlying ffmpeg distribution. A multimedia file
* could be encoded and generated only if the specified format is in this
* list.
*
* @return A list with the names of all the supported file formats at
* encoding time.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getSupportedEncodingFormats() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = FORMAT_PATTERN.matcher(line);
if (matcher.matches()) {
String encoderFlag = matcher.group(2);
if ("E".equals(encoderFlag)) {
String aux = matcher.group(3);
StringTokenizer st = new StringTokenizer(aux, ",");
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
if (!res.contains(token)) {
res.add(token);
}
}
}
} else {
break;
}
} else if (line.trim().equals("File formats:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a list with the names of all the file formats supported at
* decoding time by the underlying ffmpeg distribution. A multimedia file
* could be open and decoded only if its format is in this list.
*
* @return A list with the names of all the supported file formats at
* decoding time.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public String[] getSupportedDecodingFormats() throws EncoderException {
ArrayList res = new ArrayList();
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-formats");
try {
ffmpeg.execute();
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getInputStream()));
String line;
boolean evaluate = false;
while ((line = reader.readLine()) != null) {
if (line.trim().length() == 0) {
continue;
}
if (evaluate) {
Matcher matcher = FORMAT_PATTERN.matcher(line);
if (matcher.matches()) {
String decoderFlag = matcher.group(1);
if ("D".equals(decoderFlag)) {
String aux = matcher.group(3);
StringTokenizer st = new StringTokenizer(aux, ",");
while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
if (!res.contains(token)) {
res.add(token);
}
}
}
} else {
break;
}
} else if (line.trim().equals("File formats:")) {
evaluate = true;
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
int size = res.size();
String[] ret = new String[size];
for (int i = 0; i < size; i++) {
ret[i] = (String) res.get(i);
}
return ret;
}
/**
* Returns a set informations about a multimedia file, if its format is
* supported for decoding.
*
* @param source
* The source multimedia file.
* @return A set of informations about the file and its contents.
* @throws InputFormatException
* If the format of the source file cannot be recognized and
* decoded.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
public MultimediaInfo getInfo(File source) throws InputFormatException,
EncoderException {
FFMPEGExecutor ffmpeg = locator.createExecutor();
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
return parseMultimediaInfo(source, reader);
} finally {
ffmpeg.destroy();
}
}
/**
* Private utility. It parses the ffmpeg output, extracting informations
* about a source multimedia file.
*
* @param source
* The source multimedia file.
* @param reader
* The ffmpeg output channel.
* @return A set of informations about the source multimedia file and its
* contents.
* @throws InputFormatException
* If the format of the source file cannot be recognized and
* decoded.
* @throws EncoderException
* If a problem occurs calling the underlying ffmpeg executable.
*/
private MultimediaInfo parseMultimediaInfo(File source,
RBufferedReader reader) throws InputFormatException,
EncoderException {
Pattern p1 = Pattern.compile("^\\s*Input #0, (\\w+).+$\\s*",
Pattern.CASE_INSENSITIVE);
Pattern p2 = Pattern.compile(
"^\\s*Duration: (\\d\\d):(\\d\\d):(\\d\\d)\\.(\\d).*$",
Pattern.CASE_INSENSITIVE);
Pattern p3 = Pattern.compile(
"^\\s*Stream #\\S+: ((?:Audio)|(?:Video)|(?:Data)): (.*)\\s*$",
Pattern.CASE_INSENSITIVE);
MultimediaInfo info = null;
try {
int step = 0;
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
if (step == 0) {
String token = source.getAbsolutePath() + ": ";
if (line.startsWith(token)) {
String message = line.substring(token.length());
throw new InputFormatException(message);
}
Matcher m = p1.matcher(line);
if (m.matches()) {
String format = m.group(1);
info = new MultimediaInfo();
info.setFormat(format);
step++;
}
} else if (step == 1) {
Matcher m = p2.matcher(line);
if (m.matches()) {
long hours = Integer.parseInt(m.group(1));
long minutes = Integer.parseInt(m.group(2));
long seconds = Integer.parseInt(m.group(3));
long dec = Integer.parseInt(m.group(4));
long duration = (dec * 100L) + (seconds * 1000L)
+ (minutes * 60L * 1000L)
+ (hours * 60L * 60L * 1000L);
info.setDuration(duration);
step++;
} else {
step = 3;
}
} else if (step == 2) {
Matcher m = p3.matcher(line);
if (m.matches()) {
String type = m.group(1);
String specs = m.group(2);
if ("Video".equalsIgnoreCase(type)) {
VideoInfo video = new VideoInfo();
StringTokenizer st = new StringTokenizer(specs, ",");
for (int i = 0; st.hasMoreTokens(); i++) {
String token = st.nextToken().trim();
if (i == 0) {
video.setDecoder(token);
} else {
boolean parsed = false;
// Video size.
Matcher m2 = SIZE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int width = Integer.parseInt(m2
.group(1));
int height = Integer.parseInt(m2
.group(2));
video.setSize(new VideoSize(width,
height));
parsed = true;
}
// Frame rate.
m2 = FRAME_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
try {
float frameRate = Float
.parseFloat(m2.group(1));
video.setFrameRate(frameRate);
} catch (NumberFormatException e) {
;
}
parsed = true;
}
// Bit rate.
m2 = BIT_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int bitRate = Integer.parseInt(m2
.group(1));
video.setBitRate(bitRate);
parsed = true;
}
}
}
info.setVideo(video);
} else if ("Audio".equalsIgnoreCase(type)) {
AudioInfo audio = new AudioInfo();
StringTokenizer st = new StringTokenizer(specs, ",");
for (int i = 0; st.hasMoreTokens(); i++) {
String token = st.nextToken().trim();
if (i == 0) {
audio.setDecoder(token);
} else {
boolean parsed = false;
// Sampling rate.
Matcher m2 = SAMPLING_RATE_PATTERN
.matcher(token);
if (!parsed && m2.find()) {
int samplingRate = Integer.parseInt(m2
.group(1));
audio.setSamplingRate(samplingRate);
parsed = true;
}
// Channels.
m2 = CHANNELS_PATTERN.matcher(token);
if (!parsed && m2.find()) {
String ms = m2.group(1);
if ("mono".equalsIgnoreCase(ms)) {
audio.setChannels(1);
} else if ("stereo"
.equalsIgnoreCase(ms)) {
audio.setChannels(2);
}
parsed = true;
}
// Bit rate.
m2 = BIT_RATE_PATTERN.matcher(token);
if (!parsed && m2.find()) {
int bitRate = Integer.parseInt(m2
.group(1));
audio.setBitRate(bitRate);
parsed = true;
}
}
}
info.setAudio(audio);
}
} else {
step = 3;
}
}
if (step == 3) {
reader.reinsertLine(line);
break;
}
}
} catch (IOException e) {
throw new EncoderException(e);
}
if (info == null) {
throw new InputFormatException();
}
return info;
}
/**
* Private utility. Parse a line and try to match its contents against the
* {@link Encoder#PROGRESS_INFO_PATTERN} pattern. It the line can be parsed,
* it returns a hashtable with progress informations, otherwise it returns
* null.
*
* @param line
* The line from the ffmpeg output.
* @return A hashtable with the value reported in the line, or null if the
* given line can not be parsed.
*/
private Hashtable parseProgressInfoLine(String line) {
Hashtable table = null;
Matcher m = PROGRESS_INFO_PATTERN.matcher(line);
while (m.find()) {
if (table == null) {
table = new Hashtable();
}
String key = m.group(1);
String value = m.group(2);
table.put(key, value);
}
return table;
}
/**
* Re-encode a multimedia file.
*
* @param source
* The source multimedia file. It cannot be null. Be sure this
* file can be decoded (see
* {@link Encoder#getSupportedDecodingFormats()},
* {@link Encoder#getAudioDecoders()} and
* {@link Encoder#getVideoDecoders()}).
* @param target
* The target multimedia re-encoded file. It cannot be null. If
* this file already exists, it will be overwrited.
* @param attributes
* A set of attributes for the encoding process.
* @throws IllegalArgumentException
* If both audio and video parameters are null.
* @throws InputFormatException
* If the source multimedia file cannot be decoded.
* @throws EncoderException
* If a problems occurs during the encoding process.
*/
public void encode(File source, File target, EncodingAttributes attributes)
throws IllegalArgumentException, InputFormatException,
EncoderException {
encode(source, target, attributes, null);
}
/**
* Re-encode a multimedia file.
*
* @param source
* The source multimedia file. It cannot be null. Be sure this
* file can be decoded (see
* {@link Encoder#getSupportedDecodingFormats()},
* {@link Encoder#getAudioDecoders()} and
* {@link Encoder#getVideoDecoders()}).
* @param target
* The target multimedia re-encoded file. It cannot be null. If
* this file already exists, it will be overwrited.
* @param attributes
* A set of attributes for the encoding process.
* @param listener
* An optional progress listener for the encoding process. It can
* be null.
* @throws IllegalArgumentException
* If both audio and video parameters are null.
* @throws InputFormatException
* If the source multimedia file cannot be decoded.
* @throws EncoderException
* If a problems occurs during the encoding process.
*/
public void encode(File source, File target, EncodingAttributes attributes,
EncoderProgressListener listener) throws IllegalArgumentException,
InputFormatException, EncoderException {
String formatAttribute = attributes.getFormat();
Float offsetAttribute = attributes.getOffset();
Float durationAttribute = attributes.getDuration();
AudioAttributes audioAttributes = attributes.getAudioAttributes();
VideoAttributes videoAttributes = attributes.getVideoAttributes();
if (audioAttributes == null && videoAttributes == null) {
throw new IllegalArgumentException(
"Both audio and video attributes are null");
}
target = target.getAbsoluteFile();
target.getParentFile().mkdirs();
FFMPEGExecutor ffmpeg = locator.createExecutor();
if (offsetAttribute != null) {
ffmpeg.addArgument("-ss");
ffmpeg.addArgument(String.valueOf(offsetAttribute.floatValue()));
}
ffmpeg.addArgument("-i");
ffmpeg.addArgument(source.getAbsolutePath());
if (durationAttribute != null) {
ffmpeg.addArgument("-t");
ffmpeg.addArgument(String.valueOf(durationAttribute.floatValue()));
}
if (videoAttributes == null) {
ffmpeg.addArgument("-vn");
} else {
String codec = videoAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-vcodec");
ffmpeg.addArgument(codec);
}
String tag = videoAttributes.getTag();
if (tag != null) {
ffmpeg.addArgument("-vtag");
ffmpeg.addArgument(tag);
}
Integer bitRate = videoAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-b");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer frameRate = videoAttributes.getFrameRate();
if (frameRate != null) {
ffmpeg.addArgument("-r");
ffmpeg.addArgument(String.valueOf(frameRate.intValue()));
}
VideoSize size = videoAttributes.getSize();
if (size != null) {
ffmpeg.addArgument("-s");
ffmpeg.addArgument(String.valueOf(size.getWidth()) + "x"
+ String.valueOf(size.getHeight()));
}
}
if (audioAttributes == null) {
ffmpeg.addArgument("-an");
} else {
String codec = audioAttributes.getCodec();
if (codec != null) {
ffmpeg.addArgument("-acodec");
ffmpeg.addArgument(codec);
}
Integer bitRate = audioAttributes.getBitRate();
if (bitRate != null) {
ffmpeg.addArgument("-ab");
ffmpeg.addArgument(String.valueOf(bitRate.intValue()));
}
Integer channels = audioAttributes.getChannels();
if (channels != null) {
ffmpeg.addArgument("-ac");
ffmpeg.addArgument(String.valueOf(channels.intValue()));
}
Integer samplingRate = audioAttributes.getSamplingRate();
if (samplingRate != null) {
ffmpeg.addArgument("-ar");
ffmpeg.addArgument(String.valueOf(samplingRate.intValue()));
}
Integer volume = audioAttributes.getVolume();
if (volume != null) {
ffmpeg.addArgument("-vol");
ffmpeg.addArgument(String.valueOf(volume.intValue()));
}
}
ffmpeg.addArgument("-f");
ffmpeg.addArgument(formatAttribute);
ffmpeg.addArgument("-y");
ffmpeg.addArgument(target.getAbsolutePath());
try {
ffmpeg.execute();
} catch (IOException e) {
throw new EncoderException(e);
}
try {
String lastWarning = null;
long duration;
long progress = 0;
RBufferedReader reader = null;
reader = new RBufferedReader(new InputStreamReader(ffmpeg
.getErrorStream()));
MultimediaInfo info = parseMultimediaInfo(source, reader);
if (durationAttribute != null) {
duration = (long) Math
.round((durationAttribute.floatValue() * 1000L));
} else {
duration = info.getDuration();
if (offsetAttribute != null) {
duration -= (long) Math
.round((offsetAttribute.floatValue() * 1000L));
}
}
if (listener != null) {
listener.sourceInfo(info);
}
int step = 0;
String line;
while ((line = reader.readLine()) != null) {
if (step == 0) {
if (line.startsWith("WARNING: ")) {
if (listener != null) {
listener.message(line);
}
} else if (!line.startsWith("Output #0")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 1) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 2) {
if (!line.startsWith("Stream mapping:")) {
throw new EncoderException(line);
} else {
step++;
}
} else if (step == 3) {
if (!line.startsWith(" ")) {
step++;
}
}
if (step == 4) {
line = line.trim();
if (line.length() > 0) {
Hashtable table = parseProgressInfoLine(line);
if (table == null) {
if (listener != null) {
listener.message(line);
}
lastWarning = line;
} else {
if (listener != null) {
String time = (String) table.get("time");
if (time != null) {
int dot = time.indexOf('.');
if (dot > 0 && dot == time.length() - 2
&& duration > 0) {
String p1 = time.substring(0, dot);
String p2 = time.substring(dot + 1);
try {
long i1 = Long.parseLong(p1);
long i2 = Long.parseLong(p2);
progress = (i1 * 1000L)
+ (i2 * 100L);
int perm = (int) Math
.round((double) (progress * 1000L)
/ (double) duration);
if (perm > 1000) {
perm = 1000;
}
listener.progress(perm);
} catch (NumberFormatException e) {
;
}
}
}
}
lastWarning = null;
}
}
}
}
if (lastWarning != null) {
if (!SUCCESS_PATTERN.matcher(lastWarning).matches()) {
throw new EncoderException(lastWarning);
}
}
} catch (IOException e) {
throw new EncoderException(e);
} finally {
ffmpeg.destroy();
}
}
}
| [
"[email protected]"
] | |
f162967eee3a0a90e986378dee2cb98302ddc756 | 0b73edba1f99524694d1514d49dca1065cbd8cee | /ProjectEx03/src/main/java/com/csm/customer/service/BestMBoardService.java | ef3ddf06b02bc67c0425bc1039ddd9fad8e1d26b | [] | no_license | TeamCSM/CSM | 72169ae885c3c7b6c0171932ecdf8439d9d28e0e | 92d6d3e328815d287ce5c2008cdb43a29f8d4318 | refs/heads/master | 2021-05-15T04:27:40.986208 | 2018-03-22T10:31:37 | 2018-03-22T10:31:37 | 119,650,282 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | package com.csm.customer.service;
import java.util.List;
import com.csm.customer.domain.BestMVO;
import com.csm.customer.domain.BestQVO;
import com.csm.customer.domain.Criteria;
import com.csm.customer.domain.SearchCriteria;
import com.csm.user.domain.UserVO;
public interface BestMBoardService {
public void regist(BestMVO board)throws Exception;
public BestMVO read(Integer bno)throws Exception;
public void modify(BestMVO board)throws Exception;
public void answer(BestMVO vo)throws Exception;
public void remove(Integer bno)throws Exception;
public List<BestMVO> listAll() throws Exception;
public List<BestMVO> listCriteria(Criteria cri) throws Exception;
public int listCountCriteria(Criteria cri)throws Exception;
public int listSearchCount(SearchCriteria cri)throws Exception;
public List<BestMVO> listSearchCriteria(SearchCriteria cri)throws Exception;
}
| [
"[email protected]"
] | |
49a57efae0292607318cce9360f9e52191f7b4f9 | 9760f7b54d77cf937e2ebaf78f1036c5d29247d3 | /src/main/java/cz/martlin/cp/serializer/BaseSerializer.java | c379ff2fd197348f5858d02fe9baa214909dac3d | [] | no_license | martlin2cz/ConstantsProvider | c2048a373c1e2c879ce8d5ba62e21afb17836ae5 | 1b5cf512bbd72ea2d1e51f963165395a5bf6577b | refs/heads/master | 2021-01-10T07:19:14.082180 | 2016-03-07T00:20:08 | 2016-03-07T00:20:08 | 53,260,816 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 600 | java | package cz.martlin.cp.serializer;
/**
* Serializes and deserializes value of one type. Which and how - that's the
* question.
*
* @author martlin
*
* @param <T>
*/
public interface BaseSerializer<T> {
/**
* Parses value from given string.
*
* @param type
* @param value
* @return
* @throws Exception
*/
public abstract T parse(Class<T> type, String value) throws Exception;
/**
* Serializes given value to string.
*
* @param type
* @param value
* @return
* @throws Exception
*/
public abstract String serialize(Class<T> type, T value) throws Exception;
}
| [
"[email protected]"
] | |
3d2b8cb68ce0cf97914316d6d0358b12e4c455ed | e3e17f440c7c1e27be41f7d634af0da5369486d4 | /NewTestAutomationFramework/src/lesson3/part1/additional/Task8.java | 531f6568a0daecdeca052182458c0a57c97e0f82 | [] | no_license | AllaShechovtsova/TestAutomationLessons | 41815aa37d5f4e9dec4ff0ef1b261f73dc18b6ee | 1bb013267ddfc9acae67842c0c86a381e3ee48b8 | refs/heads/master | 2021-06-16T12:04:58.308961 | 2017-03-13T17:09:07 | 2017-03-13T17:09:07 | 73,172,160 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 503 | java | package lesson3.part1.additional;
public class Task8 {
public String showCombination(String myWord, int myNumber){
String myCombination="";
for (int i=myNumber;i>=1; i--){
myCombination=myCombination+myWord.substring(0,i);
}
return myCombination;
}
public static void main(String[] args) {
Task8 myInstance=new Task8();
System.out.println(myInstance.showCombination("Testing", 4));
System.out.println(myInstance.showCombination("SoftwareTesting", 12));
}
}
| [
"[email protected]"
] | |
625bd6769c40a4fe15f00a23b24b933baf841bc6 | 8342246e1920ee930aa337b7e89c7fd0d20fc839 | /기초5_2_문자열/src/_1131_문자출력하기.java | c770efd760d756b2612377402f3f0152268ed2e8 | [] | no_license | sujinkim123/CodeUp | 5945945e6ff06bb696032123af9c874bf8d61b34 | 663be91d8a559d72af2447df8f3956a8c2287244 | refs/heads/master | 2023-06-05T10:02:44.234854 | 2021-06-27T15:06:06 | 2021-06-27T15:06:06 | 378,378,916 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 216 | java | import java.util.Scanner;
public class _1131_문자출력하기 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
char c = stdIn.next().charAt(0);
System.out.println(c);
}
}
| [
"[email protected]"
] | |
bb64e741ccf07bdac9347f467cfa2031937df3b8 | 4fcf2a9bff70aa293e02bf4df1a6f4d4e67ad6b2 | /atm_system/src/atm_system/FastCash.java | cd549e277f139606435fc6f05acfd0f86fcf1dde | [] | no_license | yuktachadha/ATM_Simulator_System | 00efeeb223d698aa9350003d0b91880cf3b1e66a | d29d9d1181ee1f4f106487e98bf0831010a28ea4 | refs/heads/master | 2023-01-31T01:23:29.986683 | 2020-12-16T06:02:07 | 2020-12-16T06:02:07 | 321,882,924 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,466 | java | package atm_system;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
public class FastCash extends JFrame implements ActionListener{
JLabel l1,l2;
JButton b1,b2,b3,b4,b5,b6,b7,b8;
JTextField t1;
FastCash(){
setFont(new Font("System", Font.BOLD, 22));
Font f = getFont();
FontMetrics fm = getFontMetrics(f);
int x = fm.stringWidth("FAST CASH");
int y = fm.stringWidth(" ");
int z = getWidth() - (4*x);
int w = z/y;
String pad ="";
//for (int i=0; i!=w; i++) pad +=" ";
pad = String.format("%"+w+"s", pad);
setTitle(pad+"FAST CASH");
l1 = new JLabel("SELECT WITHDRAWL AMOUNT");
l1.setFont(new Font("System", Font.BOLD, 38));
l2 = new JLabel("Enter PIN");
l2.setFont(new Font("System", Font.BOLD, 13));
t1 = new JTextField();
t1.setFont(new Font("System", Font.BOLD, 13));
b1 = new JButton("Rs 100");
b1.setFont(new Font("System", Font.BOLD, 18));
b1.setBackground(Color.BLACK);
b1.setForeground(Color.WHITE);
b2 = new JButton("Rs 500");
b2.setFont(new Font("System", Font.BOLD, 18));
b2.setBackground(Color.BLACK);
b2.setForeground(Color.WHITE);
b3 = new JButton("Rs 1000");
b3.setFont(new Font("System", Font.BOLD, 18));
b3.setBackground(Color.BLACK);
b3.setForeground(Color.WHITE);
b4 = new JButton("Rs 2000");
b4.setFont(new Font("System", Font.BOLD, 18));
b4.setBackground(Color.BLACK);
b4.setForeground(Color.WHITE);
b5 = new JButton("Rs 5000");
b5.setFont(new Font("System", Font.BOLD, 18));
b5.setBackground(Color.BLACK);
b5.setForeground(Color.WHITE);
b6 = new JButton("Rs 10000");
b6.setFont(new Font("System", Font.BOLD, 18));
b6.setBackground(Color.BLACK);
b6.setForeground(Color.WHITE);
b7 = new JButton("BACK");
b7.setFont(new Font("System", Font.BOLD, 18));
b7.setBackground(Color.BLACK);
b7.setForeground(Color.WHITE);
b7 = new JButton("EXIT");
b7.setFont(new Font("System", Font.BOLD, 18));
b7.setBackground(Color.BLACK);
b7.setForeground(Color.WHITE);
setLayout(null);
l2.setBounds(640,10,60,40);
add(l2);
t1.setBounds(710,10,60,40);
add(t1);
l1.setBounds(100,100,700,40);
add(l1);
b1.setBounds(40,250,300,60);
add(b1);
b2.setBounds(440,250,300,60);
add(b2);
b3.setBounds(40,360,300,60);
add(b3);
b4.setBounds(440,360,300,60);
add(b4);
b5.setBounds(40,470,300,60);
add(b5);
b6.setBounds(440,470,300,60);
add(b6);
b7.setBounds(240,600,300,60);
add(b7);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
getContentPane().setBackground(Color.WHITE);
setSize(800,800);
setLocation(500,90);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
try{
String a = t1.getText();
double balance = 0;
if(ae.getSource()==b1){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=100;
String q1= "insert into bank values('"+pin+"',null,100,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+100+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b2){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=500;
String q1= "insert into bank values('"+pin+"',null,500,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+500+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b3){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=1000;
String q1= "insert into bank values('"+pin+"',null,1000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+1000+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b4){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=2000;
String q1= "insert into bank values('"+pin+"',null,2000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+2000+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b5){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=5000;
String q1= "insert into bank values('"+pin+"',null,5000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+5000+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b6){
Conn c1 = new Conn();
ResultSet rs = c1.s.executeQuery(" select * from bank where pin = '"+a+"' ");
if(rs.next()){
String pin = rs.getString("pin");
balance = rs.getDouble("balance");
balance-=10000;
String q1= "insert into bank values('"+pin+"',null,10000,'"+balance+"')";
c1.s.executeUpdate(q1);
}
JOptionPane.showMessageDialog(null, "Rs. "+10000+" Debited Successfully");
new Transactions().setVisible(true);
setVisible(false);
}
else if(ae.getSource()==b7){
System.exit(0);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("error: "+e);
}
}
public static void main(String[] args){
new FastCash().setVisible(true);
}
} | [
"acer@LAPTOP-785GIK4B"
] | acer@LAPTOP-785GIK4B |
60b0049ab453651fe754c6a7e103d08160db4c1d | 06a89ad43f85232f7fd710eb78d16b3804318a91 | /src/main/java/com/naif/tools/dbffile/DBFFile.java | 4612fc35082ad5b1ae63c2db5de23dc15131f648 | [] | no_license | nelsonjava/naif | 40d08e644750bfa60a618ab4390180764e9e5fea | af1ee95ed44aff5e9b25c05b0c57bccd61eccad7 | refs/heads/master | 2020-06-04T17:07:49.631807 | 2014-07-08T04:29:56 | 2014-07-08T04:29:56 | 21,189,854 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,085 | java | package com.naif.tools.dbffile;
import java.util.ArrayList;
/**
* This class will be the container for a
* .DBF file, designed for legacy system
* database.
*
* @author Nelson Ivan Fernandez Suarez
*/
public final class DBFFile {
/** DBF File header. */
private DBFHeader header;
/** DBF File fields descriptions. */
private ArrayList<DBFFieldDescriptor> fieldDescs;
/** All the table records in the DBF File. */
private ArrayList<DBFRecord> records;
// CONSTRUCTORS //
/** Default constructor. */
public DBFFile() {
this.header = new DBFHeader();
this.fieldDescs = new ArrayList<DBFFieldDescriptor>();
this.records = new ArrayList<DBFRecord>();
} // end : constructor
// ______________________________________________________________//
// *********************** PUBLIC METHODS ***********************//
/** @see DBFFile#getRecordProcess(String, T) */
public DBFRecord getRecord(String fieldColumn, String value) {
return getRecordProcess(fieldColumn, value);
} // end : getRecord(String,String) Method
/** @see DBFFile#getRecordProcess(String, T) */
public DBFRecord getRecord(String fieldColumn, Integer value) {
return getRecordProcess(fieldColumn, value);
} // end : getRecord(String,Integer) Method
/** @see DBFFile#getRecordProcess(String, T) */
public DBFRecord getRecord(String fieldColumn, Float value) {
return getRecordProcess(fieldColumn, value);
} // end : getRecord(String,Float) Method
/**
* It will retrieve a record(row) from the .DBF file
* according to the first occurrence found from the
* specified parameters.
*
* @param fieldColumn The column property related with the data.
* @param value The value to be contained in the returned record.
* @return A registry from the record table from the .DBF file; if nothing found, null.
*/
private <T> DBFRecord getRecordProcess(String fieldColumn, T value) {
DBFRecord recordFound = null;
if (fieldColumn == null || fieldColumn.isEmpty()) {
throw new IllegalArgumentException("Field column for the search is null/empty.");
}
if (value == null) {
throw new IllegalArgumentException("Value for the search is null.");
}
if (records.isEmpty()) {
throw new IllegalArgumentException("Search not possible, there are not records.");
}
// Search the record inside the file
for (DBFRecord record : records) {
T fieldValueReaded = (T)record.getField(fieldColumn);
if (fieldValueReaded != null
&& fieldValueReaded.equals(value)) {
recordFound = record;
break;
}
}
return recordFound;
} // end : getRecordProcess(String,T) Method
// GETTERS AND SETTERS //
/** @return The header representation of the .DBF file. */
public DBFHeader getHeader() {
return header;
}
/** @return Information of the field descriptions in the .DBF file. */
public ArrayList<DBFFieldDescriptor> getFieldDescs() {
return fieldDescs;
}
/** @return Information rows of the records in the .DBF file. */
public ArrayList<DBFRecord> getRecords() {
return records;
}
} | [
"[email protected]"
] | |
b0dd1024907c6f6a44ef01184be8bedf9465118b | ca2a8c739d937da64d6e0a5fecef68542cca7d7d | /service-core/src/main/java/com/delesio/exception/MemberIdTakenException.java | 7c4a0b64acaac69129178748123bce5dabbb487f | [] | no_license | tdelesio/framework | ff02996b39c361a572f6e76368deaa31d35657ff | 1f6a3aa89c0b3b8918e68bb653f8ce51cca0803d | refs/heads/master | 2021-01-22T01:04:32.943996 | 2014-05-29T18:04:36 | 2014-05-29T18:04:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 91 | java | package com.delesio.exception;
public class MemberIdTakenException extends Exception {
}
| [
"[email protected]"
] | |
13de41c316ab8d606fe809807aaeca355c9b1805 | 52898aaddd0c4da32c468d56eeeab39d40472db7 | /djmall_admin/src/main/java/com/dj/mall/admin/web/dict/pro_sku/ProSkuPageController.java | 91faded96ecb1ad7481bd03dd392dda42e0b17bf | [] | no_license | hmm17713260527/djmall | 1ffdfc8735df65d0ab4424b367b1e18713bc3600 | c6ea6bd8c5d314d03151bd0278514a15b27ac7b2 | refs/heads/master | 2022-07-16T11:06:56.086918 | 2020-08-23T12:45:13 | 2020-08-23T12:45:13 | 251,302,809 | 0 | 0 | null | 2022-06-21T03:06:01 | 2020-03-30T12:49:37 | HTML | UTF-8 | Java | false | false | 1,546 | java | package com.dj.mall.admin.web.dict.pro_sku;
import com.alibaba.dubbo.config.annotation.Reference;
import com.dj.mall.api.dict.pro_sku.ProSkuApi;
import com.dj.mall.model.base.SystemConstant;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* @ProjectName: djmall
* @Package: com.dj.mall.admin.web.dict.product_sku
* @ClassName: ProductSkuPageController
* @Author: Administrator
* @Description:
* @Date: 2020/4/11 21:26
* @Version: 1.0
*/
@Controller
@RequestMapping("/dict/product_sku/")
public class ProSkuPageController {
@Reference
private ProSkuApi proSkuApi;
/**
* 去展示
* @return
* @throws Exception
*/
@RequestMapping("toShow")
@RequiresPermissions(value = SystemConstant.PRODUCT_SKU_MANAGER)
public String toShow() throws Exception {
return "product_sku/product_sku_show";
}
/**
* 去查看关联属性
* @param code
* @return
* @throws Exception
*/
@RequestMapping("toAttr/{code}")
public ModelAndView toAttrValue(@PathVariable("code") String code) throws Exception {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("product_sku/product_attr_show");
modelAndView.addObject("productCode", code);
return modelAndView;
}
}
| [
"[email protected]"
] | |
00e29b4a6e6c3acfbf7d3cc45d7b64dd3d17747c | fe124cc2871b2bf9c77ba1827d3018555e89e8eb | /app/src/main/java/com/example/faldifavian/lat1_akb11_10116493_faldifavian/FormActivity.java | 0bf6a7aa2454025586817a35018c668059597648 | [] | no_license | faldifavian/Lat1_AKB11_10116493_FaldiFavian | 5fc672dea60421fe8e80a9c0eef9ac384a7baeb4 | 6b99dbaa906f0a17a7ee5c4441671454950eb6ec | refs/heads/master | 2020-05-05T08:31:10.194079 | 2019-04-07T00:55:13 | 2019-04-07T00:55:13 | 179,867,229 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,668 | java | package com.example.faldifavian.lat1_akb11_10116493_faldifavian;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class FormActivity extends AppCompatActivity {
EditText edtNama, edtUmur;
Button btnNext;
private String KEY_NAME = "kamu";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_form);
edtNama = findViewById(R.id.edtNama);
edtUmur = findViewById(R.id.edtUmur);
btnNext = findViewById(R.id.btnNext);
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nama = edtNama.getText().toString();
String umur = edtUmur.getText().toString();
boolean isEmptyFields = false;
if (TextUtils.isEmpty(nama)) {
isEmptyFields = true;
edtNama.setError("Harap isi dengan nama kamu!");
} else {
Intent moveIntentWithData = new Intent(FormActivity.this, HomeActivity.class);
moveIntentWithData.putExtra(KEY_NAME, nama);
startActivity(moveIntentWithData);
}
if (TextUtils.isEmpty(umur)) {
isEmptyFields = true;
edtNama.setError("Harap isi dengan umur kamu!");
}
}
});
}
}
| [
"[email protected]"
] | |
4d26211c08e9b20d5144df941033d64163702dfa | 092e1409d88257b5a5c2896f24ebc6ff64042290 | /src/KIDS_CONTROLLER/Mediaplay.java | 79e8a95ed2375d78f1a9096869ff9289fff1dba4 | [] | no_license | clasypukka/JavaFx-Projects | 8648711b216280be88982451b7736a3ad070bb25 | 5cfd17691bcea58324190a948cb2bacafd2ac49a | refs/heads/master | 2023-07-21T20:36:34.930044 | 2021-09-08T14:31:15 | 2021-09-08T14:31:15 | 404,372,344 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 271 | 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 KIDS_CONTROLLER;
/**
*
* @author philip Agbor
*/
class Mediaplay {
}
| [
"[email protected]"
] | |
7a5d5e770250a57cfb77897519fbccc396cd4b1c | fea870234301ad5c25f808b17461215ef68a321e | /src/main/java/IP/arraySorting/ArrayInterval.java | 671a90bd6742086b3586cffbb0127990170d61fc | [
"Apache-2.0"
] | permissive | soumya1984/coding-interview-prep-today | f06eb41abb9f6e9ccf3c377b0d29024474281796 | 6b1b63d9c0a83734ba7d52a440ff821998ac878f | refs/heads/master | 2023-07-31T11:02:21.032509 | 2021-05-22T19:37:57 | 2021-05-22T19:37:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 785 | java | package main.java.IP.arraySorting;
import java.util.HashSet;
public class ArrayInterval {
public static HashSet<Integer> mergeInterval(int[] a1, int[] a2) {
HashSet<Integer> result = new HashSet<Integer>();
int i = 0, j = 0;
while (i <= a1.length - 1 && j <= a2.length - 1) {
if (a1[i] == a2[j]) {
i++;
j++;
result.add(a1[i]);
} else if (a1[i] > a2[j]) {
j++;
} else if (a1[i] < a2[j]) {
i++;
}
}
return result;
}
public static void main(String[] args) {
int[] a1 = {2, 3, 3, 5, 5, 6, 7, 7, 8, 12};
int[] a2 = {5, 5, 6, 8, 8, 9, 10, 10};
mergeInterval(a1, a2);
}
}
| [
"[email protected]"
] | |
860798a152c922d00cd5eaeddb9802817043f8f4 | 1aeee3c69cb7ab9831995b4ce1b8572533a3a5e3 | /src/battleship/Winner.java | a42a210182f2449678984873434425b7a461359b | [] | no_license | Galina655/BattleShip | df906611727599a5c510b51306b6ab73d64e8c21 | 564b6a6c62077f204c72b71a64658c438b752af9 | refs/heads/master | 2020-09-14T23:23:06.375401 | 2020-08-02T17:03:17 | 2020-08-02T17:03:17 | 223,291,908 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | 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 battleship;
/**
*
* @author Galina
*/
public enum Winner {
Computer, Player;
}
| [
"[email protected]"
] | |
de4e8645d8d92de22392f863fd29d5367f0aa86f | 87cb078d0d8c6dc53ae39249245bf5926960d990 | /src/exercises_03_01_2021/Pattern15.java | d0921d25ab54afd10cd8f19d2c294f825b5873ae | [] | no_license | JackRacher/Exercises | b217563f72244fe625a0603edf0dac867bfed4c4 | c06250aafacf53ac2143e6fc2293885137c7925d | refs/heads/master | 2023-04-03T17:50:24.707393 | 2021-03-22T09:47:36 | 2021-03-22T09:47:36 | 350,286,075 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 448 | java | package exercises_03_01_2021;
public class Pattern15
{
public static void main(String[] args)
{
String res = "";
for (int rows = 1; rows <= 5; rows++)
{
for (int columns = 1; columns <=5 ; columns++)
{
if(rows == 1 || rows == 5 || columns == 1 || columns == 5)
{
res += "* ";
}
else
{
res += " ";
}
}
res += "\n";
}
System.out.println(res);
}
}
| [
"[email protected]"
] | |
5aa38102fbef2a6133e8c4bf00f50006d3c844db | 91ae8f5c4adcdc57267a3783fa034ec9b4525c45 | /Guiao8/src/g8/SimpleServerWithWorkers.java | aaa76fff32e14b7c4af4cfa11d93023ce5d51a37 | [] | no_license | Miguel-Neiva/SD | ce3053316f3e19f3b53209f0689a9d65162bd8da | 4b193172008d169251db68d5dce5a538094f543f | refs/heads/main | 2023-03-16T07:00:45.399191 | 2020-12-18T14:35:51 | 2020-12-18T14:35:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 967 | java | package g8;
import java.net.ServerSocket;
import java.net.Socket;
// import static g8.TaggedConnection.Frame;
public class SimpleServerWithWorkers {
final static int WORKERS_PER_CONNECTION = 3;
public static void main(String[] args) throws Exception {
ServerSocket ss = new ServerSocket(12345);
while(true) {
Socket s = ss.accept();
FramedConnection c = new FramedConnection(s);
Runnable worker = () -> {
try (c) {
for (;;) {
byte[] b = c.receive();
String msg = new String(b);
System.out.println("Replying to: " + msg);
c.send(msg.toUpperCase().getBytes());
}
} catch (Exception ignored) { }
};
for (int i = 0; i < WORKERS_PER_CONNECTION; ++i)
new Thread(worker).start();
}
}
}
| [
"[email protected]"
] | |
aec4fff35bffd1904743f8f4d68e0a118afb8761 | 9713d2403e100e8574bd85530ab83e3d57b86235 | /front/src/kz/maks/realestate/front/services/asyncs/DomSaleAsync.java | 2e2e1d0975402e8ac42371ee0eb47aa57afbfd22 | [] | no_license | nusip/RealEstate | 468f435fbe1a09c4dca7020f83e3a8df181933d8 | 7c39917c1a8f71c4be37c3f6f3fdd557ce3863dd | refs/heads/master | 2021-03-19T07:39:10.155419 | 2016-09-03T13:34:23 | 2016-09-03T13:34:23 | 94,367,297 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 471 | java | package kz.maks.realestate.front.services.asyncs;
import kz.maks.core.front.services.Callback;
import kz.maks.core.front.services.asyncs.ICRUDAsync;
import kz.maks.realestate.shared.dtos.dom.DomSaleDto;
import kz.maks.realestate.shared.dtos.params.DomSaleSearchParams;
import java.util.List;
public interface DomSaleAsync
extends ICRUDAsync<DomSaleSearchParams, DomSaleDto, DomSaleDto> {
void listHistory(Long id, Callback<List<DomSaleDto>> callback);
}
| [
"[email protected]"
] | |
77a6ab48deef705e8e4314a3389e7b10acfdce36 | c1a05f4f654c3413218350305394d080ace59ae5 | /Quanlikhachhang/QLKH.java | 68834546389de76f17e6d51237ee1f94ea28679f | [] | no_license | khanhtrong1999/opp-java | 825e79422dd17921449450a362cc75a47e2b4cd6 | 9b3833e13d3ccaeeb907a94f09347ef78aed9ffd | refs/heads/master | 2020-03-10T13:51:08.921196 | 2018-04-13T14:12:09 | 2018-04-13T14:12:09 | 129,410,151 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,048 | java | package quanlikhachhang;
import java.util.ArrayList;
import java.util.Scanner;
public class QLKH {
public static void main(String[] args) {
int[] Array;
int n;
ArrayList<Khachhang> danhsach = new ArrayList();
int luachon; //so luong khach hang
System.out.println("=====================");
System.out.println("1. Nhap vao n khach hang.");
System.out.println("2. Hien thi thong tin danh sach khach hang.");
System.out.println("3. Hien thi khach hang co tong luong lon hon x.");
System.out.println("4. Thoat chuong trinh");
System.out.println("======================");
Scanner key = new Scanner(System.in);
do {
System.out.println("Moi ban nhap vao lua chon: ");
try {
luachon = key.nextInt(); key.nextLine();
}catch(NumberFormatException e) {
luachon = 0;
System.out.println("ban can nhap vao so nguyen");
}
switch(luachon) {
case 1:{
System.out.println("Nhap vao so luong khach hang: ");
n = Integer.parseInt(key.nextLine());
Array = new int[n];//tao lap so luong phan tu trong mang
for(int i=0; i<Array.length;i++) {
Khachhang KH = new Khachhang();
System.out.println("Thong tin khach hang: "+(i+1));
KH.nhapTT();
danhsach.add(KH); //them khach hang vao danh sach
}
break;
}
case 2:{
System.out.println("thong tin khach hang co trong danh sach");
for(int i =0;i<danhsach.size();i++) {
System.out.println("Thong tin khach hang: "+(i+1));
danhsach.get(i).HienthiTT();
}
break;
}
case 3:{
int x;
System.out.print("Nhap vao tong luong.");
x=Integer.parseInt(key.nextLine());
System.out.println("THONG TIN KHACH HANG CO LUONG LON HON GIA TRI LUONG BAN VUA NHAP: ");
for(int i=0;i<danhsach.size();i++) {
if(x<=danhsach.get(i).getTongLuong()) {
danhsach.get(i).HienthiTT();
}
}
break;
}
case 4:{
break;
}
}
}
while(luachon!=4);
}
} | [
"[email protected]"
] | |
d022352c6202145ad748561aacb903f7bd2ae840 | b079af8eac12694b28de15677322ac3f7a3fd86b | /src/main/java/com/aunfried/challenge/business/consumer/dto/ConsumerCreateUpdateDTO.java | 58780637beb239899776aa7632df41855c00e576 | [] | no_license | alexandreunfried/challenge | 384dc57908f34eda1f4f99c539bada5b00457613 | 2b4c732ff33b75d99070b920ff50279436b32ad1 | refs/heads/master | 2020-09-27T03:56:49.759496 | 2019-12-12T01:26:47 | 2019-12-12T01:26:47 | 226,423,606 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 294 | java | package com.aunfried.challenge.business.consumer.dto;
import javax.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class ConsumerCreateUpdateDTO {
@NotBlank
private String name;
@NotBlank
private String phone;
@NotBlank
private String email;
}
| [
"[email protected]"
] | |
577f36dc044ef666270d0c08c29a7da954042a58 | dde19b2a7639b3640dd1060034d9cfc7522fa8d5 | /src/main/java/com/threadpool/NetJavaThreadPool.java | a391ecfe9cdc3b25d5b91eca3f2408ca40d82868 | [] | no_license | dongfucai/dongpractice | 6578d4cc3fed2f6c908b60df3205262382405c56 | 1f69a899a3e35553901664042eced8ee3bf67933 | refs/heads/master | 2022-12-23T19:28:03.449994 | 2019-05-28T13:36:54 | 2019-05-28T13:36:54 | 146,291,555 | 0 | 0 | null | 2022-12-16T04:31:55 | 2018-08-27T12:01:40 | Java | UTF-8 | Java | false | false | 2,786 | java | package com.threadpool;
/**
* @Package Name : ${PACKAG_NAME}
* @Author : [email protected]
* @Creation Date : 2019年02月13日下午9:39
* @Function : todo
*/
import java.util.LinkedList;
public class NetJavaThreadPool {
private final int initThreadCount;
private final PoolWorker[] threadPool;
private final LinkedList<Runnable> workerList;
public NetJavaThreadPool(int initThreadCount) {
this.initThreadCount = initThreadCount;
workerList = new LinkedList<Runnable>();
threadPool = new PoolWorker[initThreadCount];
for(int i=0;i<threadPool.length;i++)
{
threadPool[i]=new PoolWorker();
threadPool[i].setName(i+"号线程");
threadPool[i].start();
System.out.println("---"+i+"号线程已经创建,在等待任务中");
}
System.out.println("***线程池初始化完毕***");
}
public void execute(Runnable worker){
synchronized (workerList) {
workerList.addLast(worker);
workerList.notify();
System.out.println("---加入了一个任务!!!");
}
}
private class PoolWorker extends Thread {
@Override
public void run(){
Runnable r;
while(true){
synchronized (workerList) {
while(workerList.isEmpty()){
try {
workerList.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
r=(Runnable)workerList.removeFirst();
}
r.run();
}
}
}
public static void main(String a[])
{
//10个任务给带有5个线程的线程池执行,每个任务就是数0到19,一个线程要把一个任务执行结束才去执行下一个任务
NetJavaThreadPool wq=new NetJavaThreadPool(5);
for(int i=0;i<10;i++){
final int task=i;
wq.execute(new Runnable() {
@Override
public void run() {
for(int i=0;i<20;i++)
{
try {
Thread.sleep(30);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName()+" is looping of "+i+" for task of "+task);
}
}
});
}
}
}
| [
"[email protected]"
] | |
85e7a73adbb21d35edbeac5fc4545d5e5bef0b7f | ffbf4d160366b25501db42387b040c36a6e3f2db | /coral-shop-core/src/main/java/com/dookay/coral/shop/goods/service/impl/GoodsSkinServiceImpl.java | 9793f4a44de894cd9858534a95a93f2cb5393838 | [] | no_license | github2sean/coral-shop-shiatzy | 367cdee058a6adc856f8a7264a9e12dfee83a583 | 559aee541c93af6bd9f02a9abceb29f2ccb5ba2b | refs/heads/master | 2021-01-01T04:36:17.708953 | 2017-07-14T08:56:21 | 2017-07-14T08:56:21 | 97,202,815 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package com.dookay.coral.shop.goods.service.impl;
import com.dookay.coral.common.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dookay.coral.shop.goods.mapper.GoodsSkinMapper;
import com.dookay.coral.shop.goods.domain.GoodsSkinDomain;
import com.dookay.coral.shop.goods.service.IGoodsSkinService;
/**
* 商品材质的业务实现类
* @author : luxor
* @since : 2017年07月05日
* @version : v0.0.1
*/
@SuppressWarnings("SpringJavaAutowiringInspection")
@Service("goodsSkinService")
public class GoodsSkinServiceImpl extends BaseServiceImpl<GoodsSkinDomain> implements IGoodsSkinService {
@Autowired
private GoodsSkinMapper goodsSkinMapper;
}
| [
"[email protected]"
] | |
d42a5b0de8b663f80fe58847d1f1251eaf15366d | a0ef84ec48003b967505b4e5d445de160730101d | /mapReduce/Proj1.java | 8cfb098f9bac61f9ed90695a78618c45a5669a21 | [] | no_license | danielzhangyihao/myProjects | e12db54c97883e1ac3ee64c5e5b5516264dd82e0 | af6a0d967bdfbb6c2e990ebcf541c15a748d4d8d | refs/heads/master | 2020-04-05T23:20:38.745624 | 2014-03-11T20:16:58 | 2014-03-11T20:16:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,477 | java | import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.Math;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
/*
* This is the skeleton for CS61c project 1, Fall 2013.
*
* Reminder: DO NOT SHARE CODE OR ALLOW ANOTHER STUDENT TO READ YOURS.
* EVEN FOR DEBUGGING. THIS MEANS YOU.
*
*/
public class Proj1{
/*
* Inputs is a set of (docID, document contents) pairs.
*/
public static class Map1 extends Mapper<WritableComparable, Text, Text, DoublePair> {
/** Regex pattern to find words (alphanumeric + _). */
final static Pattern WORD_PATTERN = Pattern.compile("\\w+");
private String targetGram = null;
private int funcNum = 0;
/*
* Setup gets called exactly once for each mapper, before map() gets called the first time.
* It's a good place to do configuration or setup that can be shared across many calls to map
*/
@Override
public void setup(Context context) {
targetGram = context.getConfiguration().get("targetWord").toLowerCase();
try {
funcNum = Integer.parseInt(context.getConfiguration().get("funcNum"));
} catch (NumberFormatException e) {
/* Do nothing. */
}
}
@Override
public void map(WritableComparable docID, Text docContents, Context context)
throws IOException, InterruptedException {
Matcher matcher = WORD_PATTERN.matcher(docContents.toString());
Func func = funcFromNum(funcNum);
// YOUR CODE HERE
ArrayList<String> list1 = new ArrayList<String>();
ArrayList<Integer> list2 = new ArrayList<Integer>();
int count=0;
while (matcher.find()){
String the_word= matcher.group();
the_word=the_word.toLowerCase();
list1.add(the_word);
if(the_word.equals(targetGram)){
list2.add(new Integer(count));
}
count++;
}
if(list1.contains(targetGram)){
int wordIndex=0;
matcher.reset(docContents.toString());
while (matcher.find()){
double distance;
distance=Math.abs(list2.get(0).intValue()-wordIndex);
String the_word2= matcher.group().toLowerCase();
if (the_word2.equals(targetGram)){
wordIndex++;
}else{
DoublePair index= new DoublePair();
Iterator<Integer> it = list2.iterator();
while(it.hasNext()){
int tarIndex = it.next().intValue();
if (Math.abs(tarIndex-wordIndex)<distance){
distance=Math.abs(tarIndex-wordIndex);
}else{}
}
Text word = new Text();
word.set(the_word2);
double result= func.f(distance);
index.setDouble1(1.0);
index.setDouble2(result);
context.write(word,index);
wordIndex++;
}}
}else{
double distance2=0.0;
distance2=Double.POSITIVE_INFINITY;
Iterator<String> wordIter = list1.iterator();
while(wordIter.hasNext()){
String theWord= wordIter.next();
double Fd= func.f(distance2);
DoublePair index2= new DoublePair();
index2.setDouble1(1.0);
index2.setDouble2(Fd);
Text word = new Text();
word.set(theWord);
context.write(word,index2);
}
}
}
/** Returns the Func corresponding to FUNCNUM*/
private Func funcFromNum(int funcNum) {
Func func = null;
switch (funcNum) {
case 0:
func = new Func() {
public double f(double d) {
return d == Double.POSITIVE_INFINITY ? 0.0 : 1.0;
}
};
break;
case 1:
func = new Func() {
public double f(double d) {
return d == Double.POSITIVE_INFINITY ? 0.0 : 1.0 + 1.0 / d;
}
};
break;
case 2:
func = new Func() {
public double f(double d) {
return d == Double.POSITIVE_INFINITY ? 0.0 : 1.0 + Math.sqrt(d);
}
};
break;
}
return func;
}
}
/** Here's where you'll be implementing your combiner. It must be non-trivial for you to receive credit. */
public static class Combine1 extends Reducer<Text, DoublePair, Text, DoublePair> {
@Override
public void reduce(Text key, Iterable<DoublePair> values,
Context context) throws IOException, InterruptedException {
// YOUR CODE HERE
double sum=0.0;
double Sw=0.0;
double score;
for (DoublePair value: values){
sum+= value.getDouble1();
Sw+=value.getDouble2();
}
DoublePair value = new DoublePair(sum, Sw);
context.write(key, value);
}
}
public static class Reduce1 extends Reducer<Text, DoublePair, DoubleWritable, Text> {
@Override
public void reduce(Text key, Iterable<DoublePair> values,
Context context) throws IOException, InterruptedException {
// YOUR CODE HERE
double sum=0.0;
double Sw=0.0;
double score;
for (DoublePair value: values){
sum+=value.getDouble1();
Sw+=value.getDouble2();
}
if (Sw>0.0){
score = (Sw * Math.pow(Math.log(Sw), 3) / sum) *-1.0;}
else{score=0.0;
}
context.write(new DoubleWritable(score), key);
}
}
public static class Map2 extends Mapper<DoubleWritable, Text, DoubleWritable, Text> {
//maybe do something, maybe don't
}
public static class Reduce2 extends Reducer<DoubleWritable, Text, DoubleWritable, Text> {
int n = 0;
static int N_TO_OUTPUT = 20;
/*
* Setup gets called exactly once for each reducer, before reduce() gets called the first time.
* It's a good place to do configuration or setup that can be shared across many calls to reduce
*/
@Override
protected void setup(Context c) {
n = 0;
}
/*
* Your output should be a in the form of (DoubleWritable score, Text word)
* where score is the co-occurrence value for the word. Your output should be
* sorted from largest co-occurrence to smallest co-occurrence.
*/
@Override
public void reduce(DoubleWritable key, Iterable<Text> values,
Context context) throws IOException, InterruptedException {
// YOUR CODE HERE
for (Text value: values){
Double score=Math.abs(key.get()*(-1.0));
context.write(new DoubleWritable(score), value);
n++;
if (n>=N_TO_OUTPUT){
break;}
}
}
}
/*
* You shouldn't need to modify this function much. If you think you have a good reason to,
* you might want to discuss with staff.
*
* The skeleton supports several options.
* if you set runJob2 to false, only the first job will run and output will be
* in TextFile format, instead of SequenceFile. This is intended as a debugging aid.
*
* If you set combiner to false, the combiner will not run. This is also
* intended as a debugging aid. Turning on and off the combiner shouldn't alter
* your results. Since the framework doesn't make promises about when it'll
* invoke combiners, it's an error to assume anything about how many times
* values will be combined.
*/
public static void main(String[] rawArgs) throws Exception {
GenericOptionsParser parser = new GenericOptionsParser(rawArgs);
Configuration conf = parser.getConfiguration();
String[] args = parser.getRemainingArgs();
boolean runJob2 = conf.getBoolean("runJob2", true);
boolean combiner = conf.getBoolean("combiner", false);
System.out.println("Target word: " + conf.get("targetWord"));
System.out.println("Function num: " + conf.get("funcNum"));
if(runJob2)
System.out.println("running both jobs");
else
System.out.println("for debugging, only running job 1");
if(combiner)
System.out.println("using combiner");
else
System.out.println("NOT using combiner");
Path inputPath = new Path(args[0]);
Path middleOut = new Path(args[1]);
Path finalOut = new Path(args[2]);
FileSystem hdfs = middleOut.getFileSystem(conf);
int reduceCount = conf.getInt("reduces", 32);
if(hdfs.exists(middleOut)) {
System.err.println("can't run: " + middleOut.toUri().toString() + " already exists");
System.exit(1);
}
if(finalOut.getFileSystem(conf).exists(finalOut) ) {
System.err.println("can't run: " + finalOut.toUri().toString() + " already exists");
System.exit(1);
}
{
Job firstJob = new Job(conf, "job1");
firstJob.setJarByClass(Map1.class);
/* You may need to change things here */
firstJob.setMapOutputKeyClass(Text.class);
firstJob.setMapOutputValueClass(DoublePair.class);
firstJob.setOutputKeyClass(DoubleWritable.class);
firstJob.setOutputValueClass(Text.class);
/* End region where we expect you to perhaps need to change things. */
firstJob.setMapperClass(Map1.class);
firstJob.setReducerClass(Reduce1.class);
firstJob.setNumReduceTasks(reduceCount);
if(combiner)
firstJob.setCombinerClass(Combine1.class);
firstJob.setInputFormatClass(SequenceFileInputFormat.class);
if(runJob2)
firstJob.setOutputFormatClass(SequenceFileOutputFormat.class);
FileInputFormat.addInputPath(firstJob, inputPath);
FileOutputFormat.setOutputPath(firstJob, middleOut);
firstJob.waitForCompletion(true);
}
if(runJob2) {
Job secondJob = new Job(conf, "job2");
secondJob.setJarByClass(Map1.class);
/* You may need to change things here */
secondJob.setMapOutputKeyClass(DoubleWritable.class);
secondJob.setMapOutputValueClass(Text.class);
secondJob.setOutputKeyClass(DoubleWritable.class);
secondJob.setOutputValueClass(Text.class);
/* End region where we expect you to perhaps need to change things. */
secondJob.setMapperClass(Map2.class);
secondJob.setReducerClass(Reduce2.class);
secondJob.setInputFormatClass(SequenceFileInputFormat.class);
secondJob.setOutputFormatClass(TextOutputFormat.class);
secondJob.setNumReduceTasks(1);
FileInputFormat.addInputPath(secondJob, middleOut);
FileOutputFormat.setOutputPath(secondJob, finalOut);
secondJob.waitForCompletion(true);
}
}
}
| [
"[email protected]"
] | |
7e081017e79b4101301847c91d22850dad0f8208 | c301f99ea936c663c8676e127e0a4e1e71e44a99 | /src/GuitarEnum/GuitarType.java | a9554f40c09a69417735d401fd49724586a957f2 | [] | no_license | molata/molata-codeShop | 970bebddb56eedd1030d80380342e4bd222f95fc | 2c11e6103b9c9db01dd63667f15a789a7fd8ad12 | refs/heads/master | 2021-01-10T06:46:41.993557 | 2015-10-15T08:13:20 | 2015-10-15T08:13:20 | 44,290,597 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | package GuitarEnum;
public enum GuitarType {
CLASSIC, FOLK, ELECTRIC;
}
| [
"[email protected]"
] | |
36da5536e2e75c856ae7a8ad464018db7283009d | c5c28ab83aed29d6b1f7770b318f904addff30cf | /springboot_thymeleaf/src/main/java/springboot_thymeleaf/domain/Blog.java | f0e0215a6bafdbe627cdce9932fb5022066b4110 | [] | no_license | mystdeim/performance_rnd | f0b59901b6306d1ac4ff79a5f5cafb1776a3422c | f88fc776d2783ed45eba50afe5bcdce8b4ab04c4 | refs/heads/master | 2020-12-02T16:25:32.252913 | 2017-07-08T11:40:57 | 2017-07-08T11:40:57 | 96,550,101 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 557 | java | package springboot_thymeleaf.domain;
/**
* @author <a href="mailto:[email protected]">Roman Novikov</a>
*/
public class Blog {
private String title;
private String body;
public Blog(String title, String body) {
this.title = title;
this.body = body;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}
| [
"[email protected]"
] | |
fb6ae426f3af8fc446e84f956b0e142da8d1a03e | 42d7de1cfa26d11870ac875b39d50adc35790c9f | /motech-diagnostics/src/main/java/org/motechproject/diagnostics/response/ServiceResult.java | 39d11b08b1debf5d0aaf172c12e7d2fe323cc4c6 | [] | no_license | mkustusz/motech-contrib | 53cfdcb70d3bb5973152f22f8cf5bb3d871b56ca | 4aea48345b69501745cc58694265ef2c5403629c | refs/heads/master | 2021-01-16T22:49:59.938034 | 2014-08-21T08:32:10 | 2014-08-21T08:32:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 586 | java | package org.motechproject.diagnostics.response;
import java.util.List;
public class ServiceResult {
private String serviceName;
private List<DiagnosticsResult> results;
public ServiceResult(String serviceName, List<DiagnosticsResult> results) {
this.serviceName = serviceName;
this.results = results;
}
public String getServiceName() {
return serviceName;
}
public List<DiagnosticsResult> getResults() {
return results;
}
public Status status(){
return new DiagnosticResults(results).status();
}
}
| [
"[email protected]"
] | |
e36bb5d7395503fd538878907f1b43d4457ef8ac | 83d638be043d92aad2af51f7e9dd06f2a0d3ec17 | /src/main/java/com/xoriant/xorpay/repo/PaymentBatchAckDetailsRepo.java | a82c078ca2e1291535b769fa8194858c0cac1f2e | [] | no_license | lakshsharma07/XorProces | 78848341fa8d009ef23781d0c1e634aa87ac70f1 | 0ca710dba7551f7e2ec8dbfbafcc8f15f98492d6 | refs/heads/master | 2023-08-12T12:21:58.942299 | 2021-10-14T06:42:08 | 2021-10-14T06:42:08 | 416,510,442 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | package com.xoriant.xorpay.repo;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.xoriant.xorpay.entity.PaymentBatchAksDetailEntity;
@Repository
@Transactional
public interface PaymentBatchAckDetailsRepo extends JpaRepository<PaymentBatchAksDetailEntity, Integer> {
List<PaymentBatchAksDetailEntity> findByPaymentInstructionId(String messsageId);
}
| [
"[email protected]"
] | |
e559d93ee7c1cc8f87aedc3bd9237010e53d72b2 | 28a0d4ab82a7d95df269369dfe164fd02a2a6bba | /src/main/java/by/akimova/CartAPI/security/jwt/JwtConfigurer.java | 2031d1189289d6c20173b93a65d10a9b67c8e8c5 | [] | no_license | anastasiaakimova/CartAPI | 763faacfebd295e560956036a40fb1b27198934c | ecbfbca021c1291784829f7aaacde560e9b2cc97 | refs/heads/master | 2023-08-13T11:08:23.196799 | 2021-09-21T12:50:33 | 2021-09-21T12:50:33 | 399,020,382 | 0 | 0 | null | 2021-09-21T11:18:02 | 2021-08-23T08:00:03 | Java | UTF-8 | Java | false | false | 1,103 | java | package by.akimova.CartAPI.security.jwt;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;
/**
* JWT configuration for application that add {@link JwtTokenFilter} for security chain.
*
* @author anastasiyaakimava
* @version 1.0
*/
@Component
public class JwtConfigurer extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
private final JwtTokenProvider jwtTokenProvider;
public JwtConfigurer(JwtTokenProvider jwtTokenProvider) {
this.jwtTokenProvider = jwtTokenProvider;
}
@Override
public void configure(HttpSecurity httpSecurity) {
JwtTokenFilter jwtTokenFilter = new JwtTokenFilter(jwtTokenProvider);
httpSecurity.addFilterBefore(jwtTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
| [
"[email protected]"
] | |
efcb81ec33aecab2ca77be112162e1e293a6fe1a | 06abac4354af4707927b045bd023fc6982b5153b | /app/src/main/java/digua/rxlearn/fragment/c_Filtering_Observables/C9_Fragment.java | 3a36c9b399960dc960e8a20cca8688234e6d61c9 | [] | no_license | diguachaoren/RxLearn | ac8ab877979d35691e38ce7250f54641f92f6a11 | 062e77b254ae45395dbb5f996aa927317f568898 | refs/heads/master | 2021-01-22T08:29:12.422214 | 2017-02-14T06:09:03 | 2017-02-14T06:09:03 | 81,906,023 | 125 | 7 | null | null | null | null | UTF-8 | Java | false | false | 2,463 | java | package digua.rxlearn.fragment.c_Filtering_Observables;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import digua.rxlearn.R;
import digua.rxlearn.fragment.other.BaseFragment;
import digua.rxlearn.fragment.other.NoScrollListView;
import rx.Observable;
import rx.Observer;
import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* @author digua
* <p>
* on 2017/2/7.(^ ^)
*/
public class C9_Fragment extends BaseFragment {
@BindView(R.id.textview) TextView textview;
Subscription subscribe;
@BindView(R.id.list_threading_log) NoScrollListView _logsList;
@Override
public NoScrollListView setupListView() {
return _logsList;
}
@Override
public View setupView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_c9, container, false);
return view;
}
/**
* 点击事件
*/
@OnClick({R.id.skip})
public void clickEvent(View view) {
clear();
switch (view.getId()) {
case R.id.skip:
sample1();
break;
}
}
private void sample1() {
Integer[] args = {1, 2, 3, 4, 5, 6};
Observable observable = Observable.from(args).skip(3);
observable.subscribe(new Observer() {
@Override
public void onCompleted() {
Log.e("skip", "onCompleted");
CLog("skip:" + "onCompleted");
}
@Override
public void onError(Throwable e) {
Log.e("skip", "onError");
CLog("skip:" + "onError");
}
@Override
public void onNext(Object o) {
Log.e("skip", "onNext" + o);
CLog("skip:" + "onNext" + o);
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
if (subscribe != null) {
subscribe.unsubscribe();
}
}
}
| [
"[email protected]"
] | |
bec0c02306655dbacdad008fccfb5a6fc000858f | 7bed9d17365793e906de0e05725971d8e9fc3a84 | /app/src/main/java/com/sheikh/alotrial/CheckLogin.java | fe7723dd6a103653ff4f766dd0d5c0d07e914a88 | [] | no_license | A1uBhorta/Alo | 4e7f6c7fffc8a2efc757bb39970c5ea64f61ab09 | 4a4986b42a6da375e9d3467a488fa424728debeb | refs/heads/master | 2021-05-20T21:44:27.750500 | 2020-04-02T10:45:24 | 2020-04-02T10:45:24 | 225,066,849 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 642 | java | package com.sheikh.alotrial;
import android.app.Application;
import android.content.Intent;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
public class CheckLogin extends Application {
@Override
public void onCreate() {
super.onCreate();
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
if(firebaseUser != null){
Intent i = new Intent(CheckLogin.this, Homepage.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
}
}
| [
"[email protected]"
] | |
3be80098ac816d9bf81749b7bc40647816a5674a | 503cad992252c2213ef2bc4261fdb294fb979a1c | /src/String/Opinion.java | abcfd04abd589e0bd6a7640108ecac14b8933b58 | [] | no_license | paradiseyxx/YXX2 | 1a12477f22334df1c15dda567498e63d97e3dee0 | 02ac87047b03114855bb312eac1720c39f4450d2 | refs/heads/master | 2020-08-10T17:57:14.108900 | 2020-08-04T03:41:20 | 2020-08-04T03:41:20 | 214,390,645 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 403 | java | package String;
//ÅжÏ×Ö·û´®ÊÇ·ñÏàµÈ
public class Opinion {
public static void main(String args[]){
String s1 = new String("abc");
String s2 = new String("ABC");
boolean b1 = s1.equals(s2);
boolean b2 = s1.equalsIgnoreCase(s2);
System.out.println(s1+"equals"+s2+":"+b1);
System.out.println(s1+"equalsIngoreCase"+s2+":"+b2);
}
}
| [
"[email protected]"
] | |
a34ecb09ff2c3bef834cddba4b45287c314ef8a6 | c885ef92397be9d54b87741f01557f61d3f794f3 | /results/Jsoup-92/org.jsoup.parser.ParseSettings/BBC-F0-opt-70/tests/24/org/jsoup/parser/ParseSettings_ESTest_scaffolding.java | a981a153094bd09479efbb56b919c5e4a37dbbbf | [
"CC-BY-4.0",
"MIT"
] | permissive | pderakhshanfar/EMSE-BBC-experiment | f60ac5f7664dd9a85f755a00a57ec12c7551e8c6 | fea1a92c2e7ba7080b8529e2052259c9b697bbda | refs/heads/main | 2022-11-25T00:39:58.983828 | 2022-04-12T16:04:26 | 2022-04-12T16:04:26 | 309,335,889 | 0 | 1 | null | 2021-11-05T11:18:43 | 2020-11-02T10:30:38 | null | UTF-8 | Java | false | false | 6,471 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Fri Oct 22 18:00:05 GMT 2021
*/
package org.jsoup.parser;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
import org.evosuite.runtime.sandbox.Sandbox;
import org.evosuite.runtime.sandbox.Sandbox.SandboxMode;
@EvoSuiteClassExclude
public class ParseSettings_ESTest_scaffolding {
@org.junit.Rule
public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
@BeforeClass
public static void initEvoSuiteFramework() {
org.evosuite.runtime.RuntimeSettings.className = "org.jsoup.parser.ParseSettings";
org.evosuite.runtime.GuiSupport.initialize();
org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
org.evosuite.runtime.classhandling.JDKClassResetter.init();
setSystemProperties();
initializeClasses();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
}
@Before
public void initTestCase(){
threadStopper.storeCurrentThreads();
threadStopper.startRecordingTime();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
org.evosuite.runtime.GuiSupport.setHeadless();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
org.evosuite.runtime.agent.InstrumentingAgent.activate();
}
@After
public void doneWithTestCase(){
threadStopper.killAndJoinClientThreads();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
org.evosuite.runtime.classhandling.JDKClassResetter.reset();
resetClasses();
org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
}
public static void setSystemProperties() {
/*No java.lang.System property to set*/
}
private static void initializeClasses() {
org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ParseSettings_ESTest_scaffolding.class.getClassLoader() ,
"org.jsoup.internal.StringUtil",
"org.jsoup.select.NodeVisitor",
"org.jsoup.nodes.Document$QuirksMode",
"org.jsoup.nodes.Attributes",
"org.jsoup.select.Evaluator$IndexLessThan",
"org.jsoup.nodes.TextNode",
"org.jsoup.select.Evaluator$AttributeWithValue",
"org.jsoup.select.Evaluator$AttributeWithValueStarting",
"org.jsoup.select.Evaluator$AttributeWithValueNot",
"org.jsoup.nodes.Entities$EscapeMode",
"org.jsoup.select.Evaluator$IndexGreaterThan",
"org.jsoup.nodes.BooleanAttribute",
"org.jsoup.nodes.LeafNode",
"org.jsoup.select.Evaluator$IndexEvaluator",
"org.jsoup.select.Evaluator$AttributeWithValueMatching",
"org.jsoup.select.Evaluator$Matches",
"org.jsoup.SerializationException",
"org.jsoup.nodes.Document$OutputSettings",
"org.jsoup.select.Evaluator$AttributeWithValueEnding",
"org.jsoup.select.Evaluator$ContainsText",
"org.jsoup.nodes.EntitiesData",
"org.jsoup.nodes.Element",
"org.jsoup.select.Evaluator",
"org.jsoup.select.Evaluator$Id",
"org.jsoup.internal.Normalizer",
"org.jsoup.select.Evaluator$Class",
"org.jsoup.select.Evaluator$IndexEquals",
"org.jsoup.UncheckedIOException",
"org.jsoup.helper.Validate",
"org.jsoup.parser.ParseSettings",
"org.jsoup.select.Evaluator$AttributeKeyPair",
"org.jsoup.select.Evaluator$MatchesOwn",
"org.jsoup.nodes.XmlDeclaration",
"org.jsoup.parser.Tag",
"org.jsoup.nodes.Node",
"org.jsoup.select.Evaluator$Attribute",
"org.jsoup.nodes.Attribute",
"org.jsoup.parser.CharacterReader",
"org.jsoup.nodes.Document",
"org.jsoup.select.Evaluator$AttributeStarting",
"org.jsoup.select.Evaluator$Tag",
"org.jsoup.select.Evaluator$ContainsOwnText",
"org.jsoup.nodes.Entities",
"org.jsoup.select.Evaluator$AttributeWithValueContaining",
"org.jsoup.nodes.Document$OutputSettings$Syntax",
"org.jsoup.select.Evaluator$AllElements"
);
}
private static void resetClasses() {
org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ParseSettings_ESTest_scaffolding.class.getClassLoader());
org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses(
"org.jsoup.parser.ParseSettings",
"org.jsoup.nodes.Attributes",
"org.jsoup.internal.StringUtil",
"org.jsoup.nodes.Node",
"org.jsoup.nodes.Element",
"org.jsoup.nodes.Document",
"org.jsoup.internal.Normalizer",
"org.jsoup.helper.Validate",
"org.jsoup.parser.Tag",
"org.jsoup.nodes.Document$OutputSettings",
"org.jsoup.nodes.EntitiesData",
"org.jsoup.nodes.Document$OutputSettings$Syntax",
"org.jsoup.nodes.Entities",
"org.jsoup.parser.CharacterReader",
"org.jsoup.nodes.Entities$EscapeMode",
"org.jsoup.nodes.Document$QuirksMode",
"org.jsoup.nodes.Attributes$1",
"org.jsoup.nodes.Attribute",
"org.jsoup.parser.Parser",
"org.jsoup.parser.Tokeniser",
"org.jsoup.parser.ParseErrorList",
"org.jsoup.parser.TokeniserState",
"org.jsoup.parser.Token",
"org.jsoup.parser.Token$Tag",
"org.jsoup.parser.Token$StartTag",
"org.jsoup.parser.Token$TokenType",
"org.jsoup.parser.Token$EndTag",
"org.jsoup.parser.Token$Character",
"org.jsoup.parser.Token$Doctype",
"org.jsoup.parser.Token$Comment",
"org.jsoup.nodes.Entities$CoreCharset",
"org.jsoup.nodes.Entities$1",
"org.jsoup.nodes.Attributes$Dataset",
"org.jsoup.nodes.BooleanAttribute"
);
}
}
| [
"[email protected]"
] | |
6ab28e26808b5474abdd05557eb96fbf59c3096c | 1dde92e620bbf06f339c925307d9db217786c726 | /GpsProject/src/GIS/MetaDataGroup.java | 49f9f86b3e7c4edd9bf9ba2c90fd7d2419ffb064 | [] | no_license | orh92/GpsGoogleEarth | bb15a9cc63f8096f96860a016d4eb6d58e42c443 | c8d72d3a20aacaab5e4717aa6f8652037e428cbd | refs/heads/master | 2020-04-08T23:56:55.393403 | 2018-11-30T16:02:16 | 2018-11-30T16:02:16 | 159,844,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 396 | java | package GIS;
import java.util.Date;
import Geom.Point3D;
public class MetaDataGroup implements Meta_data {
private long UTC;
public MetaDataGroup() {
Date date = new Date();
UTC = date.getTime();
}
@Override
public long getUTC() {
return UTC;
}
@Override
public Point3D get_Orientation() {
return null;
}
@Override
public String toString() {
return "Info: " + getUTC();
}
}
| [
"[email protected]"
] | |
def71383aa3c1ffa998dc5902a321edffaeec19a | 1912a42c5f86e05ed159379b094e187cd44b8274 | /Native/Android/LunarConsole/lunarConsole/src/main/java/spacemadness/com/lunarconsole/dependency/DispatchQueueProvider.java | 9d8175698a8f7692e135c2c0ad2afe391295046f | [
"Apache-2.0"
] | permissive | Horror666zd/lunar-unity-console | 49df9e1d107bca7814bf859b1ccc3480516cf1b4 | 67f0e241a243024b572dd9d53a4e1d5e9cdab967 | refs/heads/master | 2023-08-31T08:44:47.654891 | 2021-10-23T01:55:20 | 2021-10-23T01:55:20 | 587,416,089 | 2 | 0 | NOASSERTION | 2023-01-10T17:46:20 | 2023-01-10T17:46:19 | null | UTF-8 | Java | false | false | 1,054 | java | //
// DispatchQueueProvider.java
//
// Lunar Unity Mobile Console
// https://github.com/SpaceMadness/lunar-unity-console
//
// Copyright 2015-2021 Alex Lementuev, SpaceMadness.
//
// 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 spacemadness.com.lunarconsole.dependency;
import spacemadness.com.lunarconsole.concurrent.DispatchQueue;
public interface DispatchQueueProvider extends ProviderDependency {
DispatchQueue createMainQueue();
DispatchQueue createSerialQueue(String name);
boolean isMainQueue();
}
| [
"[email protected]"
] | |
64747a27b2d1e04d98e003d5a3d3c11bb2ca5260 | 4b0bf4787e89bcae7e4759bde6d7f3ab2c81f849 | /aliyun-java-sdk-das/src/main/java/com/aliyuncs/das/model/v20200116/GetInstanceSqlOptimizeStatisticRequest.java | c73e8159b531b0ec6039b7d6c3aee63059bc0019 | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-java-sdk | a263fa08e261f12d45586d1b3ad8a6609bba0e91 | e19239808ad2298d32dda77db29a6d809e4f7add | refs/heads/master | 2023-09-03T12:28:09.765286 | 2023-09-01T09:03:00 | 2023-09-01T09:03:00 | 39,555,898 | 1,542 | 1,317 | NOASSERTION | 2023-09-14T07:27:05 | 2015-07-23T08:41:13 | Java | UTF-8 | Java | false | false | 3,220 | java | /*
* 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.aliyuncs.das.model.v20200116;
import com.aliyuncs.RpcAcsRequest;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.das.Endpoint;
/**
* @author auto create
* @version
*/
public class GetInstanceSqlOptimizeStatisticRequest extends RpcAcsRequest<GetInstanceSqlOptimizeStatisticResponse> {
private String endTime;
private String threshold;
private String startTime;
private String useMerging;
private String instanceId;
private String nodeId;
private String filterEnable;
public GetInstanceSqlOptimizeStatisticRequest() {
super("DAS", "2020-01-16", "GetInstanceSqlOptimizeStatistic");
setMethod(MethodType.POST);
try {
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap);
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType);
} catch (Exception e) {}
}
public String getEndTime() {
return this.endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
if(endTime != null){
putQueryParameter("EndTime", endTime);
}
}
public String getThreshold() {
return this.threshold;
}
public void setThreshold(String threshold) {
this.threshold = threshold;
if(threshold != null){
putQueryParameter("Threshold", threshold);
}
}
public String getStartTime() {
return this.startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
if(startTime != null){
putQueryParameter("StartTime", startTime);
}
}
public String getUseMerging() {
return this.useMerging;
}
public void setUseMerging(String useMerging) {
this.useMerging = useMerging;
if(useMerging != null){
putQueryParameter("UseMerging", useMerging);
}
}
public String getInstanceId() {
return this.instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
if(instanceId != null){
putQueryParameter("InstanceId", instanceId);
}
}
public String getNodeId() {
return this.nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
if(nodeId != null){
putQueryParameter("NodeId", nodeId);
}
}
public String getFilterEnable() {
return this.filterEnable;
}
public void setFilterEnable(String filterEnable) {
this.filterEnable = filterEnable;
if(filterEnable != null){
putQueryParameter("FilterEnable", filterEnable);
}
}
@Override
public Class<GetInstanceSqlOptimizeStatisticResponse> getResponseClass() {
return GetInstanceSqlOptimizeStatisticResponse.class;
}
}
| [
"[email protected]"
] | |
35097c44a003076d1fd63319df00a404dc216888 | de26350302845489b5f94cd7d672953e8911705a | /ui/databinding/api/src/main/java/org/treblereel/gwt/crysknife/databinding/client/api/handler/list/ItemAddedAtHandler.java | afdd7a2833ea56efd65e22721d1cd0244174e8a9 | [] | no_license | rob5n/crysknife | 43b6d0b410a22cdd3ce1ffaf25335bd869f3df3c | 225866c3c88fc17fcb5597619863779db501cfaa | refs/heads/master | 2021-01-04T04:27:11.838277 | 2020-02-13T09:38:21 | 2020-02-13T09:38:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,293 | java | /**
* Copyright (C) 2016 Red Hat, Inc. and/or its affiliates.
*
* 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.treblereel.gwt.crysknife.databinding.client.api.handler.list;
import java.util.List;
/**
*
* @author Max Barkley <[email protected]>
*/
@FunctionalInterface
public interface ItemAddedAtHandler<M> {
/**
* Called when a single item has been added to the list at the provided index.
*
* @param source
* a list representing the state before the item was added (equal to the old value of the
* list). Never null.
* @param index
* the index at which the item has been added.
* @param item
* the added item. May be null.
*/
void onItemAddedAt(List<M> source, int index, M item);
}
| [
"[email protected]"
] | |
ce25d6feb188d6166adad68c67e49e432f630c05 | 38e8bef690487abc3db8de3f138fbd7f72f7935b | /CODE/app/src/main/java/com/gtech/fishbangla/MODEL/User/Send_Reference.java | 4c0f52e65ab74ff1542eee5d1ad450f61efc9243 | [] | no_license | Muhaiminur/FISHBANGLA_ECOMMERCE_ANDROID | 2b8be6288a581ee5905fc5bb0bee0471d3b5a07e | b034f2259c25e5ad2f7c4292abb38602e3200ece | refs/heads/main | 2023-01-19T02:58:03.373087 | 2020-11-29T08:22:59 | 2020-11-29T08:22:59 | 316,906,394 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 718 | java | package com.gtech.fishbangla.MODEL.User;
public class Send_Reference {
String phone;
String userId;
public Send_Reference(String phone, String userId) {
this.phone = phone;
this.userId = userId;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String value) {
this.phone = value;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String value) {
this.userId = value;
}
@Override
public String toString() {
return "Send_Reference{" +
"phone='" + phone + '\'' +
", userId='" + userId + '\'' +
'}';
}
} | [
"[email protected]"
] | |
f89b83d4056494442592fab35f41c7a2e7a54723 | 79f21932ca7c531027cce24cda50ad3422dfc5b9 | /1906101019+贾佳/src/edu/sctu/java/day1027/TaskOne.java | 92c5df0606d36f19751b5f714d0f94b67a732536 | [] | no_license | gschen/sctu-java-2020 | 7647e810ac62893acaee8d9e37e48409380ad036 | 2fe56b7d55190b9e1cec92c247d5cd8bbcf7ed7a | refs/heads/master | 2023-01-06T00:04:10.153478 | 2020-11-03T02:25:58 | 2020-11-03T02:25:58 | 279,159,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 542 | java | package edu.sctu.java.day1027;
public class TaskOne implements Runnable{
int start;
int end;
void setN(int v){
this.start = v;
}
TaskOne(){
}
TaskOne(int v,int e){
this.start = v;
this.end = e;
}
@Override
public void run() {
for (int i = start; i < end ; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.print(i);
}
}
}
| [
"[email protected]"
] | |
31ca799a0b3876fdbcf3ffbedbf38cc7fe7b7d64 | 1181b3a0748661bab8230079995bf58e3852385c | /程序/HttpSessionDemo/src/com/test/Test.java | b43dd05e61923f4e35327bc72112a1433ef0a495 | [] | no_license | CKB0001/javaEE | 179478e9151631dd4e0f5cf53b4d56b3fa4c80a7 | 2c8ab0688ddf03fbaf9dc8a8dfbe78d071c2388d | refs/heads/master | 2022-04-11T18:45:43.768147 | 2020-02-28T11:05:57 | 2020-02-28T11:05:57 | 241,580,632 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package com.test;
import java.util.List;
import com.bookBean.Book;
import com.bookDOM.BookDao;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
BookDao book=new BookDao();
List<Book> book1=null;
book1=book.searchALLShopping();
for(Book c:book1)
{
System.out.println(c.getPrice());
}
}
}
| [
"[email protected]"
] | |
5fdd21898915bfbaa5440070193b90945003309d | 5e7749a5a9d1440f7ee0f0226f6a2be366f73a4c | /app/src/main/java/com/ozturkburak/itbookssearchapp/Utils.java | e16b992e2345ab41d76059eac33bbfe5a3f45c07 | [] | no_license | burakztrk/ItBooksSearchApp | aec507e3018fc8d499a705ab47886d7d4379dc77 | e74da72b040eae34e1fd39faa516cbb94d8ca6d3 | refs/heads/master | 2021-01-20T20:57:35.666079 | 2017-05-10T22:03:21 | 2017-05-10T22:03:21 | 62,324,161 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,550 | java | package com.ozturkburak.itbookssearchapp;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Created by burak on 28.06.2016.
*/
public class Utils
{
public static String getJsonDatafromUrl(String urlStr) throws Exception
{
String result;
HttpURLConnection connection = null;
try
{
connection = openHttpConnection(urlStr);
result = readInputStream(connection.getInputStream());
connection.disconnect();
}
catch (Exception ex)
{
Log.d("Exception" , ex.getMessage());
throw ex;
}finally
{
connection.disconnect();
}
return result;
}
public static HttpURLConnection openHttpConnection(String urlStr) throws IOException
{
if (!HttpUrlBuilder.urlIsValid(urlStr))
throw new IllegalArgumentException("Url is invalid");
URL url = null;
HttpURLConnection conn = null;
try
{
url = new URL(urlStr);
conn = (HttpURLConnection)url.openConnection();
}
catch (Exception ex)
{
Log.d("Exception" , ex.getMessage());
throw ex;
}
return conn;
}
private static String readInputStream(InputStream is)throws Exception
{
StringBuilder result = new StringBuilder();
try
{
InputStreamReader isr = new InputStreamReader(is);
char[] buffer = new char[1024];
int readCount;
while ( (readCount = isr.read(buffer)) >0 )
{
result.append(buffer , 0 , readCount);
buffer = new char[1024];
}
}
catch (Exception ex)
{
Log.d("Exception" , ex.getMessage());
throw ex;
}
finally
{
try
{is.close();}
catch (IOException e){ e.printStackTrace();}
}
return result.toString();
}
public static Bitmap saveImagefromUrl(Context context , String urlStr , String imageName) throws IOException
{
Bitmap result = null;
HttpURLConnection conn = openHttpConnection(urlStr);
InputStream bis = new BufferedInputStream(conn.getInputStream());
result = BitmapFactory.decodeStream(bis);
OutputStream os = context.openFileOutput( imageName , Context.BIND_AUTO_CREATE);
result.compress(Bitmap.CompressFormat.JPEG , 100 , os);
return result;
}
public static Bitmap downloadImagefromUrl(String urlStr) throws IOException
{
Bitmap result = null;
HttpURLConnection conn = openHttpConnection(urlStr);
InputStream bis = new BufferedInputStream(conn.getInputStream());
result = BitmapFactory.decodeStream(bis);
return result;
}
public static Intent openWebBrowser(String url)
{
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
return new Intent(Intent.ACTION_VIEW , Uri.parse(url));
}
public static void openChromeCustomTab(Activity activity , String url)
{
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder
.setToolbarColor(Color.parseColor("#303f9f"))
.setShowTitle(true)
.build();
customTabsIntent.launchUrl(activity , Uri.parse(url));
}
public static void hideKeyboard(Activity activity)
{
View view = activity.getCurrentFocus();
if (view != null)
{
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
}
| [
"[email protected]"
] | |
c76507ca3407abb06d14657426069f5c13633c37 | 5a7d59c765502fab90456d7b7a47153088c499fe | /app/src/main/java/net/simplifiedcoding/androidpagingexample/ItemViewModel.java | aa070d2f06747b2e8b114336ff6c68ec511d0f8e | [] | no_license | mohamedebrahim96/android-paging-library-example-master | 3f30649fef9869f75e61d2ea543aa642d1820104 | c3e5c963e991ad4b527d5375fab1d796a14594d3 | refs/heads/master | 2020-05-02T19:39:05.298978 | 2019-03-17T09:41:03 | 2019-03-17T09:41:03 | 178,164,793 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 957 | java | package net.simplifiedcoding.androidpagingexample;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModel;
import android.arch.paging.LivePagedListBuilder;
import android.arch.paging.PageKeyedDataSource;
import android.arch.paging.PagedList;
public class ItemViewModel extends ViewModel {
LiveData<PagedList<Item>> itemPagedList;
LiveData<PageKeyedDataSource<Integer, Item>> liveDataSource;
public ItemViewModel() {
ItemDataSourceFactory itemDataSourceFactory = new ItemDataSourceFactory();
liveDataSource = itemDataSourceFactory.getItemLiveDataSource();
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setPageSize(ItemDataSource.PAGE_SIZE).build();
itemPagedList = (new LivePagedListBuilder(itemDataSourceFactory, pagedListConfig))
.build();
}
}
| [
"[email protected]"
] | |
7eaa6f6cd7aacb63d541b154291982a58ed67ceb | 6e0fe0c6b38e4647172259d6c65c2e2c829cdbc5 | /modules/desktop/desktop-util-awt/src/main/java/com/intellij/openapi/util/ColoredItem.java | 821f20a02fddd487b3de37e7827dbd9c219007a5 | [
"Apache-2.0",
"LicenseRef-scancode-jgraph"
] | permissive | TCROC/consulo | 3f9a6df84e0fbf2b6211457b8a5f5857303b3fa6 | cda24a03912102f916dc06ffce052892a83dd5a7 | refs/heads/master | 2023-01-30T13:19:04.216407 | 2020-12-06T16:57:00 | 2020-12-06T16:57:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.util;
import javax.annotation.Nullable;
import java.awt.*;
/**
* @author gregsh
*/
public interface ColoredItem {
@Nullable
Color getColor();
}
| [
"[email protected]"
] | |
6404381b138115f519c5f27565923f315cc5b5a1 | 00e3d3386496339950258f807101d9cc91a179cc | /src/main/java/coffeemachine/view/IssueScene.java | d16fa661be20891a0ddab611c4291e8b45d6c222 | [] | no_license | elliass/coffee-machine-gui | 2b59e345c7c0627b9da08f1d613b15660c2e8e23 | acdf1b55e54769cded5beed671231976065a72d3 | refs/heads/master | 2023-08-03T22:25:27.502664 | 2021-09-12T20:30:11 | 2021-09-12T20:30:11 | 400,745,543 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 297 | java | package coffeemachine.view;
import coffeemachine.view.issue.IssuePane;
import javafx.scene.Scene;
public class IssueScene extends Scene {
public IssueScene() {
super(new IssuePane());
this.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
}
}
| [
"[email protected]"
] | |
33b4aa773149e250d23fe6140ac16344265d5293 | 2588cc3e2476198959e506541797e041b1413837 | /src/main/java/fr/miage/bibaldenis/config/liquibase/package-info.java | 1c7cf93fb00febf772ef8ebc0ec54a6fcbb9a887 | [
"MIT"
] | permissive | BulkSecurityGeneratorProject/fuzzy-happiness | 23f950975ed18bc9fa9ec8eceb2615d1a437ea88 | 45a4ab11677401110bc354ec716cb037183b2b14 | refs/heads/master | 2022-12-14T19:11:12.524814 | 2016-11-07T14:47:25 | 2016-11-07T14:47:25 | 296,668,423 | 0 | 0 | MIT | 2020-09-18T16:04:10 | 2020-09-18T16:04:09 | null | UTF-8 | Java | false | false | 82 | java | /**
* Liquibase specific code.
*/
package fr.miage.bibaldenis.config.liquibase;
| [
"[email protected]"
] | |
3f629e84956b7d0a0dd1aff9a4b375843633c20d | 63a2162cc89e61ce276420488c7115df239b9b15 | /TestWeb/src/example/taglib/BodyTagSample.java | 76e4331dbaba5f500e438086eaf77801559f5baf | [] | no_license | anabasis/eclipse | 1840cf7e43a0561dafced2afc07e0934697de6fb | 58cb2400941fd6859294b0be2193d3add2038581 | refs/heads/master | 2022-09-13T13:07:07.061110 | 2021-01-07T08:15:58 | 2021-01-07T08:15:58 | 17,169,636 | 0 | 0 | null | 2022-09-08T01:13:30 | 2014-02-25T10:39:06 | HTML | UHC | Java | false | false | 827 | java | package example.taglib;
import java.io.IOException;
import java.io.StringWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
public class BodyTagSample extends SimpleTagSupport {
StringWriter sw = new StringWriter();
public void doTag() throws JspException, IOException {
getJspBody().invoke(sw);
getJspContext().getOut().println(sw.toString() + "<br/>");
getJspContext().getOut().println(calGuGuDan());
}
// 구구단 계산 ////////////////////////////////////////////
public String calGuGuDan() {
String message = "<table>";
for (int i = 1; i <= 9; i++) {
message += "<tr>";
for (int j = 1; j <= 9; j++)
message += ("<td>" + i + " * " + j + " = " + (i * j) + "</td>");
message += "</tr>";
}
message += "</table>";
return message;
}
} | [
"[email protected]"
] | |
d94b4bc005e632e8feeb7d39180e2d352d1c8918 | 878ea136e3ae64a5d2a5dea11163bf923484b95d | /car_system/src/main/java/xyz/jfshare/car/system/entity/User.java | 9a966e9d29dae7d8d4e702f63077047416e9d556 | [] | no_license | zhouxinyi201607340/ZhouXinYiOfficialVehicleSystem | 5df5058e90e17b9599e3461fc60d499816cac324 | f21e24bfbdbb1f237c1b556f5470b9df39c14a39 | refs/heads/master | 2022-12-26T12:48:03.472394 | 2020-05-26T08:36:52 | 2020-05-26T08:36:52 | 248,507,097 | 0 | 1 | null | 2022-12-16T04:24:06 | 2020-03-19T13:13:44 | JavaScript | UTF-8 | Java | false | false | 1,395 | java | package xyz.jfshare.car.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;
@Data
@TableName("sys_user")
public class User {
/** id主键 */
@TableId(type = IdType.AUTO)
private Integer id;
/** 0:正常 1:注销 */
private Integer status;
/** 用户名 */
private String username;
/** 密码 */
private String password;
/** 昵称 */
private String nickname;
/** 盐 */
private String salt;
/** 头像 */
private String icon;
/** 角色id */
private Integer roleId;
/** 创建时间 */
private Timestamp createTime;
/** 修改时间 */
private Timestamp updateTime;
/** 角色 */
@TableField(exist = false)
private String roleName;
/** 所有权限 */
@TableField(exist = false)
private List<Permission> allPerm;
/** 菜单权限 */
@TableField(exist = false)
private List<Permission> menuPerm;
/** 跳过的条数 */
@TableField(exist = false)
private Integer skip;
/** 搜索的条数 */
@TableField(exist = false)
private Integer size;
}
| [
"[email protected]"
] | |
e9b7bcf14f5c1b2e3b1d07b856daa88b60545b35 | b7df4c7f2d4029cbd2ebd03c6bad62854ee95358 | /src/main/java/one/digitalinnovation/statics/Dog.java | 0b23ecea3a994a9544a59a3a27325133b1efaeda | [] | no_license | Ricky-Bustillos-Study/java-features-part-1 | 4e93983f630f6f77ff7d68aa969bad48d972312a | c07d13ceb5baf5546679f8cc5fdd0677c2c77502 | refs/heads/master | 2023-06-27T02:15:56.999825 | 2021-08-02T19:51:22 | 2021-08-02T19:51:22 | 392,075,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 251 | java | package one.digitalinnovation.statics;
public class Dog {
public String zoology = "Quadruped"; // a instance
//public static String zoology = "Quadruped"; // all instances
public static String bark() {
return "Au! Au!";
}
}
| [
"[email protected]"
] | |
09c5d2ca4f2e2d63b38b3d5e2ea3a2fe97ddf709 | 958686722dfc58ea022354a1e4f72dd4971af42d | /COMP1006/tester.java | 435ac04738394e30b24fe42823434d11264a916e | [
"MIT"
] | permissive | cal-smith/Class | 449e43abdda9126db5530d3e23ce5b7ae51e51a1 | cf05e0aad68ccc53311cda2c945b6ac5cd5faf2b | refs/heads/master | 2021-06-03T20:24:29.143739 | 2015-09-11T23:49:30 | 2015-09-11T23:49:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 74 | java | public class tester extends test {
public tester() {
this.a = "b";
}
} | [
"[email protected]"
] | |
e3959e236f5f4f2b03a9148108db02abb52d5ef8 | d3041165f4f39de38d4fc668fa6a2b202125dded | /src/main/java/com/example/redisdemo/repository/RedisRepositoryImpl.java | 573b8abeba85fe4254cab8c5cc584c7a1b91f3a9 | [] | no_license | javasam/redis | e80d8c0a01fc99acd94b69c52a34cfede95a47e5 | c298a527413352c32cdd5d5f5428eea078a24439 | refs/heads/master | 2023-01-23T08:29:53.770974 | 2020-11-25T13:44:14 | 2020-11-25T13:44:14 | 313,323,609 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,497 | java | package com.example.redisdemo.repository;
import com.example.redisdemo.model.Movie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@Repository
public class RedisRepositoryImpl implements RedisRepository {
private static final String KEY = "Movie";
private final RedisTemplate<String, Object> redisTemplate;
private HashOperations<String, String, String> hashOperations;
@Autowired
public RedisRepositoryImpl(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@PostConstruct
private void init() {
hashOperations = redisTemplate.opsForHash();
}
public void add(final Movie movie) {
hashOperations.put(KEY, movie.getId(), movie.getName());
}
public void delete(final String id) {
hashOperations.delete(KEY, id);
}
public Movie findMovie(final String id) {
String movieName = hashOperations.get(KEY, id);
if (Objects.isNull(movieName)) {
return new Movie("", "");
} else {
return new Movie(id, movieName);
}
}
public Map<String, String> findAllMovies() {
return hashOperations.entries(KEY);
}
}
| [
"[email protected]"
] | |
60c8aba173324198abbecd55eb3f33b6bf774684 | 1bfef594f6c8c63a3f7a408f88ec8b04761c2564 | /Bircle_04241/app/src/main/java/com/bookkos/bircle/InactivityTimer.java | 7825d0371728f822a502b4f74ae348cb58412122 | [] | no_license | birclep/buppinn | bf8c08ce432553ae197f93bf00081a0dcceeb263 | 34fc404827f4017cfe18d985cf496318a2b26865 | refs/heads/master | 2021-01-10T14:13:53.843327 | 2016-01-16T08:41:08 | 2016-01-16T08:41:08 | 36,778,671 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,356 | java | /*
* Copyright (C) 2010 ZXing 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 com.bookkos.bircle;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.os.BatteryManager;
import android.util.Log;
/**
* Finishes an activity after a period of inactivity if the device is on battery power.
*/
final class InactivityTimer {
private static final String TAG = InactivityTimer.class.getSimpleName();
private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L;
private final Activity activity;
private final BroadcastReceiver powerStatusReceiver;
private boolean registered;
private AsyncTask<Object,Object,Object> inactivityTask;
InactivityTimer(Activity activity) {
this.activity = activity;
powerStatusReceiver = new PowerStatusReceiver();
registered = false;
onActivity();
}
synchronized void onActivity() {
cancel();
inactivityTask = new InactivityAsyncTask();
inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public synchronized void onPause() {
cancel();
if (registered) {
activity.unregisterReceiver(powerStatusReceiver);
registered = false;
} else {
Log.w(TAG, "PowerStatusReceiver was never registered?");
}
}
public synchronized void onResume() {
if (registered) {
Log.w(TAG, "PowerStatusReceiver was already registered?");
} else {
activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
registered = true;
}
onActivity();
}
private synchronized void cancel() {
AsyncTask<?,?,?> task = inactivityTask;
if (task != null) {
task.cancel(true);
inactivityTask = null;
}
}
void shutdown() {
cancel();
}
private final class PowerStatusReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent){
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
// 0 indicates that we're on battery
boolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0;
if (onBatteryNow) {
InactivityTimer.this.onActivity();
} else {
InactivityTimer.this.cancel();
}
}
}
}
private final class InactivityAsyncTask extends AsyncTask<Object,Object,Object> {
@Override
protected Object doInBackground(Object... objects) {
try {
Thread.sleep(INACTIVITY_DELAY_MS);
Log.i(TAG, "Finishing activity due to inactivity");
activity.finish();
} catch (InterruptedException e) {
// continue without killing
}
return null;
}
}
}
| [
"[email protected]"
] | |
3d92ebdce05bc1a60a3cb523b835129570ca9c61 | e1ca32ff178c7fccfef026d689cd1fcb0832576b | /src/Frame/Adminİslemleri.java | a0a157d2444a3c7de6754462faf20da7271eff48 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | alparslankorkutata/Kutuphane-Otomasyonu | 4d8afe1b023df3b12aa4a85c9adce61e068fe5af | 89c76d9c42c75489f57cfbbb96665fb4b74e32d0 | refs/heads/master | 2023-03-01T08:21:06.012808 | 2021-01-31T21:26:27 | 2021-01-31T21:26:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,866 | 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 Frame;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.sql.ResultSet;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar;
/**
*
* @author ASUS
*/
public class Adminİslemleri extends javax.swing.JFrame {
private ImageIcon icon;
/**
* Creates new form Adminİslemleri
*/
public Adminİslemleri() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
kitapislemleri = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Admin İşlemleri");
setBackground(new java.awt.Color(0, 153, 153));
setLocation(new java.awt.Point(550, 200));
jPanel1.setBackground(new java.awt.Color(0, 102, 102));
kitapislemleri.setBackground(new java.awt.Color(0, 0, 0));
kitapislemleri.setFont(new java.awt.Font("Comic Sans MS", 3, 14)); // NOI18N
kitapislemleri.setForeground(new java.awt.Color(255, 255, 255));
kitapislemleri.setIcon(new javax.swing.ImageIcon("C:\\Users\\ASUS\\Desktop\\Software\\icons for java\\Books-2-icon.png")); // NOI18N
kitapislemleri.setText("KİTAP İŞLEMLERİ");
kitapislemleri.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
kitapislemleri.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
kitapislemleriActionPerformed(evt);
}
});
jButton2.setBackground(new java.awt.Color(0, 0, 0));
jButton2.setFont(new java.awt.Font("Comic Sans MS", 3, 14)); // NOI18N
jButton2.setForeground(new java.awt.Color(255, 255, 255));
jButton2.setIcon(new javax.swing.ImageIcon("C:\\Users\\ASUS\\Desktop\\Software\\icons for java\\Books-1-icon.png")); // NOI18N
jButton2.setText("ÖDÜNÇ VERME İŞLEMLERİ");
jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(kitapislemleri, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(26, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(kitapislemleri, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
ÖdüncVerme frm3 = new ÖdüncVerme();
frm3.setVisible(true);
dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void kitapislemleriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kitapislemleriActionPerformed
// TODO add your handling code here:
Kitapİslemleri frm2 = new Kitapİslemleri();
frm2.setVisible(true);
dispose();
}//GEN-LAST:event_kitapislemleriActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Adminİslemleri.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Adminİslemleri.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Adminİslemleri.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Adminİslemleri.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Adminİslemleri().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton2;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton kitapislemleri;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
759c8612103f3c04e506aa5663973d98fcc44d43 | 40f3c748a78ce3b007d554087d6ba0a44351bea2 | /src/main/java/com/astontech/hr/rest/EmployeeRest.java | 2b2e7f463686306ec6967ceca18a22a6d49a13b6 | [] | no_license | TuckerNemcek/SOARest_finalProject | cccf3e4428fb1efba225f11d03f4ec707692c1d0 | fcfd12b17615ca0b8c63471035f67b27b799271f | refs/heads/master | 2020-12-22T14:21:46.756382 | 2020-01-31T20:24:48 | 2020-01-31T20:24:48 | 236,820,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,400 | java | package com.astontech.hr.rest;
import com.astontech.hr.domain.Employee;
import com.astontech.hr.services.EmployeeService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/employee")
public class EmployeeRest {
private Logger log = Logger.getLogger(EmployeeRest.class);
@Autowired
private EmployeeService employeeService;
//Returns all employees
@RequestMapping(value = "/", method = RequestMethod.GET)
public Iterable<Employee> getAll() {
return employeeService.listAllEmployees();
}
//GET BY ID
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Employee getById(@PathVariable int id) {
return employeeService.getEmployeeById(id);
}
//SAVE
@RequestMapping(value = "/", method = RequestMethod.POST)
public Employee save(@RequestBody Employee employee){
return employeeService.saveEmployee(employee);
}
//DELETE
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public Boolean delete(@PathVariable int id) {
boolean result = false;
try {
employeeService.deleteEmployee(id);
result = true;
} catch (Exception ex) {
log.error(ex);
}
return result;
}
}
| [
"[email protected]"
] | |
72f3dcbe4aa45f70244de36a4e46c1c732e79bd6 | 8a42be3f930d8a215394a96ad2e91c95c3b7ff86 | /Source/JRecord_RE/src/net/sf/JRecord/IO/MicroFocusLineWriter.java | fc7f48f40d3e717e9201783d95b8479059fe84a0 | [] | no_license | java-tools/jrec | 742e741418c987baa4350390d126d74c0d7c4689 | 9ece143cdd52832804eca6f3fb4a1490e2a6f891 | refs/heads/master | 2021-09-27T19:24:11.979955 | 2017-11-18T06:35:31 | 2017-11-18T06:35:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,697 | java | /* -------------------------------------------------------------------------
*
* Sub-Project: RecordEditor's version of JRecord
*
* Sub-Project purpose: Low-level IO and record translation
* code + Cobol Copybook Translation
*
* Author: Bruce Martin
*
* License: GPL 2.1 or later
*
* Copyright (c) 2016, Bruce Martin, All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ------------------------------------------------------------------------ */
package net.sf.JRecord.IO;
import java.io.IOException;
import java.io.OutputStream;
import net.sf.JRecord.ByteIO.MicroFocusByteWriter;
import net.sf.JRecord.ByteIO.MicroFocusFileHeader;
import net.sf.JRecord.Details.AbstractLayoutDetails;
import net.sf.JRecord.Details.AbstractLine;
/**
* Purpose: Write a Microfocus Cobol Sequential file with a Header Record
*
* @author Bruce Martin
*
*/
public class MicroFocusLineWriter extends AbstractLineWriter {
private MicroFocusByteWriter writer = new MicroFocusByteWriter();
private boolean toInit;
@Override
public void open(String fileName) throws IOException {
writer.open(fileName);
toInit = true;
}
@Override
public void open(OutputStream outputStream) throws IOException {
writer.open(outputStream);
toInit = true;
}
@SuppressWarnings("unchecked")
@Override
public void setLayout(AbstractLayoutDetails layout) throws IOException {
if (toInit) {
int len;
int maxLen = 0;
int minLen = Integer.MAX_VALUE;
for (int i = 0; i < layout.getRecordCount(); i++) {
len = layout.getRecord(i).getLength();
maxLen = Math.max(maxLen, len);
minLen = Math.min(minLen, len);
}
writer.writeHeader(
new MicroFocusFileHeader(MicroFocusFileHeader.FORMAT_SEQUENTIAL, minLen, maxLen)
);
super.setLayout(layout);
toInit = false;
}
}
@SuppressWarnings("unchecked")
@Override
public void write(AbstractLine line) throws IOException {
setLayout(line.getLayout());
writer.write(line.getData());
}
@Override
public void close() throws IOException {
writer.close();
}
}
| [
"bruce_a_martin@b856f413-25aa-4700-8b60-b3441822b2ec"
] | bruce_a_martin@b856f413-25aa-4700-8b60-b3441822b2ec |
0f8637cd69bbe5ac71286d8cb62bc6b4e19ea4ed | b50e289aafb8298e9ade06c0a718e9e1b1587923 | /app/src/main/java/com/test/kmlparser/DataListener.java | fe10865c9dc8f1c5c7d4f6fe3a8cc27a459119ca | [] | no_license | ViktorYastrebov/agrimotor_tracker | 15d1cf68ccde6ea5d15567809fbfd5c7b489a1bc | 5d0edaaff14cb0182de08fc5987d468cc6696b48 | refs/heads/master | 2020-03-24T18:42:54.155980 | 2018-08-18T18:15:48 | 2018-08-18T18:15:48 | 142,897,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,720 | java | package com.test.kmlparser;
import android.content.Context;
import com.google.android.gms.maps.model.LatLng;
import com.test.kmlparser.GRPMC.*;
import android.os.Handler;
public class DataListener implements Runnable {
//private Context m_contex;
private Handler m_handler;
private GPRMCFileParser m_parser;
private TrackModel m_track_model;
private final long timerPause = 100; //ms
private int initCameraPoints = 30;
public DataListener(Handler main_handler, GPRMCFileParser parser, TrackModel trackModel) {
this.m_handler = main_handler;
this.m_parser = parser;
this.m_track_model = trackModel;
}
@Override
public void run() {
// Delta around 3-5 meters. On curve - make it more detailed
try {
LatLng p = m_parser.process(); //data
if(p != null) {
Thread.sleep(timerPause); //emulation of read()
//m_handler.postDelayed( new InitPoster(m_track_model,p), 2000);
m_handler.post(new InitPoster(m_track_model,p));
}
p = m_parser.process();
while( p != null) {
Thread.sleep(timerPause);
if(initCameraPoints != 0) {
//m_handler.postDelayed( new MessagePoster(m_track_model, p), 2000);
m_handler.post(new MessagePoster(m_track_model, p, true));
--initCameraPoints;
} else {
m_handler.post(new MessagePoster(m_track_model, p, false));
}
p = m_parser.process();
}
} catch (Exception ex) {}
}
}
| [
"[email protected]"
] | |
12d6e6fe06d7c0a2fe829acb757731b5907a4823 | 1554a26a5479e62bc347eee4dcfeb8c97e058525 | /app/src/main/java/net/december1900/douby/common/model/Comment.java | 8d02397d27dce2f4714fa5c774e6b80b0b325da1 | [] | no_license | December1900/Douby | 02d753b826c5986e1882473a0239376a7cef43fe | bcb9e9d27d6c5ea2b30c43b808d727b432dfc710 | refs/heads/master | 2021-01-19T13:57:06.070966 | 2017-11-17T15:08:37 | 2017-11-17T15:08:37 | 100,867,429 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,035 | java | package net.december1900.douby.common.model;
/**
* Created by december on 22/10/2017.
*/
public class Comment {
/**
* comment :
又看《霸王别姬》,不一样的环境,一样的感动。
有几大矛盾对象:
程蝶衣与段小楼
蝶衣从最开始近京剧班,就与小楼有着很深厚的感情。我们可以看到许多感人的画面:小楼受罚,黑夜冬天在院子了跪着,蝶衣则隔着窗子心疼地看着他,等小楼回来后则自己光着身子,却把被子给小楼裹上。接着那个他们依偎在一起睡觉的场面大家一定很难忘记,蝶衣紧紧地搂着小楼,仿佛怕失去了他。而小楼对蝶衣也是身份的爱护,他开始知道蝶衣不想学京戏了,那一次,他却把蝶衣放走了,尽管他十分的不舍的。还有后来让老板来,听蝶衣总唱不好“我本是女娇娥”,就用烟斗烫他,从而使蝶衣第一次唱对。
毋庸置疑,他们都是相互喜欢的,但是,小楼对蝶衣只是好兄弟一样的感情,而蝶衣对小楼则超越了亲情。由于总在戏中扮演青衣,唱的是女腔,学得是女形,久而久之,在社会及角色中,他则比较倾向于女性。对小楼,他也一直是以一个女性的角色,例如帮小楼舔伤口,给小楼画脸谱,其亲昵的动作无不体现出他对小楼的超出一般的感情。尤其是在出现了菊仙以后,他对菊仙的嫉妒和对小楼的怨恨,都很明显的变现了他社会角色中女性化的特点。
程蝶衣与小癞子
小癞子给蝶衣留下的最深的印象,莫过于一句话:“等以后我成角儿了就天天吃糖葫芦”和一个场景了“最后因为害怕被师傅毒打,而上吊自杀。”他的自杀是有准备的,由于看着蝶衣被打的恐怖的场面,或许还由于他觉得成为一个角儿还要挨很多很疼的打而觉得害怕?总之,他有准备的自杀了,死之前他把自己身上所有的吃的东西都急急忙忙的吞了下去。这也许是许多学京戏却没有成角儿的人的另一种选择吧。梦不能成真,就只有在虚无的世界中去寻找了。
但他却留给蝶衣一生的印象。在蝶衣成角儿后,一次入场前他听到了冰糖葫芦的吆喝声,就愣住了。那时候,他想到了什么呢?小癞子的梦想?小癞子的死?或许是震惊和无奈?
程蝶衣与张公公
张公公玷污了蝶衣。成了角儿,也并不一定只是荣誉和欢乐。他们或许还不知道,开始只是拼命的向前奔,可后来等达到了目标,却才发现这结果也许并不是美好的,可却,只能接受而不能改变了。
讽刺的是,后来的新中国成立前夕,曾经呼风唤雨,为所欲为的太监,张公公,却成了一个买烟的贫苦的老人,并且已经神智不清,只知道买烟的人。他曾干过的一切,就在他的混沌中被遗忘了吗?可是受到伤害的人,却是一生的无法挽回的创痛。社会中人与人之间,一件事也许对一个人来说微乎其微,何时对另一个人来讲也许是决定性的。
程蝶衣与菊仙(妈妈)
从一开始蝶衣对菊仙就充满了敌意,嫉妒,因为她抢走了小楼,一个蝶衣生命中最最重要的人。他们之间也许存在着一场战斗,而蝶衣注定是失败者。
可是,在一幕幕蝶衣与菊仙的对视中,他有对蝶衣有一定的依恋,是一种对于母亲的依恋。尤其在他戒毒瘾时菊仙抱着他哄他睡觉更表现得淋漓尽致。蝶衣从小就被妈妈送到京戏班,连妈妈的最后一眼,那个空荡荡的没有人影的门,都没有看到。因此他对母爱是渴望的。并且菊仙和蝶衣妈妈得出身一样,都是妓女,更给他一种幻象,菊仙有着他妈妈的众多特性,女性,泼辣,妓女。
因此他对菊仙的感情就非常的矛盾了,在敌视与依恋中徘徊。
程蝶衣与袁四爷
也许袁四爷是他的知音,在京戏方面。他在蝶衣失去小楼的最痛苦的时候,让蝶衣产生了幻觉。他很欣赏蝶衣,他也给过蝶衣很多的帮助,各个方面。但小楼对他是充满敌意的,也许是因为他对蝶衣的特殊的关照也令小楼嫉妒了?但他的命运让小楼和蝶衣都很惊讶,一个社会上游刃有余的名流,终会遇到一种无法逍遥自在的社会。他就那么的死了,被历史碾死了。
程蝶衣与小四
蝶衣捡来了小四,在师傅死后,又收养了小四。他是想让小四延续京剧的发展。可时候来,小四却无情的将蝶衣打下了地狱。他抢占了蝶衣的上台的机会,他抢占了虞姬的角色。而对于蝶衣,一个把京剧视为生命,甚至比生命还重要的人,如果连京戏都被剥夺了,那他还能剩下什么呢?
程蝶衣与京戏(师傅)
师傅把蝶衣领进了京剧的世界,一个严厉的,传统的,却对京剧充满理解的师傅,他最终在唱京剧时倒下了,辞世了。无疑,他给了蝶衣很大的影响。蝶衣慢慢的从只知其声,其形,到了解其中的精粹,最终把其视为生命。他在表演时非常的入境,常到达一种与戏中的人物和一的境界。那种潜心投入的表演,一切外在的喧闹和烦扰都不能够影响。
程蝶衣与时代(清末,侵华,民国,新中国初期,文化大革命,之后)
一个动荡的年代,人们的思想也是非常慌乱的,不确定的。连国家,民族,你都不能确信,你就更不能确信任何其他的一切了。人们仿佛都是漂浮在空气中的,没有根基。善于生活的人也不一定能够生(比如袁四爷),懂得人生常识的人也不一定能够生,(比如菊仙)。
清末,百姓,戏子,被动得像旗子一样受封建残余的玩弄,不能把握自己的命运。
日寇来了,无辜的人们的姓名也不能幸免。或许艺术能够无国界,可是舆论却不能够接受,民族感情不能接受。
民国呢,仍然是动荡不安,随时都回发生变动。
短暂的新中国初期,对于京剧形式的变形,蝶衣很难接受,毕竟,那不是他心中的京剧的印象。可是他不能决定一切,因为时间的车轮在不停的转着。
他一直都在唱着,不管是哪一个时期,或许,每个时期都需要艺术。艺术没有时间性。可是,在这其中蝶衣总要时不时地受到外界的干扰,政治,一个无聊的却无法避免的东西,在艺术前进的道路上洒满了图钉。
文化大革命来了,一切真的都颠覆了?革文化的命,对文化进行批判,打破固有的一切文化。或许如果这只在学术界进行,只是行而上的批判是好的,可是当权力掌握在了不成熟的头脑发热的人的手中,也许就变味了。没有了文化,没有了标准,没有了历史,每个人都可以是他想是的了,最终,也就什么都不是了。
程蝶衣与死
蝶衣真的累了,经历了那么多辉煌与动荡,得到,失去,又得到。最终,他选择了在戏中结束自己的生命。一生都无法把握住自己,一生都宿命的漂泊,终在死亡这件事上他做了自己的主人。一幅完美的画面——霸王别姬,永不能重演了。留下了孤零零的楚霸王,人生,也许真的只是一场戏。爱,别,离,怨,憎,恚,总得有一个苦涩的结局来收场。
程蝶衣与张国荣
虞姬死了,呈蝶衣死了,张国荣死了。戏里戏外,真真假假,可是,结果都一样。
* rate1 : 5.05
* rate2 : 9.09
* rate3 : 35.35
* rate4 : 51.51
*/
public String comment;
public double rate1;
public double rate2;
public double rate3;
public double rate4;
}
| [
"[email protected]"
] | |
bff4c566f9a4e66f5437728f923bd8db6798a7fb | d498f45b10dd974dd8ce63b3711b43e43a3b1474 | /src/test/java/BookingTest.java | de2165002f351e58d0d7a5333ac907f25c266405 | [] | no_license | akcshing/java-codeclan-towers-multiple-classes-hashmaps-lab | 664913a7b0bf9ba6f56bc020731d8eac5438a278 | a5f5fd0b805599ceb1d3348923fb239d41c7027f | refs/heads/master | 2020-05-02T14:50:51.220184 | 2019-03-27T15:20:16 | 2019-03-27T15:20:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 658 | java | import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class BookingTest {
Booking booking1;
Hotel hotel;
Bedroom bedroom1;
@Before
public void before() {
bedroom1 = new Bedroom(3, 1, "single", 69.99);
booking1 = new Booking(bedroom1, 3);
}
@Test
public void hasBedroom() {
assertEquals(bedroom1, booking1.getBedroom());
}
@Test
public void hasNumberOfNights() {
assertEquals(3, booking1.getNumberOfNights());
}
@Test
public void canGiveTotalBill() {
assertEquals(209.97, booking1.totalBill(), 0.001);
}
}
| [
"[email protected]"
] | |
ad5940daec1aa757dd23ebde9a2853c9f3588ebf | 35e7c94143d0f19d22b278b3e77095e9c0e4ec0a | /src/com/virtualclassrooms/services/NewsServicesImpl.java | eff1629017b4124b6ccfeb7dc4b62b12a9eab4ce | [] | no_license | NikhilAnumandla79/VirtualClassroom | 934e7a377cb13ed02c6f8c9780804f630785eea9 | b6ca4775433abee13930ab8b26bdf6d3f6dad2d7 | refs/heads/master | 2023-04-23T20:00:39.514909 | 2021-04-20T03:21:14 | 2021-04-20T03:21:14 | 358,587,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 290 | java | package com.virtualclassrooms.services;
import java.util.List;
import com.virtualclassrooms.dao.NewsDaoImpl;
import com.virtualclassrooms.model.News;
public class NewsServicesImpl{
public List<News> getNews() {
List<News> topnews=new NewsDaoImpl().fetchNews();
return topnews;
}
}
| [
"[email protected]"
] | |
b62521d79a140097eeb4137263e3f9c829923b6e | ddb43578326eb5f24b594323f7539a7f06d08c76 | /contentSale-manager/contentSale-manager-web/src/main/java/com/contentsale/controller/AccountController.java | 989cb41e8c99f83c4bdddf28b258253ead0b1137 | [] | no_license | Yinqingseu/com.contentSale | cbf0127cbbec39c105099ea6a7c46e69736a0d10 | dcd66fb04e45249c32503f389021593b3ef2a728 | refs/heads/master | 2021-04-27T07:54:24.295630 | 2018-03-06T14:36:44 | 2018-03-06T14:36:44 | 122,641,966 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,359 | java | package com.contentsale.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.contentsale.pojo.Contents;
import com.contentsale.pojo.Product;
import com.contentsale.pojo.User;
import com.contentsale.pojo.UserShoppingRecord;
import com.contentsale.service.ContentService;
import com.contentsale.service.ProductService;
import com.contentsale.service.UserService;
import com.contentsale.service.UserShoppingRecordService;
@Controller
public class AccountController {
@Autowired
private UserService userService;
@Autowired
private ContentService contentService;
@Autowired
private UserShoppingRecordService shoppingRecordService;
@Autowired
private ProductService productService;
/**
* 用户账务展示
* @return
*/
@RequestMapping("/account")
public Model accountShow(HttpSession session,Model map) {
List<Product> buyList = new ArrayList<Product>();
//用户信息获取
User user = (User) session.getAttribute("user");
if(user != null) {
int userId = user.getId();
//获取当前用户全部购买信息
List<UserShoppingRecord> records = shoppingRecordService.getShoppingRecordsByUserId(userId);
System.out.println("交易记录数:"+records.size());
for(UserShoppingRecord record:records) {
System.out.println("内容ID:"+record.getContentid()+"购买数量:"+ record.getBuynum());
int contentId = record.getContentid();
//查询内容信息
Contents content = contentService.getContentById(contentId);
Product product = productService.AssignProductAttr(content, true, true,
record.getBuynum(), record.getBuyprice(), record.getBuytime());
buyList.add(product);
}
}
map.addAttribute("buyList", buyList);
return map;
}
/**
* 用户购物车
* @return
*/
@RequestMapping("/settleAccount")
public String settleAccount(HttpSession session,Model map) {
//用户类型获取
User user = (User) session.getAttribute("user");
Integer type;
if(user == null) {
return "redirect:login";
}else {
map.addAttribute("user", user);
}
return "settleAccount";
}
}
| [
"[email protected]"
] |
Subsets and Splits