text
stringlengths 10
2.72M
|
|---|
package creature.intelligence.output;
import creature.intelligence.brain.Brain;
import creature.intelligence.brain.Node;
/**
* Created by Michael on 01.06.2017.
*/
public class Decisions {
/**
* A static method to get a walk direction from a Brain.
*/
public static int[] decideWalkDirection(Brain brain) {
int[] direction = new int[2];
direction[0] = 0;
direction[1] = 0;
if (brain != null) {
int dir = 0;
int width = brain.getWidth();
int length = brain.getLength();
double velocity = 0,angle = 0;
if (brain.getNode(length-1,0) != null) {
velocity = brain.getNode(length-1,0).getExcitement();
}
if (brain.getNode(length-1,1) != null) {
angle = brain.getNode(length-1,1).getExcitement();
}
angle = angle*2d*Math.PI/100d;
direction[0] = (int) (Math.cos(angle)*velocity/30d);
direction[1] = (int) (Math.sin(angle)*velocity/30d);
}
return direction;
}
}
|
package tp.tbert12.cola;
import org.junit.Test;
import static org.junit.Assert.*;
public class ColaTest {
@Test
public void crearColaVacia() {
Cola laCola = new Cola();
assertEquals(laCola.size(),0);
assertTrue(laCola.isEmpty());
}
@Test
public void colaConUnElemento() {
Cola<Integer> laCola = new Cola<>();
laCola.add(1994);
assertEquals(laCola.size(),1);
assertEquals(laCola.top(),(Integer) 1994);
assertFalse(laCola.isEmpty());
}
@Test
public void colaAgregoYEliminoUnElemento() {
Cola<String> laCola = new Cola<>();
laCola.add("Tomas");
assertEquals("Tomas",laCola.top());
laCola.remove();
assertTrue(laCola.isEmpty());
assertEquals(laCola.size(),0);
}
@Test
public void pruebaDeVolumen() {
Cola<Integer> laCola = new Cola<>();
for (Integer i = 0; i <= 167; i++) {
laCola.add(i);
}
assertFalse(laCola.isEmpty());
for (Integer i = 0; i <= 167; i++) {
assertEquals(laCola.top(),i);
assertEquals(168 - i,laCola.size());
laCola.remove();
}
assertTrue(laCola.isEmpty());
}
}
|
package com.neuedu.classwork;
import java.io.Serializable;
public class MyBook implements Serializable {
//成员name(书名String)、price(价格 double)、press(出版社String)、author(作者 String)、bookISBN(书的ISBN号String)
private String name;
private double price;
private String press;
private String author;
private String bookISBN;
public String getName() {
return name;
}
public MyBook(String name, Double price, String press, String author, String bookISBN) {
super();
this.name = name;
this.price = price;
this.press = press;
this.author = author;
this.bookISBN = bookISBN;
}
@Override
public String toString() {
return "MyBooks{" +
"书名:'" + name + '\'' +
", 价格:" + price +
", 出版商:'" + press + '\'' +
", 作者'" + author + '\'' +
", 书号'" + bookISBN + '\'' +
'}';
}
}
|
package com.oddle.app.weather.models.open_weather;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class MainData {
private float temperature;
private float feelsLike;
private int pressure;
private short humidity;
private float minTemperature;
private float maxTemperature;
private int seaLevelPressure;
private int groundLevelPressure;
@JsonProperty("temperature")
public float getTemperature() {
return temperature;
}
@JsonProperty("temp")
public void setTemperature(float temperature) {
this.temperature = temperature;
}
@JsonProperty("feelsLike")
public float getFeelsLike() {
return feelsLike;
}
@JsonProperty("feels_like")
public void setFeelsLike(float feelsLike) {
this.feelsLike = feelsLike;
}
public int getPressure() {
return pressure;
}
public void setPressure(int pressure) {
this.pressure = pressure;
}
public short getHumidity() {
return humidity;
}
public void setHumidity(short humidity) {
this.humidity = humidity;
}
@JsonProperty("minTemperature")
public float getMinTemperature() {
return minTemperature;
}
@JsonProperty("temp_min")
public void setMinTemperature(float minTemperature) {
this.minTemperature = minTemperature;
}
@JsonProperty("maxTemperature")
public float getMaxTemperature() {
return maxTemperature;
}
@JsonProperty("temp_max")
public void setMaxTemperature(float maxTemperature) {
this.maxTemperature = maxTemperature;
}
@JsonProperty("seaLevelPressure")
public int getSeaLevelPressure() {
return seaLevelPressure;
}
@JsonProperty("sea_level")
public void setSeaLevelPressure(int seaLevelPressure) {
this.seaLevelPressure = seaLevelPressure;
}
@JsonProperty("groundLevelPressure")
public int getGroundLevelPressure() {
return groundLevelPressure;
}
@JsonProperty("grnd_level")
public void setGroundLevelPressure(int groundLevelPressure) {
this.groundLevelPressure = groundLevelPressure;
}
}
|
package View;
import java.util.ArrayList;
import Listeners.ViewListenable;
import javafx.event.ActionEvent;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class GameView {
private ArrayList<ViewListenable> allListeners;
private ArrayList<TextField> tf1;
private ArrayList<TextField> tf2;
private ArrayList<Integer> score1;
private ArrayList<Integer> score2;
private Stage stage;
private Scene scene;
private GridPane gppane;
private Label lblGameType;
private Label name1;
private Label name2;
private HBox hbTF1;
private HBox hbTF2;
private Button btnDone;
private Button bTemp;
public GameView(Button b, String participantName1, String participantName2, String gameType) {
allListeners = new ArrayList<ViewListenable>();
bTemp = b;
stage = new Stage();
gppane = new GridPane();
gppane.setAlignment(Pos.CENTER);
gppane.setPrefHeight(500);
gppane.setPrefWidth(400);
createRowsAndColums();
createTextField(gameType);
GridPane gpCenter = new GridPane();
ColumnConstraints c1 = new ColumnConstraints();
c1.setPercentWidth(100);
c1.setHgrow(Priority.SOMETIMES);
gpCenter.getColumnConstraints().add(c1);
RowConstraints r1 = new RowConstraints();
r1.setPercentHeight(50);
r1.setVgrow(Priority.SOMETIMES);
gpCenter.getRowConstraints().add(r1);
RowConstraints r2 = new RowConstraints();
r2.setPercentHeight(50);
r2.setVgrow(Priority.SOMETIMES);
gpCenter.getRowConstraints().add(r2);
hbTF1 = new HBox(10);
name1 = new Label(participantName1);
name1.setMaxWidth(50);
name1.setPrefWidth(50);
hbTF1.getChildren().add(name1);
hbTF1.getChildren().addAll(tf1);
gpCenter.add(hbTF1, 0, 0, 2, 1);
hbTF2 = new HBox(10);
name2 = new Label(participantName2);
name2.setMaxWidth(50);
name2.setPrefWidth(50);
hbTF2.getChildren().add(name2);
hbTF2.getChildren().addAll(tf2);
gpCenter.add(hbTF2, 0, 1, 2, 1);
gppane.add(gpCenter, 0, 1, 2, 1);
btnDone = new Button("Done!");
gppane.add(btnDone, 0, 2, 2, 1);
GridPane.setHalignment(btnDone, HPos.CENTER);
lblGameType = new Label(gameType);
lblGameType.setFont(new Font(40));
lblGameType.setTextFill(Color.RED);
gppane.add(lblGameType, 0, 0, 2, 1);
GridPane.setHalignment(lblGameType, HPos.CENTER);
btnDone.setOnAction(e -> sendScoresEventHandler(e));
scene = new Scene(gppane, 500, 400);
stage.setScene(scene);
stage.setTitle("New Game");
stage.show();
}
private void sendScoresEventHandler(ActionEvent e) {
score1 = new ArrayList<Integer>();
score2 = new ArrayList<Integer>();
for (int i = 0; i < tf1.size(); i++) {
score1.add(Integer.parseInt(tf1.get(i).getText()));
score2.add(Integer.parseInt(tf2.get(i).getText()));
}
allListeners.get(0).viewGameSendsScoresToGetWinner();
}
private void createTextField(String gameType) {
if (gameType.equals("Tennis")) {
makeTextFieldForGame(5);
tf1.get(3).setEditable(false);
tf1.get(3).setText("0");
tf1.get(4).setEditable(false);
tf1.get(4).setText("0");
tf2.get(3).setEditable(false);
tf2.get(3).setText("0");
tf2.get(4).setEditable(false);
tf2.get(4).setText("0");
}
if (gameType.equals("BasketBall")) {
makeTextFieldForGame(4);
}
if (gameType.equals("Soccer")) {
makeTextFieldForGame(4);
tf1.get(2).setEditable(false);
tf1.get(2).setText("0");
tf2.get(2).setEditable(false);
tf2.get(2).setText("0");
tf1.get(3).setEditable(false);
tf1.get(3).setText("0");
tf2.get(3).setEditable(false);
tf2.get(3).setText("0");
}
}
private void makeTextFieldForGame(int size) {
tf1 = new ArrayList<TextField>();
tf2 = new ArrayList<TextField>();
for (int i = 0; i < size; i++) {
TextField tf = new TextField();
tf.setMaxWidth(30);
tf.setPrefWidth(30);
tf1.add(tf);
}
for (int i = 0; i < size; i++) {
TextField tf = new TextField();
tf.setMaxWidth(30);
tf.setPrefWidth(30);
tf2.add(tf);
}
}
public void unGreyTextFields() {
tf1.get(4).setEditable(true);
tf1.get(3).setEditable(true);
tf2.get(4).setEditable(true);
tf2.get(3).setEditable(true);
Alert errorAlert = new Alert(AlertType.ERROR);
errorAlert.setHeaderText("Still no Winner");
errorAlert.setContentText("Now lets add 2 more");
errorAlert.showAndWait();
}
public void shownoWinnerEnterAgainError() {
Alert errorAlert = new Alert(AlertType.ERROR);
errorAlert.setHeaderText("No Winner");
errorAlert.setContentText("There is no Winner\nTry Again!");
errorAlert.showAndWait();
}
private void createRowsAndColums() {
for (int i = 0; i < 2; i++) {
ColumnConstraints c = new ColumnConstraints();
c.setPercentWidth(25);
c.setHgrow(Priority.SOMETIMES);
gppane.getColumnConstraints().add(c);
}
for (int i = 0; i < 3; i++) {
RowConstraints r = new RowConstraints();
r.setPercentHeight(33);
r.setVgrow(Priority.SOMETIMES);
gppane.getRowConstraints().add(r);
}
}
public void addMoreTextFieldsSoccer() {
if (tf1.get(2).isEditable()) {
tf1.get(3).setEditable(true);
tf2.get(3).setEditable(true);
showUpdateNeedPenaltiesSoccer();
} else {
tf1.get(2).setEditable(true);
tf2.get(2).setEditable(true);
showUpdateNeedMoreRound();
}
}
private void showUpdateNeedPenaltiesSoccer() {
Alert errorAlert = new Alert(AlertType.INFORMATION);
errorAlert.setHeaderText("Soccer Penalties Round");
errorAlert.setContentText("its Still Even. Now Enter Penalties!");
errorAlert.showAndWait();
}
private void showUpdateNeedMoreRound() {
Alert errorAlert = new Alert(AlertType.INFORMATION);
errorAlert.setHeaderText("Soccer Third Round");
errorAlert.setContentText("its Even. Now Enter Another Round!");
errorAlert.showAndWait();
}
public void close() {
stage.close();
}
public void registerListener(ViewListenable lvGame) {
allListeners.add(lvGame);
}
public String getName1() {
return name1.getText();
}
public String getName2() {
return name2.getText();
}
public ArrayList<TextField> getTf1() {
return tf1;
}
public ArrayList<TextField> getTf2() {
return tf2;
}
public ArrayList<Integer> getScore1() {
return score1;
}
public ArrayList<Integer> getScore2() {
return score2;
}
public Button getbTemp() {
return bTemp;
}
}
|
package com.jcotes.kmeans.cluster;
import com.jcotes.kmeans.data_obj.Cluster;
import com.jcotes.kmeans.data_obj.Record;
import com.jcotes.kmeans.file_tools.fileIO;
import java.util.ArrayList;
import java.util.Random;
/**
* KMeans uses KMeans++ to initialize clusters and Lloyd algorithm to cluster
* the data.
*
* @author Josh Cotes
* @version Homework 4
*/
public class KMeans {
private ArrayList<Cluster> _clusters;
private ArrayList<Record<Double>> _recordSet;
private int _nClusters_K;
private int _runs = 0;
public KMeans(ArrayList<Record<Double>> records, int nClusters) {
_recordSet = records;
_nClusters_K = nClusters;
}
public KMeans(String fileName, int nClusters) {
_recordSet = fileIO.loadDataSet(fileName);
_nClusters_K = nClusters;
}
/**
* Calculate sum of squared errors
*
* @return - The SSE
*/
private double calculateSSE() {
double sse = 0.0d;
for (Cluster cluster : _clusters)
sse += cluster.getSSE();
return sse;
}
/**
* Sets first clusters using KPP algorithm
*/
private void initializeKPP() {
ArrayList<Record<Double>> _recordsClone = (ArrayList<Record<Double>>) _recordSet.clone();
Random rand = new Random();
_clusters = new ArrayList<>();
Cluster cluster = new Cluster();
cluster.addRecord(_recordsClone.remove(Math.abs(rand.nextInt() % _recordsClone.size())));
_clusters.add(cluster);
int i = 0;
for (; i < _nClusters_K; i++) {
double sum = 0.0d;
double[] distances = new double[_recordsClone.size()];
for (int d = 0; d < _recordsClone.size(); d++) {
Cluster closestC = nearestClusterCenter(_recordsClone.get(d));
distances[d] = closestC.distanceToCentroid(_recordsClone.get(d));
sum += distances[d];
}
sum *= rand.nextDouble();
for (int c = 0; c < distances.length; c++) {
sum -= distances[c];
if (sum > 0) {
_recordsClone.get(c).setClusterIndex(i);
_clusters.add(new Cluster(_recordsClone.remove(c)));
break;
}
}
}
while (_recordsClone.size() > 0) {
addRecordToClosestCluster(_recordsClone.remove(0));
}
}
/**
* Getter for the member variable _recordSet
*
* @return - the record set
*/
public ArrayList<Record<Double>> getRecords() {
return _recordSet;
}
private Cluster nearestClusterCenter(Record<Double> record) {
Cluster closest = _clusters.get(0);
for (Cluster cluster : _clusters) {
if (cluster.distanceToCentroid(record) < closest.distanceToCentroid(record))
closest = cluster;
}
return closest;
}
/**
* Adds the given record to the cluster with the closest centroid, removing
* the record from its cluster of origin.
*
* @param record - the object record
*/
private void addRecordToClosestCluster(Record<Double> record) {
Cluster closestCluster = _clusters.get(0);
int closestClusterIndex = 0;
for (int i = 0; i < _clusters.size(); i++) {
if (_clusters.get(i).distanceToCentroid(record) < closestCluster.distanceToCentroid(record)) {
closestCluster = _clusters.get(i);
closestClusterIndex = i;
}
}
record.setClusterIndex(closestClusterIndex);
closestCluster.addRecord(record);
}
/**
* Removes the Record[recordNumber] from the cluster and assigns it to
* the cluster with the closest centroid.
* @param cluster - cluster currently holding the record
* @param recordNumber - record number
*/
private void addRecordToClosestCluster(Cluster cluster, int recordNumber) {
Cluster closestCluster = cluster;
Record<Double> objectRecord = closestCluster.getRecords().get(recordNumber);
int closestClusterIndex = _clusters.indexOf(cluster);
for (int i = 0; i < _clusters.size(); i++) {
// if cluster(i) centroid is closer than currently assigned centroid
if (_clusters.get(i).distanceToCentroid(objectRecord) < closestCluster.distanceToCentroid(objectRecord)) {
closestCluster = _clusters.get(i);
closestClusterIndex = i;
}
}
// only move the record if it is assigned to a new cluster
if (!closestCluster.equals(cluster)) {
cluster.getRecords().get(recordNumber).setClusterIndex(closestClusterIndex);
closestCluster.addRecord(cluster.getRecords().remove(recordNumber));
}
}
/**
* Executes the Lloyd kmeans algorith.
* @param maxIterations - maximum iterations (convergence breaks)
* @return - the final clusters
*/
public ArrayList<Cluster> doKMeans(int maxIterations) {
_runs++;
int i = 0;
double lastSSE = 0.0;
System.out.println("Assigning random clusters...");
initializeKPP();
System.out.println("Reassigning records to clusters to " + maxIterations + " max iterations or convergence...");
while (i++ < maxIterations && lastSSE != calculateSSE()) {
lastSSE = calculateSSE();
for (Cluster cluster : _clusters) {
for (int j = 0; j < cluster.getRecords().size(); j++) {
addRecordToClosestCluster(cluster, j);
}
cluster.setCentroid();
}
}
System.out.println("KMeans complete, total iterations: " + i);
// check for local optimum and adjust accordingly
for (Cluster cluster : _clusters) {
if (cluster.getRecords().size() < _recordSet.size() * .015) {
System.out.println("\nLocal optimum cluster, re-running kmeans...\n");
if (_runs <= 10) {
doKMeans(maxIterations);
break;
} else
System.out.println("\nMaximum runs reached\n");
}
}
return _clusters;
}
}
|
package com.example.pavlion.quizit;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.Toast;
import java.lang.CharSequence;
public class MainActivity extends AppCompatActivity {
private static final String LOG_TAG = MainActivity.class.getSimpleName();
// Question 1
RadioButton question1_choice2;
// Question 2
RadioButton question2_choice3;
// Question 3
CheckBox question3_choice1;
CheckBox question3_choice2;
CheckBox question3_choice3;
CheckBox question3_choice4;
// Question 4
CheckBox question4_choice1;
CheckBox question4_choice2;
CheckBox question4_choice3;
CheckBox question4_choice4;
// Question 5
RadioButton question5_choice2;
// Question 6
RadioButton question6_choice2;
// Question 7
CheckBox question7_choice1;
CheckBox question7_choice2;
CheckBox question7_choice3;
CheckBox question7_choice4;
// Question 8
CheckBox question8_choice1;
CheckBox question8_choice2;
CheckBox question8_choice3;
CheckBox question8_choice4;
// Question 9
RadioButton question9_choice3;
// Question 10
RadioButton question10_choice1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void submitAnswers(View view) {
CharSequence resultsDisplay;
Log.e(LOG_TAG, " " + this.findViewById(R.id.question3_choice3));
int answer1_score;
int answer2_score;
int answer3_score;
int answer4_score;
int answer5_score;
int answer6_score;
int answer7_score;
int answer8_score;
int answer9_score;
int answer10_score;
int final_score;
//------------------------------------------------------------------------------------------
// Question 1 - Correct Answer is #2 (Portugal)
//------------------------------------------------------------------------------------------
Boolean answer1;
question1_choice2 = (RadioButton) this.findViewById(R.id.question1_choice2);
answer1 = question1_choice2.isChecked();
if (answer1) {
answer1_score = 1;
} else {
answer1_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 2 - Correct Answer is #3 (Russia)
//------------------------------------------------------------------------------------------
Boolean answer2;
question2_choice3 = (RadioButton) this.findViewById(R.id.question2_choice3);
answer2= question2_choice3.isChecked();
if (answer2) {
answer2_score = 1;
} else {
answer2_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 3 - Correct Answers are #1 (Larry Page) and #3 (Sergey Brin)
//------------------------------------------------------------------------------------------
Boolean answer3_choice1;
Boolean answer3_choice2;
Boolean answer3_choice3;
Boolean answer3_choice4;
question3_choice1 = (CheckBox) this.findViewById(R.id.question3_choice1);
question3_choice2 = (CheckBox) this.findViewById(R.id.question3_choice2);
question3_choice3 = (CheckBox) this.findViewById(R.id.question3_choice3);
question3_choice4 = (CheckBox) this.findViewById(R.id.question3_choice4);
answer3_choice1 = question3_choice1.isChecked();
answer3_choice2 = question3_choice2.isChecked();
answer3_choice3 = question3_choice3.isChecked();
answer3_choice4 = question3_choice4.isChecked();
if (answer3_choice1 && !answer3_choice2 && answer3_choice3 && !answer3_choice4) {
answer3_score = 1;
} else {
answer3_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 4 - Correct Answers are #2 (Ryan Gosling) and #3 (Leonardo di Caprio)
//------------------------------------------------------------------------------------------
Boolean answer4_choice1;
Boolean answer4_choice2;
Boolean answer4_choice3;
Boolean answer4_choice4;
question4_choice1 = (CheckBox) this.findViewById(R.id.question4_choice1);
question4_choice2 = (CheckBox) this.findViewById(R.id.question4_choice2);
question4_choice3 = (CheckBox) this.findViewById(R.id.question4_choice3);
question4_choice4 = (CheckBox) this.findViewById(R.id.question4_choice4);
answer4_choice1 = question4_choice1.isChecked();
answer4_choice2 = question4_choice2.isChecked();
answer4_choice3 = question4_choice3.isChecked();
answer4_choice4 = question4_choice4.isChecked();
if (!answer4_choice1 && answer4_choice2 && answer4_choice3 && !answer4_choice4) {
answer4_score = 1;
} else {
answer4_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 5 - Correct Answers is #2 (Peru)
//------------------------------------------------------------------------------------------
Boolean answer5;
question5_choice2 = (RadioButton) this.findViewById(R.id.question5_choice2);
answer5 = question5_choice2.isChecked();
if (answer5) {
answer5_score = 1;
} else {
answer5_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 6 - Correct Answer is #2 (Japan)
//------------------------------------------------------------------------------------------
Boolean answer6;
question6_choice2 = (RadioButton) this.findViewById(R.id.question6_choice2);
answer6 = question6_choice2.isChecked();
if (answer6) {
answer6_score = 1;
} else {
answer6_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 7 - Correct Answers are #3 (Earth) and #4 (Pluto)
//------------------------------------------------------------------------------------------
Boolean answer7_choice1;
Boolean answer7_choice2;
Boolean answer7_choice3;
Boolean answer7_choice4;
question7_choice1 = (CheckBox) this.findViewById(R.id.question7_choice1);
question7_choice2 = (CheckBox) this.findViewById(R.id.question7_choice2);
question7_choice3 = (CheckBox) this.findViewById(R.id.question7_choice3);
question7_choice4 = (CheckBox) this.findViewById(R.id.question7_choice4);
answer7_choice1 = question7_choice1.isChecked();
answer7_choice2 = question7_choice2.isChecked();
answer7_choice3 = question7_choice3.isChecked();
answer7_choice4 = question7_choice4.isChecked();
if (!answer7_choice1 && !answer7_choice2 && answer7_choice3 && answer7_choice4) {
answer7_score = 1;
} else {
answer7_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 8 - Correct Answers are #1 (Hamlet) and #4 (As you Like It)
//------------------------------------------------------------------------------------------
Boolean answer8_choice1;
Boolean answer8_choice2;
Boolean answer8_choice3;
Boolean answer8_choice4;
question8_choice1 = (CheckBox) this.findViewById(R.id.question8_choice1);
question8_choice2 = (CheckBox) this.findViewById(R.id.question8_choice2);
question8_choice3 = (CheckBox) this.findViewById(R.id.question8_choice3);
question8_choice4 = (CheckBox) this.findViewById(R.id.question8_choice4);
answer8_choice1 = question8_choice1.isChecked();
answer8_choice2 = question8_choice2.isChecked();
answer8_choice3 = question8_choice3.isChecked();
answer8_choice4 = question8_choice4.isChecked();
if (answer8_choice1 && !answer8_choice2 && !answer8_choice3 && answer8_choice4) {
answer8_score = 1;
} else {
answer8_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 9 - Correct Answers is #3 (Rafael Nadal)
//------------------------------------------------------------------------------------------
Boolean answer9;
question9_choice3 = (RadioButton) this.findViewById(R.id.question9_choice3);
answer9 = question9_choice3.isChecked();
if (answer9) {
answer9_score = 1;
} else {
answer9_score = 0;
}
//------------------------------------------------------------------------------------------
// Question 10 - Correct Answer is #1 (Gay Lussac)
//------------------------------------------------------------------------------------------
Boolean answer10;
question10_choice1 = (RadioButton) this.findViewById(R.id.question10_choice1);
answer10 = question10_choice1.isChecked();
if (answer10) {
answer10_score = 1;
} else {
answer10_score = 0;
}
//------------------------------------------------------------------------------------------
// Final Score
//------------------------------------------------------------------------------------------
final_score = answer1_score + answer2_score + answer3_score + answer4_score + answer5_score +
answer6_score + answer7_score + answer8_score + answer9_score + answer10_score;
if (final_score == 10) {
resultsDisplay = "Perfect! You scored 10 out of 10";
} else {
resultsDisplay = "Try again. You scored " + final_score + " out of 10";
}
Context context = getApplicationContext();
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, resultsDisplay, duration);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
public void finishQuiz(View view){
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
}
|
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Administrator on 2018/11/29.
*/
@Controller
public class FtlIndexController {
@RequestMapping("/ftlIndex")
public String ftlIndex(){
int i = 1/0;
System.out.println("sdsdsd");
return "index.ftl";
}
@RequestMapping("/test")
public String test(){
return "index";
}
}
|
package com.tencent.mm.plugin.mall.ui;
import android.content.Context;
import com.tencent.mm.plugin.wallet_core.ui.q.b;
class MallIndexUI$6 implements b {
final /* synthetic */ MallIndexUI lab;
MallIndexUI$6(MallIndexUI mallIndexUI) {
this.lab = mallIndexUI;
}
public final int bce() {
return 3;
}
public final Context getContext() {
return this.lab;
}
}
|
package com.guilhermefgl.spring.crudproduto.models.repositories;
import java.util.List;
import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import com.guilhermefgl.spring.crudproduto.models.Imagem;
import com.guilhermefgl.spring.crudproduto.models.Produto;
@Transactional(readOnly = true)
@NamedQueries({
@NamedQuery(name = "ImagemRepository.findByProduto",
query = "SELECT img FROM Imagem img WHERE img.produto = :produto") })
public interface ImagemRepository extends JpaRepository<Imagem, Integer> {
Imagem findByIdImagem(Integer idImagem);
List<Imagem> findAll();
List<Imagem> findByProduto(@Param("produto") Produto produto);
}
|
package de.madjosz.adventofcode.y2020;
import static org.junit.jupiter.api.Assertions.assertEquals;
import de.madjosz.adventofcode.AdventOfCodeUtil;
import java.util.List;
import org.junit.jupiter.api.Test;
class Day03Test {
@Test
void day03() {
List<String> lines = AdventOfCodeUtil.readLines(2020, 3);
Day03 day03 = new Day03(lines);
assertEquals(252, day03.a1());
assertEquals(2608962048L, day03.a2());
}
@Test
void day03_exampleInput() {
List<String> lines = AdventOfCodeUtil.readLines(2020, 3, "test");
Day03 day03 = new Day03(lines);
assertEquals(7, day03.a1());
assertEquals(336L, day03.a2());
}
}
|
package Kodluyoruz_HomeWork_AbdAlrahimZakaria.Week2_Homework;
import java.util.Scanner;
public class UniversityGradesCalculator {
/*
* This function calculates and prints the letter grade of given grades
* @author Abd Alrahim Zakaria - 05.07.2021
*/
public static void main(String[] args) {
System.out.println("Welcome to the University Letter Calculator! \nPlease enter your midterm and final grades");
System.out.println("Your letter grade is: "+LetterGrade());
}
public static double GradeCalculator(double midTerm, double finals) {
return (int) Math.round(midTerm*40/100 + finals*60/100);
}
public static String LetterGrade() {
Scanner scanner = new Scanner(System.in);
int grade = (int) GradeCalculator(scanner.nextDouble(), scanner.nextDouble());
if (grade >= 0 && grade < 20) {
System.out.println(grade);
return "FF" ;
}
else if (grade >= 20 && grade < 50)
return "CB";
else if (grade >= 50 && grade < 70)
return "BB";
else if (grade >= 70 && grade <= 100)
return "AA";
else
return "Grade isn't valid!";
}
}
|
package com.fit2cloud.netty.config;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@MapperScan(basePackages = "com.fit2cloud.netty.dao", sqlSessionFactoryRef = "sqlSessionFactory")
@EnableTransactionManagement
public class BasicDataSourceConfig {
}
|
package com.service.impl;
import com.bean.ArrangementInfo;
import com.mapper.ArrangementInfoMapper;
import com.service.ArrangementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("ArrangementInfoService")
public class ArrangementInfoServiceImpl implements ArrangementInfoService {
@Autowired
ArrangementInfoMapper arrangementInfoMapper;
public List<ArrangementInfo> getArrangementInfo(ArrangementInfo arrangementInfo){
return arrangementInfoMapper.getArrangementInfo(arrangementInfo);
}
}
|
package io.malibu.malibu.Models;
import com.google.gson.annotations.SerializedName;
/**
* Created by Tier on 31.10.14.
*/
public class Tag {
@SerializedName("tagid")
public Long id;
private String name;
public Tag(Long id, String name) {
this.id = id;
this.name = name;
}
public String getName() {
return String.format("#%s", name);
}
}
|
package com.medic.quotesbook.services;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import com.medic.quotesbook.R;
import com.medic.quotesbook.models.Quote;
import com.medic.quotesbook.receivers.QuoteTimeReceiver;
import com.medic.quotesbook.utils.QuoteNetwork;
import com.medic.quotesbook.utils.TodayQuoteManager;
import com.medic.quotesbook.views.activities.QuoteActivity;
import java.io.IOException;
import java.net.URL;
/**
* Created by capi on 27/05/15.
*
* Servicio que prepara la cita del día para ser notificada al usuario.
*/
public class PrepareDaysQuoteService extends IntentService {
private final String TAG = "PrepareDaysQuoteService";
/**
* Creates an IntentService. Invoked by your subclass's constructor.
*
*/
public PrepareDaysQuoteService() {
super("PrepareDaysQuoteService");
}
@Override
protected void onHandleIntent(Intent intent) {
//QuoteTimeReceiver.setQuoteTimeAlarm(this.getBaseContext());
TodayQuoteManager quotesManager = new TodayQuoteManager(this.getBaseContext());
Quote quote = quotesManager.getNextQuote();
if (quote != null)
giveQuote(quote, this.getBaseContext());
}
private Bitmap getAuthorImage(String imageUrl){
Bitmap image = null;
try {
URL url = new URL(imageUrl);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
private void giveQuote(Quote quote, Context ctx){
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
String notificationTitle = getBaseContext().getResources().getString(R.string.nt_todaysquote_title);
String notificationContent = getBaseContext().getResources().getString(R.string.nt_todaysquote_subtitle);
builder.setContentText(notificationContent + " " + quote.getAuthor().getFullName())
.setContentTitle(notificationTitle)
.setSmallIcon(R.drawable.ic_notification)
.setAutoCancel(true);
if (quote.getAuthor() != null){
Bitmap authorImage = getAuthorImage(QuoteNetwork.getRootURLByLocaleLanguage() + quote.getAuthor().getPictureUrl());
builder.setLargeIcon(authorImage);
}
Intent intent = new Intent(ctx, QuoteActivity.class);
intent.putExtra(QuoteActivity.QUOTE_KEY, quote);
intent.putExtra(QuoteActivity.DAYQUOTE_KEY, true);
intent.setAction(quote.getKey()); // Dummuy action for force update current activity
/*
TaskStackBuilder stackBuilder = TaskStackBuilder.create(ctx);
stackBuilder.addParentStack(BaseActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
*/
// https://stackoverflow.com/questions/3168484/pendingintent-works-correctly-for-the-first-notification-but-incorrectly-for-the
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone ringtone = RingtoneManager.getRingtone(getBaseContext(), notification);
NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(5, builder.build());
ringtone.play();
}
}
|
package com.issp.ispp.repository;
import com.issp.ispp.entity.DatosAdicionalesUsuario;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface DatosAdicionalesRepository extends CrudRepository<DatosAdicionalesUsuario,Long> {
}
|
public class TampilPersegi extends Persegi {
public static void main(String[] args) {
Persegi p1 = new Persegi();
p1.sisi = 10;
p1.tampilSisiPanjang();
System.out.println("Luas persegi : " + p1.hitungLuas());
System.out.println("Keliling persegi : " + p1.hitungKeliling());
}
}
|
package com.tencent.mm.plugin.websearch.api;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.text.TextUtils;
import com.tencent.map.geolocation.internal.TencentExtraKeys;
import com.tencent.mm.a.e;
import com.tencent.mm.a.o;
import com.tencent.mm.bg.d;
import com.tencent.mm.g.a.ly;
import com.tencent.mm.kernel.a;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.protocal.GeneralControlWrapper;
import com.tencent.mm.protocal.JsapiPermissionWrapper;
import com.tencent.mm.protocal.c.aqs;
import com.tencent.mm.sdk.platformtools.ad;
import com.tencent.mm.sdk.platformtools.ao;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import com.tencent.mm.storage.aa;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.json.JSONObject;
public final class p {
private static Map<Integer, ae> pLp = new HashMap();
private static Map<Integer, g> pLq = new HashMap();
public static Properties A(File file) {
Throwable e;
Properties properties = new Properties();
if (file != null && file.isFile()) {
InputStream fileInputStream;
try {
fileInputStream = new FileInputStream(file);
try {
properties.load(fileInputStream);
e.f(fileInputStream);
} catch (Exception e2) {
e = e2;
try {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e, "", new Object[0]);
e.f(fileInputStream);
return properties;
} catch (Throwable th) {
e = th;
e.f(fileInputStream);
throw e;
}
}
} catch (Exception e3) {
e = e3;
fileInputStream = null;
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e, "", new Object[0]);
e.f(fileInputStream);
return properties;
} catch (Throwable th2) {
e = th2;
fileInputStream = null;
e.f(fileInputStream);
throw e;
}
}
return properties;
}
public static final String zK(int i) {
StringBuilder append = new StringBuilder().append(i).append("_");
g.Eg();
return append.append(o.getString(a.Df())).append("_").append(System.currentTimeMillis()).toString();
}
static {
pLp.put(Integer.valueOf(1), new ae("fts_browse/res", "wrd_template.zip", "browse"));
pLp.put(Integer.valueOf(0), new ae("fts/res", "fts_template.zip", ""));
Map map = pLq;
Integer valueOf = Integer.valueOf(0);
zM(0);
map.put(valueOf, v.bTa());
map = pLq;
valueOf = Integer.valueOf(1);
zM(1);
map.put(valueOf, v.bTa());
}
public static ae zL(int i) {
return (ae) pLp.get(Integer.valueOf(i));
}
private static String zM(int i) {
return ((ae) pLp.get(Integer.valueOf(i))).adP() + File.separator + "app.html";
}
public static String bSL() {
pLp.get(Integer.valueOf(1));
return "app.html";
}
public static String bSM() {
pLp.get(Integer.valueOf(1));
return "config.conf";
}
public static void bSN() {
Iterator it = pLq.values().iterator();
while (it.hasNext()) {
it.next();
}
}
public static int zN(int i) {
ae aeVar = (ae) pLp.get(Integer.valueOf(i));
String str = TextUtils.isEmpty(aeVar.pMx) ? "config.conf" : aeVar.pMx + File.separator + "config.conf";
AssetManager assets = ad.getContext().getAssets();
Properties properties = new Properties();
InputStream inputStream = null;
try {
inputStream = assets.open(str);
properties.load(inputStream);
} catch (Throwable e) {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e, e.getMessage(), new Object[0]);
} finally {
e.f(inputStream);
}
return Integer.valueOf(properties.getProperty("version", "1")).intValue();
}
public static boolean zO(int i) {
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "isFTSH5TemplateAvail exportType:%d, use search default.", new Object[]{Integer.valueOf(i)});
return ((ae) pLp.get(Integer.valueOf(i))).Oe() > 1;
}
public static int zP(int i) {
return ((ae) pLp.get(Integer.valueOf(i))).Oe();
}
public static boolean zQ(int i) {
OutputStream outputStream = null;
AssetManager assets = ad.getContext().getAssets();
String bTp = ((ae) pLp.get(Integer.valueOf(i))).bTp();
ae aeVar = (ae) pLp.get(Integer.valueOf(i));
String str = TextUtils.isEmpty(aeVar.pMx) ? aeVar.pMw : aeVar.pMx + File.separator + aeVar.pMw;
if (bi.oW(bTp) || bi.oW(str)) {
x.w("MicroMsg.WebSearch.WebSearchApiLogic", "copyTemplateFromAsset no dstPath or template path!");
return false;
}
InputStream open;
try {
open = assets.open(str);
} catch (Throwable e) {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e, "", new Object[0]);
open = null;
}
if (open == null) {
x.e("MicroMsg.WebSearch.WebSearchApiLogic", "file inputStream not found");
return false;
}
File file = new File(bTp);
if (file.exists()) {
file.delete();
}
file.getParentFile().mkdirs();
try {
outputStream = new FileOutputStream(file);
} catch (Throwable e2) {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e2, "", new Object[0]);
}
if (outputStream != null) {
try {
e(open, outputStream);
return true;
} catch (Throwable e22) {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e22, "", new Object[0]);
return false;
} finally {
e.f(open);
e.closeOutputStream(outputStream);
}
} else {
e.f(open);
return false;
}
}
private static void e(InputStream inputStream, OutputStream outputStream) {
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
outputStream.write(bArr, 0, read);
} else {
return;
}
}
}
public static String zR(int i) {
return ((ae) pLp.get(Integer.valueOf(i))).bTp();
}
public static int zS(int i) {
return ((ae) pLp.get(Integer.valueOf(i))).bTn();
}
public static String zT(int i) {
return ((ae) pLp.get(Integer.valueOf(i))).adP();
}
public static String zU(int i) {
return ((ae) pLp.get(Integer.valueOf(zX(i)))).adP();
}
public static String zV(int i) {
return ((ae) pLp.get(Integer.valueOf(zX(i)))).pMw;
}
public static int zW(int i) {
return ((ae) pLp.get(Integer.valueOf(zX(i)))).Oe();
}
private static int zX(int i) {
switch (i) {
case 1:
return 0;
case 2:
return 1;
default:
return -1;
}
}
public static String zY(int i) {
return A(new File(((ae) pLp.get(Integer.valueOf(i))).adP(), "config_data.conf")).getProperty("kv_set", "");
}
public static String bjC() {
if (ao.isWifi(ad.getContext())) {
return TencentExtraKeys.LOCATION_SOURCE_WIFI;
}
if (ao.is4G(ad.getContext())) {
return "4g";
}
if (ao.is3G(ad.getContext())) {
return "3g";
}
if (ao.is2G(ad.getContext())) {
return "2g";
}
if (ao.isConnected(ad.getContext())) {
return "";
}
return "fail";
}
public static aqs JU() {
try {
String str = (String) g.Ei().DT().get(67591, null);
if (str != null) {
aqs aqs = new aqs();
String[] split = str.split(",");
aqs.ryV = Integer.valueOf(split[0]).intValue();
aqs.ryY = Integer.valueOf(split[1]).intValue();
aqs.rms = ((float) Integer.valueOf(split[2]).intValue()) / 1000000.0f;
aqs.rmr = ((float) Integer.valueOf(split[3]).intValue()) / 1000000.0f;
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "lbs location is not null, %f, %f", new Object[]{Float.valueOf(aqs.rms), Float.valueOf(aqs.rmr)});
return aqs;
}
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "lbs location is null, lbsContent is null!");
return null;
} catch (Exception e) {
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "lbs location is null, reason %s", new Object[]{e.getMessage()});
return null;
}
}
private static Intent ag(Intent intent) {
if (intent == null) {
return null;
}
intent.putExtra("hardcode_jspermission", JsapiPermissionWrapper.qWa);
intent.putExtra("hardcode_general_ctrl", GeneralControlWrapper.qVX);
intent.putExtra("neverGetA8Key", true);
return intent;
}
public static Intent adR() {
return ag(new Intent());
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public static java.util.Map<java.lang.String, java.lang.String> a(int r10, boolean r11, int r12, java.lang.String r13, java.lang.String r14, java.lang.String r15, java.lang.String r16, java.lang.String r17, java.lang.String r18, java.lang.String r19, java.lang.String r20) {
/*
r4 = new java.util.HashMap;
r4.<init>();
r1 = android.text.TextUtils.isEmpty(r14);
if (r1 != 0) goto L_0x0011;
L_0x000b:
r1 = "searchId";
r4.put(r1, r14);
L_0x0011:
r1 = android.text.TextUtils.isEmpty(r15);
if (r1 != 0) goto L_0x001d;
L_0x0017:
r1 = "sessionId";
r4.put(r1, r15);
L_0x001d:
r1 = android.text.TextUtils.isEmpty(r18);
if (r1 != 0) goto L_0x002b;
L_0x0023:
r1 = "subSessionId";
r0 = r18;
r4.put(r1, r0);
L_0x002b:
r1 = android.text.TextUtils.isEmpty(r16);
if (r1 != 0) goto L_0x0039;
L_0x0031:
r1 = "query";
r0 = r16;
r4.put(r1, r0);
L_0x0039:
r1 = android.text.TextUtils.isEmpty(r17);
if (r1 != 0) goto L_0x0047;
L_0x003f:
r1 = "sceneActionType";
r0 = r17;
r4.put(r1, r0);
L_0x0047:
r1 = android.text.TextUtils.isEmpty(r20);
if (r1 != 0) goto L_0x0055;
L_0x004d:
r1 = "pRequestId";
r0 = r20;
r4.put(r1, r0);
L_0x0055:
r1 = "scene";
r2 = java.lang.String.valueOf(r10);
r4.put(r1, r2);
r1 = "type";
r2 = java.lang.String.valueOf(r12);
r4.put(r1, r2);
r1 = "lang";
r2 = com.tencent.mm.sdk.platformtools.ad.getContext();
r2 = com.tencent.mm.sdk.platformtools.w.fD(r2);
r4.put(r1, r2);
r1 = "platform";
r2 = "android";
r4.put(r1, r2);
r1 = android.text.TextUtils.isEmpty(r19);
if (r1 != 0) goto L_0x008e;
L_0x0086:
r1 = "poiInfo";
r0 = r19;
r4.put(r1, r0);
L_0x008e:
r1 = android.text.TextUtils.isEmpty(r13);
if (r1 != 0) goto L_0x009a;
L_0x0094:
r1 = "extParams";
r4.put(r1, r13);
L_0x009a:
switch(r10) {
case 21: goto L_0x0178;
default: goto L_0x009d;
};
L_0x009d:
r1 = 0;
r1 = zP(r1);
r1 = java.lang.String.valueOf(r1);
L_0x00a6:
r2 = "version";
r4.put(r2, r1);
r1 = 0;
r3 = 0;
r2 = 0;
switch(r10) {
case 3: goto L_0x01f1;
case 6: goto L_0x02cc;
case 9: goto L_0x02cc;
case 11: goto L_0x02df;
case 14: goto L_0x01f1;
case 20: goto L_0x01f1;
case 22: goto L_0x01f1;
case 24: goto L_0x02f2;
case 33: goto L_0x0197;
case 300: goto L_0x0183;
default: goto L_0x00b2;
};
L_0x00b2:
r5 = "MicroMsg.WebSearch.WebSearchApiLogic";
r6 = "genFTSParams scene=%d isHomePage=%b type=%d %b %b %b";
r7 = 6;
r7 = new java.lang.Object[r7];
r8 = 0;
r9 = java.lang.Integer.valueOf(r10);
r7[r8] = r9;
r8 = 1;
r9 = java.lang.Boolean.valueOf(r11);
r7[r8] = r9;
r8 = 2;
r9 = java.lang.Integer.valueOf(r12);
r7[r8] = r9;
r8 = 3;
r9 = java.lang.Boolean.valueOf(r1);
r7[r8] = r9;
r8 = 4;
r9 = java.lang.Boolean.valueOf(r3);
r7[r8] = r9;
r8 = 5;
r9 = java.lang.Boolean.valueOf(r2);
r7[r8] = r9;
com.tencent.mm.sdk.platformtools.x.i(r5, r6, r7);
if (r1 == 0) goto L_0x00f3;
L_0x00ea:
r1 = "isSug";
r5 = "1";
r4.put(r1, r5);
L_0x00f3:
if (r3 == 0) goto L_0x00fe;
L_0x00f5:
r1 = "isLocalSug";
r3 = "1";
r4.put(r1, r3);
L_0x00fe:
if (r2 == 0) goto L_0x0109;
L_0x0100:
r1 = "isMostSearchBiz";
r2 = "1";
r4.put(r1, r2);
L_0x0109:
if (r11 != 0) goto L_0x030b;
L_0x010b:
r1 = "isHomePage";
r2 = "0";
r4.put(r1, r2);
L_0x0114:
r1 = com.tencent.mm.sdk.platformtools.ad.getContext();
r1 = com.tencent.mm.bp.a.fe(r1);
r2 = 1065353216; // 0x3f800000 float:1.0 double:5.263544247E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x0122:
r2 = 1063256064; // 0x3f600000 float:0.875 double:5.25318294E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x0128:
r2 = 1066401792; // 0x3f900000 float:1.125 double:5.2687249E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x012e:
r2 = 1067450368; // 0x3fa00000 float:1.25 double:5.273905555E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x0134:
r2 = 1068498944; // 0x3fb00000 float:1.375 double:5.27908621E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x013a:
r2 = 1070596096; // 0x3fd00000 float:1.625 double:5.289447516E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x0140:
r2 = 1072693248; // 0x3ff00000 float:1.875 double:5.299808824E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x0146:
r2 = 1073846682; // 0x4001999a float:2.025 double:5.305507545E-315;
r2 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
if (r2 == 0) goto L_0x014f;
L_0x014d:
r1 = 1065353216; // 0x3f800000 float:1.0 double:5.263544247E-315;
L_0x014f:
r2 = "fontRatio";
r1 = java.lang.String.valueOf(r1);
r4.put(r2, r1);
r1 = "netType";
r2 = bjC();
r4.put(r1, r2);
r1 = com.tencent.mm.an.b.PY();
if (r1 == 0) goto L_0x0177;
L_0x0169:
r1 = com.tencent.mm.an.b.Qa();
if (r1 == 0) goto L_0x0177;
L_0x016f:
r2 = "musicSnsId";
r1 = r1.rsp;
r4.put(r2, r1);
L_0x0177:
return r4;
L_0x0178:
r1 = 1;
r1 = zP(r1);
r1 = java.lang.String.valueOf(r1);
goto L_0x00a6;
L_0x0183:
r5 = "mixGlobal";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
if (r11 == 0) goto L_0x019a;
L_0x018c:
r6 = "mixSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x0197:
r1 = 1;
goto L_0x00b2;
L_0x019a:
r6 = 1;
if (r12 != r6) goto L_0x01a9;
L_0x019d:
r6 = "bizSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x01a8:
goto L_0x0197;
L_0x01a9:
r6 = 8;
if (r12 != r6) goto L_0x01b9;
L_0x01ad:
r6 = "snsSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x01b8:
goto L_0x0197;
L_0x01b9:
r6 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
if (r12 != r6) goto L_0x01c9;
L_0x01bd:
r6 = "novelSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x01c8:
goto L_0x0197;
L_0x01c9:
r6 = 512; // 0x200 float:7.175E-43 double:2.53E-321;
if (r12 != r6) goto L_0x01d9;
L_0x01cd:
r6 = "musicSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x01d8:
goto L_0x0197;
L_0x01d9:
r6 = 384; // 0x180 float:5.38E-43 double:1.897E-321;
if (r12 == r6) goto L_0x01e5;
L_0x01dd:
r6 = 256; // 0x100 float:3.59E-43 double:1.265E-321;
if (r12 == r6) goto L_0x01e5;
L_0x01e1:
r6 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
if (r12 != r6) goto L_0x00b2;
L_0x01e5:
r6 = "emotionSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x01f0:
goto L_0x0197;
L_0x01f1:
r5 = 1;
if (r12 != r5) goto L_0x0207;
L_0x01f4:
r5 = "bizTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "bizSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x0207;
L_0x0206:
r1 = 1;
L_0x0207:
r5 = 2;
if (r12 != r5) goto L_0x021d;
L_0x020a:
r5 = "articleTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x021d;
L_0x021c:
r1 = 1;
L_0x021d:
r5 = 8;
if (r12 != r5) goto L_0x0240;
L_0x0221:
r5 = "snsTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r6 = r5.optInt(r6, r7);
r7 = 1;
if (r6 != r7) goto L_0x0234;
L_0x0233:
r1 = 1;
L_0x0234:
r6 = "localSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x0240;
L_0x023f:
r3 = 1;
L_0x0240:
if (r11 != 0) goto L_0x0258;
L_0x0242:
r5 = 4;
if (r12 != r5) goto L_0x0258;
L_0x0245:
r5 = "bizTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "bizServiceSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x0258;
L_0x0257:
r1 = 1;
L_0x0258:
r5 = 1;
if (r12 != r5) goto L_0x026e;
L_0x025b:
r5 = "bizTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "mfsBizSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x026e;
L_0x026d:
r2 = 1;
L_0x026e:
r5 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
if (r12 != r5) goto L_0x0285;
L_0x0272:
r5 = "novelTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x0285;
L_0x0284:
r1 = 1;
L_0x0285:
r5 = 512; // 0x200 float:7.175E-43 double:2.53E-321;
if (r12 != r5) goto L_0x029c;
L_0x0289:
r5 = "musicTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x029c;
L_0x029b:
r1 = 1;
L_0x029c:
r5 = 384; // 0x180 float:5.38E-43 double:1.897E-321;
if (r12 != r5) goto L_0x02b3;
L_0x02a0:
r5 = "emotionTab";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x02b3;
L_0x02b2:
r1 = 1;
L_0x02b3:
if (r12 != 0) goto L_0x00b2;
L_0x02b5:
if (r11 == 0) goto L_0x00b2;
L_0x02b7:
r5 = "mixGlobal";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "mixSugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x02c9:
r1 = 1;
goto L_0x00b2;
L_0x02cc:
r5 = "bizEntry";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r5 = r5.optInt(r6);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x02dd:
goto L_0x0197;
L_0x02df:
r5 = "bizUnionTopEntry";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r5 = r5.optInt(r6);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x02f0:
goto L_0x0197;
L_0x02f2:
r5 = 384; // 0x180 float:5.38E-43 double:1.897E-321;
if (r12 != r5) goto L_0x00b2;
L_0x02f6:
r5 = "emoticonMall";
r5 = com.tencent.mm.plugin.websearch.api.r.PX(r5);
r6 = "sugSwitch";
r7 = 0;
r5 = r5.optInt(r6, r7);
r6 = 1;
if (r5 != r6) goto L_0x00b2;
L_0x0308:
r1 = 1;
goto L_0x00b2;
L_0x030b:
r1 = "isHomePage";
r2 = "1";
r4.put(r1, r2);
goto L_0x0114;
*/
throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.websearch.api.p.a(int, boolean, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String):java.util.Map<java.lang.String, java.lang.String>");
}
public static Map<String, String> b(int i, boolean z, int i2) {
return a(i, z, i2, "");
}
public static Map<String, String> a(int i, boolean z, int i2, String str) {
return a(i, z, i2, str, "", "", "", "", "", "", "");
}
public static boolean j(Activity activity, int i) {
try {
if (android.support.v4.content.a.f(activity, "android.permission.ACCESS_COARSE_LOCATION") == 0) {
h.mEJ.h(15104, new Object[]{Integer.valueOf(i), Integer.valueOf(2)});
return true;
}
h.mEJ.h(15104, new Object[]{Integer.valueOf(i), Integer.valueOf(1)});
if (android.support.v4.app.a.a(activity, "android.permission.ACCESS_COARSE_LOCATION")) {
x.w("MicroMsg.WebSearch.WebSearchApiLogic", "has shown request permission and user denied, do not show agagin");
return true;
}
x.w("MicroMsg.WebSearch.WebSearchApiLogic", "showing request permission dialog");
android.support.v4.app.a.a(activity, new String[]{"android.permission.ACCESS_COARSE_LOCATION"}, 73);
return false;
} catch (Throwable e) {
x.printErrStackTrace("MicroMsg.WebSearch.WebSearchApiLogic", e, "", new Object[0]);
return true;
}
}
public static void a(Context context, String str, Intent intent, String str2, String str3, String str4, String str5, String str6) {
String str7 = "";
String str8 = "";
if (context == null) {
x.e("MicroMsg.WebSearch.WebSearchApiLogic", "openNews intent is null, or context is null");
return;
}
Intent ag = ag(intent);
ag.putExtra("ftsbizscene", 21);
ag.putExtra("ftsQuery", str);
if (str2 != null) {
ag.putExtra("title", str2);
}
ag.putExtra("isWebwx", str);
ag.putExtra("ftscaneditable", false);
ag.putExtra("key_load_js_without_delay", true);
String zK = TextUtils.isEmpty(str5) ? zK(21) : str5;
ag.putExtra("rawUrl", a(str3, str4, zK, str, "2", false, TextUtils.isEmpty(str6) ? zK(21) : str6, str7, str8));
ag.putExtra("sessionId", zK);
ag.putExtra("customize_status_bar_color", Color.parseColor("#F2F2F2"));
ag.putExtra("status_bar_style", "black");
d.b(context, "webview", ".ui.tools.fts.FTSWebViewUI", ag);
}
public static String bSO() {
String optString = r.PX("discoverRecommendEntry").optString("wording");
if (bi.oW(optString)) {
x.e("MicroMsg.WebSearch.WebSearchApiLogic", "empty query");
return "";
}
return a(null, null, zK(21), optString, null, true, zK(21), "", "");
}
private static String a(String str, String str2, String str3, String str4, String str5, boolean z, String str6, String str7, String str8) {
Map a = a(21, false, 2, str, str2, str3, str4, str5, str6, "", str7);
if (z) {
a.put("isPreload", "1");
}
if (!bi.oW(str8)) {
a.put("redPointMsgId", str8);
}
return c(a, 1);
}
public static void bSP() {
g.Em().H(new Runnable() {
public final void run() {
Object bSO = p.bSO();
if (!TextUtils.isEmpty(bSO)) {
z.bTc().cu(bSO, 2);
}
}
});
}
public static void bSQ() {
fz(0);
}
public static void fz(long j) {
g.Em().h(new 2(), j);
}
public static void bSR() {
fA(0);
}
public static void fA(long j) {
g.Em().h(new 3(), j);
}
public static String bSS() {
return aP(-1, zK(-1));
}
public static String aP(int i, String str) {
Map b = b(i, true, 0);
b.put("sessionId", str);
b.put("inputMarginTop", "32");
b.put("inputMarginLeftRight", "24");
b.put("inputHeight", "48");
b.put("isPreload", "1");
return c(b, 0);
}
public static String v(Map<String, String> map) {
return c(map, 0);
}
public static String c(Map<String, String> map, int i) {
int i2 = 1;
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("file://");
String adP = zL(i).adP();
String str = "isOpenPreload";
StringBuilder stringBuilder = new StringBuilder();
z bTc = z.bTc();
int i3 = i == 1 ? 2 : 1;
if (ad.cic()) {
boolean bTd;
switch (i3) {
case 1:
bTd = bTc.bTd();
break;
default:
bTd = bTc.bTe();
break;
}
if (!bTd) {
i2 = 0;
}
map.put(str, stringBuilder.append(i2).toString());
stringBuffer.append(adP);
StringBuffer append;
if (map.size() > 0) {
append = stringBuffer.append("/");
zL(i);
append.append("app.html?");
for (Entry entry : map.entrySet()) {
stringBuffer.append((String) entry.getKey());
stringBuffer.append("=");
stringBuffer.append((String) entry.getValue());
stringBuffer.append("&");
}
String str2 = (String) map.get("sessionId");
if (!map.containsKey("sessionId")) {
str2 = zK(bi.WU((String) map.get("scene")));
stringBuffer.append("sessionId");
stringBuffer.append("=");
stringBuffer.append(str2);
stringBuffer.append("&");
}
if (!map.containsKey("subSessionId")) {
stringBuffer.append("subSessionId");
stringBuffer.append("=");
stringBuffer.append(str2);
stringBuffer.append("&");
}
stringBuffer.append("wechatVersion");
stringBuffer.append("=");
stringBuffer.append(com.tencent.mm.protocal.d.qVN);
stringBuffer.append("&");
return stringBuffer.substring(0, stringBuffer.length() - 1);
}
append = stringBuffer.append("/");
zL(i);
append.append("app.html");
return stringBuffer.toString();
}
throw new IllegalStateException("please call from main process");
}
public static void ah(Intent intent) {
intent.putExtra("ftsbizscene", 24);
Map b = b(24, false, 384);
String zK = zK(bi.WU((String) b.get("scene")));
b.put("sessionId", zK);
intent.putExtra("sessionId", zK);
intent.putExtra("rawUrl", c(b, 0));
intent.putExtra("ftsType", 384);
}
public static long LP(String str) {
if (TextUtils.isEmpty(str)) {
return 0;
}
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "seq %s to snsId %d ", new Object[]{str, Long.valueOf(new BigInteger(str).longValue())});
return new BigInteger(str).longValue();
}
public static boolean fB(long j) {
x.i("MicroMsg.WebSearch.WebSearchApiLogic", "rec updateRedDotTimestamp %d", new Object[]{Long.valueOf(j)});
g.Ei().DT().a(aa.a.sZQ, Long.valueOf(j));
return false;
}
public static boolean bST() {
JSONObject PX = r.PX("snsContactMatch");
if (PX == null) {
return false;
}
if (PX.optInt("matchSwitch") == 1) {
return true;
}
return false;
}
public static void a(String str, String str2, String str3, String str4, int i) {
ly lyVar = new ly();
lyVar.bWq.bWm = str4;
lyVar.bWq.bJK = str2;
lyVar.bWq.bWr = str3;
lyVar.bWq.scene = i;
lyVar.bWq.bWs = str;
com.tencent.mm.sdk.b.a.sFg.m(lyVar);
}
public static int bSU() {
JSONObject PX = r.PX("snsContactMatch");
if (PX != null) {
return PX.optInt("queryUtfLenLimit");
}
return 0;
}
public static String U(Map<String, ? extends Object> map) {
StringBuffer stringBuffer = new StringBuffer();
for (Entry entry : map.entrySet()) {
stringBuffer.append((String) entry.getKey());
stringBuffer.append("=");
if (entry.getValue() != null) {
stringBuffer.append(entry.getValue().toString());
}
stringBuffer.append("&");
}
return stringBuffer.substring(0, stringBuffer.length() - 1).toString();
}
public static String t(Map<String, Object> map, String str) {
if (map.containsKey(str)) {
return map.get(str) != null ? map.get(str).toString() : "";
} else {
return "";
}
}
public static boolean u(Map<String, Object> map, String str) {
String t = t(map, str);
if (bi.oW(t)) {
return false;
}
try {
if ("1".equals(t)) {
return true;
}
if ("0".equals(t)) {
return false;
}
return Boolean.valueOf(t).booleanValue();
} catch (Exception e) {
return false;
}
}
public static int c(Map<String, Object> map, String str, int i) {
String t = t(map, str);
if (bi.oW(t)) {
return i;
}
try {
return Integer.valueOf(t).intValue();
} catch (Exception e) {
return i;
}
}
public static long a(Map<String, Object> map, String str, long j) {
String t = t(map, str);
if (bi.oW(t)) {
return j;
}
try {
return Long.valueOf(t).longValue();
} catch (Exception e) {
return j;
}
}
public static void c(Context context, String str, Intent intent) {
try {
String str2 = ad.chX() + ".plugin.topstory";
if (str.startsWith(".")) {
str = str2 + str;
}
intent.setClassName(ad.getPackageName(), str);
Class.forName(str, false, context.getClassLoader());
if (context instanceof Activity) {
context.startActivity(intent);
return;
}
intent.addFlags(268435456);
context.startActivity(intent);
} catch (Exception e) {
x.e("MicroMsg.WebSearch.WebSearchApiLogic", "Class Not Found when startActivity %s", new Object[]{e});
}
}
public static void d(Context context, String str, Intent intent) {
try {
String str2 = ad.chX() + ".plugin.topstory";
if (str.startsWith(".")) {
str = str2 + str;
}
intent.setClassName(ad.getPackageName(), str);
Class.forName(str, false, context.getClassLoader());
if (context instanceof Activity) {
((Activity) context).startActivityForResult(intent, 10001);
}
} catch (Exception e) {
x.e("MicroMsg.WebSearch.WebSearchApiLogic", "Class Not Found when startActivity %s", new Object[]{e});
}
}
public static boolean bSV() {
return com.tencent.mm.sdk.platformtools.d.CLIENT_VERSION.endsWith("0F");
}
}
|
package day48_constructors_static.static_examples;
public class CalculatorTest {
public static void main(String[] args) {
//add is static method, can be called using Classname, staticMethodName
//static way of calling the method
Calculator.add(5,3);
// Calculator.multiply(2,4); ERROR ---> non static need object to call it
//multiply is instance method, and we creating object then calling it
Calculator calcObject = new Calculator();
calcObject.multiply(3,4);
//static method can also be called using an object
calcObject.add(10,45);
}
}
|
package com.tencent.mm.g.a;
import com.tencent.mm.sdk.b.b;
public final class di extends b {
public a bLa;
public b bLb;
public di() {
this((byte) 0);
}
private di(byte b) {
this.bLa = new a();
this.bLb = new b();
this.sFm = false;
this.bJX = null;
}
}
|
package com.medic.quotesbook.utils;
/**
* Created by capi on 12/09/15.
*/
public class GAK {
public static final String CATEGORY_QUOTESBOOK = "quotesbook";
public static final String CATEGORY_DAYQUOTE = "dayquote";
public static final String CATEGORY_SOMEQUOTES = "somequotes";
public static final String CATEGORY_QUOTE = "quote";
public static final String CATEGORY_GPS = "Google Play Services";
public static final String CATEGORY_SHARE = "share";
public static final String CATEGORY_SEARCH = "search";
public static final String ACTION_QUOTE_SAVED = "quote saved";
public static final String ACTION_QUOTE_UNSAVED = "quote unsaved";
public static final String ACTION_QUOTE_SELECTED = "quote selected";
public static final String ACTION_QUOTE_SEARCH = "quote search";
public static final String ACTION_PAGE_PASSED = "Page passed";
public static final String ACTION_QUOTE_TEXT_SHARED = "quote text shared";
public static final String ACTION_QUOTE_IMAGE_SHARED = "quote image shared";
public static final String ACTION_GPS_UPDATE_REQUIRED = "update required";
}
|
package com.widget.demo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;
import android.widget.TextView;
public class AutoCompleteDemo extends Activity {
/** Called when the activity is first created. */
private static final String[] nContent = { "zhuo", "kobe", "zhuori",
"kobebryant", "ko8e", "ko8ebryant" };
private AutoCompleteTextView autoView = null;
private MultiAutoCompleteTextView autoView2 = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.autocomplete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, nContent);
autoView = (AutoCompleteTextView) findViewById(R.id.autoView);
// 将adapter添加到AutoCompleteTextView中
autoView.setAdapter(adapter);
autoView.setThreshold(4);
//多行处理
autoView2 = (MultiAutoCompleteTextView) findViewById(R.id.autoView2);
autoView2.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
autoView2.setAdapter(adapter);
autoView2.setThreshold(4);
}
}
|
package com.example.zealience.oneiromancy.ui.widget;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Scroller;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.zealience.oneiromancy.R;
/**
* @user steven
* @createDate 2019/2/21 14:55
* @description 自定义
*/
public class ScrollPaintView extends RelativeLayout {
/**
* TAG
*/
private static final String TAG = "ScrollPaintView";
/**
* 默认滚轴高度
*/
private final int DEFAULT_PAINT_SCROLL_HEIGHT = 25;
/**
* 默认滚动的速度
*/
private final int DEFAULT_SCROLL_SPEED = 1000;
/**
* 默认分割点高度
*/
private final int DEFAULT_PARTITION_NODE = 200;
/**
* 默认画轴文字大小
*/
private final int DEFAULT_PAINT_SCROLL_TXT_SIZE = 16;
/**
* Scroller
*/
private Scroller mScroller;
/**
* 滚轴Iv
*/
private ImageView mPaintScrollImageView;
/**
* 滚轴Tv
*/
private TextView mPaintScrollTextView;
/**
* 图画Iv
*/
private ImageView mPaintView;
/**
* 画轴图
*/
private Bitmap mPaintScrollBp;
/**
* 画轴高度
*/
private int mPaintIvHeight;
/**
* 画轴文字
*/
private String mPaintScrollTxt;
/**
* 画轴文字大小
*/
private float mPaintScrollTxtSize;
/**
* 画轴文字颜色
*/
private int mPaintScrollTxtColor;
/**
* 图画开始时的高度
*/
private int mPaintStartHeight;
/**
* 上一次获取的Y
*/
private int mLastY;
/**
* 滚动速度
*/
private int mScrollSpeed;
/**
* 分隔节点
*/
private int partitionNode;
/**
* 是否是向上滚动
*/
private boolean isScrllerTop = false;
/**
* 是否正在点击
*/
private boolean isClick = false;
/**
* 布局参数
*/
private LayoutParams lpp;
/**
* 屏幕高度
*/
private int screenHeight;
/**
* 屏幕宽度
*/
private int screenWidth;
/**
* 回调监听
*/
private ScrollPaintCompleteListener listener;
/**
* 上一次滚动的Y值
*/
private int lastScrollY;
/**
* 回调接口
*/
public interface ScrollPaintCompleteListener {
/**
* 点击时的回调
*/
public void onScrollTouch(TextView tv);
/**
* 收缩时的回调
*/
public void onScrollTop(TextView tv);
/**
* 展开时的回调
*/
public void onScrollBottom(TextView tv);
/**
* 滚动中的回调
*/
public void onScrollMove(TextView tv);
}
public ScrollPaintView(Context context) {
this(context, null);
}
public ScrollPaintView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ScrollPaintView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// 获取属性
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ScrollPaintView);
mPaintIvHeight = (int) ta.getDimension(R.styleable.ScrollPaintView_paintScrollHeight, TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, DEFAULT_PAINT_SCROLL_HEIGHT, getResources().getDisplayMetrics()));
mScrollSpeed = ta.getInteger(R.styleable.ScrollPaintView_scrollSpeed, DEFAULT_SCROLL_SPEED);
partitionNode = ta.getInteger(R.styleable.ScrollPaintView_scrollPartitionNode, DEFAULT_PARTITION_NODE);
mPaintScrollBp = drawableToBitamp(ta.getDrawable(R.styleable.ScrollPaintView_paintScrollSrc));
mPaintScrollTxt = ta.getString(R.styleable.ScrollPaintView_paintScrollTxt);
mPaintScrollTxtColor = ta.getColor(R.styleable.ScrollPaintView_paintScrollTxtColor, Color.BLACK);
mPaintScrollTxtSize = px2sp(ta.getDimensionPixelSize(R.styleable.ScrollPaintView_paintScrollTxtSize, DEFAULT_PAINT_SCROLL_TXT_SIZE));
ta.recycle();
init();
makePaintScroll();
handleView();
}
/**
* 设置paintView
*
* @param paintView
*/
public void setPaintView(ImageView paintView) {
if (null == paintView) {
Log.e(TAG, "设置的View为空");
return;
}
// 处理图片,对图片按照屏幕宽高比进行缩放
Bitmap bp = drawableToBitamp(paintView.getDrawable());
paintView.setImageBitmap(scaleBitmal(bp));
// 设置缩放形式
paintView.setScaleType(ImageView.ScaleType.MATRIX);
mPaintView = paintView;
}
/**
* 设置回调
*/
public void setScrollPaintCompleteListener(ScrollPaintCompleteListener listener) {
if (null != listener) {
this.listener = listener;
}
}
/**
* 初始化
*/
private void init() {
mScroller = new Scroller(getContext());
lpp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
// 获取屏幕信息
DisplayMetrics displayMetrics = new DisplayMetrics();
((AppCompatActivity) getContext()).getWindowManager().getDefaultDisplay()
.getMetrics(displayMetrics);
// 屏幕高度
screenHeight = displayMetrics.heightPixels;
// 屏幕宽度
screenWidth = displayMetrics.widthPixels;
}
/**
* 创建滚轴
*/
private void makePaintScroll() {
// 如果已经存在,则不再创建
if (null != mPaintScrollImageView || null != mPaintScrollTextView) {
return;
}
// 创建滚轴
mPaintScrollImageView = new ImageView(getContext());
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lp.height = mPaintIvHeight;
mPaintScrollImageView.setLayoutParams(lp);
mPaintScrollImageView.setScaleType(ImageView.ScaleType.FIT_XY);
mPaintScrollImageView.setImageBitmap(null == mPaintScrollBp ? makeDefaultScroll() : mPaintScrollBp);
addView(mPaintScrollImageView);
// 创建文字
mPaintScrollTextView = new TextView(getContext());
LayoutParams lpt = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lpt.height = mPaintIvHeight;
mPaintScrollTextView.setLayoutParams(lpt);
mPaintScrollTextView.setText(null == mPaintScrollTxt ? "" : mPaintScrollTxt);
mPaintScrollTextView.setTextSize(mPaintScrollTxtSize);
mPaintScrollTextView.setTextColor(mPaintScrollTxtColor);
mPaintScrollTextView.setGravity(Gravity.CENTER);
addView(mPaintScrollTextView);
}
/**
* 测量方法
*
* @param widthMeasureSpec
* @param heightMeasureSpec
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (null != mPaintView && getTop() + mPaintIvHeight != mPaintView.getHeight()) {
// 重新设置图画高度
mPaintStartHeight = getTop() + mPaintIvHeight / 2;
lpp.height = mPaintStartHeight;
mPaintView.setLayoutParams(lpp);
}
// 测量状态栏高度
Rect frame = new Rect();
((Activity) getContext()).getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
// 高度为屏幕高度减去状态栏高度和top的高度
setMeasuredDimension(screenWidth, screenHeight - getTop() - statusBarHeight);
}
/**
* 处理View
*/
private void handleView() {
mPaintScrollImageView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (null == mPaintView) {
Log.e(TAG, "设置的View为空");
return true;
}
// 获取点击的XY坐标
int x = (int) event.getRawX();
int y = (int) event.getRawY();
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN: {
// 请求处理点击事件
requestDisallowInterceptTouchEvent(true);
isClick = true;
mLastY = y;
if (!mScroller.isFinished()) { // 如果上次的调用没有执行完就取消。
mScroller.abortAnimation();
}
if (null != listener) {
listener.onScrollTouch(mPaintScrollTextView);
}
return true;
}
case MotionEvent.ACTION_MOVE: {
// 移动的距离
int dy = y - mLastY;
mLastY = y;
// 滑动
scrollBy(0, -dy);
// 如果是向上滑动并且是在初始位置,则不去做处理
if (getScrollY() >= 0 && dy <= 0) {
lpp.height = mPaintStartHeight;
mPaintView.setLayoutParams(lpp);
scrollTo(0, 0);
return true;
}
// 如果是向下滑动并且超过屏幕高度,则不去处理
if (Math.abs(getScrollY()) >= getHeight() - mPaintIvHeight && dy >= 0) {
lpp.height = mPaintStartHeight + getHeight() - mPaintIvHeight;
mPaintView.setLayoutParams(lpp);
scrollTo(0, -(getHeight() - mPaintIvHeight));
return true;
}
// 滚动回调
if (null != listener) {
listener.onScrollMove(mPaintScrollTextView);
}
// 重新设置显示的控件高度
if (Math.abs(getScrollY()) > 0) {
lpp.height = mPaintStartHeight + Math.abs(getScrollY());
mPaintView.setLayoutParams(lpp);
}
return true;
}
case MotionEvent.ACTION_UP:
// 恢复事件处理
requestDisallowInterceptTouchEvent(false);
isClick = false;
// 没有发生移动
if (getScrollY() >= 0) {
if (null != listener) {
listener.onScrollTop(mPaintScrollTextView);
}
return true;
}
if (-getScrollY() < partitionNode) { // 如果小于临界值,则返回起始坐标
// XY都从滑动的距离回去,最后一个参数是多少毫秒内执行完这个动作。
isScrllerTop = true;
mScroller.startScroll(getScrollX(), getScrollY(), -getScrollX(), -getScrollY(), mScrollSpeed);
} else { // 如果大于临界值,则展开
isScrllerTop = false;
mScroller.startScroll(getScrollX(), getScrollY(), -getScrollX(), -(getHeight() - (-getScrollY()) - mPaintIvHeight), mScrollSpeed);
}
invalidate();
return true;
}
return false;
}
});
}
/**
* 滑动处理
*/
@Override
public void computeScroll() {
if (mScroller.computeScrollOffset()) { // 计算新位置,并判断上一个滚动是否完成。
// 请求处理点击事件,防止父控件滑动
requestDisallowInterceptTouchEvent(true);
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
// 重新设置显示的控件高度
if (0 < Math.abs(mScroller.getCurrY())) {
if (!isScrllerTop) {
lpp.height = mPaintStartHeight + Math.abs(mScroller.getCurrY()) + mPaintIvHeight / 2;
} else {
lpp.height = mPaintStartHeight + Math.abs(mScroller.getCurrY()) - mPaintIvHeight / 2;
}
} else {
lpp.height = mPaintStartHeight;
}
mPaintView.setLayoutParams(lpp);
invalidate();
} else {
// 重新设置画图高度,防止高度异常
if (mPaintView.getHeight() > mPaintStartHeight + Math.abs(mScroller.getCurrY()) && !isScrllerTop && mScroller.getStartY() > 0) {
lpp.height = mPaintStartHeight + Math.abs(mScroller.getCurrY());
mPaintView.setLayoutParams(lpp);
}
}
// 防止多次调用
if (lastScrollY != mScroller.getCurrY()) {
// 收缩完成
if (mScroller.getCurrY() >= 0 && !isClick) {
if (null != listener) {
listener.onScrollTop(mPaintScrollTextView);
}
}
// 展开完成
if (-mScroller.getCurrY() >= getHeight() - mPaintIvHeight && !isClick) {
if (null != listener) {
listener.onScrollBottom(mPaintScrollTextView);
}
}
lastScrollY = mScroller.getCurrY();
}
}
/**
* 重置滚动
*/
public void replaceScroll() {
// 重置信息
scrollTo(0, 0);
mScroller.setFinalY(0);
lastScrollY = 0;
lpp.height = mPaintStartHeight;
mPaintView.setLayoutParams(lpp);
if (null != listener) {
listener.onScrollTop(mPaintScrollTextView);
}
}
/**
* drawable转bitmap
*
* @param drawable
* @return
*/
private Bitmap drawableToBitamp(Drawable drawable) {
if (null == drawable) {
return null;
}
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bd = (BitmapDrawable) drawable;
return bd.getBitmap();
}
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
drawable.draw(canvas);
return bitmap;
}
/**
* 按照屏幕宽高缩放图片
*
* @param bp
* @return
*/
private Bitmap scaleBitmal(Bitmap bp) {
// 宽度比例
float scaleW = (float) screenWidth / (float) bp.getWidth();
// 高度比例
float scaleH = (float) screenHeight / (float) bp.getHeight();
// 矩阵,用于缩放图片
Matrix matrix = new Matrix();
matrix.postScale(scaleW, scaleH);
// 缩放后的图片
Bitmap scaleBp = Bitmap.createBitmap(bp, 0, 0, bp.getWidth(), bp.getHeight(), matrix, true);
return scaleBp;
}
/**
* 设置默认的滚轴
*
* @return
*/
private Bitmap makeDefaultScroll() {
Bitmap defaultBp = Bitmap.createBitmap(screenWidth, mPaintIvHeight,
Bitmap.Config.ARGB_8888);
//填充颜色
defaultBp.eraseColor(Color.parseColor("#FF0000"));
return defaultBp;
}
/**
* 将px值转换为sp值,保证文字大小不变
*/
public int px2sp(float pxValue) {
final float fontScale = getContext().getResources().getDisplayMetrics().scaledDensity;
return (int) (pxValue / fontScale + 0.5f);
}
}
|
package com.te.springmvc.controllers;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping("/cookies")
public class CookieController {
@GetMapping("/cookiespage")
public String getCookies() {
return "cookie";
}
@GetMapping("/createcookies")
public String createCookies(HttpServletResponse response, ModelMap map) {
Cookie cookie = new Cookie("EmpName", "Sai");
response.addCookie(cookie);
map.addAttribute("msg", "Created Cookies");
return "cookie";
}
@GetMapping("/showcookies")
public String showCookies(@CookieValue(name="EmpName")String name, ModelMap map) {
map.addAttribute("cookie", name);
return "cookie";
}
}
|
package com.deepak.dynamic;
import java.util.Arrays;
import java.util.Random;
public class peak {
int length;
public int[] inputarray=new int[length];
public peak(int[] inputarray,int length) {
this.length=length;
this.inputarray = inputarray;
}
public void peakfinder(int[] array) {
if (this.inputarray[0]>this.inputarray[1]){
System.out.println("One Peak is "+this.inputarray[0]);
return;
}
if (this.inputarray[this.length-2]<this.inputarray[this.length-1]){
System.out.println("One Peak is "+this.inputarray[this.length-1]);
return;
}
int length = array.length;
int mid=(int)Math.ceil(length/2.0);
System.out.println("mid value is"+mid+"\n mid is"+array[mid-1]);
System.out.println("Length is " + length);
if (length == 2) {
if (array[0] < array[1]) {
System.out.println("peak is" + array[1]);
// return;
} else {
System.out.println("peak is" + array[0]);
// return;
}
}
if (length > 2) {
if (array[mid-1] < array[(mid-1) - 1]) {
int[] array1 = Arrays.copyOfRange(array, 0, (mid-1) );
System.out.println("Array 1");
for (int i : array1) {
System.out.print(i + " ");
}
if(array1.length>1){
if(array1[mid-2]>array1[mid-3]){
System.out.println("Peak is "+array1[mid-2]);
}}
peakfinder(array1);
} else if (array[mid-1] < array[(mid-1) + 1]) {
int[] array2 = Arrays.copyOfRange(array, (mid-1) + 1, length );
System.out.println("Array 2");
for (int i : array2) {
System.out.print(i + " ");
}
if(array2.length>1){
if(array2[0]>array2[1]){
System.out.println("Peak is "+array2[0]);
}}
peakfinder(array2);
} else {
System.out.println("peak is" + array[mid-1]);
// return;
}
}
}
public static void main(String[] args){
int[] arraya=new int[]
{6, 32,
20,
31,
33,
35,
69,
89,
91,
24
};
// for(int i=0;i<arraya.length;i++)
// {
// Random rand = new Random();
// arraya[i]=rand.nextInt(100);
// }
for (int i:arraya){
System.out.print(i+" ");
}
System.out.println("\n *********");
peak newpeak=new peak(arraya,10);
newpeak.peakfinder(arraya);
}
}
|
package com.hooper.barber;
import java.util.concurrent.*;
/**
* Write a description of class Shared here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Shared
{
public Semaphore barberReady;
public Semaphore custReady;
public Semaphore custHappy;
public Semaphore accessWRSeats;
public int numberOfFreeWRSeats;
public Shared(int n)
{
barberReady = new Semaphore(0);
custReady = new Semaphore(0);
custHappy = new Semaphore(0);
accessWRSeats = new Semaphore(1);
numberOfFreeWRSeats = n;
}
}
|
package com.app;
import java.io.FileReader;
public class JSONParser {
public Object parse(FileReader fileReader) {
return null;
}
}
|
package pkg;
import java.sql.*;
public class Studentwork{
String uname,b1,b2;
Connection myconn;
Studentwork(String username)
{ try {
//bkname = s;
uname = username;
myconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","student");
String query = "SELECT * FROM db1.students where roll_no = ?" ;
PreparedStatement ps = myconn.prepareStatement(query);
ps.setString(1,uname);
ResultSet rs = ps.executeQuery();
while (rs.next())
{
b1 = rs.getString("book_1");
b2 = rs.getString("book_2");
}
ps.close();
}
catch(Exception e){
S.sop("Error....."+e);
}
}
int issue(String bkname)
{
try {
if(b1!=null && b2!=null) { S.sop("You have exceeded book limit"); }
else if(b1==null)
{
String sqlUpdate = "UPDATE db1.students "
+ "SET book_1 = ? "
+ "WHERE roll_no = ?";
PreparedStatement pstmt = myconn.prepareStatement(sqlUpdate);
pstmt.setString(1, bkname);
pstmt.setString(2, uname);
pstmt.executeUpdate();
return 1;
}
else
{ S.sop("Erer");
String sqlUpdate = "UPDATE db1.students "
+ "SET book_2 = ? "
+ "WHERE roll_no = ?";
PreparedStatement pstmt = myconn.prepareStatement(sqlUpdate);
pstmt.setString(1, bkname);
pstmt.setString(2, uname);
pstmt.executeUpdate();
return 1;
}
}
catch(Exception e){;}
return 0;
}//issue function ends here
void Returnbook(String bkname)
{
try {
if(bkname.equals(b1))
{
String sqlUpdate = "UPDATE db1.students "
+ "SET book_1 = ? "
+ "WHERE roll_no = ?";
PreparedStatement pstmt = myconn.prepareStatement(sqlUpdate);
pstmt.setNull(1, Types.VARCHAR);
pstmt.setString(2, uname);
pstmt.executeUpdate();
pstmt.close();
S.sop("Done");
}
else if(bkname.equals(b2))
{
String sqlUpdate = "UPDATE db1.students "
+ "SET book_2 = ? "
+ "WHERE roll_no = ?";
PreparedStatement pstmt = myconn.prepareStatement(sqlUpdate);
pstmt.setNull(1,Types.VARCHAR);
pstmt.setString(2, uname);
pstmt.executeUpdate();
pstmt.close();
S.sop("Done");
}
else
{
S.sop("No such book");
}
}
catch(Exception e) { S.sop(e + "Occured "); }
} //returnbook function ends here
void Issuedbks()
{
if(b1 == null && b2 == null) { S.sop("No books issued"); }
else
{ S.sop("Issued Boook(s) :");
if(b1!=null) { S.sop(b1); }
if(b2!=null) { S.sop(b2); }
}
}
}
/*
static void issue(String s,String username)
{
}
*/
|
package com.hendriksen.squashtracker;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import com.hendriksen.listeners.OnFileSave;
import com.hendriksen.model.Swing;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
/**
* Save a swing in the background.
* This will save the swing to a text file on the device.
* @author Sam Hendriksen
*
*/
public class SaveSwingTask extends AsyncTask<Swing, Integer, Boolean> {
//Tag used to determine this class.
public static String TAG = SaveSwingTask.class.getName();
//Used to show the saving progress.
private ProgressDialog progressDialog;
//Used to update the progress.
private Activity act;
//File location that will be used to save.
private File swingSaveTo;
//User defined swing type.
private String userDefinedSwingType;
//Alert when the file has been saved.
private OnFileSave listener;
public SaveSwingTask(Activity act, String userDefinedSwingType, OnFileSave listener) {
this.act = act;
this.userDefinedSwingType = userDefinedSwingType;
this.listener = listener;
}
@Override
protected void onPreExecute()
{
progressDialog= ProgressDialog.show(act, act.getString(R.string.saving_swing), act.getString(R.string.saving_packets), true);
};
@Override
protected Boolean doInBackground(Swing... swing) {
if(swing == null) {
Log.e(TAG, "Swing is null");
return false;
}
//Make sure that the data is sampled.
swing[0].sampleData();
//Make sure the features have been calculated.
swing[0].determineFeatures();
//Save the File in a Weka format. http://weka.wikispaces.com/Programmatic+Use
//Create the destination file.
swingSaveTo = GlobalApplication.getInstance().getUserProfile();
//Generate the Weka Attributes.
FastVector fvWekaAttributes = Helper.getInstance().getWekaAttributes();
// Create an empty training set
Instances swingInstanceData = new Instances("swing_set", fvWekaAttributes, swing[0].timeValuesSampled.length);
// Set class index
swingInstanceData.setClassIndex(fvWekaAttributes.size() - 1);
//Output the data.
try {
OutputStream os;
boolean isAppend;
//If a training file already exists.
if(!GlobalApplication.getInstance().isNewProfile()){
os = new FileOutputStream(swingSaveTo, true);
isAppend = true;
}else{
os = new FileOutputStream(swingSaveTo);
isAppend = false;
}
Instance tempInstance;
//Add the data.
for(int i = 0; i < swing[0].timeValuesSampled.length; i++){
// Create and add the instance
tempInstance = Helper.getInstance().createWekaInstance(swing[0], i, userDefinedSwingType);
//Add the instance to our new instance set.
swingInstanceData.add(tempInstance);
//Add the instance to our training set to help the application learn.
//SwingTypeProcessor.getInstance().addInstanceToClassifier(swingInstanceData.lastInstance());
if(isAppend){
//Log for debugging.
Log.d(TAG, '\n' + swingInstanceData.lastInstance().toString());
//Write the row to the file.
os.write(('\n' + swingInstanceData.lastInstance().toString()).getBytes());
}
}
//If we are creating a new file.
if(!isAppend){
//Log for debugging.
Log.d(TAG, swingInstanceData.toString());
//Write the data to the file.
os.write(swingInstanceData.toString().getBytes());
}
//Close the output stream.
os.flush();
os.close();
return true;
}catch (Exception e){
Log.e(TAG, "Failed to output the file: " + e);
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
progressDialog.dismiss();
progressDialog = null;
if(listener != null){
listener.onSuccess();
}
if(!result) {
Helper.getInstance().showToast("Failed to train.", Toast.LENGTH_LONG, true);
return;
}else{
//Helper.getInstance().showToast("Trained successfully.", Toast.LENGTH_SHORT, false);
Log.i(TAG, "Swing saved, successfully. file: " + swingSaveTo.getAbsolutePath());
return;
}
}
}
|
package AlgorithmsHW.HW5;
import java.util.ArrayList;
import java.util.Scanner;
/**
* Created by joetomjob on 4/22/17.
*/
public class Maze {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
//Take the input; d1 = number of rows and d2 = number of columns
String initialip = in.nextLine();
String[] iniarr = initialip.split(" ");
int d1 = Integer.parseInt(iniarr[0]);
int d2 = Integer.parseInt(iniarr[1]);
int[][] g = new int[d1][d2];
int destr,destcol,startr,startcol;
for (int i = 0; i < d1; i++) {
String row = in.nextLine();
String[] rowarr = row.split(" ");
for (int j = 0; j < d2; j++) {
g[i][j] = Integer.parseInt(rowarr[j]);
if(g[i][j] == 2){
startr = i;
startcol = j;
}
else if(g[i][j]==3){
destr = i;
destcol = j;
}
}
}
for (int i = 0; i < d1; i++) {
for (int j = 0; j < d2; j++) {
System.out.print(g[i][j]);
System.out.print("\t");
}
System.out.print("\n");
}
}
}
|
package com.alfa.work1;
import com.alfa.work2.MyConverter;
import java.util.*;
import java.util.function.Predicate;
public class Runner {
public void run() {
Integer[] arrInt = createArrayInt();
System.out.println(Arrays.toString(arrInt));
//Arrays.sort(arrInt, (a, b) -> b.compareTo(a));
Arrays.sort(arrInt, Comparator.reverseOrder());
System.out.println(Arrays.toString(arrInt));
//System.out.println();
System.out.println(sum(arrInt, x->x%2==0));
System.out.println(sum(arrInt, x->x%2==1));
System.out.println(sum(arrInt, x->x>0));
List<String> list = createList();
System.out.println(list);
// Collections.sort(list, Collections.reverseOrder());
Collections.sort(list, (s1, s2) -> s2.compareTo(s1));
// System.out.println(list);
// printStr(list, x -> x.charAt(0) > 'd');
// System.out.println();
// printStr(list, x -> x.charAt(0) < 'd');
// System.out.println();
updateList(list, str -> MyConverter.isnull(str) ? str : str.toUpperCase());
System.out.println(list);
updateList(list, str -> MyConverter.isnull(str) ? str : str.concat(str));
System.out.println(list);
}
private Integer[] createArrayInt() {
Random random = new Random();
Integer[] array = new Integer[20];
for (int i = 0; i < array.length; i++) {
array[i] = random.nextInt(100) - 50;
}
return array;
}
private List<String> createList() {
Random random = new Random();
List<String> list = new ArrayList<>();
String temp = "jdhgfsgfjhgdjhsgfjhgkkjhbhgg";
for (int i = 0; i < 12; i++) {
// list.add(String.valueOf((char) random.nextInt(26)+65));
int pos = random.nextInt(temp.length());
list.add(temp.substring(pos, pos + 1));
}
return list;
}
public Integer sum(Integer[] arrInt, Predicate<Integer> predicate) {
int sumInt = 0;
for (Integer elem : arrInt) {
if(predicate.test(elem)){
sumInt+=elem;
}
}
return sumInt;
}
public void printStr(List<String> list, Predicate<String> predicate){
for (String elem:list) {
if(predicate.test(elem)){
System.out.print(elem + "\t");
}
}
}
public void updateList(List<String> list, MyConverter converter){
for (int i = 0; i < list.size(); i++) {
list.set(i,converter.convertStr(list.get(i)));
}
}
}
|
package com.rudecrab.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ValidationAndExceptionHandlerApplication {
public static void main(String[] args) {
SpringApplication.run(ValidationAndExceptionHandlerApplication.class, args);
}
}
|
package replicatorg.model.j3d;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Locale;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TriangleArray;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3f;
import replicatorg.app.Base;
public class StlAsciiWriter extends ModelWriter {
public StlAsciiWriter(OutputStream ostream) {
super(ostream);
}
Locale l = Locale.US;
@Override
public void writeShape(Shape3D shape, Transform3D transform) {
PrintWriter w = new PrintWriter(ostream);
TriangleArray g = getGeometry(shape);
if (g == null) {
Base.logger.info("Couldn't find valid geometry during save.");
return;
}
// Oops-- this is part of the v1.4 API. Until we ship a new J3D w/ the
// Mac release, fall back to a default.
// String name = shape.getName();
// if (name == null) { name = "Default"; }
String name = "Default";
w.printf(l,"solid %s\n", name);
int faces = g.getVertexCount()/3;
float[] norm = new float[3];
double[] coord = new double[3];
for (int faceIdx = 0; faceIdx < faces; faceIdx++) {
g.getNormal(faceIdx*3, norm);
Vector3f norm3f = new Vector3f(norm);
transform.transform(norm3f);
norm3f.normalize();
w.printf(l," facet normal %e %e %e\n", norm3f.x,norm3f.y,norm3f.z);
w.printf(l," outer loop\n");
Point3d face3d;
g.getCoordinate(faceIdx*3, coord);
face3d = new Point3d(coord);
transform.transform(face3d);
w.printf(l," vertex %e %e %e\n", face3d.x,face3d.y,face3d.z);
g.getCoordinate((faceIdx*3)+1, coord);
face3d = new Point3d(coord);
transform.transform(face3d);
w.printf(l," vertex %e %e %e\n", face3d.x,face3d.y,face3d.z);
g.getCoordinate((faceIdx*3)+2, coord);
face3d = new Point3d(coord);
transform.transform(face3d);
w.printf(l," vertex %e %e %e\n", face3d.x,face3d.y,face3d.z);
w.printf(l," endloop\n");
w.printf(l," endfacet\n");
}
w.printf(l,"endsolid %s\n", name);
w.close();
}
}
|
package com.ifeiyang.bijia.entity;
import java.util.ArrayList;
public class Data
{
// 2
int TotalCount;// 9,
ArrayList<Product> LineList;// [
public int getTotalCount()
{
return TotalCount;
}
public void setTotalCount(int totalCount)
{
TotalCount = totalCount;
}
public ArrayList<Product> getLineList()
{
return LineList;
}
public void setLineList(ArrayList<Product> lineList)
{
LineList = lineList;
}
@Override
public String toString()
{
return "Data [TotalCount=" + TotalCount + ", LineList=" + LineList + "]";
}
}
|
package io.github.wickhamwei.wessential.wprotect.eventlistener;
import io.github.wickhamwei.wessential.WEssentialMain;
import io.github.wickhamwei.wessential.wprotect.WProtect;
import io.github.wickhamwei.wessential.wresidence.WResidence;
import io.github.wickhamwei.wessential.wtools.WPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class ChestLockListener implements Listener {
@EventHandler
public void onPlayerOpenChest(PlayerInteractEvent event) {
WPlayer player = WPlayer.getWPlayer(event.getPlayer().getName());
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) {
Block chestBlock = event.getClickedBlock();
if (event.getItem() != null && event.getMaterial() == Material.OAK_SIGN) {
if (event.getBlockFace() == BlockFace.EAST || event.getBlockFace() == BlockFace.SOUTH || event.getBlockFace() == BlockFace.WEST || event.getBlockFace() == BlockFace.NORTH) {
Block signBlock = chestBlock.getRelative(event.getBlockFace());
if (signBlock.getType() == Material.AIR) {
if (player.getBukkitPlayer().getGameMode() == GameMode.CREATIVE) {
player.sendMessage(WEssentialMain.languageConfig.getConfig().getString("message.w_protect_survival_only"));
return;
}
if (WResidence.isBlockInResidence(player, chestBlock,false)) {
return;
}
String chestOwnerName = WProtect.getChestOwnerName(chestBlock);
if (chestOwnerName == null) {
WProtect.lockChest(player, chestBlock, signBlock, event.getBlockFace());
} else if (chestOwnerName.equals(player.getName())) {
WProtect.ownerClickChest(player, chestBlock);
} else {
player.sendMessage(WEssentialMain.languageConfig.getConfig().getString("message.w_protect_chest_already_lock"));
}
}
}
}
}
}
}
}
|
package com.chalienko.medcard.service;
import com.chalienko.medcard.domain.model.Patient;
import com.chalienko.medcard.domain.repository.PatientRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by Chalienko on 26.04.2016.
*/
@Service
public class PatientService {
@Autowired
private PatientRepository patientRepository;
public Patient getPatientById(Long id) {
return patientRepository.getOne(id);
}
public List<Patient> getPatientsByDoctorId(Long id){
return patientRepository.getPatientByDoctorId(id);
}
public void insertPatient(Patient patient){
patientRepository.save(patient);}
}
|
package com.technology.share.service;
import com.technology.share.domain.Icon;
public interface IconService extends BaseService<Icon> {
}
|
/*
* SUNSHINE TEAHOUSE PRIVATE LIMITED CONFIDENTIAL
* __________________
*
* [2015] - [2017] Sunshine Teahouse Private Limited
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Sunshine Teahouse Private Limited and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Sunshine Teahouse Private Limited
* and its suppliers, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Sunshine Teahouse Private Limited.
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.12.21 at 08:10:40 PM IST
//
package www.chaayos.com.chaimonkbluetoothapp.domain.model.new_model;
/**
* <p>
* Java class for UnitRegion.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* <simpleType name="UnitRegion">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="MENU"/>
* <enumeration value="PAID_ADDON"/>
* <enumeration value="FREE_ADDON"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
public enum ProductClassification {
MENU, PAID_ADDON, FREE_ADDON, VARIANT, PRODUCT_VARIANT;
public String value() {
return name();
}
public static ProductClassification fromValue(String v) {
return valueOf(v);
}
}
|
package com.tencent.mm.plugin.webview.ui.tools.jsapi;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import com.tencent.mm.plugin.webview.ui.tools.jsapi.g.86;
class g$86$2 implements OnClickListener {
final /* synthetic */ 86 qjN;
g$86$2(86 86) {
this.qjN = 86;
}
public final void onClick(DialogInterface dialogInterface, int i) {
g.a(this.qjN.qiK, this.qjN.qiH, "nfcCheckState:nfc_off", null);
}
}
|
package com.jim.multipos.ui.service_fee_new;
import com.jim.multipos.core.Presenter;
import com.jim.multipos.data.db.model.ServiceFee;
/**
* Created by Portable-Acer on 28.10.2017.
*/
public interface ServiceFeePresenter extends Presenter {
void initDataToServiceFee();
void deleteServiceFee(ServiceFee serviceFee);
void addServiceFee(double amount, int type, String reason, int appType, boolean checked);
void onSave(double amount, int type, String description, int appType, boolean active, ServiceFee serviceFee);
void sortList(ServiceFeePresenterImpl.ServiceFeeSortTypes serviceFeeSortTypes);
void onClose();
}
|
package com.jk.jkproject.ui.widget.recyclerview;
import android.content.Context;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import com.jk.jkproject.R;
import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.header.MaterialHeader;
import in.srain.cube.views.ptr.util.PtrLocalDisplay;
/**
* @author YanLu
* @since 16/3/23
*/
public class WrapperRecyclerView extends FrameLayout {
private static final String TAG = "RefreshRecyclerView";
private RecyclerView mRecyclerView;
private BaseWrapperRecyclerAdapter mAdapter;
private PtrFrameLayout mPtrFrameLayout;
private RefreshRecyclerViewListener mRecyclerViewListener;
private RecyclerOnScrollListener mOnScrollListener;
//当前列表y轴位置
private int ScallY = -1;
//滑动距离
private float MoveY = -1;
public WrapperRecyclerView(Context context) {
super(context);
initRefreshRecyclerView(context);
}
public WrapperRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
initRefreshRecyclerView(context);
}
public WrapperRecyclerView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initRefreshRecyclerView(context);
}
private void initRefreshRecyclerView(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.refresh_recycler_view, this);
mRecyclerView = (RecyclerView) findViewById(R.id.service_recycler_view);
mPtrFrameLayout = (PtrFrameLayout) findViewById(R.id.material_style_ptr_frame);
// header
final MaterialHeader header = new MaterialHeader(context);
//header.setColorSchemeColors(new int[]{R.color.line_color_run_speed_13});
int[] colors = getResources().getIntArray(R.array.refresh_progress_bar_colors);
header.setColorSchemeColors(colors);
header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
header.setPadding(0, PtrLocalDisplay.dp2px(15), 0, PtrLocalDisplay.dp2px(10));
header.setPtrFrameLayout(mPtrFrameLayout);
mPtrFrameLayout.setDurationToCloseHeader(500);
mPtrFrameLayout.setDurationToClose(500);
mPtrFrameLayout.setHeaderView(header);
mPtrFrameLayout.addPtrUIHandler(header);
mPtrFrameLayout.setEnabledNextPtrAtOnce(false);
// mPtrFrameLayout.setKeepHeaderWhenRefresh(true);
//设置下拉刷新阻尼系数,越小越容易触发下拉刷新
mPtrFrameLayout.setResistance(1.5f);
mPtrFrameLayout.setRatioOfHeaderHeightToRefresh(1.2f);
}
// default enable load more listener
public void setLayoutManager(RecyclerView.LayoutManager layout) {
setLayoutManager(layout, true);
}
public void setLayoutManager(RecyclerView.LayoutManager layout, boolean enableLoadMore) {
mRecyclerView.setLayoutManager(layout);
if (layout instanceof LinearLayoutManager) {
if (enableLoadMore) {
setLinearLayoutOnScrollListener((LinearLayoutManager) layout);
}
setPtrHandler();
setGridLayoutManager(layout);
} else if (layout instanceof StaggeredGridLayoutManager) {
if (enableLoadMore) {
setStaggeredGridOnScrollListener((StaggeredGridLayoutManager) layout);
}
setPtrHandler();
} else {
Log.e(TAG, "only support LinearLayoutManager and StaggeredGridLayoutManager");
}
}
private void setStaggeredGridOnScrollListener(StaggeredGridLayoutManager layoutManager) {
mOnScrollListener = new StaggeredGridWithRecyclerOnScrollListener(layoutManager) {
@Override
public void onLoadMore(int pagination, int pageSize) {
if (mRecyclerViewListener != null) {
mRecyclerViewListener.onLoadMore(pagination, pageSize);
}
}
public boolean checkCanDoRefresh() {
//todo < api 14
//return !mRecyclerView.canScrollVertically(-1);
if (android.os.Build.VERSION.SDK_INT < 14) {
return !(ViewCompat.canScrollVertically(mRecyclerView, -1) || mRecyclerView.getScrollY() > 0);
} else {
return !ViewCompat.canScrollVertically(mRecyclerView, -1);
}
}
};
mRecyclerView.addOnScrollListener(mOnScrollListener);
}
private void setLinearLayoutOnScrollListener(LinearLayoutManager layoutManager) {
mOnScrollListener = new LinearLayoutWithRecyclerOnScrollListener(layoutManager) {
@Override
public void onLoadMore(int pagination, int pageSize) {
if (mRecyclerViewListener != null) {
mRecyclerViewListener.onLoadMore(pagination, pageSize);
}
}
};
mRecyclerView.addOnScrollListener(mOnScrollListener);
}
private void setPtrHandler() {
mPtrFrameLayout.setPtrHandler(new TouchPtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
// return super.checkCanDoRefresh(frame, content, header);
return mOnScrollListener.checkCanDoRefresh();
}
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
mOnScrollListener.setPagination(1);//恢复第一页
if (mRecyclerViewListener != null) {
mRecyclerViewListener.onRefresh();
}
}
});
// mPtrFrameLayout.setPtrHandler(new PtrHandler() {
// @Override
// public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
// //暂时改为永远返回true,因为mOnScrollListener.checkCanDoRefresh()还没有搞明白
//// return true;
//// ScallY = content.getScrollY();
//// MoveY = content.getY();
//// LogUtils.e("ScallY:" + ScallY + "MoveY:" + MoveY);
//
//// if (ScallY > 20) {
// return mOnScrollListener.checkCanDoRefresh();
//// } else {
//// return false;
//// }
// }
//
// @Override
// public void onRefreshBegin(PtrFrameLayout frame) {
// mOnScrollListener.setPagination(1);//恢复第一页
// if (mRecyclerViewListener != null) {
// mRecyclerViewListener.onRefresh();
// }
// }
// });
// }
}
private void setGridLayoutManager(RecyclerView.LayoutManager layout) {
if (layout instanceof GridLayoutManager) {
GridLayoutManager.SpanSizeLookup lookup = ((GridLayoutManager) layout).getSpanSizeLookup();
//if user not define, it,s DefaultSpanSizeLookup, then custom it.
if (lookup instanceof GridLayoutManager.DefaultSpanSizeLookup) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layout;
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (mAdapter.isContentView(position)) {
return 1;
} else {
//full line
return gridLayoutManager.getSpanCount();//number of columns of the grid
}
}
});
}
}
}
//about adapterRecyclerView
public void addItemDecoration(RecyclerView.ItemDecoration decor) {
mRecyclerView.addItemDecoration(decor, -1);
}
public void addItemDecoration(RecyclerView.ItemDecoration decor, int index) {
mRecyclerView.addItemDecoration(decor, index);
}
public void setRecyclerViewPadding(int left, int top, int right, int bottom) {
mRecyclerView.setPadding(left, top, right, bottom);
}
public void setRecyclerViewClipToPadding(boolean clipToPadding) {
mRecyclerView.setClipToPadding(clipToPadding);
}
//about adapter
public void setAdapter(BaseWrapperRecyclerAdapter adapter) {
this.mAdapter = adapter;
mRecyclerView.setAdapter(adapter);
}
//about refresh
public void refreshComplete() {
mPtrFrameLayout.refreshComplete();
}
public void autoRefresh() {
autoRefresh(true, 1000);
}
public void autoRefresh(boolean atOnce) {
autoRefresh(atOnce, 1000);
}
public void autoRefresh(boolean atOnce, int duration) {
mPtrFrameLayout.autoRefresh(atOnce, duration);
}
//about load more
public void setPageSize(int pageSize) {
mOnScrollListener.setPageSize(pageSize);
mOnScrollListener.setPagination(pageSize);
}
public void setPagination(int pagination) {
mOnScrollListener.setPagination(pagination);
}
public void disableRefresh() {
mPtrFrameLayout.setEnabled(false);
}
public void enableRefresh() {
mPtrFrameLayout.setEnabled(true);
}
public void disableLoadMore() {
if (mOnScrollListener == null) {
throw new IllegalArgumentException("mOnScrollListener is null, this method could only be called after setLayoutManager(layout, true)");
} else {
mOnScrollListener.setLoadMoreEnable(false);
}
}
public void enableLoadMore() {
if (mOnScrollListener == null) {
throw new IllegalArgumentException("mOnScrollListener is null, this method could only be called after setLayoutManager(layout, true)");
} else {
mOnScrollListener.setLoadMoreEnable(true);
}
}
public void loadMoreComplete() {
if (mOnScrollListener != null) {
mOnScrollListener.loadComplete();
}
}
public void showLoadMoreView() {
mAdapter.showLoadMoreView();
}
public void showNoMoreDataView() {
mAdapter.showNoMoreDataView();
}
public void hideFooterView() {
mAdapter.hideFooterView();
}
public RecyclerView getRecyclerView() {
return mRecyclerView;
}
public PtrFrameLayout getPtrFrameLayout() {
return mPtrFrameLayout;
}
public void setRecyclerViewListener(RefreshRecyclerViewListener recyclerViewListener) {
this.mRecyclerViewListener = recyclerViewListener;
}
public RefreshRecyclerViewListener getRecyclerViewListener() {
return mRecyclerViewListener;
}
public void smoothScrollToPosition() {
// mRecyclerView.smoothScrollToPosition(0);
mRecyclerView.scrollTo(0,0);
}
}
|
package by.epam.module1.part2;
import java.util.Scanner;
/*
Найти max{min(a, b), min(c, d)}.
*/
public class BranchingTask2 {
public static void main(String[] args) {
double a;
double b;
double c;
double d;
double result;
a = readDouble("a >> ");
b = readDouble("b >> ");
c = readDouble("c >> ");
d = readDouble("d >> ");
result = Math.max(Math.min(a, b), Math.min(c, d));
System.out.println("max{min(a, b), min(c, d)} = " + result);
}
public static double readDouble(String message) {
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
double number;
do {
System.out.println(message);
while (!scan.hasNextDouble()) {
scan.nextLine();
System.out.println(message);
}
number = scan.nextDouble();
} while (!сheckDoubleValidation(number));
return number;
}
public static boolean сheckDoubleValidation(double value) {
if (value > Double.MAX_VALUE || value < -Double.MAX_VALUE) {
System.out.println("The value is out of range for double.");
return false;
}
return true;
}
}
|
package com.labforward.frequency.webservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.labforward.frequency.dto.ResponseDTO;
import com.labforward.frequency.service.NoteBookService;
@RestController
@RequestMapping
public class NoteBookWebService {
@Autowired
NoteBookService noteBookservice;
/**
* web service to get the Frenquency And Words Similar
*
* @param word
* @param fileName
* @return
* @throws Exception
*/
@GetMapping("/frequency")
public ResponseDTO getFrenquencyAndWordSimilar(@RequestParam(value = "word") String word,
@RequestParam(value = "fileName") String fileName) throws Exception {
return noteBookservice.getFrenquencyAndWordSimilar(word, fileName);
}
}
|
package net.trejj.talk.Variables;
/** Created by AwsmCreators * */
public class Variables {
//Setup google play billing details
//public static String licence_key ="playstore public key";
//public static String MERCHANT_ID = "your playstore merchant key";
//Setup google pay(tez) upi payment id for indian users only
//public static String UPI_ID ="yourupi@okaxis";
//public static String UPI_NAME = "Your upi name";
//enable or disable UPI //True to Enable, False to Disable
//public static Boolean ENABLE_UPI = true;
//set your own welcome credits // Do not put number alone/ for example if u want to give 100 credits, make it 100.0
//or if you want to set 0 , make it 0.0 ==== otherwise app will crash
public static Double WELCOME_CREDITS = 10.0;
//minimum credits need to make a call
public static Double MINIMUM_CREDITS = 200.0;
//Minimum call rate if somehow system undetected the country code
public static Double MINIMUM_CALL_RATE = 1200.0;
//Setup credit packs
public static Integer SMALL_PACK_CREDITS = 5000;
public static Integer MEDIUM_PACK_CREDITS = 20000;
public static Integer BIG_PACK_CREDITS = 60000;
//setup pack names
//public static String SMALL_PACK_NAME = "Mini pack";
// public static String MEDIUM_PACK_NAME = "Smart pack";
//public static String BIG_PACK_NAME = "Big bundle";
//SETUP PACKAGE COST FOR (UPI) INDIAN USERS (INR) Indian rupee
//public static Integer SMALL_PACK_COST = 1;//INR
//public static Integer MEDIUM_PACK_COST = 100;//INR
//public static Integer BIG_PACK_COST = 300;//INR
}
|
package soumyavn.store.SalesTax.catalog;
import java.math.BigDecimal;
public interface Imported {
String DUTY_VALUE="0.05";
BigDecimal DUTY=new BigDecimal(DUTY_VALUE);
BigDecimal calcDuty();
}
|
package edu.progmatic.messageapp.services;
import edu.progmatic.messageapp.dto.CreateMsgDto;
import edu.progmatic.messageapp.dto.MessageRepDTO;
import edu.progmatic.messageapp.exceptions.MessageNotFoundException;
import edu.progmatic.messageapp.modell.Message;
import edu.progmatic.messageapp.modell.Message_;
import edu.progmatic.messageapp.modell.Topic;
import edu.progmatic.messageapp.modell.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.*;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class MessageService {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageService.class);
@PersistenceContext
EntityManager em;
/*private List<Message> messages = new ArrayList<>();
{
messages.add(new Message("Aladár", "Mz/x jelkezz", LocalDateTime.now()));
messages.add(new Message("Kriszta", "Bemutatom lüke Aladárt", LocalDateTime.now()));
messages.add(new Message("Blöki", "Vauvau", LocalDateTime.now()));
messages.add(new Message("Maffia", "Miau", LocalDateTime.now()));
messages.add(new Message("Aladár", "Kapcs/ford", LocalDateTime.now()));
messages.add(new Message("Aladár", "Adj pénzt", LocalDateTime.now()));
}
*/
@Transactional
public List<Message> filterMessage(Long id, String author, String text, LocalDateTime from, LocalDateTime to,
String orderby, String order, Integer limit, boolean isDeleted, Topic topic) {
/*List<Message> messages = em.createQuery(
"SELECT m FROM Message m", Message.class)
.getResultList();
*/
/*CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Message> messageCriteriaQuery = cb.createQuery(Message.class);
Root<Message> messageFrom = messageCriteriaQuery.from(Message.class);
messageCriteriaQuery.select(messageFrom);
List<Message> messages = em.createQuery(messageCriteriaQuery).getResultList();
*/
LOGGER.info("filterMessages method started");
LOGGER.debug("id: {}, author: {}, text: {}", id, author, text);
//Comparator<Message> messageComparator = Comparator.comparing(Message::getCreationDate);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Message> msgQuery = cb.createQuery(Message.class);
Root<Message> msgRoot = msgQuery.from(Message.class);
List<Predicate> predicates = new ArrayList<>();
if (from != null) {
predicates.add(cb.greaterThan(msgRoot.get(Message_.creationDate), from));
}
if (to != null){
predicates.add(cb.lessThan(msgRoot.get(Message_.creationDate), to));
}
if (!StringUtils.isEmpty(author)) {
predicates.add(cb.equal(msgRoot.get(Message_.author), author));
}
if (!StringUtils.isEmpty(text)) {
predicates.add(cb.equal(msgRoot.get(Message_.text), text));
}
if (id != null) {
predicates.add(cb.equal(msgRoot.get(Message_.id), id));
}
if (!isDeleted) {
predicates.add(cb.equal(msgRoot.get(Message_.isDeleted), isDeleted));
}
msgQuery.select(msgRoot).where(predicates.toArray(new Predicate[0]));
LOGGER.debug("filterMessages method started");
Expression orderByExpression =null;
switch (orderby) {
case "text":
//messageComparator = Comparator.comparing(Message::getText);
orderByExpression = msgRoot.get(Message_.text);
break;
case "author":
//messageComparator = Comparator.comparing(m -> m.getAuthor().getUsername());
orderByExpression = msgRoot.get(Message_.author);
break;
case"isDeleted":
if (SecurityContextHolder.getContext().getAuthentication().getAuthorities().contains
(new SimpleGrantedAuthority("ROLE_ADMIN"))) {
//messageComparator = Comparator.comparing(Message::isDeleted);
orderByExpression = msgRoot.get(Message_.IS_DELETED);
}
break;
default:
//messageComparator = Comparator.comparing(Message::getId);
orderByExpression = msgRoot.get(Message_.id);
break;
}
if (order.equals("desc")) {
//messageComparator.reversed();
msgQuery.orderBy(
cb.desc(orderByExpression));
} else {
msgQuery.orderBy(cb.asc(orderByExpression));
}
/*List<Message> msgs = messages.stream()
.filter(m -> id == null || m.getId().equals(id))
.filter(m -> StringUtils.isEmpty(author) || m.getAuthor().getUsername().contains(author))
.filter(m -> StringUtils.isEmpty(text) || m.getText().contains(text))
.filter(m -> from == null || m.getCreationDate().isAfter(from))
.filter(m -> to == null || m.getCreationDate().isBefore(to))
.filter(m -> !isDeleted || m.isDeleted())
.sorted(messageComparator)
.limit(limit).collect(Collectors.toList());
return msgs;
*/
return em.createQuery(msgQuery).getResultList();
}
public Message getMessage(Long msgId) {
//Optional<Message> message = messages.stream().filter(m -> m.getId().equals(msgId)).findFirst();
Message message = em.find(Message.class, msgId);
if (message == null) {
throw new MessageNotFoundException();
} else {
return message;
}
}
/*@Transactional
public void createMessage(Message m) {
//m.setId((long) messages.size());
String loggedInUserName = SecurityContextHolder.getContext().getAuthentication().getName();
m.setAuthor(loggedInUserName);
m.setCreationDate(LocalDateTime.now());
em.persist(m);
//messages.add(m);
}
*/
@Transactional
public Message addMessage(CreateMsgDto message) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Message newMessage = new Message();
Topic newTopic = new Topic();
newTopic.setTopicId(message.getTopicId());
newMessage.setText(message.getText());
newMessage.setAuthor(user);
newMessage.setCreationDate(LocalDateTime.now());
newMessage.setTopic(newTopic);
//messages.add(message);
em.persist(newMessage);
em.refresh(newMessage); //Kell, hogy legyen topic.author
return newMessage;
}
@Transactional
public void getMessageToModify(long msgId, String newText, Long sleep) {
Message message = em.find(Message.class, msgId);
message.setText(newText);
if(sleep != null){
try {
Thread.sleep(sleep);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public int getNumOfMsg() {
return (int) em.createQuery("SELECT count(m) from Message m").getSingleResult();
}
@PreAuthorize("hasRole('ADMIN')")
@Transactional
public void deleteMessage(long msgId) {
//messages.remove(message);
//messages.removeIf()
Message message = getMessage(msgId);
// ezzel is működik -- Message message1 = em.find(Message.class, msgId);
/*if (message != null) {
return false;
} else {
return true;
}
*/
message.setDeleted(true);
}
public List<MessageRepDTO> messageList() {
List<Message> msgs = em.createQuery("select m from Message m", Message.class).getResultList();
List<MessageRepDTO> dtoMsgs = new ArrayList<>();
for (Message message : msgs) {
MessageRepDTO dto = new MessageRepDTO();
dto.setAuthor(message.getAuthor().getUserName());
dto.setCreationDate(message.getCreationDate());
dto.setId(message.getId());
dto.setText(message.getText());
dto.setTopic(message.getTopic().getTopicTheme());
dtoMsgs.add(dto);
}
return dtoMsgs;
//return em.createQuery("SELECT t FROM Topic t", Topic.class).getResultList();
//return em.createQuery("SELECT m from Message m", Message.class).getResultList();
}
}
|
package com.tencent.mm.app;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.design.a$i;
import com.tencent.mm.g.a.eu;
import com.tencent.mm.plugin.base.stub.WXBizEntryActivity;
import com.tencent.mm.plugin.base.stub.WXCustomSchemeEntryActivity;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ad;
import com.tencent.mm.sdk.platformtools.bi;
import com.tencent.mm.sdk.platformtools.x;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
class WorkerProfile$8 extends c<eu> {
final /* synthetic */ WorkerProfile bzO;
WorkerProfile$8(WorkerProfile workerProfile) {
this.bzO = workerProfile;
this.sFo = eu.class.getName().hashCode();
}
private static boolean a(eu euVar) {
if (euVar == null) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:event is null.");
return false;
} else if (!(euVar instanceof eu)) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:event is not a instance of ExtCallBizEvent.");
return false;
} else if (euVar.bMx == null) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:event.data is null.");
return false;
} else {
Intent intent;
switch (euVar.bMx.op) {
case a$i.AppCompatTheme_actionModeStyle /*27*/:
if (euVar.bMx.selectionArgs == null || euVar.bMx.selectionArgs.length < 2) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent selectionArgs error.");
return true;
}
Object encode;
String str = "";
Object obj = euVar.bMx.selectionArgs[0];
String str2 = euVar.bMx.selectionArgs[1];
if (euVar.bMx.selectionArgs.length >= 3) {
Object oV = bi.oV(euVar.bMx.selectionArgs[2]);
try {
encode = URLEncoder.encode(oV, "UTF-8");
} catch (UnsupportedEncodingException e) {
encode = oV;
}
} else {
String encode2 = str;
}
if (obj == null || str2 == null) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent wrong args, %s, %s", new Object[]{obj, str2});
return true;
}
int i;
if (euVar.bMx.selectionArgs.length >= 4) {
str = euVar.bMx.selectionArgs[3];
if (!bi.oW(str)) {
i = bi.getInt(str, 0);
x.i("MicroMsg.WorkerProfile", "ExtCallBizEvent jump biz tempSession");
str = String.format("weixin://dl/business/tempsession/?username=%s&appid=%s&sessionFrom=%s&showtype=%s&scene=%s", new Object[]{str2, obj, encode2, Integer.valueOf(i), Integer.valueOf(0)});
intent = new Intent(euVar.bMx.context, WXCustomSchemeEntryActivity.class);
intent.addFlags(268435456);
intent.setData(Uri.parse(str));
intent.putExtra("translate_link_scene", 1);
euVar.bMx.context.startActivity(intent);
return true;
}
}
i = 0;
x.i("MicroMsg.WorkerProfile", "ExtCallBizEvent jump biz tempSession");
str = String.format("weixin://dl/business/tempsession/?username=%s&appid=%s&sessionFrom=%s&showtype=%s&scene=%s", new Object[]{str2, obj, encode2, Integer.valueOf(i), Integer.valueOf(0)});
intent = new Intent(euVar.bMx.context, WXCustomSchemeEntryActivity.class);
intent.addFlags(268435456);
intent.setData(Uri.parse(str));
intent.putExtra("translate_link_scene", 1);
euVar.bMx.context.startActivity(intent);
return true;
case a$i.AppCompatTheme_actionModeCloseButtonStyle /*28*/:
x.i("MicroMsg.WorkerProfile", "ExtCallBizEvent open exdevice rank list.");
Context context = euVar.bMx.context;
intent = new Intent(context, WXBizEntryActivity.class);
intent.addFlags(268435456);
intent.putExtra("key_command_id", 11);
context.startActivity(intent);
return true;
default:
return a(euVar.bMx.context, euVar.bMx.selectionArgs, euVar.bMx.bGj, euVar.bMx.source, euVar.bMx.bMy);
}
}
}
private static boolean a(Context context, String[] strArr, String[] strArr2, int i, String str) {
if (context == null) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:context is null.");
context = ad.getContext();
}
if (strArr == null || strArr.length < 2) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:args error.");
return false;
}
int i2;
int length = strArr.length;
for (i2 = 0; i2 < length; i2++) {
x.i("MicroMsg.WorkerProfile", "arg : %s", new Object[]{strArr[i2]});
}
String str2 = strArr[0];
String str3 = strArr[1];
String str4 = null;
if (strArr.length > 2) {
str4 = strArr[2];
}
length = 0;
if (strArr.length > 3) {
length = bi.getInt(strArr[3], 0);
}
int i3 = 0;
if (strArr.length > 4) {
i3 = bi.getInt(strArr[4], 0);
}
x.i("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:source(%d)", new Object[]{Integer.valueOf(i)});
switch (i) {
case 1:
if (strArr2 == null || strArr2.length == 0) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:packageNames is null or nil.");
return false;
}
case 2:
if (bi.oW(str)) {
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:fromURL(%s) is null or nil.", new Object[]{str});
return false;
}
break;
default:
x.e("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener:source is out of range.");
return false;
}
x.i("MicroMsg.WorkerProfile", "ExtCallBizEvent IListener: appId(%s), toUserName(%s), extInfo(%s), fromURL(%s)", new Object[]{str2, str3, str4, str});
if (bi.oW(str2) || bi.oW(str3)) {
x.e("MicroMsg.WorkerProfile", "appId or toUsername is null or nil.");
return false;
}
int i4 = 0;
if (length == 1) {
i4 = 8;
} else if (length == 0) {
i4 = 7;
}
Intent intent = new Intent(context, WXBizEntryActivity.class);
intent.putExtra("key_command_id", i4);
intent.putExtra("appId", str2);
intent.putExtra("toUserName", str3);
intent.putExtra("extInfo", str4);
intent.putExtra("source", i);
intent.putExtra("scene", length);
intent.putExtra("jump_profile_type", i3);
intent.addFlags(268435456).addFlags(67108864);
if (strArr2 != null && strArr2.length > 0) {
ArrayList arrayList = new ArrayList();
for (Object add : strArr2) {
arrayList.add(add);
}
intent.putStringArrayListExtra("androidPackNameList", arrayList);
}
context.startActivity(intent);
return true;
}
}
|
package com.example.neelpatel.demonstration;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by Neel Patel on 11/25/2017.
*/
public class UserRatingAdapter extends RecyclerView.Adapter<UserRatingAdapter.UserRatingViewHolder>{
private ArrayList<String> ratings;
private int rowLayout;
public static class UserRatingViewHolder extends RecyclerView.ViewHolder {
TextView rating;
public UserRatingViewHolder(View v) {
super(v);
rating = (TextView) v.findViewById(R.id.textView15);
}
}
public UserRatingAdapter(ArrayList<String> ratings, int rowLayout) {
this.ratings = ratings;
this.rowLayout = rowLayout;
}
@Override
public UserRatingAdapter.UserRatingViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
return new UserRatingAdapter.UserRatingViewHolder(view);
}
@Override
public void onBindViewHolder(UserRatingViewHolder holder, int position) {
holder.rating.setText(ratings.get(position));
}
@Override
public int getItemCount() {
return ratings.size();
}
}
|
package com.meihf.mjoyblog.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.meihf.mjoyblog.bean.Catalog;
import com.meihf.mjoyblog.dao.CatalogDao;
import com.meihf.mjoyblog.util.DateUtil;
/**
* @desc添加目录
* @author 梅海风
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"file:WebContent/WEB-INF/spring-servlet.xml"})
public class CatalogUnit {
@Autowired
private CatalogDao catalogDao;
@Autowired
private MongoTemplate mongoTemplate;
@Test
public void Test(){
mongoTemplate.dropCollection(Catalog.class);
this.Init();
System.out.println(catalogDao.queryList(new Query()).size());
}
public void Init(){
Catalog catalog = new Catalog();
catalog.setCatalogId("你好今天");
catalog.setCatalogPath("/MJoyBlog/main/hello/today");
catalog.setPermission((short) 1);
catalog.setState((short) 1);
catalog.setCreateDate(DateUtil.getCurrDate());
catalog.setCategories("你好");
catalog.setloginName("meihf2");;
Catalog catalog1 = new Catalog();
catalog1.setCatalogId("你好明天");
catalog1.setCategories("你好");
catalog1.setCatalogPath("/MJoyBlog/main/hello/tomorrow");
catalog1.setPermission((short) 3);
catalog1.setState((short) 3);
catalog1.setCreateDate(DateUtil.getCurrDate());
catalog1.setloginName("meihf2");;
Catalog catalog2 = new Catalog();
catalog2.setCatalogId("你好后天");
catalog2.setCategories("你好");
catalog2.setCatalogPath("/MJoyBlog/main/hello/tdat");
catalog2.setPermission((short) 2);
catalog2.setState((short) 2);
catalog2.setCreateDate(DateUtil.getCurrDate());
catalog2.setloginName("meihf3");;
Catalog catalog3 = new Catalog();
catalog3.setCatalogId("hello今天");
catalog3.setCategories("hellos");
catalog3.setCatalogPath("/MJoyBlog/main/hellos/today");
catalog3.setPermission((short) 4);
catalog3.setState((short) 4);
catalog3.setCreateDate(DateUtil.getCurrDate());
catalog3.setloginName("meihf3");;
Catalog catalog4 = new Catalog();
catalog4.setCatalogId("hello明天");
catalog4.setCategories("hellos");
catalog4.setCatalogPath("/MJoyBlog/main/hellos/tomorrow");
catalog4.setPermission((short) 5);
catalog4.setState((short) 5);
catalog4.setCreateDate(DateUtil.getCurrDate());
catalog4.setloginName("meihf4");;
Catalog catalog5 = new Catalog();
catalog5.setCatalogId("hello后天");
catalog5.setCategories("hellos");
catalog5.setCatalogPath("/MJoyBlog/main/hellos/tdat");
catalog5.setPermission((short) 6);
catalog5.setState((short) 6);
catalog5.setCreateDate(DateUtil.getCurrDate());
catalog5.setloginName("meihf4");
catalogDao.save(catalog1);
catalogDao.save(catalog2);
catalogDao.save(catalog);
catalogDao.save(catalog3);
catalogDao.save(catalog4);
catalogDao.save(catalog5);
}
}
|
package com.tencent.mm.plugin.appbrand.jsapi.f.a;
import com.tencent.mm.plugin.appbrand.compat.a.b.l;
import com.tencent.mm.plugin.appbrand.jsapi.f.a.c.e;
import com.tencent.mm.plugin.appbrand.jsapi.f.a.c.f.a;
class c$7 implements l {
final /* synthetic */ c fTi;
c$7(c cVar) {
this.fTi = cVar;
}
public final void adO() {
for (e eVar : this.fTi.fTa.values()) {
if (eVar.fTx != null && eVar.fTx.fTA != null && eVar.fTx.fTA.fTH == a.fTJ && eVar.fTv.isInfoWindowShown()) {
eVar.fTv.hideInfoWindow();
}
}
if (this.fTi.fSZ != null) {
this.fTi.fSZ.ajg();
}
}
}
|
/*******************************************************************************
* Besiege
* by Kyle Dhillon
* Source Code available under a read-only license. Do not copy, modify, or distribute.
******************************************************************************/
package kyle.game.besiege.army;
import kyle.game.besiege.Faction;
import kyle.game.besiege.Kingdom;
import kyle.game.besiege.Point;
import kyle.game.besiege.location.City;
import kyle.game.besiege.location.Location;
import kyle.game.besiege.location.Village;
import kyle.game.besiege.party.PartyType.Type;
public class Farmer extends Army {
private final String textureRegion = "Farmer";
private final float FARMER_WAIT = 2.5f;
private final float wanderDistance = 60;
private final int farmStart = 7;
private final int farmEnd = 20;
private boolean waitToggle;
private Location location;
public Farmer() {}
public Farmer(Kingdom kingdom, String name, Faction faction,
float posX, float posY) {
super(kingdom, name, faction, posX, posY, Type.FARMERS, null);
// this.shouldEject = false;
this.type = ArmyType.FARMER;
this.passive = true;
}
@Override
public void uniqueAct() {
// if (shouldEject) System.out.println("should eject");
farm();
}
public void resetWaitToggle() {
this.waitToggle = false;
}
// @Override
// public void drawUniqueInfo(SpriteBatch batch, float parentAlpha) {
// Kingdom.arial.draw(batch, "Farming around " + village.getName(), getX(), getY() - getOffset()*getKingdom().getZoom());
// }
@Override
public String getUniqueAction() {
return "Farming";
}
@Override
public void garrisonAct(float delta) {
// shouldStopRunning();
detectNearby();
if (farmTime() && shouldStopRunning() && canEject()) {
//System.out.println("ejecting " + this.getName());
// double check to see if fixes problem
// detectNearby();
// if (shouldStopRunning())
setNewFarmDest();
}
// else System.out.println(runFrom.getName());
}
/** return true if time to farm, false otherwise
*
* @return
*/
private boolean farmTime() {
return getKingdom().getTime() >= farmStart && getKingdom().getTime() <= farmEnd;
}
public void farm() {
if (isRunning()) throw new AssertionError();
if (farmTime()) {
if (this.isGarrisoned()) eject();
if (!this.hasTarget()) {
if (waitToggle) {
this.waitFor(FARMER_WAIT);
// System.out.println("waiting for " + FARMER_WAIT);
waitToggle = false;
}
else {
setNewFarmDest();
waitToggle = true;
}
}
else {
path.travel();
}
}
else {
if (this.getTarget() != location) setTarget(location);
}
}
private void setNewFarmDest() {
Point newTarget;
int count = 0;
do {
float dx = (float) ((Math.random()*2-1)*wanderDistance); //number btw -1 and 1
float dy = (float) ((Math.random()*2-1)*wanderDistance);
newTarget = new Point(location.getCenterX() + dx, location.getCenterY() + dy);
count++;
}
while (getKingdom().getMap().isInWater(newTarget) && count < 10); // do this until sets a valid target
if (count == 10) {
if (location == null) throw new AssertionError();
setTarget(location);
System.out.println("farmer just searched for 10 targets and couldn't find valid");
}
else {
setTarget(newTarget);
}
if (!hasTarget()) throw new AssertionError();
}
public void setLocation(Location location) {
this.location = location;
// if (getKingdom().night)
// Start garrisoned for efficiency.
this.garrisonIn(location);
}
// farmers can garrison in villages
// @Override
// public Location detectNearbyFriendlyLocationForRunning() {
// for (City city : getKingdom().getCities()) {
// if (!isAtWar(city)) {
// double dist = this.distToCenter(city);
// if (dist < getLineOfSight() && dist < getRunFrom().distToCenter(city)) {
// return city;
// }
// }
// }
// for (Village village : getKingdom().villages) {
// double dist = this.distToCenter(village);
// if (dist < getLineOfSight() && dist < getRunFrom().distToCenter(village)) {
// return village;
// }
// }
// return null;
// }
public Location getLocation() {
return location;
}
@Override
public boolean canHideInVillage() {
return true;
}
@Override
public void destroy() {
getKingdom().removeArmy(this);
this.remove();
getLocation().removeFarmer(this);
}
}
|
/*
* 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 ufes.q_03.builder;
import ufes.q_03.composite.CPU;
import ufes.q_03.composite.Computador;
import ufes.q_03.composite.HardDisk;
import ufes.q_03.composite.Memoria;
import ufes.q_03.composite.PlacaMae;
/**
*
* @author Lucas
*/
public class ComputadorBasico extends ComputadorBuilder {
@Override
public void adicionarPecas() {
this.getComputador().adicionarPeca(new PlacaMae("G41-B", 200.50));
this.getComputador().adicionarPeca(new Memoria("ddr3 4GB 1333mhz", 100));
this.getComputador().adicionarPeca(new CPU("Intel core 2 quad Q6600", 10.99));
this.getComputador().adicionarPeca(new HardDisk("Seagate 250GB", 80.90));
}
@Override
public void criarComputador() {
this.setComputador(new Computador("Computador basico OBRABO-1083"));
}
}
|
#include<iostream>
using namespace std;
int main()
{
int rows,columns,no;
cin>>rows>>columns>>no;
int s,sl;
s=rows*2;
sl=rows*(columns-1);
if((no>s-3&&no<=s)||(no>sl-3&&no<=sl))
cout<<"It is a mango tree";
else
cout<<"It is not a mango tree";
//Type your code here.
}
|
package com.thoughtworks.todo_list.handler;
import com.thoughtworks.todo_list.exception.InvalidIdException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
@ControllerAdvice
public class MyExceptionHanlder {
@ExceptionHandler(InvalidIdException.class)
@ResponseBody
@ResponseStatus(HttpStatus.NOT_FOUND)
public String todoNotFound() {
return InvalidIdException.EXCEPTION_MASSAGE;
}
}
|
package org.hisilicon.plugins.copytoslave.fromzookeeper;
import java.io.IOException;
import java.util.List;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooDefs.Ids;
import static org.apache.zookeeper.ZooKeeper.States.CLOSED;
import static org.apache.zookeeper.ZooKeeper.States.CONNECTED;
import org.apache.zookeeper.data.Stat;
/**
*
* @author y00349282
*/
public class ZookeeperClient {
private ZooKeeper zookeeperClient;
private static final int SESSION_TIMEOUT = 2000;
private final Watcher watcher = new Watcher() {
public void process(WatchedEvent event) {
}
};
/**
* connect the zookeeper
* @param zookeeperAddress
* @throws IOException
* <br>------------------------------<br>
*/
public void connect(String zookeeperAddress) throws IOException {
zookeeperClient = new ZooKeeper(zookeeperAddress, SESSION_TIMEOUT, watcher);
}
/**
* close the session
* @throws java.lang.InterruptedException
* <br>------------------------------<br>
*/
public void close() throws InterruptedException {
zookeeperClient.close();
}
/**
* createEphemeralNode
* @param nodePath
* @param nodeContent
* @throws org.apache.zookeeper.KeeperException
* @throws java.lang.InterruptedException
* <br>------------------------------<br>
*/
public void createEphemeralNode(String nodePath,String nodeContent) throws KeeperException, InterruptedException {
zookeeperClient.create(nodePath, nodeContent.getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
}
/**
* getNodeData
* @param nodePath
* @return the content fo node
* @throws org.apache.zookeeper.KeeperException
* @throws java.lang.InterruptedException
* <br>------------------------------<br>
*/
public String getNodeData(String nodePath) throws KeeperException, InterruptedException {
String result = null;
byte[] bytes = zookeeperClient.getData(nodePath, null, null);
if(bytes != null){
result = new String(bytes);
}
return result;
}
/**
* getAllChildNode
* @param nodePath
* @return all the child node on the nodePath
* @throws org.apache.zookeeper.KeeperException
* @throws java.lang.InterruptedException
* <br>------------------------------<br>
*/
public List<String> getAllChildNode(String nodePath) throws KeeperException, InterruptedException {
List<String> list = zookeeperClient.getChildren(nodePath, true);
return list;
}
/**
* nodeIsExists
* @param nodePath
* @return
* @throws org.apache.zookeeper.KeeperException
* @throws java.lang.InterruptedException
* <br>------------------------------<br>
*/
public boolean nodeIsExists(String nodePath) throws KeeperException, InterruptedException {
Stat stat = zookeeperClient.exists(nodePath, false);
return stat!=null;
}
/**
* getSessionId
* @return
* <br>------------------------------<br>
*/
public long getSessionId(){
return zookeeperClient.getSessionId();
}
/**
* isSessionClosed
* @return
* <br>------------------------------<br>
*/
public boolean isSessionClosed(){
if(zookeeperClient.getState()==CLOSED){
return true;
}else{
return false;
}
}
/**
* isSessionConnected
* @return
* <br>------------------------------<br>
*/
public boolean isSessionConnected(){
if(zookeeperClient.getState()==CONNECTED){
return true;
}else{
return false;
}
}
}
|
/* *****************************************************************************
* Name: Alan Turing
* Coursera User ID: 123456
* Last modified: 1/1/2019
**************************************************************************** */
public class Huntingtons {
public static int maxRepeats(String dna) {
int j = 0;
int i = 0;
int[] a = new int[(dna.length() / 2)];
int k = (dna.indexOf("CAG"));
int index = k;
a[0] = dna.indexOf("CAG");
while (j < dna.length() && dna.indexOf("CAG", k + 1) != -1) {
i = i + 1;
k = dna.indexOf("CAG", k + 1);
a[i] = k;
j = j + 1;
}
int x = 0;
int flag = 1;
int max = 0;
while (x < a.length) {
while (a[x + 1] == a[x] + 3) {
flag += 1;
x = x + 1;
}
if (flag >= max) {
max = flag;
}
if (a[x + 1] == a[x]) {
break;
}
flag = 1;
x = x + 1;
}
if (index == -1) {
return 0;
}
return max;
}
public static String removeWhitespace(String s) {
String a = s.replace(" ", "");
a = a.replace("\n", "");
a = a.replace("\t", "");
return a;
}
public static String diagnose(int maxRepeats) {
if (maxRepeats >= 0 && maxRepeats <= 9) {
return "not human";
}
else if (maxRepeats >= 10 && maxRepeats <= 35) {
return "normal";
}
else if (maxRepeats >= 36 && maxRepeats <= 39) {
return "high risk";
}
else if (maxRepeats >= 40 && maxRepeats <= 180) {
return "Huntington's";
}
else {
return "not human";
}
}
public static void main(String[] args) {
String name = args[0];
String d = "";
//System.out.println("shivam");
In in = new In(name);
while (!in.isEmpty()) {
d = in.readAll();
}
String a = removeWhitespace(d);
System.out.println("max repeats = " + maxRepeats(a));
System.out.println(diagnose(maxRepeats(a)));
}
}
|
/*
* Copyright (C) 2015 Miquel Sas
*
* 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 com.qtplaf.library.trading.data;
import java.util.Locale;
import com.qtplaf.library.util.TextServer;
/**
* Units used to define periods of aggregate incoming quotes.
*
* @author Miquel Sas
*/
public enum Unit {
Millisecond("MS"),
Second("SC"),
Minute("MN"),
Hour("HR"),
Day("DY"),
Week("WK"),
Month("MT"),
Year("YR");
/**
* Returns the unit of the given id.
*
* @param id The unit id.
* @return The unit.
*/
public static Unit parseId(String id) {
Unit[] units = values();
for (Unit unit : units) {
if (unit.getId().equals(id.toUpperCase())) {
return unit;
}
}
throw new IllegalArgumentException("Invalid unit id: " + id);
}
/** 2 char id. */
private String id;
/**
* Constructor.
*
* @param id Two char id.
*/
private Unit(String id) {
this.id = id;
}
/**
* Returns the two char id.
*
* @return The id.
*/
public String getId() {
return id;
}
/**
* Returns the short description.
*
* @return The short description.
*/
public String getShortDescription() {
switch (this) {
case Millisecond:
return TextServer.getString("tradeUnitMillisecondDescription", Locale.UK);
case Second:
return TextServer.getString("tradeUnitSecondDescription", Locale.UK);
case Minute:
return TextServer.getString("tradeUnitMinuteDescription", Locale.UK);
case Hour:
return TextServer.getString("tradeUnitHourDescription", Locale.UK);
case Day:
return TextServer.getString("tradeUnitDayDescription", Locale.UK);
case Week:
return TextServer.getString("tradeUnitWeekDescription", Locale.UK);
case Month:
return TextServer.getString("tradeUnitMonthDescription", Locale.UK);
case Year:
return TextServer.getString("tradeUnitYearDescription", Locale.UK);
default:
throw new IllegalArgumentException();
}
}
}
|
/**
*
*/
package org.devapriya.shoppingbasket;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
/**
* This class define all the methods related to filling shopping basket
* @author dbherath
*
*/
public class ShoppingBasket {
private ArrayList<Item> basket;
/**
* @param categoryList
*/
public ShoppingBasket() {
super();
this.basket = new ArrayList<Item>();
}
/**
* This function will return all the items
* @return
*/
protected ArrayList<Item> getItemList(){
return this.basket;
}
/**
* This function will return existing item from the shopping basket
* @param itemId
* @return
*/
protected Item getItem(int itemId) {
return this.basket.stream().filter(item -> item.getItemId()==itemId).findFirst().orElse(null);
}
/**
* This function will be adding new items to shopping basket
* @param item
*/
protected void addItem(Item item) {
this.basket.add(item);
}
/**
* Method to get total cost of picked items in the shopping basket
* @return total cost of the items
*/
public BigDecimal getTotalCostOfShoppingBasket() {
BigDecimal totalCostOfBasket = new BigDecimal(0.00);
for (Item item:this.basket) {
totalCostOfBasket = totalCostOfBasket.add(item.getTotalCost());
}
return totalCostOfBasket;
}
/**
* Method to get the sum of ratings in the shopping basket
* @return sum of ratings of the items in basket
*/
public int getSumOfRatingsOfPickedItems() {
int sumOfRatings = 0;
for (Item item:this.basket) {
sumOfRatings += item.getRating();
}
return sumOfRatings;
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
for (Item item:this.basket) {
result.append(item.toString()).append("\n");
}
return result.toString();
}
}
|
public class CTest
{
public static void main(String[] args) {
int [] x ={23, 55, 83, 19};
int [] y ={36, 78, 12, 24};
x =y;
y=x;
System.out.println(x);
System.out.println(y);
}
}
|
package view;
import global.StringOps;
import graphana.MainControl;
import graphana.operationsystem.Operation;
import scriptinterface.SignatureInterface;
import view.argumentcomponents.ArgumentComponentManager;
import java.awt.*;
import java.util.LinkedList;
/**
* Handles automatic completion of operation calls etc.
*
* @author Andreas Fender
*/
public class AutoCompletion {
private static final char[] WHITE_SPACES = {' ', '\t', '\n', '\r'};
private static final char[] NON_WORDS = {' ', '\t', '\n', '\r', '+', '-', '*', '/', '#', '"', '\'', ';', ',',
'!', '?', '$', '{', '}', '(', ')', '=', '\\', '>', '<', '|', '%', '&', '^', '~'};
private MainControl mainControl;
private int lastCompletionPos;
public AutoCompletion(MainControl mainControl) {
this.mainControl = mainControl;
}
private static boolean isWhiteSpace(char character) {
return StringOps.charContained(character, WHITE_SPACES);
}
private static boolean isNonLetter(char character) {
return StringOps.charContained(character, NON_WORDS);
}
private static boolean isLetter(char character) {
return !isNonLetter(character);
}
/**
* Tries to complete the given String at the given location or opens the call assistant, if the position is
* located within the call.
*
* @param string the string to complete
* @param position the position at where to complete the string. Completion will be inserted into
* the given position
* @param argumentComponentManager the component manager for the case that the arguments of the call are completed
* @param parentComponent the component relative to which the component manager (if needed) should be
* placed.
* @return the completed string or the input string, if nothing was there to complete
*/
public String completeStringAt(String string, int position, ArgumentComponentManager argumentComponentManager,
Component parentComponent) {
String word = "";
int startWord = position - 1;
int endWord = position;
char c = 0;
while (startWord >= 0 && isLetter(c = string.charAt(startWord))) {
word = c + word;
startWord--;
}
while (endWord < string.length() && isLetter(c = string.charAt(endWord))) {
word = word + c;
endWord++;
}
word = word.trim();
String restString;
if (endWord < string.length()) restString = string.substring(endWord);
else restString = "";
String result = string.substring(0, startWord + 1);
if (word.equals("")) {
//Complete call arguments
if (argumentComponentManager != null) {
while (startWord >= 0 && isWhiteSpace(c = string.charAt(startWord)) && c != '(') startWord--;
if (c == '(') {
while (endWord < string.length() && isWhiteSpace(c = string.charAt(endWord)) && c != ')') endWord++;
if (c == ')') {
int startKey = startWord - 1;
while (startKey >= 0 && isLetter(string.charAt(startKey))) startKey--;
startKey++;
String key = string.substring(startKey, startWord).trim();
Operation operation = mainControl.getOperationSet().getOperation(key);
if (operation != null) {
SignatureInterface signature = operation.getSignature();
String call = argumentComponentManager.openAutoCompleteAssistant(signature,
parentComponent);
if (call != null) result += call;
}
lastCompletionPos = result.length();
}
}
}
} else {
//Complete operation key
String completed = completeString(word);
result += completed;
lastCompletionPos = result.length();
if (mainControl.getOperationSet().hasOperation(completed) && !restString.trim().startsWith("(")) {
result += "()";
lastCompletionPos++;
}
}
result += restString;
if (lastCompletionPos > result.length()) lastCompletionPos = result.length();
return result;
}
/**
* Returns the position of the last character of the inserted string
*/
public int getLastCompletetionPos() {
return lastCompletionPos;
}
/**
* Tries to complete the given word.
*
* @param word the word to complete
* @return the completed word, or the given word, if nothing was completed
*/
public String completeString(String word) {
LinkedList<String> suggestions = getSuggestions(word);
if (suggestions.size() == 1) {
return suggestions.getFirst();
} else if (suggestions.isEmpty()) return word;
else {
String sug = suggestions.getFirst();
int i = word.length();
while (true) {
if (i >= sug.length()) break;
char c = sug.charAt(i);
for (String otherSug : suggestions) {
if (otherSug.length() <= i || otherSug.charAt(i) != c) {
c = 0;
break;
}
}
if (c == 0) break;
i++;
}
return sug.substring(0, i);
}
}
/**
* Returns a list of all possible strings that begin with the given string
*/
public LinkedList<String> getSuggestions(String wordBeginning) {
LinkedList<String> result = new LinkedList<>();
String wordBeginningUpper = wordBeginning.toUpperCase();
for (Operation operation : mainControl.getOperationSet().getOperations()) {
for (String key : operation.getSignature().getKeyArray()) {
if (key.toUpperCase().startsWith(wordBeginningUpper)) {
result.add(key);
}
}
}
return result;
}
}
|
package com.duofei.spi;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Adaptive;
import org.apache.dubbo.common.extension.SPI;
/**
* 服务接口
* @author duofei
* @date 2020/1/14
*/
@SPI
public interface Robot {
void sayHello();
@Adaptive("key")
void showColor(URL url);
}
|
package com.zingoworks.blackjack.domain;
import org.junit.Test;
import static com.zingoworks.blackjack.domain.Hand.BLACKJACK_NUMBER;
import static com.zingoworks.blackjack.domain.HandType.*;
import static com.zingoworks.blackjack.domain.card.CardTest.*;
import static org.assertj.core.api.Java6Assertions.assertThat;
public class HandTest {
public static final Hand BLACKJACK_HAND = new Hand();
public static final Hand BURST_HAND = new Hand();
public static final Hand NORMAL_HAND = new Hand();
static {
BLACKJACK_HAND.receiveCard(ACE_CLUB);
BLACKJACK_HAND.receiveCard(TEN_CLUB);
BURST_HAND.receiveCard(FIVE_CLUB);
BURST_HAND.receiveCard(TEN_CLUB);
BURST_HAND.receiveCard(TEN_CLUB);
NORMAL_HAND.receiveCard(ACE_CLUB);
}
@Test
public void getTotalTest() {
assertThat(BLACKJACK_HAND.getTotal()).isEqualTo(BLACKJACK_NUMBER);
}
@Test
public void getHandTypeTest() {
assertThat(BLACKJACK_HAND.getHandType()).isEqualTo(BLACKJACK);
assertThat(BURST_HAND.getHandType()).isEqualTo(BURST);
assertThat(NORMAL_HAND.getHandType()).isEqualTo(NORMAL);
}
}
|
package lesson3.preIntermediate;
/**
* Created by Angelina on 22.01.2017.
*/
public class Task11 {
public static void main(String[] args) {
Task11 t11 = new Task11();
t11.sequence123check();
}
public void sequence123check(){
System.out.println("Given an array of integer positive numbers. For example, {4, 6, 0, 1, 2, 3, 1, 9}, but it can be any random. Write Java-program which returns True, if sequence {1, 2, 3} appears somewhere in the array. Provide additional boundary checks");
int a;
int[] arr = {1, 6, 3, 1, 6, 5, 7, 1, 2, 3};
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 1) {
if (arr[i+1] == 2){
if(arr[i+2] == 3){
System.out.println("Result - " + true);
}
}
}
}
}
}
|
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser 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 Lesser General Public License for more
* details.
*/
package com.liferay.form.onboarding.service.persistence;
import com.liferay.form.onboarding.model.OBFormFieldMapping;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.util.OrderByComparator;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.util.tracker.ServiceTracker;
/**
* The persistence utility for the ob form field mapping service. This utility wraps <code>com.liferay.form.onboarding.service.persistence.impl.OBFormFieldMappingPersistenceImpl</code> and provides direct access to the database for CRUD operations. This utility should only be used by the service layer, as it must operate within a transaction. Never access this utility in a JSP, controller, model, or other front-end class.
*
* <p>
* Caching information and settings can be found in <code>portal.properties</code>
* </p>
*
* @author Evan Thibodeau
* @see OBFormFieldMappingPersistence
* @generated
*/
public class OBFormFieldMappingUtil {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
*/
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#clearCache()
*/
public static void clearCache() {
getPersistence().clearCache();
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#clearCache(com.liferay.portal.kernel.model.BaseModel)
*/
public static void clearCache(OBFormFieldMapping obFormFieldMapping) {
getPersistence().clearCache(obFormFieldMapping);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery)
*/
public static long countWithDynamicQuery(DynamicQuery dynamicQuery) {
return getPersistence().countWithDynamicQuery(dynamicQuery);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#fetchByPrimaryKeys(Set)
*/
public static Map<Serializable, OBFormFieldMapping> fetchByPrimaryKeys(
Set<Serializable> primaryKeys) {
return getPersistence().fetchByPrimaryKeys(primaryKeys);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery)
*/
public static List<OBFormFieldMapping> findWithDynamicQuery(
DynamicQuery dynamicQuery) {
return getPersistence().findWithDynamicQuery(dynamicQuery);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int)
*/
public static List<OBFormFieldMapping> findWithDynamicQuery(
DynamicQuery dynamicQuery, int start, int end) {
return getPersistence().findWithDynamicQuery(dynamicQuery, start, end);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator)
*/
public static List<OBFormFieldMapping> findWithDynamicQuery(
DynamicQuery dynamicQuery, int start, int end,
OrderByComparator<OBFormFieldMapping> orderByComparator) {
return getPersistence().findWithDynamicQuery(
dynamicQuery, start, end, orderByComparator);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#update(com.liferay.portal.kernel.model.BaseModel)
*/
public static OBFormFieldMapping update(
OBFormFieldMapping obFormFieldMapping) {
return getPersistence().update(obFormFieldMapping);
}
/**
* @see com.liferay.portal.kernel.service.persistence.BasePersistence#update(com.liferay.portal.kernel.model.BaseModel, ServiceContext)
*/
public static OBFormFieldMapping update(
OBFormFieldMapping obFormFieldMapping, ServiceContext serviceContext) {
return getPersistence().update(obFormFieldMapping, serviceContext);
}
/**
* Returns all the ob form field mappings where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @return the matching ob form field mappings
*/
public static List<OBFormFieldMapping> findByobFormEntryId(
long obFormEntryId) {
return getPersistence().findByobFormEntryId(obFormEntryId);
}
/**
* Returns a range of all the ob form field mappings where obFormEntryId = ?.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param obFormEntryId the ob form entry ID
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @return the range of matching ob form field mappings
*/
public static List<OBFormFieldMapping> findByobFormEntryId(
long obFormEntryId, int start, int end) {
return getPersistence().findByobFormEntryId(obFormEntryId, start, end);
}
/**
* Returns an ordered range of all the ob form field mappings where obFormEntryId = ?.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param obFormEntryId the ob form entry ID
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @return the ordered range of matching ob form field mappings
*/
public static List<OBFormFieldMapping> findByobFormEntryId(
long obFormEntryId, int start, int end,
OrderByComparator<OBFormFieldMapping> orderByComparator) {
return getPersistence().findByobFormEntryId(
obFormEntryId, start, end, orderByComparator);
}
/**
* Returns an ordered range of all the ob form field mappings where obFormEntryId = ?.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param obFormEntryId the ob form entry ID
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching ob form field mappings
*/
public static List<OBFormFieldMapping> findByobFormEntryId(
long obFormEntryId, int start, int end,
OrderByComparator<OBFormFieldMapping> orderByComparator,
boolean useFinderCache) {
return getPersistence().findByobFormEntryId(
obFormEntryId, start, end, orderByComparator, useFinderCache);
}
/**
* Returns the first ob form field mapping in the ordered set where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching ob form field mapping
* @throws NoSuchFieldMappingException if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping findByobFormEntryId_First(
long obFormEntryId,
OrderByComparator<OBFormFieldMapping> orderByComparator)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().findByobFormEntryId_First(
obFormEntryId, orderByComparator);
}
/**
* Returns the first ob form field mapping in the ordered set where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching ob form field mapping, or <code>null</code> if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping fetchByobFormEntryId_First(
long obFormEntryId,
OrderByComparator<OBFormFieldMapping> orderByComparator) {
return getPersistence().fetchByobFormEntryId_First(
obFormEntryId, orderByComparator);
}
/**
* Returns the last ob form field mapping in the ordered set where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the last matching ob form field mapping
* @throws NoSuchFieldMappingException if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping findByobFormEntryId_Last(
long obFormEntryId,
OrderByComparator<OBFormFieldMapping> orderByComparator)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().findByobFormEntryId_Last(
obFormEntryId, orderByComparator);
}
/**
* Returns the last ob form field mapping in the ordered set where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the last matching ob form field mapping, or <code>null</code> if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping fetchByobFormEntryId_Last(
long obFormEntryId,
OrderByComparator<OBFormFieldMapping> orderByComparator) {
return getPersistence().fetchByobFormEntryId_Last(
obFormEntryId, orderByComparator);
}
/**
* Returns the ob form field mappings before and after the current ob form field mapping in the ordered set where obFormEntryId = ?.
*
* @param obFormFieldMappingId the primary key of the current ob form field mapping
* @param obFormEntryId the ob form entry ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next ob form field mapping
* @throws NoSuchFieldMappingException if a ob form field mapping with the primary key could not be found
*/
public static OBFormFieldMapping[] findByobFormEntryId_PrevAndNext(
long obFormFieldMappingId, long obFormEntryId,
OrderByComparator<OBFormFieldMapping> orderByComparator)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().findByobFormEntryId_PrevAndNext(
obFormFieldMappingId, obFormEntryId, orderByComparator);
}
/**
* Removes all the ob form field mappings where obFormEntryId = ? from the database.
*
* @param obFormEntryId the ob form entry ID
*/
public static void removeByobFormEntryId(long obFormEntryId) {
getPersistence().removeByobFormEntryId(obFormEntryId);
}
/**
* Returns the number of ob form field mappings where obFormEntryId = ?.
*
* @param obFormEntryId the ob form entry ID
* @return the number of matching ob form field mappings
*/
public static int countByobFormEntryId(long obFormEntryId) {
return getPersistence().countByobFormEntryId(obFormEntryId);
}
/**
* Returns the ob form field mapping where formFieldReference = ? and obFormEntryId = ? or throws a <code>NoSuchFieldMappingException</code> if it could not be found.
*
* @param formFieldReference the form field reference
* @param obFormEntryId the ob form entry ID
* @return the matching ob form field mapping
* @throws NoSuchFieldMappingException if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping findByo_f(
String formFieldReference, long obFormEntryId)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().findByo_f(formFieldReference, obFormEntryId);
}
/**
* Returns the ob form field mapping where formFieldReference = ? and obFormEntryId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
*
* @param formFieldReference the form field reference
* @param obFormEntryId the ob form entry ID
* @return the matching ob form field mapping, or <code>null</code> if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping fetchByo_f(
String formFieldReference, long obFormEntryId) {
return getPersistence().fetchByo_f(formFieldReference, obFormEntryId);
}
/**
* Returns the ob form field mapping where formFieldReference = ? and obFormEntryId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
*
* @param formFieldReference the form field reference
* @param obFormEntryId the ob form entry ID
* @param useFinderCache whether to use the finder cache
* @return the matching ob form field mapping, or <code>null</code> if a matching ob form field mapping could not be found
*/
public static OBFormFieldMapping fetchByo_f(
String formFieldReference, long obFormEntryId, boolean useFinderCache) {
return getPersistence().fetchByo_f(
formFieldReference, obFormEntryId, useFinderCache);
}
/**
* Removes the ob form field mapping where formFieldReference = ? and obFormEntryId = ? from the database.
*
* @param formFieldReference the form field reference
* @param obFormEntryId the ob form entry ID
* @return the ob form field mapping that was removed
*/
public static OBFormFieldMapping removeByo_f(
String formFieldReference, long obFormEntryId)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().removeByo_f(formFieldReference, obFormEntryId);
}
/**
* Returns the number of ob form field mappings where formFieldReference = ? and obFormEntryId = ?.
*
* @param formFieldReference the form field reference
* @param obFormEntryId the ob form entry ID
* @return the number of matching ob form field mappings
*/
public static int countByo_f(
String formFieldReference, long obFormEntryId) {
return getPersistence().countByo_f(formFieldReference, obFormEntryId);
}
/**
* Caches the ob form field mapping in the entity cache if it is enabled.
*
* @param obFormFieldMapping the ob form field mapping
*/
public static void cacheResult(OBFormFieldMapping obFormFieldMapping) {
getPersistence().cacheResult(obFormFieldMapping);
}
/**
* Caches the ob form field mappings in the entity cache if it is enabled.
*
* @param obFormFieldMappings the ob form field mappings
*/
public static void cacheResult(
List<OBFormFieldMapping> obFormFieldMappings) {
getPersistence().cacheResult(obFormFieldMappings);
}
/**
* Creates a new ob form field mapping with the primary key. Does not add the ob form field mapping to the database.
*
* @param obFormFieldMappingId the primary key for the new ob form field mapping
* @return the new ob form field mapping
*/
public static OBFormFieldMapping create(long obFormFieldMappingId) {
return getPersistence().create(obFormFieldMappingId);
}
/**
* Removes the ob form field mapping with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param obFormFieldMappingId the primary key of the ob form field mapping
* @return the ob form field mapping that was removed
* @throws NoSuchFieldMappingException if a ob form field mapping with the primary key could not be found
*/
public static OBFormFieldMapping remove(long obFormFieldMappingId)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().remove(obFormFieldMappingId);
}
public static OBFormFieldMapping updateImpl(
OBFormFieldMapping obFormFieldMapping) {
return getPersistence().updateImpl(obFormFieldMapping);
}
/**
* Returns the ob form field mapping with the primary key or throws a <code>NoSuchFieldMappingException</code> if it could not be found.
*
* @param obFormFieldMappingId the primary key of the ob form field mapping
* @return the ob form field mapping
* @throws NoSuchFieldMappingException if a ob form field mapping with the primary key could not be found
*/
public static OBFormFieldMapping findByPrimaryKey(long obFormFieldMappingId)
throws com.liferay.form.onboarding.exception.
NoSuchFieldMappingException {
return getPersistence().findByPrimaryKey(obFormFieldMappingId);
}
/**
* Returns the ob form field mapping with the primary key or returns <code>null</code> if it could not be found.
*
* @param obFormFieldMappingId the primary key of the ob form field mapping
* @return the ob form field mapping, or <code>null</code> if a ob form field mapping with the primary key could not be found
*/
public static OBFormFieldMapping fetchByPrimaryKey(
long obFormFieldMappingId) {
return getPersistence().fetchByPrimaryKey(obFormFieldMappingId);
}
/**
* Returns all the ob form field mappings.
*
* @return the ob form field mappings
*/
public static List<OBFormFieldMapping> findAll() {
return getPersistence().findAll();
}
/**
* Returns a range of all the ob form field mappings.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @return the range of ob form field mappings
*/
public static List<OBFormFieldMapping> findAll(int start, int end) {
return getPersistence().findAll(start, end);
}
/**
* Returns an ordered range of all the ob form field mappings.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @return the ordered range of ob form field mappings
*/
public static List<OBFormFieldMapping> findAll(
int start, int end,
OrderByComparator<OBFormFieldMapping> orderByComparator) {
return getPersistence().findAll(start, end, orderByComparator);
}
/**
* Returns an ordered range of all the ob form field mappings.
*
* <p>
* Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>OBFormFieldMappingModelImpl</code>.
* </p>
*
* @param start the lower bound of the range of ob form field mappings
* @param end the upper bound of the range of ob form field mappings (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of ob form field mappings
*/
public static List<OBFormFieldMapping> findAll(
int start, int end,
OrderByComparator<OBFormFieldMapping> orderByComparator,
boolean useFinderCache) {
return getPersistence().findAll(
start, end, orderByComparator, useFinderCache);
}
/**
* Removes all the ob form field mappings from the database.
*/
public static void removeAll() {
getPersistence().removeAll();
}
/**
* Returns the number of ob form field mappings.
*
* @return the number of ob form field mappings
*/
public static int countAll() {
return getPersistence().countAll();
}
public static OBFormFieldMappingPersistence getPersistence() {
return _serviceTracker.getService();
}
private static ServiceTracker
<OBFormFieldMappingPersistence, OBFormFieldMappingPersistence>
_serviceTracker;
static {
Bundle bundle = FrameworkUtil.getBundle(
OBFormFieldMappingPersistence.class);
ServiceTracker
<OBFormFieldMappingPersistence, OBFormFieldMappingPersistence>
serviceTracker =
new ServiceTracker
<OBFormFieldMappingPersistence,
OBFormFieldMappingPersistence>(
bundle.getBundleContext(),
OBFormFieldMappingPersistence.class, null);
serviceTracker.open();
_serviceTracker = serviceTracker;
}
}
|
package de.lise.terradoc.core.graph;
public class ResourceDependency {
private ResourceNode source;
private StateNode destination;
public ResourceDependency(ResourceNode source, StateNode destination) {
this.source = source;
this.destination = destination;
}
public StateNode getSource() {
return source;
}
public StateNode getDestination() {
return destination;
}
}
|
//This class is responsible for creating objects that are clickable images, with a highlighted version and a result by clicking
import java.awt.*;
import java.awt.image.ImageObserver;
public class clickablePicture extends optionPicture implements ImageObserver {
private Image clickedVersion;
private int width;
private int height;
private boolean highlighted;
private boolean clickable;
public clickablePicture(int x, int y,int w, int h, Image pic, Image pic2)
{
super(x, y, pic);
setClickedVersion(pic2);
setWidth(w);
setHeight(h);
setClickable(false);
setHighlighted(false);
}
public void setClickedVersion(Image clickedVersion) {
this.clickedVersion = clickedVersion;
}
public Image getClickedVersion() {
return clickedVersion;
}
public void setWidth(int width) {
this.width = width;
}
public int getWidth() {
return width;
}
public void setHeight(int height) {
this.height = height;
}
public int getHeight() {
return height;
}
public void setHighlighted(boolean highlighted) {
this.highlighted = highlighted;
}
public boolean isHighlighted() {
return highlighted;
}
public void setClickable(boolean clickable) {
this.clickable = clickable;
}
public boolean isClickable() {
return clickable;
}
@Override
public boolean imageUpdate(Image arg0, int arg1, int arg2, int arg3,
int arg4, int arg5) {
// TODO Auto-generated method stub
return false;
}
}
|
package org.tit_admin_dao.core.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.tit_admin_dao.core.UserDao;
import org.tit_admin_model.core.entity.User;
@Repository("userDaoImpl")
public class UserDaoImpl implements UserDao{
private @Autowired JdbcTemplate springJDBCTemplate;
@Override
@Transactional
public User insert(User u) {
String sql="insert into tit_user t(userName,email,mobile,role,address,passWord,loginCount,currentLoginAt,lastLoginAt,currentLoginIp,lastLoginIp,createDt,updateDt) values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
Object [] para ={u.getUserName(),u.getEmail(),u.getMobile(),u.getRole(),u.getAddress(),u.getPassWord(),u.getLoginCount(),u.getCurrentLoginAt(),u.getLastLoginAt(),u.getCurrentLoginIp(),u.getLastLoginIp(),new Date(),new Date()};
this.springJDBCTemplate.update(sql, para);
return u;
}
@Override
public User findByUsername(String username) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object findByEmail(String email) {
// TODO Auto-generated method stub
return null;
}
@Override
public User update(User user) {
// TODO Auto-generated method stub
return null;
}
}
|
package uk.ac.ed.inf.aqmaps.visualisation;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Deque;
import com.mapbox.geojson.FeatureCollection;
import org.locationtech.jts.geom.Coordinate;
import uk.ac.ed.inf.aqmaps.simulation.Sensor;
import uk.ac.ed.inf.aqmaps.simulation.planning.path.PathSegment;
/**
* Formats and writes the flight path and geojson visualisation to a file
*/
public class OutputFormatter {
/**
* Write flight path to given file
* @param flightPath
* @param file
* @throws IOException
*/
public static void writePath(Deque<PathSegment> flightPath, OutputStream file) throws IOException{
// open writer to the output stream
try(OutputStreamWriter writer = new OutputStreamWriter(file)){
// number of leftover segments
int segmentCount = flightPath.size();
int segmentIdx = 1;
// for each path segment writa a comma separated line
for (PathSegment pathSegment : flightPath) {
// line number
writer.write(String.format("%s,",segmentIdx));
// start point - long,lat
Coordinate startPoint = pathSegment.getStartPoint();
writer.write(String.format("%s,",startPoint.getX()));
writer.write(String.format("%s,",startPoint.getY()));
// direction - int
int direction = pathSegment.getDirection();
writer.write(String.format("%s,",direction));
// end point - long,lat
Coordinate endPoint = pathSegment.getEndPoint();
writer.write(String.format("%s,",endPoint.getX()));
writer.write(String.format("%s,",endPoint.getY()));
// location of connected sensor, or null if none read
Sensor readSensor = pathSegment.getSensorRead();
writer.write(readSensor == null ? "null" : readSensor.getW3WLocation());
// this will be 0 when we just processed last segment
segmentCount -= 1;
segmentIdx += 1;
// write newline character after each line except the last one
if(segmentCount != 0)
writer.write("\n");
}
}
// resources will be disposed off automatically via try block
}
/**
* Write geojson readings visualisation to the given file
* @param readingsMap
* @param file
* @throws IOException
*/
public static void writeReadingsMap(FeatureCollection readingsMap,OutputStream file) throws IOException{
// open writer to the output stream
try(OutputStreamWriter writer = new OutputStreamWriter(file)){
// convert feature collection to json and dump it to the output stream
writer.write(readingsMap.toJson());
}
// resources will be disposed off automatically via try block
}
}
|
package controller;
import model.Product;
import service.ProductService;
import service.ProductServiceIpl;
import javax.servlet.RequestDispatcher;
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 java.io.IOException;
@WebServlet(name = "SearchServlet", urlPatterns = "/search")
public class SearchServlet extends HttpServlet {
private ProductService productServiceIpl= new ProductServiceIpl();
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("search");
Product product= productServiceIpl.searchByName(name);
RequestDispatcher dispatcher;
if(product==null){
dispatcher=request.getRequestDispatcher("404-error.jsp");
}else {
dispatcher=request.getRequestDispatcher("view/searchproduct.jsp");
request.setAttribute("product", product);
}
try {
dispatcher.forward(request,response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
|
package com.ani.interfaces.functional;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
public class ShortHandLambas {
public static void main(String[] args) {
List<String> list = new ArrayList<String>(List.of("Animesh", "Ani", "Chikki", "Chinu"));
// Long way to represent lambdas
/*
* Consumer<String> c = (String s) -> { System.out.println(s); };
*
* list.forEach(c);
*/
// Shorthand
list.forEach(s -> System.out.println(s));
}
}
|
package Lab02.Zad3;
public class Rifle implements Weapon {
@Override
public void useWeapon() {
System.out.println("Shooting a rifle");
}
}
|
package com.sourceallies.filter;
import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletResponse;
public class ResponseLoggerTest {
@Test
public void testGetWriter() throws Exception{
HttpServletResponse mockResponse = new MockHttpServletResponse();
ResponseLogger responseLogger = new ResponseLogger(mockResponse);
PrintWriterLoggerFactory mockFactory = mock(PrintWriterLoggerFactory.class);
PrintWriterLogger mockPrintWriterLogger = mock(PrintWriterLogger.class);
when(mockFactory.create(isA(PrintWriter.class))).thenReturn(mockPrintWriterLogger);
responseLogger.setPrintWriterLoggerFactory(mockFactory);
PrintWriter writer = responseLogger.getWriter();
assertSame(mockPrintWriterLogger, writer);
}
}
|
package com.b2i.bookshelfrcp.handlers;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Shell;
import com.b2international.library.InputBookDialog;
import com.b2international.library.model.Book;
import com.b2international.library.model.Library;
public class AddBookHandler {
@Execute
public void execute(IEclipseContext workbenchContext, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
System.out.println("In Add Book Handler.");
InputBookDialog inputBookDialog = new InputBookDialog(shell);
int returnCode = inputBookDialog.open();
if(returnCode == Dialog.OK) {
Book book = inputBookDialog.getBook();
Library library = (Library) workbenchContext.get("com.b2i.bookshelfrcp.E4LifeCycle.library");
library.addBook(book);
}
}
}
|
package com.locadoraveiculosweb.service;
import static com.locadoraveiculosweb.constants.MessageConstants.BusinessMessages.NOME_OBRIGATORIO;
import static com.locadoraveiculosweb.util.messages.MessageUtils.getMessage;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.List;
import javax.enterprise.inject.Model;
import javax.inject.Inject;
import com.locadoraveiculosweb.dao.FabricanteDAO;
import com.locadoraveiculosweb.exception.NegocioException;
import com.locadoraveiculosweb.mappers.FabricateMapper;
import com.locadoraveiculosweb.modelo.Fabricante;
import com.locadoraveiculosweb.modelo.dtos.FabricanteDto;
import com.locadoraveiculosweb.util.jpa.Transactional;
@Model
public class FabricanteService implements Service<FabricanteDto> {
private static final long serialVersionUID = 1L;
@Inject
private FabricanteDAO fabricanteDAO;
@Inject
private FabricateMapper mapper;
@Transactional
public FabricanteDto salvar(FabricanteDto fabricanteDto) throws NegocioException {
if(isBlank(fabricanteDto.getNome())) {
throw new NegocioException(getMessage(NOME_OBRIGATORIO.getDescription(), Fabricante.class.getSimpleName()));
}
Fabricante fabricante = mapper.toFabricante(ofNullable(fabricanteDto).orElse(new FabricanteDto()));
fabricante = fabricanteDAO.salvar(fabricante);
return mapper.toFabricanteDto(fabricante);
}
@Override
public FabricanteDto buscarPeloCodigo(String codigo) {
Fabricante fabricante = this.fabricanteDAO.buscarPeloCodigo(new Long(codigo));
return mapper.toFabricanteDto(ofNullable(fabricante).orElse(null));
}
@Override
public void excluir(FabricanteDto viewObject) throws NegocioException {
Fabricante fabricante = mapper.toFabricante(viewObject);
fabricanteDAO.excluir(fabricante);
}
@Override
public List<FabricanteDto> buscarTodos() {
return mapper.toFabricanteDto(fabricanteDAO.buscarTodos());
}
}
|
package com.rc.portal.vo;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.rc.app.framework.webapp.model.BaseModel;
public class RxTOrderExample extends BaseModel{
protected String orderByClause;
protected List oredCriteria;
public RxTOrderExample() {
oredCriteria = new ArrayList();
}
protected RxTOrderExample(RxTOrderExample example) {
this.orderByClause = example.orderByClause;
this.oredCriteria = example.oredCriteria;
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public List getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
}
public static class Criteria {
protected List criteriaWithoutValue;
protected List criteriaWithSingleValue;
protected List criteriaWithListValue;
protected List criteriaWithBetweenValue;
protected Criteria() {
super();
criteriaWithoutValue = new ArrayList();
criteriaWithSingleValue = new ArrayList();
criteriaWithListValue = new ArrayList();
criteriaWithBetweenValue = new ArrayList();
}
public boolean isValid() {
return criteriaWithoutValue.size() > 0
|| criteriaWithSingleValue.size() > 0
|| criteriaWithListValue.size() > 0
|| criteriaWithBetweenValue.size() > 0;
}
public List getCriteriaWithoutValue() {
return criteriaWithoutValue;
}
public List getCriteriaWithSingleValue() {
return criteriaWithSingleValue;
}
public List getCriteriaWithListValue() {
return criteriaWithListValue;
}
public List getCriteriaWithBetweenValue() {
return criteriaWithBetweenValue;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteriaWithoutValue.add(condition);
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
Map map = new HashMap();
map.put("condition", condition);
map.put("value", value);
criteriaWithSingleValue.add(map);
}
protected void addCriterion(String condition, List values, String property) {
if (values == null || values.size() == 0) {
throw new RuntimeException("Value list for " + property + " cannot be null or empty");
}
Map map = new HashMap();
map.put("condition", condition);
map.put("values", values);
criteriaWithListValue.add(map);
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
List list = new ArrayList();
list.add(value1);
list.add(value2);
Map map = new HashMap();
map.put("condition", condition);
map.put("values", list);
criteriaWithBetweenValue.add(map);
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return this;
}
public Criteria andIdIn(List values) {
addCriterion("id in", values, "id");
return this;
}
public Criteria andIdNotIn(List values) {
addCriterion("id not in", values, "id");
return this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return this;
}
public Criteria andOrderSnIsNull() {
addCriterion("order_sn is null");
return this;
}
public Criteria andOrderSnIsNotNull() {
addCriterion("order_sn is not null");
return this;
}
public Criteria andOrderSnEqualTo(String value) {
addCriterion("order_sn =", value, "orderSn");
return this;
}
public Criteria andOrderSnNotEqualTo(String value) {
addCriterion("order_sn <>", value, "orderSn");
return this;
}
public Criteria andOrderSnGreaterThan(String value) {
addCriterion("order_sn >", value, "orderSn");
return this;
}
public Criteria andOrderSnGreaterThanOrEqualTo(String value) {
addCriterion("order_sn >=", value, "orderSn");
return this;
}
public Criteria andOrderSnLessThan(String value) {
addCriterion("order_sn <", value, "orderSn");
return this;
}
public Criteria andOrderSnLessThanOrEqualTo(String value) {
addCriterion("order_sn <=", value, "orderSn");
return this;
}
public Criteria andOrderSnLike(String value) {
addCriterion("order_sn like", value, "orderSn");
return this;
}
public Criteria andOrderSnNotLike(String value) {
addCriterion("order_sn not like", value, "orderSn");
return this;
}
public Criteria andOrderSnIn(List values) {
addCriterion("order_sn in", values, "orderSn");
return this;
}
public Criteria andOrderSnNotIn(List values) {
addCriterion("order_sn not in", values, "orderSn");
return this;
}
public Criteria andOrderSnBetween(String value1, String value2) {
addCriterion("order_sn between", value1, value2, "orderSn");
return this;
}
public Criteria andOrderSnNotBetween(String value1, String value2) {
addCriterion("order_sn not between", value1, value2, "orderSn");
return this;
}
public Criteria andMemberIdIsNull() {
addCriterion("member_id is null");
return this;
}
public Criteria andMemberIdIsNotNull() {
addCriterion("member_id is not null");
return this;
}
public Criteria andMemberIdEqualTo(Long value) {
addCriterion("member_id =", value, "memberId");
return this;
}
public Criteria andMemberIdNotEqualTo(Long value) {
addCriterion("member_id <>", value, "memberId");
return this;
}
public Criteria andMemberIdGreaterThan(Long value) {
addCriterion("member_id >", value, "memberId");
return this;
}
public Criteria andMemberIdGreaterThanOrEqualTo(Long value) {
addCriterion("member_id >=", value, "memberId");
return this;
}
public Criteria andMemberIdLessThan(Long value) {
addCriterion("member_id <", value, "memberId");
return this;
}
public Criteria andMemberIdLessThanOrEqualTo(Long value) {
addCriterion("member_id <=", value, "memberId");
return this;
}
public Criteria andMemberIdIn(List values) {
addCriterion("member_id in", values, "memberId");
return this;
}
public Criteria andMemberIdNotIn(List values) {
addCriterion("member_id not in", values, "memberId");
return this;
}
public Criteria andMemberIdBetween(Long value1, Long value2) {
addCriterion("member_id between", value1, value2, "memberId");
return this;
}
public Criteria andMemberIdNotBetween(Long value1, Long value2) {
addCriterion("member_id not between", value1, value2, "memberId");
return this;
}
public Criteria andReceiverIsNull() {
addCriterion("receiver is null");
return this;
}
public Criteria andReceiverIsNotNull() {
addCriterion("receiver is not null");
return this;
}
public Criteria andReceiverEqualTo(String value) {
addCriterion("receiver =", value, "receiver");
return this;
}
public Criteria andReceiverNotEqualTo(String value) {
addCriterion("receiver <>", value, "receiver");
return this;
}
public Criteria andReceiverGreaterThan(String value) {
addCriterion("receiver >", value, "receiver");
return this;
}
public Criteria andReceiverGreaterThanOrEqualTo(String value) {
addCriterion("receiver >=", value, "receiver");
return this;
}
public Criteria andReceiverLessThan(String value) {
addCriterion("receiver <", value, "receiver");
return this;
}
public Criteria andReceiverLessThanOrEqualTo(String value) {
addCriterion("receiver <=", value, "receiver");
return this;
}
public Criteria andReceiverLike(String value) {
addCriterion("receiver like", value, "receiver");
return this;
}
public Criteria andReceiverNotLike(String value) {
addCriterion("receiver not like", value, "receiver");
return this;
}
public Criteria andReceiverIn(List values) {
addCriterion("receiver in", values, "receiver");
return this;
}
public Criteria andReceiverNotIn(List values) {
addCriterion("receiver not in", values, "receiver");
return this;
}
public Criteria andReceiverBetween(String value1, String value2) {
addCriterion("receiver between", value1, value2, "receiver");
return this;
}
public Criteria andReceiverNotBetween(String value1, String value2) {
addCriterion("receiver not between", value1, value2, "receiver");
return this;
}
public Criteria andAreaIdIsNull() {
addCriterion("area_id is null");
return this;
}
public Criteria andAreaIdIsNotNull() {
addCriterion("area_id is not null");
return this;
}
public Criteria andAreaIdEqualTo(Long value) {
addCriterion("area_id =", value, "areaId");
return this;
}
public Criteria andAreaIdNotEqualTo(Long value) {
addCriterion("area_id <>", value, "areaId");
return this;
}
public Criteria andAreaIdGreaterThan(Long value) {
addCriterion("area_id >", value, "areaId");
return this;
}
public Criteria andAreaIdGreaterThanOrEqualTo(Long value) {
addCriterion("area_id >=", value, "areaId");
return this;
}
public Criteria andAreaIdLessThan(Long value) {
addCriterion("area_id <", value, "areaId");
return this;
}
public Criteria andAreaIdLessThanOrEqualTo(Long value) {
addCriterion("area_id <=", value, "areaId");
return this;
}
public Criteria andAreaIdIn(List values) {
addCriterion("area_id in", values, "areaId");
return this;
}
public Criteria andAreaIdNotIn(List values) {
addCriterion("area_id not in", values, "areaId");
return this;
}
public Criteria andAreaIdBetween(Long value1, Long value2) {
addCriterion("area_id between", value1, value2, "areaId");
return this;
}
public Criteria andAreaIdNotBetween(Long value1, Long value2) {
addCriterion("area_id not between", value1, value2, "areaId");
return this;
}
public Criteria andAreaNameIsNull() {
addCriterion("area_name is null");
return this;
}
public Criteria andAreaNameIsNotNull() {
addCriterion("area_name is not null");
return this;
}
public Criteria andAreaNameEqualTo(String value) {
addCriterion("area_name =", value, "areaName");
return this;
}
public Criteria andAreaNameNotEqualTo(String value) {
addCriterion("area_name <>", value, "areaName");
return this;
}
public Criteria andAreaNameGreaterThan(String value) {
addCriterion("area_name >", value, "areaName");
return this;
}
public Criteria andAreaNameGreaterThanOrEqualTo(String value) {
addCriterion("area_name >=", value, "areaName");
return this;
}
public Criteria andAreaNameLessThan(String value) {
addCriterion("area_name <", value, "areaName");
return this;
}
public Criteria andAreaNameLessThanOrEqualTo(String value) {
addCriterion("area_name <=", value, "areaName");
return this;
}
public Criteria andAreaNameLike(String value) {
addCriterion("area_name like", value, "areaName");
return this;
}
public Criteria andAreaNameNotLike(String value) {
addCriterion("area_name not like", value, "areaName");
return this;
}
public Criteria andAreaNameIn(List values) {
addCriterion("area_name in", values, "areaName");
return this;
}
public Criteria andAreaNameNotIn(List values) {
addCriterion("area_name not in", values, "areaName");
return this;
}
public Criteria andAreaNameBetween(String value1, String value2) {
addCriterion("area_name between", value1, value2, "areaName");
return this;
}
public Criteria andAreaNameNotBetween(String value1, String value2) {
addCriterion("area_name not between", value1, value2, "areaName");
return this;
}
public Criteria andDetailedAddressIsNull() {
addCriterion("detailed_address is null");
return this;
}
public Criteria andDetailedAddressIsNotNull() {
addCriterion("detailed_address is not null");
return this;
}
public Criteria andDetailedAddressEqualTo(String value) {
addCriterion("detailed_address =", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressNotEqualTo(String value) {
addCriterion("detailed_address <>", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressGreaterThan(String value) {
addCriterion("detailed_address >", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressGreaterThanOrEqualTo(String value) {
addCriterion("detailed_address >=", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressLessThan(String value) {
addCriterion("detailed_address <", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressLessThanOrEqualTo(String value) {
addCriterion("detailed_address <=", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressLike(String value) {
addCriterion("detailed_address like", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressNotLike(String value) {
addCriterion("detailed_address not like", value, "detailedAddress");
return this;
}
public Criteria andDetailedAddressIn(List values) {
addCriterion("detailed_address in", values, "detailedAddress");
return this;
}
public Criteria andDetailedAddressNotIn(List values) {
addCriterion("detailed_address not in", values, "detailedAddress");
return this;
}
public Criteria andDetailedAddressBetween(String value1, String value2) {
addCriterion("detailed_address between", value1, value2, "detailedAddress");
return this;
}
public Criteria andDetailedAddressNotBetween(String value1, String value2) {
addCriterion("detailed_address not between", value1, value2, "detailedAddress");
return this;
}
public Criteria andLongitudeIsNull() {
addCriterion("longitude is null");
return this;
}
public Criteria andLongitudeIsNotNull() {
addCriterion("longitude is not null");
return this;
}
public Criteria andLongitudeEqualTo(String value) {
addCriterion("longitude =", value, "longitude");
return this;
}
public Criteria andLongitudeNotEqualTo(String value) {
addCriterion("longitude <>", value, "longitude");
return this;
}
public Criteria andLongitudeGreaterThan(String value) {
addCriterion("longitude >", value, "longitude");
return this;
}
public Criteria andLongitudeGreaterThanOrEqualTo(String value) {
addCriterion("longitude >=", value, "longitude");
return this;
}
public Criteria andLongitudeLessThan(String value) {
addCriterion("longitude <", value, "longitude");
return this;
}
public Criteria andLongitudeLessThanOrEqualTo(String value) {
addCriterion("longitude <=", value, "longitude");
return this;
}
public Criteria andLongitudeLike(String value) {
addCriterion("longitude like", value, "longitude");
return this;
}
public Criteria andLongitudeNotLike(String value) {
addCriterion("longitude not like", value, "longitude");
return this;
}
public Criteria andLongitudeIn(List values) {
addCriterion("longitude in", values, "longitude");
return this;
}
public Criteria andLongitudeNotIn(List values) {
addCriterion("longitude not in", values, "longitude");
return this;
}
public Criteria andLongitudeBetween(String value1, String value2) {
addCriterion("longitude between", value1, value2, "longitude");
return this;
}
public Criteria andLongitudeNotBetween(String value1, String value2) {
addCriterion("longitude not between", value1, value2, "longitude");
return this;
}
public Criteria andLatitudeIsNull() {
addCriterion("latitude is null");
return this;
}
public Criteria andLatitudeIsNotNull() {
addCriterion("latitude is not null");
return this;
}
public Criteria andLatitudeEqualTo(String value) {
addCriterion("latitude =", value, "latitude");
return this;
}
public Criteria andLatitudeNotEqualTo(String value) {
addCriterion("latitude <>", value, "latitude");
return this;
}
public Criteria andLatitudeGreaterThan(String value) {
addCriterion("latitude >", value, "latitude");
return this;
}
public Criteria andLatitudeGreaterThanOrEqualTo(String value) {
addCriterion("latitude >=", value, "latitude");
return this;
}
public Criteria andLatitudeLessThan(String value) {
addCriterion("latitude <", value, "latitude");
return this;
}
public Criteria andLatitudeLessThanOrEqualTo(String value) {
addCriterion("latitude <=", value, "latitude");
return this;
}
public Criteria andLatitudeLike(String value) {
addCriterion("latitude like", value, "latitude");
return this;
}
public Criteria andLatitudeNotLike(String value) {
addCriterion("latitude not like", value, "latitude");
return this;
}
public Criteria andLatitudeIn(List values) {
addCriterion("latitude in", values, "latitude");
return this;
}
public Criteria andLatitudeNotIn(List values) {
addCriterion("latitude not in", values, "latitude");
return this;
}
public Criteria andLatitudeBetween(String value1, String value2) {
addCriterion("latitude between", value1, value2, "latitude");
return this;
}
public Criteria andLatitudeNotBetween(String value1, String value2) {
addCriterion("latitude not between", value1, value2, "latitude");
return this;
}
public Criteria andStoreIdIsNull() {
addCriterion("store_id is null");
return this;
}
public Criteria andStoreIdIsNotNull() {
addCriterion("store_id is not null");
return this;
}
public Criteria andStoreIdEqualTo(String value) {
addCriterion("store_id =", value, "storeId");
return this;
}
public Criteria andStoreIdNotEqualTo(String value) {
addCriterion("store_id <>", value, "storeId");
return this;
}
public Criteria andStoreIdGreaterThan(String value) {
addCriterion("store_id >", value, "storeId");
return this;
}
public Criteria andStoreIdGreaterThanOrEqualTo(String value) {
addCriterion("store_id >=", value, "storeId");
return this;
}
public Criteria andStoreIdLessThan(String value) {
addCriterion("store_id <", value, "storeId");
return this;
}
public Criteria andStoreIdLessThanOrEqualTo(String value) {
addCriterion("store_id <=", value, "storeId");
return this;
}
public Criteria andStoreIdLike(String value) {
addCriterion("store_id like", value, "storeId");
return this;
}
public Criteria andStoreIdNotLike(String value) {
addCriterion("store_id not like", value, "storeId");
return this;
}
public Criteria andStoreIdIn(List values) {
addCriterion("store_id in", values, "storeId");
return this;
}
public Criteria andStoreIdNotIn(List values) {
addCriterion("store_id not in", values, "storeId");
return this;
}
public Criteria andStoreIdBetween(String value1, String value2) {
addCriterion("store_id between", value1, value2, "storeId");
return this;
}
public Criteria andStoreIdNotBetween(String value1, String value2) {
addCriterion("store_id not between", value1, value2, "storeId");
return this;
}
public Criteria andMobileIsNull() {
addCriterion("mobile is null");
return this;
}
public Criteria andMobileIsNotNull() {
addCriterion("mobile is not null");
return this;
}
public Criteria andMobileEqualTo(String value) {
addCriterion("mobile =", value, "mobile");
return this;
}
public Criteria andMobileNotEqualTo(String value) {
addCriterion("mobile <>", value, "mobile");
return this;
}
public Criteria andMobileGreaterThan(String value) {
addCriterion("mobile >", value, "mobile");
return this;
}
public Criteria andMobileGreaterThanOrEqualTo(String value) {
addCriterion("mobile >=", value, "mobile");
return this;
}
public Criteria andMobileLessThan(String value) {
addCriterion("mobile <", value, "mobile");
return this;
}
public Criteria andMobileLessThanOrEqualTo(String value) {
addCriterion("mobile <=", value, "mobile");
return this;
}
public Criteria andMobileLike(String value) {
addCriterion("mobile like", value, "mobile");
return this;
}
public Criteria andMobileNotLike(String value) {
addCriterion("mobile not like", value, "mobile");
return this;
}
public Criteria andMobileIn(List values) {
addCriterion("mobile in", values, "mobile");
return this;
}
public Criteria andMobileNotIn(List values) {
addCriterion("mobile not in", values, "mobile");
return this;
}
public Criteria andMobileBetween(String value1, String value2) {
addCriterion("mobile between", value1, value2, "mobile");
return this;
}
public Criteria andMobileNotBetween(String value1, String value2) {
addCriterion("mobile not between", value1, value2, "mobile");
return this;
}
public Criteria andPaymentIdIsNull() {
addCriterion("payment_id is null");
return this;
}
public Criteria andPaymentIdIsNotNull() {
addCriterion("payment_id is not null");
return this;
}
public Criteria andPaymentIdEqualTo(Long value) {
addCriterion("payment_id =", value, "paymentId");
return this;
}
public Criteria andPaymentIdNotEqualTo(Long value) {
addCriterion("payment_id <>", value, "paymentId");
return this;
}
public Criteria andPaymentIdGreaterThan(Long value) {
addCriterion("payment_id >", value, "paymentId");
return this;
}
public Criteria andPaymentIdGreaterThanOrEqualTo(Long value) {
addCriterion("payment_id >=", value, "paymentId");
return this;
}
public Criteria andPaymentIdLessThan(Long value) {
addCriterion("payment_id <", value, "paymentId");
return this;
}
public Criteria andPaymentIdLessThanOrEqualTo(Long value) {
addCriterion("payment_id <=", value, "paymentId");
return this;
}
public Criteria andPaymentIdIn(List values) {
addCriterion("payment_id in", values, "paymentId");
return this;
}
public Criteria andPaymentIdNotIn(List values) {
addCriterion("payment_id not in", values, "paymentId");
return this;
}
public Criteria andPaymentIdBetween(Long value1, Long value2) {
addCriterion("payment_id between", value1, value2, "paymentId");
return this;
}
public Criteria andPaymentIdNotBetween(Long value1, Long value2) {
addCriterion("payment_id not between", value1, value2, "paymentId");
return this;
}
public Criteria andDeliveryIdIsNull() {
addCriterion("delivery_id is null");
return this;
}
public Criteria andDeliveryIdIsNotNull() {
addCriterion("delivery_id is not null");
return this;
}
public Criteria andDeliveryIdEqualTo(Long value) {
addCriterion("delivery_id =", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdNotEqualTo(Long value) {
addCriterion("delivery_id <>", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdGreaterThan(Long value) {
addCriterion("delivery_id >", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdGreaterThanOrEqualTo(Long value) {
addCriterion("delivery_id >=", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdLessThan(Long value) {
addCriterion("delivery_id <", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdLessThanOrEqualTo(Long value) {
addCriterion("delivery_id <=", value, "deliveryId");
return this;
}
public Criteria andDeliveryIdIn(List values) {
addCriterion("delivery_id in", values, "deliveryId");
return this;
}
public Criteria andDeliveryIdNotIn(List values) {
addCriterion("delivery_id not in", values, "deliveryId");
return this;
}
public Criteria andDeliveryIdBetween(Long value1, Long value2) {
addCriterion("delivery_id between", value1, value2, "deliveryId");
return this;
}
public Criteria andDeliveryIdNotBetween(Long value1, Long value2) {
addCriterion("delivery_id not between", value1, value2, "deliveryId");
return this;
}
public Criteria andOrderStatusIsNull() {
addCriterion("order_status is null");
return this;
}
public Criteria andOrderStatusIsNotNull() {
addCriterion("order_status is not null");
return this;
}
public Criteria andOrderStatusEqualTo(Integer value) {
addCriterion("order_status =", value, "orderStatus");
return this;
}
public Criteria andOrderStatusNotEqualTo(Integer value) {
addCriterion("order_status <>", value, "orderStatus");
return this;
}
public Criteria andOrderStatusGreaterThan(Integer value) {
addCriterion("order_status >", value, "orderStatus");
return this;
}
public Criteria andOrderStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("order_status >=", value, "orderStatus");
return this;
}
public Criteria andOrderStatusLessThan(Integer value) {
addCriterion("order_status <", value, "orderStatus");
return this;
}
public Criteria andOrderStatusLessThanOrEqualTo(Integer value) {
addCriterion("order_status <=", value, "orderStatus");
return this;
}
public Criteria andOrderStatusIn(List values) {
addCriterion("order_status in", values, "orderStatus");
return this;
}
public Criteria andOrderStatusNotIn(List values) {
addCriterion("order_status not in", values, "orderStatus");
return this;
}
public Criteria andOrderStatusBetween(Integer value1, Integer value2) {
addCriterion("order_status between", value1, value2, "orderStatus");
return this;
}
public Criteria andOrderStatusNotBetween(Integer value1, Integer value2) {
addCriterion("order_status not between", value1, value2, "orderStatus");
return this;
}
public Criteria andCreateDtIsNull() {
addCriterion("create_dt is null");
return this;
}
public Criteria andCreateDtIsNotNull() {
addCriterion("create_dt is not null");
return this;
}
public Criteria andCreateDtEqualTo(Date value) {
addCriterion("create_dt =", value, "createDt");
return this;
}
public Criteria andCreateDtNotEqualTo(Date value) {
addCriterion("create_dt <>", value, "createDt");
return this;
}
public Criteria andCreateDtGreaterThan(Date value) {
addCriterion("create_dt >", value, "createDt");
return this;
}
public Criteria andCreateDtGreaterThanOrEqualTo(Date value) {
addCriterion("create_dt >=", value, "createDt");
return this;
}
public Criteria andCreateDtLessThan(Date value) {
addCriterion("create_dt <", value, "createDt");
return this;
}
public Criteria andCreateDtLessThanOrEqualTo(Date value) {
addCriterion("create_dt <=", value, "createDt");
return this;
}
public Criteria andCreateDtIn(List values) {
addCriterion("create_dt in", values, "createDt");
return this;
}
public Criteria andCreateDtNotIn(List values) {
addCriterion("create_dt not in", values, "createDt");
return this;
}
public Criteria andCreateDtBetween(Date value1, Date value2) {
addCriterion("create_dt between", value1, value2, "createDt");
return this;
}
public Criteria andCreateDtNotBetween(Date value1, Date value2) {
addCriterion("create_dt not between", value1, value2, "createDt");
return this;
}
public Criteria andOrderAmountIsNull() {
addCriterion("order_amount is null");
return this;
}
public Criteria andOrderAmountIsNotNull() {
addCriterion("order_amount is not null");
return this;
}
public Criteria andOrderAmountEqualTo(BigDecimal value) {
addCriterion("order_amount =", value, "orderAmount");
return this;
}
public Criteria andOrderAmountNotEqualTo(BigDecimal value) {
addCriterion("order_amount <>", value, "orderAmount");
return this;
}
public Criteria andOrderAmountGreaterThan(BigDecimal value) {
addCriterion("order_amount >", value, "orderAmount");
return this;
}
public Criteria andOrderAmountGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("order_amount >=", value, "orderAmount");
return this;
}
public Criteria andOrderAmountLessThan(BigDecimal value) {
addCriterion("order_amount <", value, "orderAmount");
return this;
}
public Criteria andOrderAmountLessThanOrEqualTo(BigDecimal value) {
addCriterion("order_amount <=", value, "orderAmount");
return this;
}
public Criteria andOrderAmountIn(List values) {
addCriterion("order_amount in", values, "orderAmount");
return this;
}
public Criteria andOrderAmountNotIn(List values) {
addCriterion("order_amount not in", values, "orderAmount");
return this;
}
public Criteria andOrderAmountBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("order_amount between", value1, value2, "orderAmount");
return this;
}
public Criteria andOrderAmountNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("order_amount not between", value1, value2, "orderAmount");
return this;
}
public Criteria andFreightIsNull() {
addCriterion("freight is null");
return this;
}
public Criteria andFreightIsNotNull() {
addCriterion("freight is not null");
return this;
}
public Criteria andFreightEqualTo(BigDecimal value) {
addCriterion("freight =", value, "freight");
return this;
}
public Criteria andFreightNotEqualTo(BigDecimal value) {
addCriterion("freight <>", value, "freight");
return this;
}
public Criteria andFreightGreaterThan(BigDecimal value) {
addCriterion("freight >", value, "freight");
return this;
}
public Criteria andFreightGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("freight >=", value, "freight");
return this;
}
public Criteria andFreightLessThan(BigDecimal value) {
addCriterion("freight <", value, "freight");
return this;
}
public Criteria andFreightLessThanOrEqualTo(BigDecimal value) {
addCriterion("freight <=", value, "freight");
return this;
}
public Criteria andFreightIn(List values) {
addCriterion("freight in", values, "freight");
return this;
}
public Criteria andFreightNotIn(List values) {
addCriterion("freight not in", values, "freight");
return this;
}
public Criteria andFreightBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("freight between", value1, value2, "freight");
return this;
}
public Criteria andFreightNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("freight not between", value1, value2, "freight");
return this;
}
public Criteria andPromotionalDiscountIsNull() {
addCriterion("promotional_discount is null");
return this;
}
public Criteria andPromotionalDiscountIsNotNull() {
addCriterion("promotional_discount is not null");
return this;
}
public Criteria andPromotionalDiscountEqualTo(BigDecimal value) {
addCriterion("promotional_discount =", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountNotEqualTo(BigDecimal value) {
addCriterion("promotional_discount <>", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountGreaterThan(BigDecimal value) {
addCriterion("promotional_discount >", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("promotional_discount >=", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountLessThan(BigDecimal value) {
addCriterion("promotional_discount <", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountLessThanOrEqualTo(BigDecimal value) {
addCriterion("promotional_discount <=", value, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountIn(List values) {
addCriterion("promotional_discount in", values, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountNotIn(List values) {
addCriterion("promotional_discount not in", values, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("promotional_discount between", value1, value2, "promotionalDiscount");
return this;
}
public Criteria andPromotionalDiscountNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("promotional_discount not between", value1, value2, "promotionalDiscount");
return this;
}
public Criteria andCouponDiscountIsNull() {
addCriterion("coupon_discount is null");
return this;
}
public Criteria andCouponDiscountIsNotNull() {
addCriterion("coupon_discount is not null");
return this;
}
public Criteria andCouponDiscountEqualTo(BigDecimal value) {
addCriterion("coupon_discount =", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountNotEqualTo(BigDecimal value) {
addCriterion("coupon_discount <>", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountGreaterThan(BigDecimal value) {
addCriterion("coupon_discount >", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("coupon_discount >=", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountLessThan(BigDecimal value) {
addCriterion("coupon_discount <", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountLessThanOrEqualTo(BigDecimal value) {
addCriterion("coupon_discount <=", value, "couponDiscount");
return this;
}
public Criteria andCouponDiscountIn(List values) {
addCriterion("coupon_discount in", values, "couponDiscount");
return this;
}
public Criteria andCouponDiscountNotIn(List values) {
addCriterion("coupon_discount not in", values, "couponDiscount");
return this;
}
public Criteria andCouponDiscountBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("coupon_discount between", value1, value2, "couponDiscount");
return this;
}
public Criteria andCouponDiscountNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("coupon_discount not between", value1, value2, "couponDiscount");
return this;
}
public Criteria andIntegrationDiscountIsNull() {
addCriterion("integration_discount is null");
return this;
}
public Criteria andIntegrationDiscountIsNotNull() {
addCriterion("integration_discount is not null");
return this;
}
public Criteria andIntegrationDiscountEqualTo(BigDecimal value) {
addCriterion("integration_discount =", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountNotEqualTo(BigDecimal value) {
addCriterion("integration_discount <>", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountGreaterThan(BigDecimal value) {
addCriterion("integration_discount >", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("integration_discount >=", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountLessThan(BigDecimal value) {
addCriterion("integration_discount <", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountLessThanOrEqualTo(BigDecimal value) {
addCriterion("integration_discount <=", value, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountIn(List values) {
addCriterion("integration_discount in", values, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountNotIn(List values) {
addCriterion("integration_discount not in", values, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("integration_discount between", value1, value2, "integrationDiscount");
return this;
}
public Criteria andIntegrationDiscountNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("integration_discount not between", value1, value2, "integrationDiscount");
return this;
}
public Criteria andUseIntegrationIsNull() {
addCriterion("use_integration is null");
return this;
}
public Criteria andUseIntegrationIsNotNull() {
addCriterion("use_integration is not null");
return this;
}
public Criteria andUseIntegrationEqualTo(Integer value) {
addCriterion("use_integration =", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationNotEqualTo(Integer value) {
addCriterion("use_integration <>", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationGreaterThan(Integer value) {
addCriterion("use_integration >", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationGreaterThanOrEqualTo(Integer value) {
addCriterion("use_integration >=", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationLessThan(Integer value) {
addCriterion("use_integration <", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationLessThanOrEqualTo(Integer value) {
addCriterion("use_integration <=", value, "useIntegration");
return this;
}
public Criteria andUseIntegrationIn(List values) {
addCriterion("use_integration in", values, "useIntegration");
return this;
}
public Criteria andUseIntegrationNotIn(List values) {
addCriterion("use_integration not in", values, "useIntegration");
return this;
}
public Criteria andUseIntegrationBetween(Integer value1, Integer value2) {
addCriterion("use_integration between", value1, value2, "useIntegration");
return this;
}
public Criteria andUseIntegrationNotBetween(Integer value1, Integer value2) {
addCriterion("use_integration not between", value1, value2, "useIntegration");
return this;
}
public Criteria andAdjustAmountIsNull() {
addCriterion("adjust_amount is null");
return this;
}
public Criteria andAdjustAmountIsNotNull() {
addCriterion("adjust_amount is not null");
return this;
}
public Criteria andAdjustAmountEqualTo(BigDecimal value) {
addCriterion("adjust_amount =", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountNotEqualTo(BigDecimal value) {
addCriterion("adjust_amount <>", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountGreaterThan(BigDecimal value) {
addCriterion("adjust_amount >", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("adjust_amount >=", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountLessThan(BigDecimal value) {
addCriterion("adjust_amount <", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountLessThanOrEqualTo(BigDecimal value) {
addCriterion("adjust_amount <=", value, "adjustAmount");
return this;
}
public Criteria andAdjustAmountIn(List values) {
addCriterion("adjust_amount in", values, "adjustAmount");
return this;
}
public Criteria andAdjustAmountNotIn(List values) {
addCriterion("adjust_amount not in", values, "adjustAmount");
return this;
}
public Criteria andAdjustAmountBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("adjust_amount between", value1, value2, "adjustAmount");
return this;
}
public Criteria andAdjustAmountNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("adjust_amount not between", value1, value2, "adjustAmount");
return this;
}
public Criteria andRewardIntegrationIsNull() {
addCriterion("reward_integration is null");
return this;
}
public Criteria andRewardIntegrationIsNotNull() {
addCriterion("reward_integration is not null");
return this;
}
public Criteria andRewardIntegrationEqualTo(Integer value) {
addCriterion("reward_integration =", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationNotEqualTo(Integer value) {
addCriterion("reward_integration <>", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationGreaterThan(Integer value) {
addCriterion("reward_integration >", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationGreaterThanOrEqualTo(Integer value) {
addCriterion("reward_integration >=", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationLessThan(Integer value) {
addCriterion("reward_integration <", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationLessThanOrEqualTo(Integer value) {
addCriterion("reward_integration <=", value, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationIn(List values) {
addCriterion("reward_integration in", values, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationNotIn(List values) {
addCriterion("reward_integration not in", values, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationBetween(Integer value1, Integer value2) {
addCriterion("reward_integration between", value1, value2, "rewardIntegration");
return this;
}
public Criteria andRewardIntegrationNotBetween(Integer value1, Integer value2) {
addCriterion("reward_integration not between", value1, value2, "rewardIntegration");
return this;
}
public Criteria andIsPushIsNull() {
addCriterion("is_push is null");
return this;
}
public Criteria andIsPushIsNotNull() {
addCriterion("is_push is not null");
return this;
}
public Criteria andIsPushEqualTo(Integer value) {
addCriterion("is_push =", value, "isPush");
return this;
}
public Criteria andIsPushNotEqualTo(Integer value) {
addCriterion("is_push <>", value, "isPush");
return this;
}
public Criteria andIsPushGreaterThan(Integer value) {
addCriterion("is_push >", value, "isPush");
return this;
}
public Criteria andIsPushGreaterThanOrEqualTo(Integer value) {
addCriterion("is_push >=", value, "isPush");
return this;
}
public Criteria andIsPushLessThan(Integer value) {
addCriterion("is_push <", value, "isPush");
return this;
}
public Criteria andIsPushLessThanOrEqualTo(Integer value) {
addCriterion("is_push <=", value, "isPush");
return this;
}
public Criteria andIsPushIn(List values) {
addCriterion("is_push in", values, "isPush");
return this;
}
public Criteria andIsPushNotIn(List values) {
addCriterion("is_push not in", values, "isPush");
return this;
}
public Criteria andIsPushBetween(Integer value1, Integer value2) {
addCriterion("is_push between", value1, value2, "isPush");
return this;
}
public Criteria andIsPushNotBetween(Integer value1, Integer value2) {
addCriterion("is_push not between", value1, value2, "isPush");
return this;
}
public Criteria andPushTimeIsNull() {
addCriterion("push_time is null");
return this;
}
public Criteria andPushTimeIsNotNull() {
addCriterion("push_time is not null");
return this;
}
public Criteria andPushTimeEqualTo(Date value) {
addCriterion("push_time =", value, "pushTime");
return this;
}
public Criteria andPushTimeNotEqualTo(Date value) {
addCriterion("push_time <>", value, "pushTime");
return this;
}
public Criteria andPushTimeGreaterThan(Date value) {
addCriterion("push_time >", value, "pushTime");
return this;
}
public Criteria andPushTimeGreaterThanOrEqualTo(Date value) {
addCriterion("push_time >=", value, "pushTime");
return this;
}
public Criteria andPushTimeLessThan(Date value) {
addCriterion("push_time <", value, "pushTime");
return this;
}
public Criteria andPushTimeLessThanOrEqualTo(Date value) {
addCriterion("push_time <=", value, "pushTime");
return this;
}
public Criteria andPushTimeIn(List values) {
addCriterion("push_time in", values, "pushTime");
return this;
}
public Criteria andPushTimeNotIn(List values) {
addCriterion("push_time not in", values, "pushTime");
return this;
}
public Criteria andPushTimeBetween(Date value1, Date value2) {
addCriterion("push_time between", value1, value2, "pushTime");
return this;
}
public Criteria andPushTimeNotBetween(Date value1, Date value2) {
addCriterion("push_time not between", value1, value2, "pushTime");
return this;
}
}
}
|
package com.project.linkedindatabase.service.types;
import com.project.linkedindatabase.domain.Type.RelationKnowledge;
import com.project.linkedindatabase.service.BaseTypeService;
public interface RelationKnowledgeService extends BaseTypeService<RelationKnowledge> {
}
|
package problemas;
import algoritmos.BusquedaPatrones;
public class DecodingHallway {
private int n;
private String patron;
public DecodingHallway(int n, String patron) {
this.n = n;
this.patron = patron;
}
public boolean posible() {
String s = "";
for ( int i = n; i > 0; i-- ) {
s = s + "L";
for ( int j = s.length()-2; j >= 0; j-- ) {
s += ( s.charAt( j ) == 'R' ) ? 'L' : 'R';
}
}
BusquedaPatrones bp = new BusquedaPatrones( this.patron, s );
return bp.searchNext();
}
}
|
/*
* 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 boundary;
import entity.Pain;
import javax.ejb.Stateless;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
/**
*
* @author Pi
*/
@Stateless
public class PainResource {
@PersistenceContext
EntityManager em;
/**
* Methode permettant d'enregistrer un pain
* @param nom pain à enregistrer
* @param taille taille du pain
* @return Pain enregistre
*/
public Pain save(String nom, String taille){
Pain b = new Pain();
b.setId(UUID.randomUUID().toString());
b.setNom(nom);
b.setTaille(taille);
return this.em.merge(b);
}
/**
* Methode permettant de recuperer un pain a partir de son id
* @param id id du pain
* @return pain recupere
*/
public Pain findById(String id){
Pain res = null;
try{
res = this.em.find(Pain.class,id);
}catch(EntityNotFoundException e){
}
return res;
}
/**
* Methode permettant d'obtenir la liste de tous les pains
* @return liste des pains
*/
public List<Pain> findAll(){
Query q = this.em.createNamedQuery("Pain.findAll",Pain.class);
q.setHint("javax.persistence.cache.storeMode",CacheStoreMode.REFRESH);
return q.getResultList();
}
/**
* Methode permettant de supprimer un pain
* @param id id du pain a supprimer
*/
public void delete(String id){
try{
Pain ins = this.em.getReference(Pain.class,id);
this.em.remove(ins);
}catch (EntityExistsException ex){
System.out.println("The object doesn't exist");
}
}
}
|
package com.filiereticsa.arc.augmentepf.models;
/**
* Created by ARC© Team for AugmentEPF project on 07/05/2017.
*/
public enum UserType {
VISITOR,
STUDENT,
TEACHER,
CONTRIBUTOR,
ADMINISTRATOR
}
|
package com.invitation.model;
import javax.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Entity
@Getter @Setter
@Table(name = "persons")
public class Person {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String name;
@Column(name = "lastName")
private String lastName;
private String phone;
}
|
package de.jmda.gen.java;
import de.jmda.gen.Generator;
import de.jmda.gen.GeneratorException;
/**
* Generator for extends clause like <code>extends JFrame</code>.
*
* @author ruu.jmda@gmail.com
*/
public interface ExtendsClauseGenerator extends Generator
{
StringBuffer getExtendsClause() throws GeneratorException;
void setExtendsClause(StringBuffer extendsClause);
void setExtendsClause(String extendsClause);
void setExtendsClause(Class<?> superClass);
}
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.tripad.cootrack.pojo;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author mfachmirizal
*/
public class CustomerClass {
private String id;
private String name;
private String showname;
private List<CustomerClass> children;
public CustomerClass() {
id = null;
name=null;
showname=null;
children=new ArrayList<CustomerClass>();
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the showname
*/
public String getShowname() {
return showname;
}
/**
* @param showname the showname to set
*/
public void setShowname(String showname) {
this.showname = showname;
}
/**
* @return the children
*/
public List<CustomerClass> getChildren() {
return children;
}
/**
* @param children the children to set
*/
public void setChildren(List<CustomerClass> children) {
this.children = children;
}
}
|
package com.rc.portal.dao;
import java.sql.SQLException;
import java.util.List;
import com.rc.portal.vo.YktGoods;
import com.rc.portal.vo.YktGoodsExample;
public interface YktGoodsDAO {
int countByExample(YktGoodsExample example) throws SQLException;
int deleteByExample(YktGoodsExample example) throws SQLException;
int deleteByPrimaryKey(Long id) throws SQLException;
Long insert(YktGoods record) throws SQLException;
Long insertSelective(YktGoods record) throws SQLException;
List selectByExample(YktGoodsExample example) throws SQLException;
YktGoods selectByPrimaryKey(Long id) throws SQLException;
int updateByExampleSelective(YktGoods record, YktGoodsExample example) throws SQLException;
int updateByExample(YktGoods record, YktGoodsExample example) throws SQLException;
int updateByPrimaryKeySelective(YktGoods record) throws SQLException;
int updateByPrimaryKey(YktGoods record) throws SQLException;
}
|
package com.alonemusk.medicalapp;
public class BaseAddress {
private static String baseurl="http://ec2-13-235-73-199.ap-south-1.compute.amazonaws.com:3000";
private static String user_id="mahendra";
public BaseAddress() {
}
public static String getBaseurl() {
return baseurl;
}
public static void setBaseurl(String baseurl) {
BaseAddress.baseurl = baseurl;
}
public static String getUser_id() {
return user_id;
}
public static void setUser_id(String user_id) {
BaseAddress.user_id = user_id;
}
}
|
package nl.paulzijlmans.creational.abstractfactory;
public class AmexPlatinumCreditCard extends CreditCard {
}
|
package yincheng.gggithub.common.base;
/**
* Mail : luoyincheng@gmail.com
* Date : 2018:05:19 8:33
* Github : yincheng.luo
*/
public class BaseActivity {
}
|
package com.mo.mohttp.anno;
import java.lang.annotation.*;
/**
* 表示是线程安全的.
*/
@Target({ElementType.TYPE,ElementType.FIELD,ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
@Documented
public @interface ThreadSafe {
}
|
package com.cloudogu.smeagol;
import com.google.common.collect.ImmutableMap;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.apereo.cas.client.authentication.AttributePrincipal;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.client.RestClientTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import java.io.IOException;
import java.util.Map;
import static com.cloudogu.smeagol.AccountService.shouldRefetchToken;
import static com.cloudogu.smeagol.AccountTestData.LONG_LASTING_JWT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withNoContent;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
/**
* Unit tests for {@link com.cloudogu.smeagol.AccountService}.
*
* @author Sebastian Sdorra
*/
@RunWith(SpringRunner.class)
@RestClientTest(AccountService.class)
public class AccountServiceTest {
@MockBean
private HttpServletRequest request;
@Mock
private HttpSession session;
@MockBean
private ObjectFactory<HttpServletRequest> requestFactory;
@Mock
private AttributePrincipal principal;
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Autowired
private MockRestServiceServer server;
@Autowired
private AccountService accountService;
/**
* Prepare mocks.
*/
@Before
public void setUpMocks() {
when(request.getSession(true)).thenReturn(session);
when(requestFactory.getObject()).thenReturn(request);
}
/**
* Tests {@link AccountService#get()} without principal.
*/
@Test
public void testGetWithoutPrincipal() {
expectedException.expect(AuthenticationException.class);
expectedException.expectMessage("principal");
accountService.get();
}
/**
* Tests {@link AccountService#get()} without proxy ticket.
*/
@Test
public void testGetWithoutProxyTicket() {
when(request.getUserPrincipal()).thenReturn(principal);
expectedException.expect(AuthenticationException.class);
expectedException.expectMessage("proxy");
expectedException.expectMessage("ticket");
accountService.get();
}
/**
* Tests {@link AccountService#get()} with an error during access token fetch.
*/
@Test
public void testGetFailedToFetchAccessToken() {
when(request.getUserPrincipal()).thenReturn(principal);
String accessTokenEndpoint = "/api/v2/cas/auth/";
when(principal.getProxyTicketFor("https://192.168.56.2/scm" + accessTokenEndpoint)).thenReturn("pt-123");
server.expect(requestTo(accessTokenEndpoint)).andRespond(withNoContent());
expectedException.expect(AuthenticationException.class);
expectedException.expectMessage("could not get accessToken from scm endpoint");
accountService.get();
}
/**
* Tests {@link AccountService#get()}.
*
* @throws IOException
*/
@Test
public void testGet() {
when(request.getUserPrincipal()).thenReturn(principal);
String accessTokenEndpoint = "/api/v2/cas/auth/";
when(principal.getProxyTicketFor("https://192.168.56.2/scm" + accessTokenEndpoint)).thenReturn("pt-123");
Map<String, Object> attributes = ImmutableMap.of(
"username", "admin", "displayName", "Administrator", "mail", "super@admin.org"
);
when(principal.getAttributes()).thenReturn(attributes);
server.expect(requestTo(accessTokenEndpoint))
.andExpect(header("Content-Type", "application/x-www-form-urlencoded"))
.andExpect(content().string("ticket=pt-123"))
.andRespond(withSuccess("jwtadmin", MediaType.TEXT_PLAIN));
Account account = accountService.get();
assertEquals("admin", account.getUsername());
assertEquals("jwtadmin", account.getAccessToken());
assertEquals("Administrator", account.getDisplayName());
assertEquals("super@admin.org", account.getMail());
verify(session).setAttribute(Account.class.getName(), account);
}
/**
* Tests {@link AccountService#get()} from session cache.
*/
@Test
public void testGetGetFromSession() {
Account account = new Account("hans", LONG_LASTING_JWT, "schalter", "hansamschalter@light.de");
when(session.getAttribute(Account.class.getName())).thenReturn(account);
Account returnedAccount = accountService.get();
assertSame(account, returnedAccount);
}
@Test
public void testShouldRefetchToken_expired() throws IOException {
assertEquals(true, shouldRefetchToken("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImp0aSI6IjZSU2FKVmdWdkgiLCJpYXQiOjE1MjM2NzU2ODAsImV4cCI6MTUyMzY3OTI4MCwic2NtLW1hbmFnZXIucmVmcmVzaEV4cGlyYXRpb24iOjE2MjM3MTg4ODAyODQsInNjbS1tYW5hZ2VyLnBhcmVudFRva2VuSWQiOiI2UlNhSlZnVnZIIn0.ignored"));
}
@Test
public void testShouldRefetchToken_valid() throws IOException {
// Token expires in year 2271
assertEquals(false, shouldRefetchToken(LONG_LASTING_JWT));
}
}
|
package com.akikun.leetcode.nowcoder;
import java.util.Scanner;
public class HJ104 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String tail = "00000000";
while (scan.hasNext()) {
int n = Integer.parseInt(scan.nextLine());
int time = 0;
while (time++ < n) {
String str = scan.nextLine();
int len = str.length();
int loop = len / 8;
StringBuilder sb = new StringBuilder();
for (int i = 0, from = 0, end = 8; i < loop; from += 8, i++, end += 8) {
sb.append(str, from, end).append("\n");
}
int left;
if ((left = len % 8) != 0) {
sb.append(str.substring(len-left))
.append(tail.substring(left))
.append("\n");
}
System.out.print(sb.toString());
}
}
}
}
|
package com.spbsu.flamestream.runtime;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntConsumer;
public class ConfigureFromEnv {
public static void configureFromEnv(String key, IntConsumer intConsumer) {
if (System.getenv().containsKey(key)) {
intConsumer.accept(Integer.parseInt(System.getenv(key)));
}
}
public static void configureFromEnv(String key, Consumer<String> consumer) {
if (System.getenv().containsKey(key)) {
consumer.accept(System.getenv(key));
}
}
public static <T> void configureFromEnv(String key, Function<String, T> factory, Consumer<T> consumer) {
if (System.getenv().containsKey(key)) {
consumer.accept(factory.apply(System.getenv(key)));
}
}
}
|
package com.itheima.mobileplayer64.db;
import java.io.File;
import android.os.Environment;
public class LyricsLoader {
private static File root = new File(Environment.getExternalStorageDirectory(),"test/audio/");
/** 从歌曲名查找歌词文件 */
public static File loadLyricFile(String displayName) {
// 根据歌曲名从本地查找.lrc文件
File lyricFile = fileExist(displayName,".lrc");
if (lyricFile != null) {
return lyricFile;
}
// 没找到lrc文件,尝试查找txt文件
lyricFile = fileExist(displayName,".txt");
if (lyricFile != null) {
return lyricFile;
}
// 尝试其他后缀的歌词文件
//....
//....
// 所有后缀的歌词文件都尝试完后,仍没有找到则尝试从服务器下载歌词
//....
//....
// 下载完成之后,将生成的歌词文件返回
lyricFile = fileExist(displayName,".lrc");
if (lyricFile != null) {
return lyricFile;
}
// 所有情况都没能获取到歌词文件,返回null
return null;
}
/** 检测指定歌曲名和后缀的歌词文件是否存在,存在则返回该文件,否则返回null */
private static File fileExist(String displayName, String lastName) {
File lyricFile = new File(root,displayName+lastName);
if (lyricFile !=null && lyricFile.exists()) {
return lyricFile;
}else {
return null;
}
}
}
|
package com.vmware.pa.multiprofile;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.dao.DataAccessException;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class MultiprofileApplication {
@Bean
public JdbcTemplate template(DataSource ds) {
return new JdbcTemplate(ds);
}
public static void main(String[] args) {
SpringApplication.run(MultiprofileApplication.class, args);
}
@RestController
public class HomeController {
@Autowired
JdbcTemplate template;
@GetMapping
public ResponseEntity<String> home()
throws DataAccessException {
return ResponseEntity.ok("Servername: " +
template.query(
"select @@SERVERNAME",
(ResultSetExtractor<String>) rs -> {
StringBuffer result = new StringBuffer();
while(rs.next()) {
result.append(rs.getString(1));
}
return result.toString();
}
)
);
}
}
}
|
package send.money.transfer;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.hateos.AbstractResource;
import io.micronaut.http.hateos.Link;
import io.micronaut.http.hateos.Resource;
import io.micronaut.http.hateos.VndError;
import io.micronaut.spring.tx.annotation.Transactional;
import send.money.ResourceUtils;
import send.money.ResourceWrapper;
import send.money.accounts.Account;
import send.money.accounts.AccountRepository;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.Optional;
@Singleton
public class OperationServiceImpl implements OperationService {
private final OperationRepository operationRepository;
private final AccountRepository accountRepository;
@Inject
public OperationServiceImpl(OperationRepository operationRepository, AccountRepository accountRepository) {
this.operationRepository = operationRepository;
this.accountRepository = accountRepository;
}
@Transactional(readOnly = true)
@Override
public HttpResponse<Resource> findOperation(Long id) {
Optional<Operation> operation = operationRepository.find(id);
if (!operation.isPresent()) {
VndError notFoundError = new VndError(String.format("Operation with id %d is not found.", id));
return HttpResponse.notFound(notFoundError);
}
AbstractResource<ResourceWrapper> accountResource = new ResourceWrapper(operation.get());
accountResource.link(Link.SELF, String.format("%s/%d", OperationsController.OPERATIONS_LINK, id));
return HttpResponse.ok(accountResource);
}
@Transactional
@Override
public Operation createNewOperation(Operation operation) {
Optional<Account> sender = accountRepository.findById(operation.getSender());
Optional<Account> recipient = accountRepository.findById(operation.getRecipient());
String message = "";
if (!sender.isPresent()) {
message += notFoundIdMessage("Sender", operation.getSender());
}
if (!recipient.isPresent()) {
message += notFoundIdMessage("Recipient", operation.getRecipient());
}
if (!sender.isPresent() || !recipient.isPresent()) {
throw new MoneyTransferException(HttpResponse.notFound(new VndError(message)));
}
return operationRepository.createNew(operation);
}
private String notFoundIdMessage(String person, Long id) {
return String.format("%s with id %d is not found. ", person, id);
}
@Transactional
@Override
public boolean withdraw(Operation operation) {
return operationRepository.withdraw(operation);
}
@Transactional
@Override
public void deposit(Operation operation) {
operationRepository.deposit(operation);
}
@Override
public HttpResponse<Resource> createOperationResource(Operation operation) {
AbstractResource<ResourceWrapper> accountResources = new ResourceWrapper(operation);
accountResources.link(Link.SELF, String.format("/operations/%d", operation.getId()));
accountResources.link("from", ResourceUtils.accountLink(operation.getSender()));
accountResources.link("to", ResourceUtils.accountLink(operation.getRecipient()));
return HttpResponse.ok(accountResources);
}
}
|
package br.com.opensig.financeiro.server.cobranca;
import org.jboleto.Banco;
import br.com.opensig.financeiro.shared.modelo.FinConta;
/**
* Classe para recuparar a cobranca de acordo com o banco.
*
* @author Pedro H. Lira
* @since 13/04/2009
* @version 1.0
*/
public class FabricaCobranca {
private static final FabricaCobranca fb = new FabricaCobranca();
private FabricaCobranca() {
}
/**
* Metodo que retorna a instancia da fábrica.
*
* @return uma fábrica de exportação.
*/
public static FabricaCobranca getInstancia() {
return fb;
}
/**
* Metodo que retorna uma classe de cobranca informado o banco.
*
* @param conta
* a conta da conbranca.
* @return o objeto de cobranca.
*/
public ICobranca getCobranca(FinConta conta) {
ICobranca cobranca;
int banco = Integer.valueOf(conta.getFinBanco().getFinBancoNumero());
switch (banco) {
case Banco.BANCO_DO_BRASIL:
cobranca = new BancoBrasil(conta);
break;
case Banco.BRADESCO:
cobranca = new Bradesco(conta);
break;
case Banco.ITAU:
cobranca = new Itau(conta);
break;
case Banco.CAIXA_ECONOMICA:
cobranca = new CaixaEconomica(conta);
break;
case Banco.HSBC:
cobranca = new Hsbc(conta);
break;
case Banco.NOSSACAIXA:
cobranca = new NossaCaixa(conta);
break;
case Banco.SANTANDER:
cobranca = new Santander(conta);
break;
default:
cobranca = null;
}
return cobranca;
}
}
|
package cn.itcast.shop.user.dao;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import cn.itcast.shop.user.vo.User;
/**
* 用户模块持久层代码
* @author Administrator
*
*/
public class UserDao extends HibernateDaoSupport{
//按名称查询是否有用户
public User findByUsername(String username){
String hql="from User where username =?";
List<User> list=this.getHibernateTemplate().find(hql, username);
if(list!=null && list.size()>0){
return list.get(0);
}
return null;
}
//注册用户存入数据库
public void save(User user) {
// TODO Auto-generated method stub
this.getHibernateTemplate().save(user);
}
//根据激活码查询用户
public User findByCode(String code) {
// TODO Auto-generated method stub
String hql="from User where code=?";
List<User> list=this.getHibernateTemplate().find(hql, code);
if(list !=null && list.size()>0){
return list.get(0);
}
return null;
}
//修改用户状态方法
public void update(User existUser) {
// TODO Auto-generated method stub
this.getHibernateTemplate().update(existUser);
}
//用户登录的方法
public User login(User user) {
// TODO Auto-generated method stub
String hql="from User where username=? and password=? and state=?";
List<User> list=this.getHibernateTemplate().find(hql,user.getUsername(),user.getPassword(),1);
if(list !=null && list.size()>0){
return list.get(0);
}
return null;
}
}
|
package com.project.buyeritemservice.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import com.project.buyeritemservice.entity.BillEntity;
public interface BillDao extends JpaRepository<BillEntity,Integer> {
}
|
package com.itheima.core.service;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.core.SpecificationService;
import com.itheima.core.dao.specification.SpecificationCheckDao;
import com.itheima.core.dao.specification.SpecificationDao;
import com.itheima.core.dao.specification.SpecificationOptionDao;
import com.itheima.core.pojo.specification.*;
import com.itheima.core.pojo.template.TypeTemplate;
import entity.PageResult;
import org.apache.commons.io.FileUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import pojogroup.SpecificationVo;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@Transactional
public class SpecificationServiceImpl implements SpecificationService {
@Autowired
private SpecificationCheckDao specificationCheckDao;
@Autowired
private SpecificationOptionDao specificationOptionDao;
@Autowired
private SpecificationDao specificationDao;
@Override
public PageResult search(Integer page, Integer rows, Specification specification) {
PageHelper.startPage(page, rows);
SpecificationQuery query = new SpecificationQuery();
SpecificationQuery.Criteria criteria = query.createCriteria();
if (null != specification.getSpecName() && !"".equals(specification.getSpecName().trim()))
criteria.andSpecNameLike("%" + specification.getSpecName().trim() + "%");
Page<Specification> p = (Page<Specification>) specificationDao.selectByExample(query);
// Page<Specification> p = (Page<Specification>) specificationDao.selectByExample(null); // 这个是无条件查询时使用的
return new PageResult(p.getTotal(), p.getResult());
}
@Override
public void add(SpecificationVo specificationVo) {
specificationCheckDao.insertSelective(specificationVo.getSpecificationCheck());
Long specId = specificationVo.getSpecificationCheck().getId();
// SpecificationOptionQuery query = new SpecificationOptionQuery();
// SpecificationOptionQuery.Criteria criteria = query.createCriteria();
// criteria.andIdIn(vo.getSpecificationOptionList().)
List<SpecificationOption> specificationOptionList = specificationVo.getSpecificationOptionList();
for (SpecificationOption specificationOption : specificationOptionList) {
specificationOption.setSpecId(specId);
specificationOptionDao.insertSelective(specificationOption);
}
}
/**
* 总结起来就是,不管是删除还是修改都必须满足是先改变的是从表,也就是先改变一对多的中的多, 再回头过来改一
*
* @param vo
*/
@Override
public void update(SpecificationVo vo) {
// SpecificationQuery query = new SpecificationQuery();
// SpecificationQuery.Criteria queryCriteria = query.createCriteria();
// if (null != vo.getSpecification() && !"".equals(vo.getSpecification().getSpecName().trim()))
// queryCriteria.andSpecNameLike("%" + vo.getSpecification().getSpecName().trim() + "%");
SpecificationCheck specificationCheck = vo.getSpecificationCheck();
if (null != specificationCheck && !"".equals(specificationCheck.getName().trim())) {
Long specId = specificationCheck.getId();
// 首先更新主表的specName
specificationCheck.setName(specificationCheck.getName().trim());
specificationCheckDao.updateByPrimaryKey(specificationCheck);
// 获取表单中的SpecificationOption集合
List<SpecificationOption> specificationOptionList = vo.getSpecificationOptionList();
SpecificationOptionQuery optionQuery = new SpecificationOptionQuery();
optionQuery.createCriteria().andSpecIdEqualTo(specId);
// 删除数据中的原specId对应的每一条SpecificationOption记录
specificationOptionDao.deleteByExample(optionQuery);
// 更新从表中每条SpecificationOption记录
for (SpecificationOption specificationOption : specificationOptionList) {
specificationOption.setSpecId(specId);
specificationOptionDao.insertSelective(specificationOption);
}
}
}
@Override
public SpecificationVo findOne(Long id) {
SpecificationVo vo = new SpecificationVo();
SpecificationCheck specificationCheck = specificationCheckDao.selectByPrimaryKey(id);
vo.setSpecificationCheck(specificationCheck);
SpecificationOptionQuery query = new SpecificationOptionQuery();
query.createCriteria().andSpecIdEqualTo(id);
// 增加根据orders排序的功能, 添加顺序可以改不了,这能通过查询的条件的限制来控制输出的顺序
query.setOrderByClause("orders desc"); // 降序需要自己写, 因为默认是升序的(升序可以省略asc)
List<SpecificationOption> specificationOptionList = specificationOptionDao.selectByExample(query);
vo.setSpecificationOptionList(specificationOptionList);
return vo;
}
/**
* 总结起来就是,不管是删除还是修改都必须满足是先改变的是从表,也就是先改变一对多的中的多, 再回头过来改一
*
* @param ids
*/
@Override
public void delete(Long[] ids) {
// SpecificationQuery specificationQuery = new SpecificationQuery();
// SpecificationQuery.Criteria specCriteria = specificationQuery.createCriteria();
// specCriteria.andIdIn(Arrays.asList(ids));
// List<Specification> specificationList = specificationDao.selectByExample(specificationQuery);
// for (int i = 0; i < specificationList.size(); i++) {
// Specification specification = specificationList.get(i);
// SpecificationOptionQuery query = new SpecificationOptionQuery();
// SpecificationOptionQuery.Criteria criteria = query.createCriteria();
// criteria.andSpecIdEqualTo(specification.getId());
// specificationOptionDao.deleteByExample(query);
// specificationDao.deleteByPrimaryKey(specification.getId());
// }
for (int i = 0; i < ids.length; i++) {
Long id = ids[i];
SpecificationOptionQuery query = new SpecificationOptionQuery();
SpecificationOptionQuery.Criteria criteria = query.createCriteria();
criteria.andSpecIdEqualTo(id);
specificationOptionDao.deleteByExample(query);
specificationCheckDao.deleteByPrimaryKey(id);
}
}
@Override
public List<Map> selectOptionList() {
return specificationDao.selectOptionList();
}
@Override
public void addSpecifications(File fo) throws Exception {
List<Specification> list = new ArrayList<>();
XSSFWorkbook workbook =null;
//创建Excel,读取文件内容
try {
workbook = new XSSFWorkbook(FileUtils.openInputStream(fo));
} catch (IOException e) {
e.printStackTrace();
}
//获取第一个工作表
XSSFSheet sheet = workbook.getSheet("specification");
//获取sheet中第一行行号
int firstRowNum = sheet.getFirstRowNum();
//获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
//循环插入数据
for(int i=firstRowNum+1;i<=lastRowNum;i++){
XSSFRow row = sheet.getRow(i);
Specification specification = new Specification();
XSSFCell name = row.getCell(1);//name
if(name!=null){
name.setCellType(Cell.CELL_TYPE_STRING);
specification.setSpecName((name.getStringCellValue()));
}
list.add(specification);
}
for (int i = 0; i < list.size(); i++) {
Specification specification = list.get(i);
specificationDao.insertSelective(specification);//往数据库插入数据
}
workbook.close();
}
}
|
package biz.fesenmeyer;
public class Arrest {
private String location;
private String crimeType;
public Arrest(String location, String crimeType) {
super();
this.location = location;
this.crimeType = crimeType;
}
public String getLocation() {
return location;
}
public String getCrimeType() {
return crimeType;
}
@Override
public String toString() {
return "Ort: " + location + " Grund: " + crimeType;
}
}
|
package com.tencent.mm.plugin.card.sharecard.ui;
import android.content.Intent;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewStub;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.mm.plugin.card.a.c;
import com.tencent.mm.plugin.card.a.d;
import com.tencent.mm.plugin.card.a.e;
import com.tencent.mm.plugin.card.a.g;
import com.tencent.mm.plugin.card.b.c$a;
import com.tencent.mm.plugin.card.b.d$a;
import com.tencent.mm.plugin.card.b.j;
import com.tencent.mm.plugin.card.base.b;
import com.tencent.mm.plugin.card.d.l;
import com.tencent.mm.plugin.card.d.m;
import com.tencent.mm.plugin.card.model.am;
import com.tencent.mm.plugin.card.sharecard.ui.a.a;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.protocal.c.pr;
import com.tencent.mm.sdk.platformtools.x;
import com.tencent.mm.ui.statusbar.DrawStatusBarActivity;
public class CardConsumeCodeUI extends DrawStatusBarActivity implements OnClickListener, c$a, d$a {
private final String TAG = "MicroMsg.CardConsumeCodeUI";
private Vibrator hni;
private int hop = 3;
private b htQ;
private String hyZ;
private int hza = 3;
private int hzb = 0;
private a hzc;
private TextView hzd;
private TextView hze;
private LinearLayout hzf;
private ImageView hzg;
private View hzh;
private LinearLayout hzi;
private View hzj;
private TextView hzk;
private TextView hzl;
private TextView hzm;
private boolean hzn = false;
protected final int getLayoutId() {
return e.card_consume_code_ui;
}
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
x.i("MicroMsg.CardConsumeCodeUI", "onCreate()");
setResult(0);
this.htQ = (b) getIntent().getParcelableExtra("key_card_info_data");
this.hop = getIntent().getIntExtra("key_from_scene", 3);
this.hza = getIntent().getIntExtra("key_previous_scene", 3);
this.hyZ = getIntent().getStringExtra("key_mark_user");
this.hzb = getIntent().getIntExtra("key_from_appbrand_type", 0);
if (this.htQ == null || this.htQ.awm() == null || this.htQ.awn() == null) {
x.e("MicroMsg.CardConsumeCodeUI", "mCardInfo == null or mCardInfo.getCardTpInfo() == null or mCardInfo.getDataInfo() == null");
finish();
return;
}
initView();
am.axo().p("", "", 3);
}
protected final void initView() {
a aVar;
if (this.htQ.avT()) {
if (TextUtils.isEmpty(this.htQ.awm().hwg)) {
setMMTitle(getString(g.card_consume_code_ui_title, new Object[]{getString(g.card_membership)}));
} else {
setMMTitle(getString(g.card_consume_code_ui_title, new Object[]{this.htQ.awm().hwg}));
}
}
setBackBtn(new 1(this));
if (this.hzc == null) {
this.hzc = new a(this, this.mController.contentView);
aVar = this.hzc;
aVar.hyW = aVar.gKS.getWindow().getAttributes().screenBrightness;
a aVar2 = this.hzc;
aVar2.hyP = (TextView) aVar2.hyK.findViewById(d.card_notice);
aVar2.hyQ = (TextView) aVar2.hyK.findViewById(d.card_pay_and_qrcode_notice);
aVar2.hyR = (CheckBox) aVar2.hyK.findViewById(d.notify_checkbox);
aVar2.hyR.setChecked(true);
aVar2.hyR.setOnClickListener(aVar2.eZF);
if (aVar2.hyW < 0.8f) {
aVar2.ag(0.8f);
}
this.hzc.hyV = new a() {
public final void nO(int i) {
am.axu().H(CardConsumeCodeUI.this.htQ.awq(), i, 1);
}
};
}
this.hzc.htQ = this.htQ;
this.hzc.hyU = true;
if (this.htQ.avS()) {
aVar = this.hzc;
String str = this.hyZ;
aVar.hyT = 1;
aVar.hyS = str;
}
this.hni = (Vibrator) getSystemService("vibrator");
this.hzd = (TextView) findViewById(d.brand_name);
this.hze = (TextView) findViewById(d.title);
this.hzf = (LinearLayout) findViewById(d.app_logo_layout);
this.hzg = (ImageView) findViewById(d.app_logo);
this.hzh = findViewById(d.dash_line);
this.hzi = (LinearLayout) findViewById(d.code_layout);
if (this.htQ.avT()) {
findViewById(d.card_consumed_code_ui).setBackgroundColor(getResources().getColor(com.tencent.mm.plugin.card.a.a.card_bg_color));
m.d(this);
com.tencent.mm.ui.statusbar.a.c(this.mController.contentView, -1, true);
} else {
int xV = l.xV(this.htQ.awm().dxh);
findViewById(d.card_consumed_code_ui).setBackgroundColor(xV);
m.a(this, this.htQ);
com.tencent.mm.ui.statusbar.a.c(this.mController.contentView, xV, true);
}
if (!this.htQ.avT() || TextUtils.isEmpty(this.htQ.awm().huW)) {
this.hzd.setText(this.htQ.awm().hwh);
this.hze.setText(this.htQ.awm().title);
} else {
this.hzf.setVisibility(0);
this.hzd.setVisibility(8);
this.hze.setVisibility(8);
this.hzh.setVisibility(8);
m.a(this.hzg, this.htQ.awm().huW, getResources().getDimensionPixelSize(com.tencent.mm.plugin.card.a.b.card_coupon_widget_logo_size), c.my_card_package_defaultlogo, true);
}
if (this.htQ.awm().rok != null) {
pr prVar = this.htQ.awm().rok;
if (!TextUtils.isEmpty(prVar.title)) {
if (this.hzj == null) {
this.hzj = ((ViewStub) findViewById(d.card_pay_and_qrcode_stub)).inflate();
}
this.hzj.setOnClickListener(this);
this.hzk = (TextView) this.hzj.findViewById(d.card_pay_and_qrcode_title);
this.hzl = (TextView) this.hzj.findViewById(d.card_pay_and_qrcode_sub_title);
this.hzm = (TextView) this.hzj.findViewById(d.card_pay_and_qrcode_aux_title);
this.hzk.setVisibility(0);
this.hzk.setText(prVar.title);
Drawable drawable = getResources().getDrawable(c.card_continue_arrow);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
drawable.setColorFilter(l.xV(this.htQ.awm().dxh), Mode.SRC_IN);
this.hzk.setCompoundDrawables(null, null, drawable, null);
this.hzk.setTextColor(l.xV(this.htQ.awm().dxh));
this.hzk.setOnClickListener(this);
if (TextUtils.isEmpty(prVar.huX)) {
this.hzl.setVisibility(0);
this.hzl.setText(getString(g.card_membership_continue_tip));
} else {
this.hzl.setVisibility(0);
this.hzl.setText(prVar.huX);
}
if (!TextUtils.isEmpty(prVar.huY)) {
this.hzm.setVisibility(0);
this.hzm.setText(prVar.huY);
}
LayoutParams layoutParams = this.hzg.getLayoutParams();
layoutParams.height = getResources().getDimensionPixelSize(com.tencent.mm.plugin.card.a.b.card_coupon_widget_small_logo_size);
layoutParams.width = getResources().getDimensionPixelSize(com.tencent.mm.plugin.card.a.b.card_coupon_widget_small_logo_size);
this.hzg.setLayoutParams(layoutParams);
layoutParams = this.hzf.getLayoutParams();
layoutParams.height = com.tencent.mm.bp.a.fromDPToPix(this, 54);
layoutParams.width = com.tencent.mm.bp.a.fromDPToPix(this, 54);
this.hzf.setLayoutParams(layoutParams);
m.a(this.hzg, this.htQ.awm().huW, getResources().getDimensionPixelSize(com.tencent.mm.plugin.card.a.b.card_coupon_widget_small_logo_size), c.my_card_package_defaultlogo, true);
this.hzi.setPadding(0, com.tencent.mm.bp.a.fromDPToPix(this, 10), 0, com.tencent.mm.bp.a.fromDPToPix(this, 30));
}
}
am.axt().a(this);
if (this.htQ.awg()) {
am.axv().a(this);
if (am.axv().isEmpty()) {
x.i("MicroMsg.CardConsumeCodeUI", "registerListener doGetCardCodes");
am.axv().xc(this.htQ.awq());
return;
}
am.axv().awC();
}
}
protected void onResume() {
this.hzc.axM();
am.axt().a(this, true);
super.onResume();
}
protected void onPause() {
am.axt().a(this, false);
super.onPause();
}
protected void onDestroy() {
a aVar = this.hzc;
aVar.ag(aVar.hyW);
l.x(aVar.eZA);
l.x(aVar.hyO);
aVar.hyV = null;
aVar.gKS = null;
am.axt().c(this);
am.axt().b(this);
if (this.htQ.awg()) {
am.axv().b(this);
am.axv().awD();
}
this.hni.cancel();
super.onDestroy();
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4) {
x.e("MicroMsg.CardConsumeCodeUI", "onKeyDown finishUI");
setResult(-1);
finish();
}
return super.onKeyDown(i, keyEvent);
}
public final void f(b bVar) {
x.i("MicroMsg.CardConsumeCodeUI", "onDataChange");
if (bVar != null && bVar.awq() != null && bVar.awq().equals(this.htQ.awq())) {
this.htQ = bVar;
this.hzc.htQ = this.htQ;
this.hzc.axM();
}
}
public final void awJ() {
this.hni.vibrate(300);
}
public final void awK() {
x.i("MicroMsg.CardConsumeCodeUI", "onFinishUI");
finish();
}
public final void xe(String str) {
x.i("MicroMsg.CardConsumeCodeUI", "onStartConsumedSuccUI");
if (this.hzn) {
x.e("MicroMsg.CardConsumeCodeUI", "has start CardConsumeSuccessUI!");
return;
}
x.i("MicroMsg.CardConsumeCodeUI", "startConsumedSuccUI() ");
this.hzn = true;
Intent intent = new Intent(this, CardConsumeSuccessUI.class);
intent.putExtra("KEY_CARD_ID", this.htQ.awq());
intent.putExtra("KEY_CARD_CONSUMED_JSON", str);
intent.putExtra("KEY_CARD_COLOR", this.htQ.awm().dxh);
intent.putExtra("key_stastic_scene", this.hop);
intent.putExtra("key_from_scene", 0);
startActivity(intent);
}
public final void awE() {
this.hzc.axM();
}
public final void xb(String str) {
com.tencent.mm.plugin.card.d.d.a(this, str, true);
}
public final void onSuccess() {
this.hzc.axM();
}
public void onClick(View view) {
if (view.getId() == d.card_pay_and_qrcode_title || view.getId() == d.card_pay_and_qrcode) {
if (this.htQ.awf()) {
j.b bVar = new j.b();
com.tencent.mm.plugin.card.d.b.a(this, bVar.huK, bVar.huL, false, this.htQ);
} else {
pr prVar = this.htQ.awm().rok;
if (!(com.tencent.mm.plugin.card.d.b.a(this.htQ.awq(), prVar, this.hza, this.hzb) || prVar == null || TextUtils.isEmpty(prVar.url))) {
com.tencent.mm.plugin.card.d.b.a(this, l.x(prVar.url, prVar.roL), 1);
h.mEJ.h(11941, new Object[]{Integer.valueOf(9), this.htQ.awq(), this.htQ.awr(), "", prVar.title});
if (l.a(prVar, this.htQ.awq())) {
String awq = this.htQ.awq();
String str = prVar.title;
l.yb(awq);
com.tencent.mm.plugin.card.d.b.a(this, this.htQ.awm().hwh);
}
}
}
finish();
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.