method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
56c2ecba-18cf-41f6-ab04-8de480510035
| 5
|
@Override public FileBlob getBlob( String urn ) {
Matcher m = SHA1EXTRACTOR.matcher(urn);
if( !m.find() ) return null;
if( !dataDir.exists() ) return null;
String sha1Base32 = m.group(1);
String postSectorPath = sha1Base32.substring(0,2) + "/" + sha1Base32;
File[] sectorFileList = dataDir.listFiles();
if( sectorFileList == null ) return null;
for( File sector : sectorFileList ) {
FileBlob blobFile = new FileBlob(sector, postSectorPath);
if( blobFile.exists() ) return blobFile;
}
return null;
}
|
77a983ea-988e-4cab-a990-eec6413a79cc
| 0
|
public GenericDAOXml(String filename, Class<T> klass) throws DaoException {
super(filename);
this.klass = klass;
}
|
7ba0b54a-babb-4766-858c-bef6bb632b14
| 0
|
public CmpPoint(int x, int y) {
this.x = x;
this.y = y;
}
|
1729f130-5fee-4c3b-afc3-431b0714e562
| 0
|
@Basic
@Column(name = "taxable")
public int getTaxable() {
return taxable;
}
|
42379742-5ba1-4da0-b87e-a61cf013a1c9
| 1
|
public void heapSort() { // decreasing order, since this is maxHeap
for (int i = 0; i < heap.size(); i++) {
BTPosition<T> tmp = remove();
System.out.println("Removed: " + tmp.element());
}
}
|
fc798a6c-b69c-4b72-b805-f58a71c8c3ba
| 9
|
private void searchWordTxtBoxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchWordTxtBoxKeyPressed
// 入力されたキーを取得
int keycode = evt.getKeyCode();
// Enterキーを入力した場合
if (keycode == KeyEvent.VK_ENTER) {
// ファイルオブジェクト
File objFile = new File(POST_CODE_FILE);
// ファイル読み込みを行うクラスのインスタンス生成
PostCodeFileSearcher postCodeFile = new PostCodeFileSearcher(POST_CODE_FILE, searchWordTxtBox.getText());
try {
// ファイルが存在しない場合
if (objFile.exists() == false) {
// 警告メッセージを出力
JOptionPane.showMessageDialog(this, "ファイルが存在しません。", "Worn", JOptionPane.WARNING_MESSAGE);
// ファイルが読み書きできない場合
} else if (objFile.canWrite() == false || objFile.canRead() == false) {
// 警告メッセージを出力
JOptionPane.showMessageDialog(this, "ファイルの読み書きができません。", "Worn", JOptionPane.WARNING_MESSAGE);
// 該当データが存在しない場合
} else if (postCodeFile.getRowNum() == 0) {
// 警告メッセージを出力
JOptionPane.showMessageDialog(this, "該当データが存在しません。", "Worn", JOptionPane.WARNING_MESSAGE);
// 該当データが存在する場合
} else {
// デフォルトテーブルを定義
DefaultTableModel defTable = (DefaultTableModel) searchResultTbl.getModel();
// 行数を設定
defTable.setRowCount(postCodeFile.getRowNum());
// 読み込んだデータを取得する
List<String[]> postCodeData = postCodeFile.getFileData();
for (int cntRow = 0; cntRow < postCodeData.size(); cntRow++) {
for (int countColumn = 0; countColumn < postCodeData.get(cntRow).length; countColumn++) {
searchResultTbl.setValueAt(postCodeData.get(cntRow)[countColumn], cntRow, countColumn);
}
}
if (deleteModeBtn.isSelected() == true){
updateBtn.setVisible(true);
updateBtn.setEnabled(true);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
|
ea58e59a-403e-44ae-8aa0-6145832f3d65
| 7
|
public Component getComponentForDataSection(TaskObserver taskObserver, String dataSectionName) throws InterruptedException
{
if (dataSectionName == DATA_SECTION_UNKNOWN0) { return getGeneralPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_VISIBLE_MAP_1) { return getVisibleMapPanel1(taskObserver); }
else if (dataSectionName == DATA_SECTION_VISIBLE_MAP_2) { return getVisibleMapPanel2(taskObserver); }
else if (dataSectionName == DATA_SECTION_FACET_ATTRIBUTES) { return getFacetAttributesPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_SPRITE_ATTRIBUTES) { return getSpriteAttributesPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_MAP_BITS) { return getMapBitsPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_REMAINING_DATA) { return getRemainingDataPanel(taskObserver); }
else return super.getComponent(dataSectionName, taskObserver);
}
|
72fbc712-3ea6-4ea7-9e71-d093782f1126
| 3
|
public void connect(String host, int port)
{
try
{
if (host.length() > 4) setConnection(new Socket(host, port));
}
catch (UnknownHostException e)
{
chatLogWrite("Impossible to find your mate's host :C. Check twice his Ip :) ");
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
|
39ff841c-b715-4e18-bcf7-2c80ce6ef6ce
| 1
|
@Override
public int attack(double agility, double luck) {
if(random.nextInt(100) < luck)
{
System.out.println("I just created a darkness jupitel!");
return random.nextInt((int) agility) * 2;
}
return 0;
}
|
28ee6cf3-af87-471a-ae2b-05339a58b2e4
| 7
|
public static String LCS2(String s1, String s2, String[][] LCSArray, int index1, int index2){
if(index1 == -1 || index2 == -1) return "";
if(s1.charAt(index1) == s2.charAt(index2)){
if(LCSArray[index1][index2]=="")
LCSArray[index1][index2] = LCS2(s1, s2, LCSArray, index1-1, index2-1);
LCSArray[index1+1][index2+1] = LCSArray[index1][index2] + s1.charAt(index1);
}else{
if(LCSArray[index1+1][index2]=="")
LCSArray[index1+1][index2] = LCS2(s1, s2, LCSArray, index1, index2-1);
if(LCSArray[index1][index2+1]=="")
LCSArray[index1][index2+1] = LCS2(s1, s2, LCSArray, index1-1, index2);
if(LCSArray[index1+1][index2].length() > LCSArray[index1][index2+1].length())
LCSArray[index1+1][index2+1] = LCSArray[index1+1][index2];
else
LCSArray[index1+1][index2+1] = LCSArray[index1][index2+1];
}
return LCSArray[index1+1][index2+1];
}
|
27ced2e9-44de-4823-9663-d4ed73327222
| 4
|
public void refaz(int esq, int dir) {
int j = esq * 2;
int x = this.fp[esq];
while (j <= dir) {
if ((j < dir) && (this.p[fp[j]] > this.p[fp[j + 1]]))
j++;
if (this.p[x] <= this.p[fp[j]])
break;
this.fp[esq] = this.fp[j];
this.pos[fp[j]] = esq;
esq = j;
j = esq * 2;
}
this.fp[esq] = x;
this.pos[x] = esq;
}
|
46422c77-44b2-4a18-aeb6-e6e55c181bed
| 5
|
public static void main(String[] args) {
int origem = 0;
int destino = 0;
try {
totalVertices = countLines("arquivo.txt");
System.out.println("O vertice de indice mais alto tem valor: " + totalVertices);
Scanner scanner = new Scanner(System.in);
System.out.println("Informe os vertices de origem e de destino e tecle ENTER");
String[] values = scanner.nextLine().split(" ");
origem = Integer.parseInt(values[0]);
destino = Integer.parseInt(values[1]);
if (origem < 0) {
System.err.println("Valor de origem invalido! Algoritmo nao suporta valores negativos!");
System.exit(-1);
}
if (destino > totalVertices) {
System.err.println("Valor de destino invalido! O valor do vertice nao existe na arvore!");
System.exit(-1);
}
} catch (IOException e) {
System.err.println("Erro na leitura do arquivo 'arquivo.txt'");
System.exit(-1);
} catch (Exception e) {
System.err.println("Erro na entrada/leitura de dados! Informe 2 numeros separados por um espaco!");
System.exit(-1);
}
try {
new Executa(origem, destino);
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
|
5abf584f-2020-44f3-a02a-668f48af6049
| 5
|
@Override
public void Draw(Graphics2D g2d)
{
switch (gameState)
{
case PLAYING:
game.Draw(g2d, mousePosition());
break;
case GAMEOVER:
game.DrawGameOver(g2d, mousePosition());
break;
case MAIN_MENU:
g2d.drawImage(shootTheDuckMenuImg, 0, 0, frameWidth, frameHeight, null);
g2d.drawString("Use left mouse button to shot the duck.", frameWidth / 2 - 83, (int)(frameHeight * 0.65));
g2d.drawString("Click with left mouse button to start the game.", frameWidth / 2 - 100, (int)(frameHeight * 0.67));
g2d.drawString("Press ESC any time to exit the game.", frameWidth / 2 - 75, (int)(frameHeight * 0.70));
g2d.setColor(Color.white);
g2d.drawString("WWW.GAMETUTORIAL.NET", 7, frameHeight - 5);
break;
case OPTIONS:
//...
break;
case GAME_CONTENT_LOADING:
g2d.setColor(Color.white);
g2d.drawString("GAME is LOADING", frameWidth / 2 - 50, frameHeight / 2);
break;
}
}
|
5d875540-3549-4418-bde8-f4adccd49602
| 0
|
public static void addEventInTime(Event e)//adds the passed in event into the date in history
{
Day d = cursor.getDayStored();//the current the c
d.addEvent(e);
CalendarProject.saveEvents(cursor);//saves the file into text
// ArrayList <Day> listOfDays= currentMonth.getDays();
// listOfDays.set(d.getNum()-1,d);
// currentMonth.setDays(listOfDays);
// ArrayList <Month> listOfMonths = currentYear.getMonths();
// listOfMonths.set(currentMonth.getNum()-1, currentMonth);
// currentYear.setMonths(listOfMonths);
// CalendarProject.updates(currentYear);
// CalendarProject.setInformationPanel(cursor);
//
}
|
235dcf69-3412-4a9b-a4af-a18ab479eb50
| 1
|
@Override
public void onEvent(Event event) {
// If this event happens to be a ScannedRobotEvent...
if (event instanceof ScannedRobotEvent) {
onScannedRobot((ScannedRobotEvent) event);
}
}
|
5e89525b-ce54-44ee-8a40-edb1df5cf861
| 7
|
protected void fileArrestResister(Law laws, Area myArea, LegalWarrant W)
{
if((W.criminal()!=null)
&&(W.arrestingOfficer()!=null)
&&(!W.arrestingOfficer().amDead())
&&(!W.crime().equalsIgnoreCase("pardoned"))
&&(!CMLib.flags().isInTheGame(W.criminal(),true))
&&(isStillACrime(W,false)))
{
if(laws.basicCrimes().containsKey("RESISTINGARREST"))
{
final String[] info=laws.basicCrimes().get("RESISTINGARREST");
fillOutWarrant(W.criminal(),
laws,
myArea,
null,
info[Law.BIT_CRIMELOCS],
info[Law.BIT_CRIMEFLAGS],
info[Law.BIT_CRIMENAME],
info[Law.BIT_SENTENCE],
info[Law.BIT_WARNMSG]);
}
}
}
|
466a5e5c-3635-4f39-983e-1b6b506f6ae6
| 5
|
final void setEnabled(final boolean enabled) {
if (isEnabled != enabled) {
isEnabled = enabled;
if (isEnabled) {
onEnable();
} else {
onDisable();
// delete all the locals
if (MiniPythonPlugin.mashUpJython) {
PyObject obj = interpreter.getLocals();
List<PyObject> list = new ArrayList<>();
for (PyObject key : obj.asIterable()) {
list.add(key);
}
for (PyObject key : list) {
obj.__delitem__(key);
}
interpreter.setLocals(Py.newStringMap());
}
}
}
}
|
0716abbd-a14f-40f3-9d64-c753997dc4fe
| 1
|
public static String md5(byte[] data) throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance(MD5);
digest.update(data);
byte[] bytes = digest.digest();
int length = bytes.length;
StringBuffer buffer = new StringBuffer(length * 2);
// 把密文转换成十六进制的字符串形式
for (int j = 0; j < length; j++) {
buffer.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
buffer.append(HEX_DIGITS[bytes[j] & 0x0f]);
}
return buffer.toString();
}
|
77d1fd35-5d57-408e-849b-4c63672951aa
| 0
|
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
}
|
df284b5c-27d0-427c-ac6d-a6d8bccb7f3e
| 4
|
public static void main(String[] args) {
final Statistic statistic = new StatisticImpl();
statistic.setStartTime(new Date());
QuestionGenerator generator = makeGenerator();
Formatter<Statistic> formatter = new StatisticFormatter();
final ManifestReader manifest = new ManifestReaderImpl();
String message = String.format("\n\nEXCEPTION QUIZ v%s\nEnter \"q\" for exit\n", manifest.getVersion());
Inquirer inquirer = new ConsoleInquirer(statistic, formatter);
inquirer.showInfoMessage(message);
DuplicateBlocker<Question> blocker = new QuestionDuplicateBlocker();
while (true) {
Question question;
do {
question = generator.randomQuestion();
} while (blocker.isDuplicate(question));
inquirer.showQuestionText(question);
String answer = inquirer.takeAnswerText(question.getPrompt());
if (QUIT_ANSWER.isRight(answer)) {
statistic.setFinishTime(new Date());
inquirer.showStatistic(statistic);
break;
} else if (question.getRightAnswer().isRight(answer)) {
statistic.incRightQuestions();
inquirer.showRightAnswerText("RIGHT!");
} else {
statistic.incMistakeQuestions();
inquirer.showRightAnswerText("MISTAKE: " + question.getAnswerText());
}
}
}
|
5d9aeca8-499c-4cfb-92d9-9a2d9eaeb83c
| 0
|
public ArrayList<Rectangle> getPanels() {
return panels;
}
|
dc72ed0d-a33e-4d01-b94e-0d66d8b9c29c
| 0
|
public FileRecv( String addr, String name ) {
srcaddr = addr;
srcname = name;
}
|
6cd1c04e-fe0e-489a-bd13-85f445221655
| 1
|
public int queueLengthIter(){
PatientDL temp = this;
int count = 0;
while (temp != null){
temp = temp.nextPatient;
count++;
}
return count;
}
|
fc337e4b-40bd-4aa7-8b62-5123f67b19e0
| 3
|
protected void initiateCandidateSolutions() {
int columns = objectiveFunction.getVariables();
position = new double[numberOfParticles][columns];
velocities = new double[numberOfParticles][columns];
for(int i = 0; i < numberOfParticles; i++){
for(int k = 0; k < columns; k++){
velocities[i][k] = 0;
if(Math.random() >= 0.5){
position[i][k] = 0;
}else{
position[i][k] = 1;
}
}
}
personalBest = position.clone();
fitness = new HashMap<Integer, Double>();
setFitness();
}
|
480cd20d-02b5-4b0a-89f4-9cef85647068
| 8
|
@Override
public void e(float sideMot, float forMot) {
if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
super.e(sideMot, forMot);
this.W = 0.5F; // Make sure the entity can walk over half slabs,
// instead of jumping
return;
}
EntityHuman human = (EntityHuman) this.passenger;
if (!RideThaMob.control.contains(human.getBukkitEntity().getName())) {
// Same as before
super.e(sideMot, forMot);
this.W = 0.5F;
return;
}
this.lastYaw = this.yaw = this.passenger.yaw;
this.pitch = this.passenger.pitch * 0.5F;
// Set the entity's pitch, yaw, head rotation etc.
this.b(this.yaw, this.pitch); // https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/Entity.java#L163-L166
this.aO = this.aM = this.yaw;
this.W = 1.0F; // The custom entity will now automatically climb up 1
// high blocks
sideMot = ((EntityLiving) this.passenger).bd * 0.5F;
forMot = ((EntityLiving) this.passenger).be;
if (forMot <= 0.0F) {
forMot *= 0.25F; // Make backwards slower
}
sideMot *= 0.75F; // Also make sideways slower
float speed = 0.35F; // 0.2 is the default entity speed. I made it
// slightly faster so that riding is better than
// walking
this.i(speed); // Apply the speed
super.e(sideMot, forMot); // Apply the motion to the entity
try {
Field jump = null;
jump = EntityLiving.class.getDeclaredField("bc");
jump.setAccessible(true);
if (jump != null && this.onGround) { // Wouldn't want it jumping
// while
// on the ground would we?
if (jump.getBoolean(this.passenger)) {
double jumpHeight = 0.5D;
this.motY = jumpHeight; // Used all the time in NMS for
// entity jumping
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
|
003afe36-a24a-4945-959f-6e5fcd163beb
| 8
|
public static boolean isValid(char[] input) {
LinkedList<Character> stack = new LinkedList<>();
for(int i=0; i< input.length; i++) {
if(stack.peek() != null) {
// get the top element
char c = stack.peek();
//switch the top element
switch(c) {
//if the top element is opening bracket of any type
case '(':
//check if current character on input array is closing bracket or not
if(input[i] == ')') {
//pop the stack
stack.pop();
} else {
//push the element
stack.push(input[i]) ;
}
break;
case '[' :
if(input[i] == ']') {
stack.pop();
} else {
stack.push(input[i]) ;
}
break;
case '{' :
if(input[i] == '}') {
stack.pop();
} else {
stack.push(input[i]) ;
}
break;
//if any other character like closing '}' is on stack top, push it to the stack
default:
stack.push(input[i]) ;
break;
}
} else {
stack.push(input[i]);
}
}
return stack.isEmpty();
}
|
619d8c9f-11af-4a3d-8542-7c4d9b88b7f2
| 8
|
static void prob8() {
/*
* Find the greatest product of five consecutive digits in the
* 1000-digit number.
*
* 73167176531330624919225119674426574742355349194934
* 96983520312774506326239578318016984801869478851843
* 85861560789112949495459501737958331952853208805511
* 12540698747158523863050715693290963295227443043557
* 66896648950445244523161731856403098711121722383113
* 62229893423380308135336276614282806444486645238749
* 30358907296290491560440772390713810515859307960866
* 70172427121883998797908792274921901699720888093776
* 65727333001053367881220235421809751254540594752243
* 52584907711670556013604839586446706324415722155397
* 53697817977846174064955149290862569321978468622482
* 83972241375657056057490261407972968652414535100474
* 82166370484403199890008895243450658541227588666881
* 16427171479924442928230863465674813919123162824586
* 17866458359124566529476545682848912883142607690042
* 24219022671055626321111109370544217506941658960408
* 07198403850962455444362981230987879927244284909188
* 84580156166097919133875499200524063689912560717606
* 05886116467109405077541002256983155200055935729725
* 71636269561882670428252483600823257530420752963450
*/
long start = System.currentTimeMillis();
String s = "73167176531330624919225119674426574742355349194934"
+ "96983520312774506326239578318016984801869478851843"
+ "85861560789112949495459501737958331952853208805511"
+ "12540698747158523863050715693290963295227443043557"
+ "66896648950445244523161731856403098711121722383113"
+ "62229893423380308135336276614282806444486645238749"
+ "30358907296290491560440772390713810515859307960866"
+ "70172427121883998797908792274921901699720888093776"
+ "65727333001053367881220235421809751254540594752243"
+ "52584907711670556013604839586446706324415722155397"
+ "53697817977846174064955149290862569321978468622482"
+ "83972241375657056057490261407972968652414535100474"
+ "82166370484403199890008895243450658541227588666881"
+ "16427171479924442928230863465674813919123162824586"
+ "17866458359124566529476545682848912883142607690042"
+ "24219022671055626321111109370544217506941658960408"
+ "07198403850962455444362981230987879927244284909188"
+ "84580156166097919133875499200524063689912560717606"
+ "05886116467109405077541002256983155200055935729725"
+ "71636269561882670428252483600823257530420752963450";
String[] array = s.split("0");
int max = 0;
int prod = 1;
for (int i = 0; i < array.length; i++)
if (array[i].length() > 0)
if (array[i].length() < 6) {
prod = 1;
for (int j = 0; j < array[i].length(); j++)
prod *= Primitive.intValue(array[i].charAt(j));
if (prod > max)
max = prod;
} else {
prod = Primitive.intValue(array[i].charAt(0))
* Primitive.intValue(array[i].charAt(1))
* Primitive.intValue(array[i].charAt(2))
* Primitive.intValue(array[i].charAt(3))
* Primitive.intValue(array[i].charAt(4));
if (prod > max)
max = prod;
for (int j = 5; j < array[i].length(); j++) {
prod /= Primitive.intValue(array[i].charAt(j - 5));
prod *= Primitive.intValue(array[i].charAt(j));
if (prod > max)
max = prod;
}
}
System.out.println("8: " + max);
System.out.println("\tTime taken: "
+ (System.currentTimeMillis() - start));
}
|
fce51b02-d164-4282-9a43-7db1ac8a81a6
| 6
|
static void removeEdge(HashSet<String> subgraph) {
double min_jaccard = 99999;
int max_union = 0;
String min_a = null;
String min_b = null;
for (String from : subgraph) {
for (String to : graph.get(from)) {
if (subgraph.contains(to)) {
double jaccard = jaccard(from, to);
if (jaccard == 0) {
min_jaccard = 0;
int union = union(from, to);
if (union > max_union) {
min_a = from;
min_b = to;
}
}
if (jaccard < min_jaccard) {
min_jaccard = jaccard;
min_a = from;
min_b = to;
}
}
}
}
//System.out.println("Removing edge: " + min_a + " -> " + min_b);
graph.get(min_a).remove(min_b);
graph.get(min_b).remove(min_a);
}
|
4a1122a7-e59f-4279-8bd2-53dab3fce28b
| 1
|
private void goBack() {
try {
myCurrentPosition--;
String url = (String) myURLHistory.get(myCurrentPosition);
setDisplay(url);
} catch (Throwable e) {
myCurrentPosition++;
}
}
|
40ba76ba-8517-429a-8c88-d0e1441c8de7
| 2
|
public Transition<TransitionInput> findFirstValidTransition(TransitionInput input) {
for(Transition<TransitionInput> transition : transitions) {
if(transition.isValid(input)) {
return transition;
}
}
return null;
}
|
a75725a8-366c-4dcc-bd37-00fa1c22d8b0
| 5
|
public Model createRDF(ArrayList<GeoEvent> geoArray){
Database db = Database.getInstance();
Model model = db.getModel();
for(GeoEvent geoEvent : geoArray){
String venueURL = geoEvent.getVenue().getUrl();
//Resource event and adding it's properties
Resource event = model.createResource(geoEvent.getEventUrl());
event.addProperty(RDFS.label, model.createLiteral(geoEvent.getEventName()));
event.addProperty(DCTerms.identifier, geoEvent.getEventID())
.addProperty(DCTerms.date, geoEvent.getDate())
.addProperty(RDF.type, "http://purl.org/ontology/mo/Performance")
.addProperty(model.createProperty("http://purl.org/NET/c4dm/event.owl#place"), geoEvent.getVenue().getUrl());
//Adding an artist
String artistRessurs = db.checkDBArtist(geoEvent.getHeadliner());
if(artistRessurs.equals("")){
lastfmapi.lastfm.Artist lastFmArtist = new lastfmapi.lastfm.Artist();
JsonObject jsonArtist = lastFmArtist.getInfo(geoEvent.getHeadliner(), "64ecb66631fd1570172e9c44108b96d4").getJsonObject();
ArtistConverter artistConverter = new ArtistConverter();
Artist artist = artistConverter.convertArtist(jsonArtist);
Resource artistResource = model.createResource(artist.getArtistURL());
artistResource.addProperty(RDFS.label, artist.getName())
.addProperty(RDF.type, "http://purl.org/ontology/mo/MusicArtist")
.addProperty(model.createProperty("http://purl.org/ontology/mo/biography"), artist.getBio());
for(String s : artist.getSimilarArtists()){
artistResource.addProperty(model.createProperty("http://purl.org/ontology/mo/similar_to"),model.createResource(s));
}
for (String t : artist.getTags()){
artistResource.addProperty(model.createProperty("http://purl.org/ontology/mo/Genre"), t);
}
event.addProperty(model.createProperty("http://purl.org/ontology/mo/performer"), artistResource);
}
else{
event.addProperty(model.createProperty("http://purl.org/ontology/mo/performer"), model.getResource(artistRessurs));
}
if(!geoEvent.getEventWebsite().isEmpty()){
event.addProperty(FOAF.homepage, geoEvent.getEventWebsite());
}
//Resource venue and adding it's properties
Resource venue = model.createResource(venueURL);
venue.addProperty(RDFS.label, geoEvent.getVenue().getName())
.addProperty(RDF.type, "music:Venue");
venue.addProperty(DCTerms.identifier, geoEvent.getVenue().getVenueID());
Resource venueAddress = model.createResource(venueURL+"#address");
venueAddress.addProperty(VCARD.Country, geoEvent.getVenue().getCountry());
venueAddress.addProperty(VCARD.Locality, geoEvent.getVenue().getCity());
venueAddress.addProperty(VCARD.Street, geoEvent.getVenue().getStreet());
venueAddress.addProperty(VCARD.Pcode, geoEvent.getVenue().getPostalCode());
venueAddress.addProperty(VCARD.TEL, geoEvent.getVenue().getPhoneNumber());
venueAddress.addProperty(model.createProperty("http://www.w3.org/2003/01/geo/wgs84_pos/#lat"), String.valueOf(geoEvent.getVenue().getLatitude()));
venueAddress.addProperty(model.createProperty("http://www.w3.org/2003/01/geo/wgs84_pos/#long"), String.valueOf(geoEvent.getVenue().getLongitude()));
venue.addProperty(OWL.sameAs, venueAddress);
event.addProperty(DC.coverage, venue);
}
return model;
}
|
4905bd87-3709-43ab-8c03-e212a24b1bff
| 5
|
public long[][] loadArrays(String filename) {
long [][] result=null;
try (InputStream input = new FileInputStream(filename)) {
List<String> lines = IOUtils.readLines(input);
int count=0;
for(String line:lines){
String[] numbers = line.split(" ");
if(numbers.length>count){
count=numbers.length;
}
}
result=new long[lines.size()][count];
int i=0;
for(String line:lines){
String[] numbers = line.split(" ");
for(int j=0;j<numbers.length;j++){
result[i][j]=Long.parseLong(numbers[j]);
}
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
|
e89c9aed-3a44-44aa-b428-92b559ac16ee
| 1
|
public void testParseLocalDateTime_simple() {
assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30), g.parseLocalDateTime("2004-06-09T10:20:30Z"));
assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30), g.parseLocalDateTime("2004-06-09T10:20:30+18:00"));
assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30), g.parseLocalDateTime("2004-06-09T10:20:30-18:00"));
assertEquals(new LocalDateTime(2004, 6, 9, 10, 20, 30, 0, BUDDHIST_PARIS),
g.withChronology(BUDDHIST_PARIS).parseLocalDateTime("2004-06-09T10:20:30Z"));
try {
g.parseDateTime("ABC");
fail();
} catch (IllegalArgumentException ex) {}
}
|
da085999-8064-403d-aca4-8f90b939bb2f
| 8
|
public void play(Board board) {
int[] sizes = board.getSizes();
for (int x = 0; x < sizes[0]; x++) {
for (int y = 0; y < sizes[1]; y++) {
for (Board.DIRECT direct : Board.DIRECT.values()) {
Board.BoardIterator iterator = board.iterator(x, y);
StringBuilder strBu = new StringBuilder();
boolean hope = true;
if (hope && iterator.hasNext(direct)) {
char ch = iterator.next(direct);
String str = strBu.append(ch).toString();
if (str.length() < dictionaries.length) {
Boolean isWord = dictionaries[str.length()].get(str);
hope = isWord != null;
if (hope) {
if (isWord) {
res.add(str);
}
}
}
}
}
}
}
}
|
1457d717-9f83-4d4e-ad05-0edbf92ca078
| 3
|
public static Semester findBestSubjectSemester(Subject thisSubject){
int bestMark = -1;
Semester bestSemester = null;
for(Semester thisSemester:thisSubject.semesters){
if(thisSemester.mark > bestMark &&
thisSemester.usedState == Semester.UsedState.none){
bestSemester = thisSemester;
bestMark = bestSemester.mark;
}
}
return bestSemester;
}
|
1d86d564-7315-497d-b6b6-95d172da0dd3
| 4
|
private List<ColumnConceptMappingDTO> getDicoFromConfiguration(final DataSetApplication datasetApp,
final String dicoToFind) throws SitoolsException {
List<ColumnConceptMappingDTO> colConceptMappingDTOList = null;
// Get the list of dictionnaries related to the datasetApplication
final List<DictionaryMappingDTO> dicoMappingList = datasetApp.getDictionaryMappings();
if (!Util.isSet(dicoMappingList) || dicoMappingList.isEmpty()) {
throw new SitoolsException("No mapping with VO concepts has been done. please contact the administrator");
}
// For each dictionary, find the interesting one and return the mapping SQLcolumn/concept
for (DictionaryMappingDTO dicoMappingIter : dicoMappingList) {
final String dicoName = dicoMappingIter.getDictionaryName();
if (dicoToFind.equals(dicoName)) {
colConceptMappingDTOList = dicoMappingIter.getMapping();
break;
}
}
return colConceptMappingDTOList;
}
|
2922d165-db03-4b16-bf69-4189a60b20a6
| 4
|
public void visitCallMethodExpr(final CallMethodExpr expr) {
expr.visitChildren(this);
genPostponed(expr);
int opcode;
if (expr.kind() == CallMethodExpr.VIRTUAL) {
opcode = Opcode.opcx_invokevirtual;
} else if (expr.kind() == CallMethodExpr.NONVIRTUAL) {
opcode = Opcode.opcx_invokespecial;
} else if (expr.kind() == CallMethodExpr.INTERFACE) {
opcode = Opcode.opcx_invokeinterface;
} else {
throw new IllegalArgumentException();
}
method.addInstruction(opcode, expr.method());
// Pop reciever object off stack
stackHeight -= 1;
// Pop each parameter off stack
final Expr[] params = expr.params();
for (int i = 0; i < params.length; i++) {
stackHeight -= params[i].type().stackHeight();
}
}
|
da33c945-dfc5-4f3d-9c43-ec084ff4f5e9
| 0
|
public CheckResultMessage checkG12(int day) {
return checkReport.checkG12(day);
}
|
1e0fcd36-b7c3-4f93-8d31-4a9e7c3693b5
| 4
|
@Override
synchronized public void adjustClock(Clock receivedTimeStamp) {
if (receivedTimeStamp == null)
System.out.println("---------------------------debug: received group clock null!!");
Hashtable<String, Integer> tmpTimeStamp = (Hashtable<String, Integer>) receivedTimeStamp.getClock();
for (String tmpKey : this.clock.keySet()) {
if (tmpTimeStamp.containsKey(tmpKey)) {
if (!tmpKey.equals(this.hostName)) {
this.clock.put(
tmpKey,
Math.max(tmpTimeStamp.get(tmpKey),
this.clock.get(tmpKey)));
} else {
this.clock.put(
tmpKey,
Math.max(tmpTimeStamp.get(tmpKey),
this.clock.get(tmpKey)) + 1);
}
}
}
}
|
b4506bcb-fe87-487f-ae86-99d4d8b5b755
| 3
|
public void setElement(ZElement elem, String index)
{
super.setElement(elem, index);
if (elem != null) {
MCDObjet obj = (MCDObjet) elem;
obj.addLink(this);
}
if (elem1 instanceof MCDObjet && elem2 instanceof MCDAssociation)
inverseZElements();
}
|
2733d021-67cb-4cb8-89dc-b1b01de9e9ed
| 9
|
public boolean fGuiCheckChildObjectExistence(WebElement objParent, String strDesc){
//Delimiters
String[] delimiters = new String[] {":="};
String[] arrFindByValues = strDesc.split(delimiters[0]);
//Get Findby and Value
String FindBy = arrFindByValues[0];
String val = arrFindByValues[1];
//WebElement Collection
List<WebElement> lst;
try
{
//Handle all FindBy cases
String strElement = FindBy.toLowerCase();
if (strElement.equalsIgnoreCase("linktext"))
{
lst = objParent.findElements(By.linkText(val));
}
else if (strElement.equalsIgnoreCase("xpath"))
{
lst = objParent.findElements(By.xpath(val));
}
else if (strElement.equalsIgnoreCase("name"))
{
lst = objParent.findElements(By.name(val));
}
else if (strElement.equalsIgnoreCase("id"))
{
lst = objParent.findElements(By.id(val));
}
else if (strElement.equalsIgnoreCase("classname"))
{
lst = objParent.findElements(By.className(val));
}
else if (strElement.equalsIgnoreCase("cssselector"))
{
lst = objParent.findElements(By.cssSelector(val));
}
else if (strElement.equalsIgnoreCase("tagname"))
{
lst = objParent.findElements(By.tagName(val));
}
else
{
Reporter.fnWriteToHtmlOutput("Check Existence of child object " + strDesc, "Object should exist", "Property " + FindBy + " specified for object is invalid", "Fail");
System.out.println("Property name " + FindBy + " specified for object " + strDesc + " is invalid");
return false;
}
if(lst.size() > 0)
{
//Reporter.fnWriteToHtmlOutput("Check Existence of child object " + strDesc, "Object Should exist", "Object Exist", "Pass");
return true;
}
else
{
//Reporter.fnWriteToHtmlOutput("Check Existence of child object " + strDesc, "Object Should exist", "Object does not exist", "Fail");
return false;
}
}
//Catch Block
catch(Exception e)
{
Reporter.fnWriteToHtmlOutput("Check Existence of child object " + strDesc, "Object should exist", "Exception occured while checking existence", "Fail");
System.out.println("Exception " + e.toString() + " occured while checking object existence");
return false;
}
}
|
8e3eccc1-a04b-446f-b6ab-3ba37c037da9
| 8
|
public float[] ProjectionHistograms() {
// Horizontal Histogram
float[] featureVector = new float[rows+columns];
int[] m_HorizontalFeatureVector = new int[rows];
int[] m_VerticalFeatureVector = new int[columns];
for (int i = 0; i < rows; i++) {
int count = 0;
for (int j = 0; j < columns; j++) {
if (a[i][j] == 1) {
count++;
}
}
m_HorizontalFeatureVector[i] = count;
}
// Vertical Histogram
for (int j = 0; j < columns; j++) {
int count = 0;
for (int i = 0; i < rows; i++) {
if (a[i][j] == 1) {
count++;
}
}
m_VerticalFeatureVector[j] = count;
}
for(int i = 0; i < m_HorizontalFeatureVector.length; i++){
featureVector[i] = m_HorizontalFeatureVector[i];
}
//Copy elements from second array into last part of new array
for(int j = m_HorizontalFeatureVector.length;j < featureVector.length;j++){
featureVector[j] = m_VerticalFeatureVector[j-m_HorizontalFeatureVector.length];
}
return featureVector;
}
|
03e0befa-051e-45c4-9205-ed00be064869
| 5
|
private boolean isPhoneNumberAdded(PhoneNumber phoneNumber)
{
for(int i=0; i<addedPhoneNumberCount; i++)
{
PhoneNumber addedPhoneNumbers = phoneNumbers[i];
if(addedPhoneNumbers.getCountryCode() == phoneNumber.getCountryCode())
{
if(addedPhoneNumbers.getAreaCode() == phoneNumber.getAreaCode())
{
if(addedPhoneNumbers.getPhoneNumbers() == phoneNumber.getPhoneNumbers())
{
if(addedPhoneNumbers.getExtension() == phoneNumber.getExtension())
{
return true;
}
}
}
}
}
return false;
}
|
567e93ec-6b46-46fb-9f35-84204ab673ff
| 1
|
public void soundToggle(){
if(soundToggled){
soundToggled = false;
} else {
currentTime = beginTime;
soundToggled = true;
}
}
|
979f9a34-156c-4c28-84d0-ee2db06fbe7f
| 7
|
public void SerializeRoom(ServerMessage Message, Room Room, int UsersNow, int Score)
{
Environment.Append(Room.Id, Message);
if(Room.Event != null)
{
Environment.Append(true, Message); // is event
Environment.Append(Room.Event.Name, Message);
}
else
{
Environment.Append(false, Message); // is event
Environment.Append(Room.Name, Message);
}
Environment.Append(Room.Owner, Message);
Environment.Append(Room.State, Message); // room state
Environment.Append((UsersNow > 0)?UsersNow:Room.UsersNow, Message);
Environment.Append(Room.UsersMax, Message);
Environment.Append(Room.Description, Message);
Environment.Append(0, Message); // ?
if(Room.Event != null)
{
Environment.Append(false, Message); // can trade
Environment.Append((Score>0)?Score:Room.Score, Message);
Environment.Append(Room.Event.Category, Message);
Environment.Append(Room.Event.StartTime, Message);
}
else
{
Environment.Append(true, Message); // can trade
Environment.Append((Score>0)?Score:Room.Score, Message);
Environment.Append(Room.Category, Message);
Environment.Append("", Message);
}
Environment.Append(Room.Tags.size(), Message);
for(String Tag : Room.Tags)
{
Environment.Append(Tag, Message);
}
Environment.Append(Room.Icon.BackgroundImage, Message);
Environment.Append(Room.Icon.ForegroundImage, Message);
Environment.Append(Room.Icon.Items.length, Message);
for(int ItemId = 0;ItemId<Room.Icon.Items.length;ItemId++)
{
String[] values = Room.Icon.Items[ItemId].split(",");
Environment.Append(Integer.parseInt(values[0]), Message);
Environment.Append(Integer.parseInt(values[1]), Message);
}
Environment.Append((Room.Flags & Server.rmAllowPets) == Server.rmAllowPets, Message); // AllowPets
Environment.Append(true, Message); // allow Ad
}
|
6ea02c32-045e-4eee-bdd5-d48254f289de
| 4
|
public void loadFile(String filename) throws Exception {
Map<String, Map<Integer, Double>> userMaps = new HashMap<>();
Map<String, Map<Integer, Double>> resMaps = new HashMap<>();
BookmarkReader reader = new BookmarkReader(0, false);
reader.readFile(filename);
List<Map<Integer, Integer>> userStats = Utilities.getUserMaps(reader
.getBookmarks());
int i = 0;
for (Map<Integer, Integer> map : userStats) {
Map<Integer, Double> resultMap = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
resultMap.put(entry.getKey(), (double) entry.getValue()
/ (double) Utilities.getMapCount(map));
}
userMaps.put(reader.getUsers().get(i++), resultMap);
}
List<Map<Integer, Integer>> resStats = Utilities.getResMaps(reader
.getBookmarks());
i = 0;
for (Map<Integer, Integer> map : resStats) {
Map<Integer, Double> resultMap = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
resultMap.put(entry.getKey(), (double) entry.getValue()
/ (double) Utilities.getMapCount(map));
}
resMaps.put(reader.getResources().get(i++), resultMap);
}
resetStructures(userMaps, resMaps, reader);
}
|
04f61465-bfc0-4f21-a893-183872ac01bc
| 0
|
public void setcoef(float parseFloat) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
|
74b80fda-bde8-4017-af2b-9a3a17bad7ac
| 0
|
public boolean isAccept()
{
return getUnprocessedInput().length() == 0;
}
|
1468e674-555a-4c2b-805f-debc84d11253
| 4
|
public void setConnection( CommentConnection connection ) {
if( this.connection != null ) {
if( this.connection.getTargetItem() != null ) {
this.connection.getTargetItem().removeDependent( this );
}
}
this.connection = connection;
if( connection != null ) {
if( connection.getTargetItem() != null ) {
connection.getTargetItem().addDependent( this );
}
}
}
|
992ae353-829d-49be-ba9d-00aa6a9be2d6
| 6
|
@Override
public void keyPressed(KeyEvent e) {
if ((Bildschirm.this.kenntEreignisanwendung != null) && (Bildschirm.this.kenntEreignisanwendung.fuehrtAus()) && (e.getKeyCode() != 17)) {
if ((e.isActionKey()) || (e.getKeyCode() < 32) || (e.getKeyCode() == 127)) {
Bildschirm.this.kenntEreignisanwendung.bearbeiteTaste((char) (e.getKeyCode() + 500));
} else {
Bildschirm.this.kenntEreignisanwendung.bearbeiteTaste(e.getKeyChar());
}
}
}
|
117dc689-a335-4428-8743-8a6b18aab67b
| 1
|
public boolean hasTeam(String team) {
return TEAM_1.toString().equals(team) || TEAM_2.toString().equals(team);
}
|
b54440df-af67-4f38-bfd9-42a8f9b9424f
| 4
|
@Override
public Settings clone()
{
Settings s = new Settings();
s.action_panel_color = new Color(this.action_panel_color.getRGB());
s.display_word_count = this.display_word_count;
s.editor_path = this.editor_path;
s.editor_use_env = this.editor_use_env;
s.font_smoothing_value = this.font_smoothing_value;
for(ExternalProcessor p : this.md_processors)
{
s.md_processors.add(new ExternalProcessor(p));
if(p.name.compareTo(this.cur_processor.name) == 0)
{
s.cur_processor = p;
}
}
for(CSSFile p : this.css_files)
{
s.css_files.add(new CSSFile(p));
if(p.name.compareTo(this.cur_css_file.name) == 0)
{
s.cur_css_file = p;
}
}
s.window_size_last = new Dimension(this.window_size_last.width, this.window_size_last.height);
s.window_size_remember = this.window_size_remember;
return s;
}
|
7137ee24-4cca-4bdd-a882-0a1211aeb9c3
| 7
|
private void setAptitud(String operacion, ArrayList<ArrayList<Integer>> restricciones) {
int auxAptitud = 0;
boolean bandera = true;
for (int i = 0; i < restricciones.size(); i++) {
int contador = 0;
auxAptitud += restricciones.get(i).size();
for (int j = 0; j < restricciones.get(i).size(); j++) {
for (int k = contador; k < operacion.length(); k++) {
if (k == restricciones.get(i).get(j)) {
if (operacion.charAt(k) != operacion.charAt(restricciones.get(i).get(0))) { //Si en la posicion de la restriccion tiene mismo valor.
bandera = false;
}
k = operacion.length();
} else {
if (operacion.charAt(k) == operacion.charAt(restricciones.get(i).get(0))) {
bandera = false;
k = operacion.length();
}
}
contador++;
}
}
if (bandera) {
auxAptitud -= restricciones.get(i).size();
}
bandera = true;
}
this.aptitud = auxAptitud;
}
|
2448e93b-9b51-45ba-903e-3733d257820c
| 3
|
public String convert(String s, int nRows) {
int rows = nRows;
Generator indexGenerator = new Generator(rows);
StringBuffer[] buffers = new StringBuffer[rows];
for (int i = 0; i < rows; i++)
buffers[i] = new StringBuffer();
int stringSize = s.length();
for (int i = 0; i < stringSize; i++)
buffers[indexGenerator.next()].append(s.charAt(i));
for (int i = 1; i < rows; i++)
buffers[0].append(buffers[i]);
return buffers[0].toString();
}
|
4911837c-782f-4333-9a2e-4b65a5ed9694
| 6
|
public void addNewCircleData(int origX, int origY, int imgWidth, int imgHeight)
{
sortRequired = true;
double pointsToPlot, angleIncrement;
for(int radius = minR; radius <= maxR; radius++)
{
Circle c = new Circle(new Coordinate2D(origX, origY), radius);
pointsToPlot = c.getPerimeter();
angleIncrement = Constants.TWO_PI/pointsToPlot;
for(double angle = 0.; angle < Constants.TWO_PI; angle += angleIncrement)
{
int x = (int) (origX + (radius * Math.cos(angle)));
int y = (int) (origY + (radius * Math.sin(angle)));
if(x >= 0 && x < imgWidth && y >= 0 && y < imgHeight)
increment(x, y, radius);
}
}
}
|
c42c01b5-f994-484e-8841-3f42b4f936aa
| 1
|
public boolean setPasswordButtonWidth(int width) {
boolean ret = true;
if (width < 0) {
this.buttonPW_Width = UISizeInits.PW_BTN.getWidth();
ret = false;
} else {
this.buttonPW_Width = width;
}
somethingChanged();
return ret;
}
|
633b1203-00dd-4ae8-8dfd-c92f0ab183a1
| 9
|
public int compareTo(PolygonNew o) {
if (compareArray(o.xpoints, xpoints)
&& compareArray(ypoints, o.ypoints) && npoints == o.npoints
&& r == o.r && g == o.g && b == o.b
&& transparency == o.transparency && order == o.order) {
return 0;
} else if (this.order > o.order) {
return -1;
} else {
return 1;
}
}
|
0d826aab-f425-4221-975b-aefbf60a8810
| 1
|
static void db(Object o) { if (true) System.err.println(o); }
|
fed7e2b5-d0cd-425c-86b2-5614d1c42962
| 4
|
private boolean checkForChildren() throws ParsingException
{
XMLEvent e;
try
{
do
{
e = eventReader.peek();
if (e.isCharacters())
{
Characters c = e.asCharacters();
// Ignore empty content
if (c.isWhiteSpace())
{
eventReader.nextEvent();
}
else
{
// The next element is text.
return true;
}
}
else
{
// Found something that isn't text.
break;
}
}
while (true);
}
catch (XMLStreamException exception)
{
throw new ParsingException(exception);
}
// If the next event is an end event, then the current element is empty. Otherwise there is at least one
// child element.
return !e.isEndElement();
}
|
c9b00b15-2c73-4ba4-8eae-bf583d4373b4
| 2
|
private static void writeItems(
final Collection itemCollection,
final DataOutput dos,
final boolean dotted) throws IOException
{
int size = itemCollection.size();
Item[] items = (Item[]) itemCollection.toArray(new Item[size]);
Arrays.sort(items);
for (int i = 0; i < size; i++) {
dos.writeUTF(items[i].name);
dos.writeInt(items[i].access);
dos.writeUTF(dotted
? items[i].desc.replace('/', '.')
: items[i].desc);
}
}
|
f679d85d-3c6d-4e1a-8e2d-01695ecc2c09
| 0
|
private Set<Card> nonStraightFiveFlush() {
return convertToCardSet("TS,7S,9S,4S,8S,KC,QC");
}
|
6d96e28c-c3bb-4a45-bb8b-e77c8b31f14c
| 1
|
public void send(String data, int port) {
byte[] byte_data = data.getBytes();
DatagramPacket sendPacket = new DatagramPacket(byte_data, byte_data.length, host, port);
try {sock.send(sendPacket);} catch (Exception e){}
}
|
0875b6c2-4347-415f-8e84-72a4344e99cd
| 1
|
@Override
protected void setReaction(Message message) {
try {
String query = getQuery(message.text);
String response = loadResponse(query);
reaction.add(message.author + ": " + response);
} catch (Exception e) {
setError(e);
}
}
|
fcfb4ef2-2208-406c-bd1e-7f004af6259f
| 0
|
public double getDexterity() {
return dexterity;
}
|
8f6262e7-0ac0-4bdf-99c7-0efd1ce3ca75
| 8
|
public void update(){
super.update();
if(getPosition()[0] < 0 && getVelocity()[0] < 0){
vel.setX(-vel.getX() * .8);
}
if(getPosition()[0] + sprite.W > Game.WIDTH/Game.scale && getVelocity()[0] > 0){
vel.setX(-vel.getX() * .8);
}
if(getPosition()[1] < 0 && getVelocity()[1] < 0 || getPosition()[1] + sprite.H + 14 > Game.HEIGHT/Game.scale && getVelocity()[1] > 0){
vel.setY(-vel.getY() * .8);
}
}
|
fc1f7160-1a46-45f7-9199-2a43b354535f
| 2
|
private int getLineCount(String text) {
int count = 0;
for (String line:text.split("\n")){
if (!line.equals("")){
count++;
}
}
return count;
}
|
9c5bec49-3a54-41c2-97ef-6ba85fc18428
| 2
|
public void finishReport(int rId, double similarity, String endTime)
{
try
{
String strStatement = "";
connect();
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
otherSymbols.setDecimalSeparator('.');
DecimalFormat df = new DecimalFormat("###.##", otherSymbols);
strStatement = "UPDATE report SET rEndTime ='" + endTime + "', rSimilarity = '" + df.format(similarity * 100) + "' WHERE rID =" + rId;
_statement.executeUpdate(strStatement);
}
catch (ClassNotFoundException e)
{
_logger.fatal(e.getMessage(), e);
e.printStackTrace();
}
catch (SQLException e)
{
_logger.fatal(e.getMessage(), e);
e.printStackTrace();
}
finally
{
disconnect();
}
}
|
77181bd8-13a6-4fbe-8c58-e6857d31aa04
| 3
|
public void run() {
if (i <= n) {
g2.clearRect(-150, -150, 300, 300);
for (Line l : lines) {
Complex tmp1 = f.evaluate(l.c1);
double re1 = ((n - i) * l.c1.getRe() / n + i * tmp1.getRe() / n);
double im1 = ((n - i) * l.c1.getIm() / n + i * tmp1.getIm() / n);
tmp1.setRe(re1);
tmp1.setIm(im1);
for (int t = 0; t <= p; t++) {
double re = ((p - t) * l.c1.getRe() / p + t * l.c2.getRe() / p);
double im = ((p - t) * l.c1.getIm() / p + t * l.c2.getIm() / p);
Complex tmp2 = f.evaluate(new Complex(re, im));
double re2 = ((n - i) * re / n + i * tmp2.getRe() / n);
double im2 = ((n - i) * im / n + i * tmp2.getIm() / n);
tmp2.setRe(re2);
tmp2.setIm(im2);
Line tmpLine = new Line(tmp1, tmp2);
tmpLine.paint(g2);
tmp1 = tmp2;
}
}
i++;
} else {
this.cancel();
}
}
|
9f957253-92ec-4661-92f9-13ff33546018
| 3
|
public void upadte() {
time++;
if (time == Integer.MAX_VALUE) time = 0;
if (time % rate == 0) {
if (frame >= legnth - 1) frame = 0;
else frame++;
sprite = sheet.getSprites()[frame];
}
}
|
8d5156b7-9f3b-49e1-9b95-a9d8d0b6e1d3
| 2
|
public String toString() {
StringBuilder out = new StringBuilder();
if (items != null) {
for (String s : items) {
out.append(s);
out.append("/");
}
}
return out.toString();
}
|
52e999fd-4d4f-44be-95db-308c81ca40fa
| 3
|
private boolean generalDevCardPreconditions(int playerIndex) {
if (serverModel.getTurnTracker().getStatus().equals("Playing") &&
serverModel.getTurnTracker().getCurrentTurn() == playerIndex &&
!serverModel.getPlayers().get(playerIndex).hasPlayedDevCard()) {
return true;
}
else {
return false;
}
}
|
d613e58a-9a77-417b-b6c9-208877ced3f5
| 6
|
public static boolean arithmeticGreaterTest(NumberWrapper x, NumberWrapper y) {
{ Surrogate testValue000 = Stella_Object.safePrimaryType(x);
if (Surrogate.subtypeOfIntegerP(testValue000)) {
{ IntegerWrapper x000 = ((IntegerWrapper)(x));
{ Surrogate testValue001 = Stella_Object.safePrimaryType(y);
if (Surrogate.subtypeOfIntegerP(testValue001)) {
{ IntegerWrapper y000 = ((IntegerWrapper)(y));
return (x000.wrapperValue > y000.wrapperValue);
}
}
else if (Surrogate.subtypeOfFloatP(testValue001)) {
{ FloatWrapper y000 = ((FloatWrapper)(y));
return (((double)(x000.wrapperValue)) > y000.wrapperValue);
}
}
else {
{ OutputStringStream stream000 = OutputStringStream.newOutputStringStream();
stream000.nativeStream.print("`" + testValue001 + "' is not a valid case option");
throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
}
}
}
}
}
else if (Surrogate.subtypeOfFloatP(testValue000)) {
{ FloatWrapper x000 = ((FloatWrapper)(x));
{ Surrogate testValue002 = Stella_Object.safePrimaryType(y);
if (Surrogate.subtypeOfIntegerP(testValue002)) {
{ IntegerWrapper y000 = ((IntegerWrapper)(y));
return (x000.wrapperValue > ((double)(y000.wrapperValue)));
}
}
else if (Surrogate.subtypeOfFloatP(testValue002)) {
{ FloatWrapper y000 = ((FloatWrapper)(y));
return (x000.wrapperValue > y000.wrapperValue);
}
}
else {
{ OutputStringStream stream001 = OutputStringStream.newOutputStringStream();
stream001.nativeStream.print("`" + testValue002 + "' is not a valid case option");
throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
}
}
}
}
}
else {
{ OutputStringStream stream002 = OutputStringStream.newOutputStringStream();
stream002.nativeStream.print("`" + testValue000 + "' is not a valid case option");
throw ((StellaException)(StellaException.newStellaException(stream002.theStringReader()).fillInStackTrace()));
}
}
}
}
|
e30bd923-213e-44e8-8b38-f8d5858c0692
| 1
|
public void visitNewArrayExpr(final NewArrayExpr expr) {
if (previous == expr.size()) {
previous = expr;
expr.parent.visit(this);
}
}
|
8a6aad6e-60a3-4865-b6ae-96dff3d77f83
| 6
|
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player)sender;
if (!HyperPVP.getGameSessions().containsKey(player.getName())) {
sender.sendMessage(ChatColor.RED + "You can't team chat if you're not in a game!");
return true;
}
if (HyperPVP.isCycling()) {
sender.sendMessage(ChatColor.RED + "You can't team chat while the game is cycling!");
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Not enough arguments!");
return false;
}
String message = TextUtilities.getFinalArg(args, 0);
Session session = HyperPVP.getSession(player);
String teamName = HyperPVP.capitalize(session.getTeam().getColor().name().toLowerCase().replace("_", " "));
for (Session teamMate : HyperPVP.getMap().getTeamMembers(session.getTeam().getColor())) {
teamMate.getPlayer().sendMessage("<" + session.getTeam().getColor() + teamName + " Team" + ChatColor.WHITE + ">" + ChatColor.GRAY +" " + player.getName() + ChatColor.DARK_GRAY + ": " + ChatColor.WHITE + message);
}
return true;
}
catch (Exception e) {
e.printStackTrace();
}
return true;
}
|
f3420ec7-37d6-4b82-9e85-4e01e989c423
| 9
|
public void receivePacket(Cell cell) {
for (Packet packet : cell.getPackets()) {
if (packet.getDestination() == this) {
if (!receiveLengths.containsKey(packet.getSource())) {
receiveLengths.put(packet.getSource(), packet.getLength());
receiveChecksums.put(packet.getSource(), true);
}
if (cell.isCorrupted()) {
receiveChecksums.put(packet.getSource(), false);
}
int remaining = receiveLengths.get(packet.getSource());
if (remaining > 1) {
receiveLengths.put(packet.getSource(), remaining - 1);
} else {
if (receiveChecksums.get(packet.getSource()) == true) {
System.out.println("HOST " + this + " RECEIVED PACKET FROM HOST " + cell
.getPacket().getSource() + " SUCCESSFULLY!");
} else {
System.out.println("HOST " + this + " RECEIVED PACKET FROM HOST " + cell
.getPacket().getSource() + " WITH INVALID CHECKSUM!");
}
receiveLengths.remove(packet.getSource());
receiveChecksums.remove(packet.getSource());
}
}
}
Set<Host> hosts = new HashSet<Host>(receiveLengths.keySet());
Set<Host> senders = new HashSet<Host>();
for (Packet p : cell.getPackets()) {
senders.add(p.getSource());
}
for (Host host : hosts) {
if (!senders.contains(host)) {
receiveLengths.remove(host);
receiveChecksums.remove(host);
}
}
}
|
0c79b641-baa7-415b-b25d-870104f91ab3
| 7
|
@Override
public boolean mayIntersect(S2Cell cell) {
if (numVertices() == 0) {
return false;
}
// We only need to check whether the cell contains vertex 0 for correctness,
// but these tests are cheap compared to edge crossings so we might as well
// check all the vertices.
for (int i = 0; i < numVertices(); ++i) {
if (cell.contains(vertex(i))) {
return true;
}
}
S2Point[] cellVertices = new S2Point[4];
for (int i = 0; i < 4; ++i) {
cellVertices[i] = cell.getVertex(i);
}
for (int j = 0; j < 4; ++j) {
S2EdgeUtil.EdgeCrosser crosser =
new S2EdgeUtil.EdgeCrosser(cellVertices[j], cellVertices[(j + 1) & 3], vertex(0));
for (int i = 1; i < numVertices(); ++i) {
if (crosser.robustCrossing(vertex(i)) >= 0) {
// There is a proper crossing, or two vertices were the same.
return true;
}
}
}
return false;
}
|
696b2941-98ab-45d7-bc81-4a5c7f8c299e
| 1
|
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
try {
sunJSSEX509TrustManager.checkServerTrusted(chain, authType);
} catch (CertificateException excep) {
excep.printStackTrace();
/*
* Possibly pop up a dialog box asking whether to trust the
* cert chain.
*/
}
}
|
89b1c551-a367-4396-8ba4-aa5d3dccce4d
| 1
|
public void setLater(final boolean flag) {
later = flag;
if (SSAPRE.DEBUG) {
System.out.println(this);
}
}
|
8cc5b709-924e-4cdb-a5e7-a4eb4a53ecdc
| 6
|
static public int emptyFolder(File folder, boolean ignoreCannotDel) throws IOException {
int counter = 0 ;
if(folder.exists() && folder.isDirectory()) {
File[] child = folder.listFiles();
for(int i = 0; i < child.length; i++) {
File file = child[i] ;
if(file.isDirectory()) counter += emptyFolder(file, ignoreCannotDel) ;
boolean result = file.delete() ;
if(!result && !ignoreCannotDel) {
throw new IOException("Cannot delete " + file.getAbsolutePath());
} else {
counter++ ;
}
}
}
return counter ;
}
|
c0a51df3-84bc-4cac-8814-bacd5d7a1dad
| 5
|
/* */ public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
/* 189 */ boolean equal = true;
/* */
/* 191 */ if (l1.length != l2.length) return false;
/* 192 */ for (int i = 0; i < l1.length; i++) {
/* 193 */ if (l1[i] != l2[i]) { equal = false; break;
/* */ }
/* */ }
/* 196 */ return equal;
/* */ }
|
1f4c2186-ba58-4e53-bb9b-f63d23691b57
| 5
|
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Report)) {
return false;
}
Report other = (Report) object;
if ((this.reportId == null && other.reportId != null) || (this.reportId != null && !this.reportId.equals(other.reportId))) {
return false;
}
return true;
}
|
4acebc10-604a-456c-8aaf-67d486a7a1f4
| 7
|
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
if (par1World.getBlockMaterial(par3, par4, par5) != Material.water)
{
return false;
}
else
{
int var6 = par2Random.nextInt(this.numberOfBlocks - 2) + 2;
byte var7 = 1;
for (int var8 = par3 - var6; var8 <= par3 + var6; ++var8)
{
for (int var9 = par5 - var6; var9 <= par5 + var6; ++var9)
{
int var10 = var8 - par3;
int var11 = var9 - par5;
if (var10 * var10 + var11 * var11 <= var6 * var6)
{
for (int var12 = par4 - var7; var12 <= par4 + var7; ++var12)
{
int var13 = par1World.getBlockId(var8, var12, var9);
if (var13 == Block.dirt.blockID || var13 == Block.blockClay.blockID)
{
par1World.setBlock(var8, var12, var9, this.clayBlockId);
}
}
}
}
}
return true;
}
}
|
58d6855a-ec05-4b52-8391-cf287bfa0e15
| 6
|
@EventHandler
public void SnowmanMiningFatigue(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getsnowgolemConfig().getDouble("Snowman.MiningFatigue.DodgeChance") / 100;
final double ChanceOfHappening = random.nextDouble();
if (ChanceOfHappening >= randomChance) {
dodged = true;
}
if (plugin.getsnowgolemConfig().getBoolean("Snowman.MiningFatigue.Enabled", true) && damager instanceof Snowman && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) {
Player player = (Player) e;
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, plugin.getsnowgolemConfig().getInt("Snowman.MiningFatigue.Time"), plugin.getsnowgolemConfig().getInt("Snowman.MiningFatigue.Power")));
}
}
|
03fe57cd-27a5-4f48-a615-b51aa6698709
| 2
|
@Override
public int compareTo(Schedule sched) {
int result = 0;
if(this.fitness<sched.fitness) result = 1;
else if(this.fitness>sched.fitness) result = -1;
return result;
}
|
926e834b-d10c-4523-8258-7a78be3c3460
| 2
|
@Override
public int compare(Player a, Player b) {
return a.hand.highCard.value < b.hand.highCard.value ?
-1 : a.hand.highCard.value == b.hand.highCard.value ? 0 : 1;
}
|
bd628544-0e73-48ff-8865-adf0fa023188
| 1
|
public void testFormatSuffixPlural4() {
try {
builder.appendSuffix(" hour", " hours");
fail();
} catch (IllegalStateException ex) {}
}
|
91321a74-68a8-4019-ab02-f61550292da5
| 3
|
@Override
public boolean equals(Object pObj)
{
if(pObj != null) {
if(pObj instanceof String) {
return mName.equalsIgnoreCase((String) pObj);
}
if(pObj instanceof Namespace) {
return mName.equals(pObj.toString());
}
}
return false;
}
|
0eebb49d-baa1-42df-bb91-e1a29382ceec
| 6
|
public ListNode mergeKLists(ArrayList<ListNode> lists) {
ListNode superHead = new ListNode(0);
ListNode insert = superHead;
for (int i =0;i<lists.size();i++){
if (lists.get(i)==null){
lists.remove(i);
i--;
}
}
while (lists.size()>0){
int minIndex = 0;
int minValue = lists.get(0).val;
for(int i = 1;i<lists.size();i++){
if (lists.get(i).val<minValue){
minIndex = i;
minValue = lists.get(i).val;
}
}
insert.next = lists.get(minIndex);
insert = insert.next;
if(lists.get(minIndex).next !=null){
ListNode temp = lists.get(minIndex).next;
lists.remove(minIndex);
lists.add(temp);
}
else{
lists.remove(minIndex);
}
}
return superHead.next;
}
|
f6ae1b23-9178-440a-a92f-bbd96ce753bd
| 7
|
@Override
public void repaint(Graphics2D g) {
if (font == null)
font = g.getFont();
if (scheme != null)
g.setColor(scheme.text);
g.setFont(font);
String largestString = "";
int offset = 0;
for (String str : leftColumn) {
if (str == null)
continue;
if (str.length() > largestString.length())
largestString = str;
}
offset = 0;
Rectangle2D bounds = g.getFont().getStringBounds(largestString, g.getFontRenderContext());
for (int i = 0, rightColumnLength = rightColumn.length; i < rightColumnLength; i++) {
PCheckBox box = rightColumn[i];
if (box != null) {
box.setX((int) (x + bounds.getWidth() + offsetIncrement));
box.setY((y + offset) - (box.getHeight() / 2) - 5);
Color c = g.getColor();
box.repaint(g);
g.setColor(c);
g.drawString(leftColumn[i], x, y + offset);
offset += box.getHeight() + 5;
}
}
}
|
85e434a3-7d80-4e18-8ca7-aea34817c513
| 7
|
public final LDAPConnection getConnection(final LDAPResource resource) throws LDAPException,
InvalidBindPasswordException,
InvalidBindUserException,
InvalidGroupBaseDNException,
InvalidInitialContextFactoryException,
InvalidPortException,
InvalidResourceException,
InvalidSearchScopeException,
InvalidSearchTimeoutException,
InvalidSecurityAuthenticationException,
InvalidServerException,
InvalidServerVendorException,
InvalidEncryptionMethodException,
InvalidUserBaseDNException {
LDAPConnection connection = null;
try {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, resource.getInitialContextFactory());
env.put(Context.PROVIDER_URL, this.getURL(resource));
env.put(Context.SECURITY_AUTHENTICATION, resource.getSecurityAuthentication());
env.put(Context.SECURITY_PRINCIPAL, resource.getBindUser());
env.put(Context.SECURITY_CREDENTIALS, resource.getPassword());
if(SSL_CONNECTION.equals(resource.getEncryption())) {
env.put(Context.SECURITY_PROTOCOL, SSL_CONNECTION);
}
LdapContext ctx = new InitialLdapContext(env, null);
// The code below is not quite correct yet.
if(TLS_CONNECTION.equals(resource.getEncryption())) {
StartTlsResponse response = (StartTlsResponse) ctx.extendedOperation(new StartTlsRequest());
response.setHostnameVerifier(new TLSHostnameVerifies());
response.negotiate((SSLSocketFactory)SSLSocketFactory.getDefault());
}
connection = new LDAPConnection(ctx);
// Grabs the connection properties
String scope = resource.getSearchScope();
SearchScope searchScope = SearchScope.SUBTREE;
if (scope.equals("subtree")) {
searchScope = SearchScope.SUBTREE;
} else if (scope.equals("object")) {
searchScope = SearchScope.OBJECT;
} else if (scope.equals("onelevel")) {
searchScope = SearchScope.ONE_LEVEL;
}
int searchTimeout = Integer.parseInt(resource.getSearchTimeout());
String secAuth = resource.getSecurityAuthentication();
connection.setSearchScope(searchScope);
connection.setSearchTimeout(searchTimeout);
connection.setSecurityAuthentication(secAuth);
} catch (NamingException namingExc) {
throw new LDAPException("Error during connection establishment", namingExc);
} catch (IOException ioExc) {
throw new LDAPException("Error during SSL/TLS connection establishment", ioExc);
}
return connection;
}
|
ca260ae6-bd14-4960-9ef9-429122e00712
| 3
|
public static JsonObjectBuilder rewriteJson(JsonObjectBuilder copyInto,JsonValue tree,String key){
/**
* Helper function used to parse json
*/
switch(tree.getValueType()){
case OBJECT:
JsonObject obj = (JsonObject) tree;
for(String name : obj.keySet()){
copyInto = rewriteJson(copyInto,obj.get(name),name);
}
break;
case STRING:
JsonString st = (JsonString) tree;
copyInto.add(key, st.getString());
break;
default:
break;
}
return copyInto;
}
|
eb50c211-d7e9-4152-89cc-b52a7d896df8
| 0
|
@Override
public Board getBoard() {
return field;
}
|
c6406065-76e4-4a24-9fe9-c5a1daeb7c32
| 2
|
public double standardError_as_Complex_ConjugateCalcn() {
boolean hold = Stat.nFactorOptionS;
if (nFactorReset) {
if (nFactorOptionI) {
Stat.nFactorOptionS = true;
} else {
Stat.nFactorOptionS = false;
}
}
Complex[] cc = this.getArray_as_Complex();
double standardError = Stat.standardErrorConjugateCalcn(cc);
Stat.nFactorOptionS = hold;
return standardError;
}
|
485ee411-fc46-499b-aeef-346a641ba9a4
| 4
|
private static void uruchomTest(List lista, Integer iloscWatkow, Long czasOpoznienia) {
LinkedList<Thread> testujace = new LinkedList<Thread>();
for (int i = 0; i < iloscWatkow; ++i) {
testujace.add(new WatekTestujacy(lista));
}
long startTime = System.currentTimeMillis();
for (Thread thread : testujace) {
thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread arg0, Throwable arg1) {
//LogManager.getLogger(Main.class).error("uncaught exception", arg1);
System.out.println("uncaught exception "+arg1.getLocalizedMessage());
}
});
thread.start();
}
for (Thread thread : testujace) {
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
long endTime = System.currentTimeMillis();
//LogManager.getLogger(Main.class).info(
System.out.println(
lista.getClass().getSimpleName() + ", " + iloscWatkow + ", " + czasOpoznienia + ", "
+ (endTime - startTime));
}
|
8313f36c-6d59-4a9c-b75a-c8da65835edd
| 0
|
public Piece(int t, boolean w, int x, int y) {
type = t;
white = w;
this.x = x;
this.y = y;
}
|
b0b0be42-105b-495c-a2ca-c94198f15771
| 4
|
public static ArrayList<Token> buildTokens(String word, int line, int position) {
ArrayList<Token> tokensOut = new ArrayList<>();
while (!"".equals(word)){
Token token;
int wordLen = word.length();
char first = word.charAt(0);
// Try building an identifier
if (Character.isLetter(first))
token = matchIdentifier(word, line, position);
else if (Character.isDigit(first))
token = matchLiteral(word, line, position);
else
token = matchOperator(word, line, position);
if (token != null){
int size = token.getText().length();
word = word.substring(size);
position += size;
} else {
// if we didn't find a token, create an unknown token out of it
token = new Token(TokenType.UNKNOWN, word.substring(0,1), line, position);
word = word.substring(1);
position++;
}
tokensOut.add(token);
}
return tokensOut;
}
|
f5fcff8b-c021-4da0-9dc6-d97a056d8222
| 5
|
public void personsSearchAction() {
String search = guicontroller.getPersonSearch();
ArrayList<User> validPersons = new ArrayList<User>();
for(User loopingUser:allUsers) {
boolean valid = true;
for(int i=0;i<loopingUser.getName().length() && i<search.length();i++) {
if(!(search.charAt(i)==loopingUser.getName().charAt(i))) valid = false;
}
if(valid) validPersons.add(loopingUser);
}
guicontroller.setAvailablePersons(validPersons);
}
|
df8b3518-f5df-48e8-aae2-f8a5d6936491
| 0
|
public double getMean(int i){
return getCell(i).getMean();
}
|
dc98de77-187c-4544-accb-eeb6387e68e1
| 8
|
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
HLLWritable other = (HLLWritable) obj;
if (!Arrays.equals(M, other.M)) {
return false;
}
if (k != other.k) {
return false;
}
if (!Arrays.equals(minhash, other.minhash)) {
return false;
}
if (p != other.p) {
return false;
}
if (s != other.s) {
return false;
}
return true;
}
|
af661d6a-e66e-419c-988b-e1ba347b9474
| 8
|
public String toString(){
StringBuffer sb = new StringBuffer();
switch(type){
case TYPE_VALUE:
sb.append("VALUE(").append(value).append(")");
break;
case TYPE_LEFT_BRACE:
sb.append("LEFT BRACE({)");
break;
case TYPE_RIGHT_BRACE:
sb.append("RIGHT BRACE(})");
break;
case TYPE_LEFT_SQUARE:
sb.append("LEFT SQUARE([)");
break;
case TYPE_RIGHT_SQUARE:
sb.append("RIGHT SQUARE(])");
break;
case TYPE_COMMA:
sb.append("COMMA(,)");
break;
case TYPE_COLON:
sb.append("COLON(:)");
break;
case TYPE_EOF:
sb.append("END OF FILE");
break;
}
return sb.toString();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.