method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
31258888-18eb-42c0-9f99-78997a3f6f5d | 7 | public String longestPrefixOf(String s) {
if (s == null || s.length() == 0) return null;
int length = 0;
Node x = root;
int i = 0;
while (x != null && i < s.length()) {
char c = s.charAt(i);
if (c < x.c) x = x.left;
else if (c > x.c) x = x... |
28ac3689-6dd4-4adb-9578-84d6091cfafd | 0 | public ItemMenuListener(Production p) {
prod = p;
} |
98bd427d-195d-4421-8229-53c32d61b501 | 5 | public void drop(Command command)
{
if (!command.hasSecondWord()){
System.out.println("drop what?");
return;
}
String id = command.getSecondWord();
int index = 0;
boolean searching = true;
while( searching && index < mochila.size()){
Item it... |
9bad6338-47e9-4990-884b-89eefc911c02 | 8 | private void countWordsSchema(SpreadsheetPOJO currentSpreadsheet, Map<String, String> configurationSpreadsheet, ArrayList<String> fields){
// verifica resposta anterior
String wordBefore = new String();
if (rowSchema == -1) {
rowSchema = currentSpreadsheet.getRow();
termsSchema++;
... |
a62d813c-b46e-46a2-a8c0-f21f3c252ec3 | 4 | private void updateOpponentPanel()
{
opponentPanel.removeAll();
Player[] playerList = latest.getPlayerList();
int index = 0;
while(!playerList[index].getFaction().equals(faction))
{
index++;
}
int end = index;
int writer = 0;
Player[] opponentList = new Player[playerList.length-1];
inde... |
e1697230-439d-457c-85da-d1c4fa91edcf | 5 | public void LogData(String[] data, long systemStamp, long timeStamp)
{
SampleCount++;
boolean exists = new File(FullPath).isFile();
FileWriter out = null;
try
{
out = new FileWriter(FullPath, ... |
39df507f-cda2-46d4-b595-43dd01111ed7 | 4 | public static boolean hasFlash(Pokemon[] pokemon)
{
for (Pokemon aPokemon : pokemon) {
if (aPokemon != null) {
for (int j = 0; j < 4; j++) {
if (aPokemon.move[j] == Pokemon.Move.CUT)
return true;
}
}
}
... |
577cda88-82ee-40cd-80a8-863a7bb15506 | 3 | public boolean isConnected() {
if (client_socket != null && os != null && is != null)
return client_socket.isConnected();
else
return false;
} |
1f210883-eea3-4903-a8bb-7aa6eaffb1b4 | 6 | void setGrbit()
{
grbit[0] = 0x0;
if( isLink )
{
grbit[0] = (byte) (0x1 | grbit[0]);
}
if( isAbsoluteLink )
{
grbit[0] = (byte) (0x2 | grbit[0]);
}
if( hasDescription )
{
grbit[0] = (byte) (0x14 | grbit[0]);
}
if( hasTextMark )
{
grbit[0] = (byte) (0x8 | grbit[0]);
}
if( hasTarg... |
d51db79b-005f-41c9-a039-34d38bb82024 | 4 | public void updateDisplayName() {
String name = getDisplayingName();
if ( name.length() > 16 ) {
name = getDisplayingName().substring( 0, 16 );
}
if ( ChatConfig.updateNicknamesOnTab ) {
ProxiedPlayer p = ProxyServer.getInstance().getPlayer( playername );
... |
6686c820-9e4a-4241-8c5d-26e2b6397d2a | 6 | @Override
public void run() {
while (true) {
int currentMotor = MotorX.getSpeed();
if (currentMotor == 0) {
currentMotor = 1;
}
DelayConstant = 22;
lightValue = ls.getLightValue();
Delay.msDelay((int) DelayConstant);
a = ls.getLightValue();
Delay.msDelay((int) DelayConstant);
b = ls.g... |
48a925f4-4f4a-4c5b-baf7-f0ea12f8744e | 2 | public boolean removeChunk(String player, String chunk, boolean force)
{
if(force)
{
player = this.owners.get(chunk);
}
Set<String> chunks = getOwnedChunks(player);
if(chunks.contains(chunk))
{
chunks.remove(chunk);
this.chunkSet.re... |
c3cdfe5b-cbf2-45a7-884c-611a4ee1f440 | 1 | private boolean credentialsValid(String email, String password) {
return email.toUpperCase().equals(EMAIL.toUpperCase()) && password.equals(PASSWORD);
} |
c8cae79d-96d0-4d68-acb3-8136e07238c8 | 6 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
/*Metodo que permite el ingreso de nuevos clientes a la tabla registroCli, verificando que se ingresen
* todos los campos solicitados.
*/
if(!jTextField1.getText().equa... |
de0d0fdd-d051-4e66-817a-b6a151ed0064 | 9 | private Object readValue() throws JSONException {
switch (read(2)) {
case 0:
return new Integer(read(!bit() ? 4 : !bit() ? 7 : 14));
case 1:
byte[] bytes = new byte[256];
int length = 0;
while (true) {
int c = read(4);
... |
aed810ff-363f-4a3b-8690-9ae08399d305 | 1 | @Override
protected void drawFrame(Graphics2D g) {
// Clear the canvas
g.setColor(Color.WHITE);
g.fillRect(0, 0, canvasWidth, canvasHeight);
// Update the model
model.tick(deltaT);
List<Ellipse2D> balls = model.getBalls();
// Transform balls to fit canvas
g.setColor(Color.RED);
g.scale(PIXELS_PER_MET... |
9bdf76e5-4f48-4921-b81c-9500cd907685 | 7 | public void visitFrame(
final int type,
final int nLocal,
final Object[] local,
final int nStack,
final Object[] stack)
{
AttributesImpl attrs = new AttributesImpl();
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
... |
2f66e237-88ba-4370-9b9d-23a5c47539ff | 7 | public static List<Long> computeDirectionChanges(double _bearingThreshold, double _accuracyThreshold, List<Bearing> _data_list) throws BearingException {
if (_bearingThreshold < 0 || _bearingThreshold > 360) {
throw new BearingException("INVALID_BEARING_THRESHOLD");
}
if (_accuracyTh... |
794c6e2c-629b-401c-a90d-77560282c050 | 6 | private boolean scanAndLoad(File folder, JMenu menu)
{
File[] files = folder.listFiles();
BiomeColorProfile profile;
boolean foundProfiles = false;
for (int i = 0; i < files.length; i++)
{
if (files[i].isFile... |
95430b38-4ff5-444b-814c-86105bae0ea2 | 5 | @Override
public void putAll(Map<? extends K,? extends V> m) {
for(Map.Entry<? extends K,? extends V> me : m.entrySet()) {
put(me.getKey(), me.getValue());
}
} |
f9764c0d-4168-437d-9205-55920950c328 | 9 | private boolean isOutOfBounds(Tetrimino tetrimino, boolean cutAtSkyline) {
Tetrimino.Shape shape = tetrimino.getShape();
Point position = tetrimino.getPosition();
int rotation = tetrimino.getRotation();
int[][] pattern = Constants.trueRotation.get(shape)[rotation];
int size = pattern.length;
int radius = (... |
ebfd75cd-565b-42d2-9095-b4ea3ef454fd | 9 | public boolean isEdgeExists(int i, int j) {
if (i < vertexNum && j < vertexNum && i >= 0 && j >= 0) {
if (i == j) return false;
if (i > j) { //exchange i & j
int k = i; i = j; j = k;
}
if (vector[i] == null) vector[i] = new Vector<Integer>(8);
for (int q = 0; q < vector[i].size(); q++) {
if ((... |
31575f51-a86a-4b33-83fc-d3e3432b64b6 | 2 | public static void handleGetEpgObjectReply(HTSMsg msg, HTSPClient client) {
Collection<String> requiredFields = Arrays.asList(new String[]{});
if (msg.keySet().containsAll(requiredFields)){
//TODO
} else if (msg.get("error") != null){
//TODO
} else{
System.out.println("Faulty reply");
}
} |
d6e91252-565d-44df-a892-188a158e0ecb | 1 | public void send(int clientId, Message msg) {
System.out.println("Sending message to client " + clientId + ": \"" + msg.encode() + "\"");
try {
send(clientId, msg.encode());
} catch (CouldNotSendPacketException e) {
System.out.println("Could not send message to client " + clientId + ": " + e.getMessage());
... |
a9fc0a8b-d755-4fbd-93d3-1ab5c57173cb | 7 | private static Vector<Token> prewortDetermineUnaryOperators(Vector<Token> postfixTokens) {
Vector<Token> outVector = postfixTokens;
Expressions expr = Calculator.expressions;
int tokenCount = outVector.size();
for(int i=0;i<tokenCount;i++) {
Token currentToken = outVector.get(i);
String currentText = cur... |
ceda1fac-cac4-4f6e-af3e-590f03d59601 | 6 | public double det()
throws Exception {
if(_rows != _cols)
throw new Exception("Matrix must be square to compute the determanent!");
if(_rows == 2 && _cols == 2)
return _det2x2();
else if(_rows == 1 && _cols == 1)
return _mat[0][0];
else {
double total = 0.0... |
7e7eb2e2-ffe1-4aea-b77b-e6180e70859d | 1 | private int startX( Side side ){
if( side == Side.EAST ){
return boundaries.x + boundaries.width;
}
else{
return boundaries.x;
}
} |
a7f01410-8731-4568-a01f-826b5f14501e | 7 | public void itemStateChanged(ItemEvent e){
int checknum = 0;
for(int cbc = 0; cbc <= statechecks.length-1; cbc++){
if(e.getItemSelectable() == statechecks[cbc]){checknum = cbc; bset = statechecks[cbc].getState();}
}
switch(checknum){
//interactive
case 0: control = 104; fireucEvent(); break;
//draw random
... |
224fd040-7962-42ea-a6d2-a0a70215b3ba | 8 | static double errorFunctionComplemented(double a) {
double x,y,z,p,q;
double P[] = {
2.46196981473530512524E-10,
5.64189564831068821977E-1,
7.46321056442269912687E0,
4.86371970985681366614E1,
1.96520832956077098242E2,
5.26445194995477358631E2,
9.34528527171957607540... |
9f6c4374-3bfc-4f67-badd-33b72dcb9ea4 | 1 | public BufferedImage loadImage(String path) {
try {
img = ImageIO.read(getClass().getResource(path));
} catch (IOException e) {
e.printStackTrace();
}
return img;
} |
c384e00a-8912-4be1-8962-ceaee9795101 | 3 | public void run()
{
screen = createVolatileImage(pixel.width, pixel.height); //actually use the graphics card (less lag)
render();
// JOptionPane.showMessageDialog(null, "Controls:\n\nWho knows!?");
while(isRunning)
{
if(!isPaused)
{
tick(); //do math and any calculations
render(); //dr... |
1e5dc682-22a8-4046-8fa1-b5f5ed7477fe | 0 | @Override
public String toString(){
return super.toString()+ " in category : Body Armor" + " with Defence " + this.defenseScore;
} |
533eacea-f99b-4a0a-bb00-1244d21138a9 | 6 | public boolean restartGame() {
Scanner input= new Scanner(System.in);
System.out.println("Do you want to restart the game?[y/n] ");
String str;
char ans = 0;
do {
str = input.next();
if (str.length() == 1) {
char []var = str.toCharArr... |
c9b9f6c3-1a8b-4877-891f-24091bb31521 | 7 | * @param shift the number of columns by which to shift
*/
private void shiftCol( int colNum, int shift )
{
Colinfo info = getColInfo( colNum );
int oldCol = colNum;
int newCol = oldCol + shift;
List<BiffRec> cells;
try
{
cells = getCellsByCol( colNum );
for( BiffRec cell : cells )
{
cell.s... |
3b602f9d-8bee-4eba-a851-c336b223d97e | 3 | private void tryDeleteDirectory(final String name) {
File file = new File(dataBaseDirectory + File.separator + name);
if (file.exists()) {
if (file.list().length == 0) {
if (!file.delete()) {
throw new DataBaseException("Cannot delete a directory!");
... |
c13b6820-32e4-4bee-9b77-fd822381f013 | 3 | @Override
protected void sort(T[] array, int leftIndex, int rightIndex) {
for (int i = leftIndex; i <= rightIndex; i++) {
int min = i;
for (int j = i + 1; j <= rightIndex; j++) {
if (array[j].compareTo(array[min]) < 0) {
min = j;
}
}
T aux = array[i];
array[i] = array[min];
arra... |
15240b75-a546-4cfb-b171-05d4ba7b9c92 | 2 | public void writeMap() throws IOException {
String line = "";
boolean success;
for(int i1 = 0; i1 < nbLine; i1++) {
do {
System.out.print("Line " + i1 + " :");
line = Scan.readString();
success = descrip... |
633246da-4f8e-48ab-8dbb-c93757463e0f | 3 | public ArrayList<ArrayList<Integer>> zigzagLevelOrder(TreeNode root) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> row = new ArrayList<Integer>();
this.reverse = false;
if (root == null) {
return result;
}
... |
47c92ea0-0e60-4267-816b-d934b6b92808 | 0 | public double getProgressPercent(){
return (double) savedLength / (double) length * 100;
} |
0a6bdaf1-47f5-434b-993f-092abf4ffe16 | 2 | public void populatePlaylist()
{
if(!currentList.isEmpty()){
//Array for song titles
ArrayList<String> songs = new ArrayList();
for(Song s : currentList.getPlaylist())
{
songs.add(s.getTitle());
}
currentPLList.setListDa... |
2e710394-620c-4eeb-bf93-16ca4b61e118 | 3 | public boolean login(String name, String password) {
String select = "SELECT * FROM ADMIN WHERE NAME=?";
PreparedStatement ps = null;
boolean correct = false;
try {
ps = conn.prepareStatement(select);
ps.setString(1, name);
ResultSet rs = ps.executeQuery();
if (rs.next() && rs.getString("PASSWORD")... |
a448387d-1f89-4fb8-ad02-05d32df167e4 | 3 | public void insertSupplierData(supplier tempSupplier) throws SQLException{
try {
databaseConnector = myConnector.getConnection();
SQLQuery = "INSERT INTO familydoctor.supplier "+"VALUES(?,?,?,?,?)";
PreparedStatement preparedStatem... |
3b14da45-9691-47ba-8726-1e3f36460d64 | 7 | @Override
public void setValue(ELContext context, Object base, Object property, Object value) {
if (context == null) {
throw new NullPointerException();
}
if (isResolvable(base)) {
if (readOnly) {
throw new PropertyNotWritableException("resolver is read-only");
}
Method method = toBeanProperty(ba... |
4d49672e-273b-4666-bfbd-0f2970c1405e | 1 | @Override
public void update (float delta) {
if (badguy != null) {
badguy.update(delta);
}
} |
db8af227-248d-4cc7-ab57-3c2e665fa163 | 0 | public static Timer getInstance()
{
return instance;
} |
8004e4dc-b052-4aca-884a-16ace4e18607 | 1 | public MediaUrlDao() {
// create a database connection
try {
con = DriverManager.getConnection("jdbc:sqlite:"
+ "twitterKeyWordSearch.sqlite");
tableCheckAndCreate();
} catch (SQLException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
} |
30c0000c-5f5b-487f-84d6-9db832724afc | 6 | public boolean testAvailabe(int H, int V, int A) { // H&V number want be bls of
// indH &indV A = index
if ((this.indexH + H) >= 8 || (this.indexV + V) >= 8
|| (this.indexV + V) < 0 || (this.indexH + H) < 0) {
this.availableCells[A] = null;
} // ok
else if (myBoard.bordaCell[this.indexH + H... |
f6d9a2fa-476c-434f-8353-7876669833d2 | 8 | public static void main(String[] args) {
//0. Preprocess parameters
if(args.length < 1 || args[0].isEmpty()) return;
int playersSecondStage = 2;
if(args.length >= 2)
try {
playersSecondStage = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
System.err.println("Expected a posit... |
daf733c8-9a51-4a3f-811c-95fe5abd048d | 4 | private boolean isHighLevelCacheEnable() {
if (highLevelCache == null) {
return false;
}
// 如果上一次连接不成功,则判断是否超过重连时间
boolean reconnect = false;
if (!highLevelCacheReachable) {
long interval = System.currentTimeMillis() - lastUnreachableTime;
if (interval > reconnectTime) {
reconnect = true;
}
... |
3e144c81-d923-4c5f-9a69-6ae6eced4ad9 | 1 | private void roomRegister(String roomid) {
DataLine rq = new DataLine();
rq.setAPI("room.register");
if (roomid != null) {
rq.set("roomid", roomid);
self.ws.close();
self.ws = getWebSocket(chatServers[0]);
} else {
rq.set("roomid", this.roomid);
}
self._send(rq, null);
} |
7466b98f-7f0a-4f4d-86af-644171088cc1 | 5 | final void method3652() {
for (Node class348 = aClass262_7732.getFirst(4);
class348 != null; class348 = aClass262_7732.nextForward((byte) 55))
((za_Sub1) class348).method3440(-82);
anInt7563++;
if (aClass18_7720 != null)
aClass18_7720.method279((byte) -126);
if (anOpenGL7664 != null) {
method37... |
3dddb7bd-f3a6-459e-b38b-545418112431 | 0 | @AfterClass
public static void tearDownClass() {
} |
4fb6aede-b2a9-4c85-b9d2-9f900b850e2e | 8 | @Override
public Split insert(int key, int value) {
/* Early split if node is full.
* This is not the canonical algorithm for B+ trees,
* but it is simpler and it does break the definition
* which might result in immature split, which might not be desired in database
* because addit... |
a923dcdc-1638-4a16-99eb-772a5b1348b0 | 4 | public List<Integer> getUncoveredEmerg(List<List<Point>> sets) {
List<Integer> uncoveredList = new ArrayList<>();
for (int i = 0; i < sets.size(); i++) {
int coveredEmerg = 0;
for (Point incident : incidents) {
for (int j = 0; j < sets.get(i).size(); j++) {
... |
8fb84d20-e52c-408c-9d48-ea3053e592cd | 8 | public void submitClientQuery(MiniServer player, String query) {
String move = UNENTERED_MOVE;
boolean clientRecognized = false;
if(query.toLowerCase().startsWith("/move") && isInList(player) ) {
try {
move = query.split(" ")[1];
} catch (Exception e) {
move = UNENTERED_MOVE;
}
} else {... |
aeeb369f-7346-4181-b4b1-4fda8c2ec853 | 8 | private int getTone (int freq) {
int a,index=-1,lowVal=999,dif;
// Store the highest and lowest frequencies detected
if (freq>highFreq) highFreq=freq;
else if (freq<lowFreq) lowFreq=freq;
// Match the frequency to a tone number
for (a=0;a<TONES.length;a++) {
dif=Math.abs(TONES[a]-freq);
if (dif<lowVal... |
a0393231-5a5a-4f70-832a-d1b9e8a3fbd5 | 9 | public void setPipelineColor(int n,Color color){
if (n==1){
jTextField1.setBackground(color);
} else if (n==2){
jTextField2.setBackground(color);
} else if (n==3){
jTextField3.setBackground(color);}
else if (n==4){
jTextField4.setBackground(color);}
... |
a3fe9a92-3503-47f5-aba8-ebd2f2456727 | 9 | Color AdvColorPix(int count) { // all new and improved colour engine
int c1;
int c2;
int r;
int g;
int b;
int or; //old red
int og;
int ob;
double dr;
double dg;
double db;
Str... |
7fdc774c-1e74-43c9-b072-30d05da507fc | 0 | public HeroClass getBossClass() {
return bossclass;
} |
e5912834-e996-41d4-9629-10dd45e8d0c7 | 8 | private void fillNode(Element parentElement, VCNTreeItem parentItem) {
NodeList children = parentElement.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
String nodeName = childEle... |
224f7189-e3a1-4e38-ab80-dfc09c8ec0e8 | 4 | public long logOnlinePlayers(long lastMillis) {
int onlinePlayersLogTime = conf.getInt("TimeBetweenOnlinePlayersLog", 15);
Format sdf = new SimpleDateFormat("mm");
if (60 % onlinePlayersLogTime == 0) {
if (onlinePlayersLogTime > 59) {
onlinePlayersLogTime = 0;
}
Str... |
94d9a683-299c-482c-9722-d7687a8e9058 | 1 | @Override
public void listening() {
if( triggeredSite == this ){
triggeredSite = null;
handlersAllowed.clear();
updateAllEnabled();
}
} |
e3ef2c78-0d74-4970-b2b2-6c389b456071 | 9 | private void Import() throws java.io.FileNotFoundException{
boolean searchingVertex = false;
String line = "";
Scanner scan = new Scanner(source);
while (!searchingVertex) {
line = scan.next();
if(line.equals("v")) {searchingVertex = true;}
}
int i = 0;
while (searchingVertex) {
i++... |
d80e07f2-410b-4b63-a54c-64ac29a7ce4c | 2 | public static void load()
{// Create the data objects for us to restore.
// Wrap all in a try/catch block to trap I/O errors.
try
{
if (!FILE.exists())
{
FILE.createNewFile();
updateFlights();
save();
} ... |
8142cb96-a34e-4205-a266-26e9a108b74c | 0 | @Override
public void init(List<String> argumentList) {
onOrOff = argumentList.get(0);
} |
c2564b5c-778f-42e9-ba09-2310ced2ce9b | 2 | public static void main(String[] args) throws Exception {
if (args.length == 0) {
help(System.err);
return;
}
CompiledClass[] entries = new CompiledClass[args.length];
int n = parse(args, entries);
if (n < 1) {
System.err.println("bad paramet... |
a62cacb5-06e5-44f8-9034-921ad96b8e48 | 7 | private final boolean cvc(int i)
{
if (i < 2 || !cons(i) || cons(i - 1) || !cons(i - 2))
{
return false;
}
{
int ch = b[i];
if (ch == 'w' || ch == 'x' || ch == 'y')
{
return false;
}
}
return ... |
677d7a83-aac2-4784-a39c-71fd6fc4fe45 | 6 | private static void setup()
{
if (isSetup)
{
return;
}
//System.out.println("Enum Helper Initalizing: ");
for (int x = 0; x < ctrs.length; x++)
{
try
{
Class<?>[] enumHeaders = new Class[ctrs[x].length + 3];
... |
d7e73502-b704-48f9-9d1e-276bba4bc5ad | 6 | private boolean compareVersions ()
{
String[] local = localVersion.split("\\.");
String[] remote = remoteVersion.split("\\.");
int longestNumber =
local.length > remote.length ? local.length : remote.length;
for (int i = 0; i < longestNumber; i++)
{
... |
6852385b-2d0e-41c2-9b52-7d6f9b91869d | 8 | public static Map<String, Product> getListOfProducts() {
try {
builder = factory.newDocumentBuilder();
File propertiesFile = new File("src/com/woolfer/testtask/properties/PriceOfProducts.xml");
try {
Document doc = builder.parse(propertiesFile);
Element root = doc.getDocumentElement();
NodeLis... |
a5da1c0f-324c-4d14-8e41-14b55d46b1e5 | 1 | private void registerHealthChecks(Environment environment) {
final Map<String, HealthCheck> beansOfType = applicationContext.getBeansOfType(HealthCheck.class);
for (Map.Entry<String, HealthCheck> entry : beansOfType.entrySet()) {
environment.healthChecks().register(entry.getKey(),entry.get... |
3c8e8a6c-3a19-4934-ae38-3354cc7e8e94 | 1 | private void appliquerLimiteSurHeuresReconnues(String categorie,
int limiteHeures) {
if (heuresAccumulees.get(categorie) > limiteHeures) {
heuresAccumulees.put(categorie, limiteHeures);
}
} |
e480c073-41e3-4667-8c72-1f5eb01ba758 | 6 | public int randomColor(int from, int to) {
if (from < 0) {
from = 0;
} else if (from > 255) {
from = 255;
}
if (to < 0) {
to = 0;
} else if (to > 255) {
to = 255;
}
if (from == to) {
return (0xFF000000 | (from << 16) | (from << 8) | from);
} else if (from > to) {
final int temp = t... |
ae247848-6795-4f5b-9874-f7ccdd5cf696 | 4 | public static boolean checkVersion(){
File clientVersionFile = new File(Util.getWorkingDirectory() + File.separator + "version");
if(clientVersionFile.exists()){
URL serverVersionFile;
try {
serverVersionFile = new URL(Settings.versionFile);
BufferedReader brServer = new BufferedReader(new InputStream... |
9d3b6fe2-7aee-4435-ab7b-d4e1af67da37 | 2 | public void enqueue(Item item) {
if (item == null)
throw new NullPointerException();
if (next == a.length)
resize(2 * a.length);
a[next] = item;
next++;
size++;
} |
b37a0218-ce04-4f93-9a73-b0d7a6bd79bd | 8 | public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl =
"jdbc:sqlserver://localhost:1433;" +
"databaseName=AdventureWorks;integratedSecurity=true;";
// Declare the JDBC objects.
Connection con = null;
... |
ea4f9f49-61af-4589-bd22-92dca640cf3b | 3 | @Override
public void run()
{
while (!end)
{
//-------------------------------------------------------
// Main code here
//-------------------------------------------------------
//pause or unpause the gamepanel
//xor logic for connecting buttons pause with keyboard p
//only pause when ... |
e6c40236-3467-4676-895f-1eca8b8851e9 | 1 | @Override
public void doIt() {
try {
content.put("datetime", new Date().getTime());
content.put("Version", Control.version);
write(content.toString());
} catch (JSONException e) {
}
} |
3b9170e5-81b2-4b44-8e85-d89abc543026 | 1 | public ArrayList<Occurrence> toArray() {
ArrayList<Occurrence> array = new ArrayList<Occurrence>();
Occurrence temp = head;
while (head != null) {
array.add(head);
head = head.next;
}
head = temp;
return array;
} |
933c78f9-3ff9-4f3c-ae76-b2bb83ac7696 | 9 | final void initialize(boolean isOnline, SocketWorker worker) {
if (socketWorker != null) {
try {
socketWorker.reset();
} catch (Exception exception) {
/* empty */
}
socketWorker = null;
}
anInt3193++;
socketWorker = worker;
writeConnectionRequest();
writeStatusUpdate(isOnline);
((ByteBuff... |
53ea61a7-f70b-44c0-8c65-8623c7b1a63f | 6 | public static double comparableAngleOnScreen( Point source, Point target, Side nullSide ){
int sx = source.x;
int sy = source.y;
int tx = target.x;
int ty = target.y;
if( sx == tx && sy == ty ){
return 0;
}
double angle = Math.atan2( tx-sx, sy-ty );
switch( nullSide ){
case NORTH: return ang... |
047a9a6f-f935-4f73-9aa6-6b632eb8ff5f | 5 | public static boolean interactSlot(int slot, String action) {
if (!checkIndex(slot) || !setExpanded(true))
return false;
if (action == null || action.length() == 0)
return useSlot(slot);
WidgetChild child = getMainChild(slot);
if (child.visible()) {
return child.interact(action);
}
return false;
} |
12539876-547a-41b1-a7a5-42654e25cd64 | 3 | public void run(){
Random rand=new Random();
while(checkState()){
if(correr&&!fin){
decision(rand.nextInt(11));
}
state=SUSP;
}
} |
57e3bc1e-12c4-4581-938e-3ecbe7bf0d5f | 6 | @Override
public void introspectAllComponents()
throws SystemNotConnectedException {
componentsId = new ArrayList<String>();
components = new ArrayList<AbstractOrocosComponent>();
logger.info("Instropection of the system components:");
BindingListHolder blistHolder = new BindingListHolder();
BindingItera... |
4ccb1274-77e3-4122-8189-62182e0895a6 | 1 | public List<String> getLink() {
if (link == null) {
link = new ArrayList<String>();
}
return this.link;
} |
ad663876-70ab-4903-b278-f1478270cb65 | 7 | private int selectSaveFile() {
JFileChooser fc = new JFileChooser();
FileNameExtensionFilter textFilter = new FileNameExtensionFilter("GenSim file", "gsm");
fc.setFileFilter(textFilter);
int chosen;
boolean goodFile;
do {
goodFile = true;
chosen ... |
a3f1d64e-7a41-4782-a01f-33e1b84d2e2b | 3 | @Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
trafficCounter.start();
InetSocketAddress address = (InetSocketAddress) ctx.channel().remoteAddress();
String ip = address.getHostString();
if (msg instanceof HttpRequest) {
Syst... |
f708c374-2069-4510-a96f-0853e40e43c5 | 3 | private void updateAREDParameters()
{
String link;
FnbSCFQScheduler sched;
for (Enumeration e = schedTable.keys(); e.hasMoreElements(); )
{
link = (String) e.nextElement();
sched = (FnbSCFQScheduler) schedTable.get(link);
if ((schedTable.get(link... |
3e9f36be-a4ae-4c87-83ae-708c2c304532 | 1 | public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
} |
5a774e88-621b-4264-b2f5-10be7bb79c54 | 4 | public LinkedList<Integer> searchForPattern(String pattern, String context){
LinkedList<Integer> foundPatternList = new LinkedList<Integer>();
int patternLength = pattern.length(); int contextLength = context.length(); int skip;
int[] shiftTable = this.BoyerMooreShiftTable(pattern);
for(int contextIndex = 0; c... |
f0c73ca3-9c98-4dd1-a53f-6d018106d00b | 4 | private void sink(int k) {
while (2 * k <= N) {
int j = 2 * k;
if (j < N && less(j, j + 1))
j++;
if (!less(k, j))
break;
exch(k, j);
k = j;
}
} |
e54d80fc-d2d8-4ca7-97e6-444088fcb3f0 | 1 | @Override
public void addItem( GraphItem item ) {
if( graph == null ){
throw new IllegalStateException( "cannot add items because there is no graph set" );
}
graph.addItem( item );
} |
6e4a8e43-f063-4852-bc45-b6e0c94736e9 | 3 | public void addEditingShip()
{
if(myTurnEditing)
{
if(mySea.shipWorks(editingShip))
mySea.addShip(new Ship(editingShip));
}
else
{
if(theirSea.shipWorks(editingShip))
theirSea.addShip(new Ship(editingShip));
}
} |
5a207121-efe5-4126-a465-f2f810471dc5 | 5 | public static int[][] generateMap(int width, int height, float roughness) {
boolean[][] bool_map;
int[][] int_map = new int[width][height];
Perlin n = new Perlin(null, roughness, width, height);
int cpt = 0;
boolean finished = false;
do {
n.initialise();
... |
e2191d44-6feb-4415-9a89-e9031fd7dfa9 | 8 | public boolean equals( Object other ) {
if ( ! ( other instanceof TObjectDoubleMap ) ) {
return false;
}
TObjectDoubleMap that = ( TObjectDoubleMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectDoubleIterator... |
f6d11d9b-dc80-44d9-b268-6e8563fb19ea | 4 | public String getCultivo(String refCat, String subparce){
if (lSub.get(refCat) == null || lSub.get(refCat).isEmpty())
return "";
if (lSub.get(refCat).get(subparce) == null || lSub.get(refCat).get(subparce).isEmpty())
return "";
return lSub.get(refCat).get(subparce);
} |
c635906d-614c-410b-83c3-82fb2f1d7c01 | 5 | void resizeScrollBars() {
// Set the max and thumb for the image canvas scroll bars.
ScrollBar horizontal = imageCanvas.getHorizontalBar();
ScrollBar vertical = imageCanvas.getVerticalBar();
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
if (width > c... |
cf4c1cd0-b47b-4e3e-82d1-2f671c9af59c | 2 | public boolean tick(int dt) {
boolean rv = false;
te += dt;
while(te > frames[fno].dur) {
te -= frames[fno].dur;
if(++fno >= frames.length) {
fno = 0;
rv = true;
}
}
curf = frames[fno].parts;
return(rv);
} |
a7d19896-cfe9-4aec-a642-6c75cf5a1d12 | 1 | private MouseEventHandler() {
// Instaniate the mouseListeningObjects, IE every
registeredListeningObjects = new SynchronisedGameQueue<IMouseEventable>();
// Create a new list for each type of event and add it to our map of
// EventType -> list of waiting events
waitingEventLists = Collections.synchronizedMa... |
024d840d-8bc7-481b-b4d6-d52517f73791 | 3 | public boolean isWithin(Vector a, Vector b) {
return (greaterThan(a) && lessThan(b)) || (lessThan(a) && greaterThan(b));
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.