method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
12da2be7-e8ef-478d-a23c-9bca2674dc4e
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; QuestionDescription other = (QuestionDescription) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other...
f369079a-5748-48cf-870a-27bd35cfb13f
7
public Weapon makeWeapon(Weapons weaponName) { Weapon weapon = new Weapon("Fists", "Mighty fists used. Possible uses range from swinging to churning butter.", new Damage(12)); switch(weaponName) { case SWORD: weapon = new Weapon("Sword", "For when you are a very concerned citizen.", new Damage(25)); brea...
65604aaf-5b74-4c56-8b78-c25be04084b1
7
protected void configFromAdjacent(boolean[] near, int numNear) { final Tile o = origin() ; if (numNear == 2) { type = TYPE_SECTION ; if (near[N] && near[S]) { facing = Y_AXIS ; if (o.y % 8 == 0) { type = TYPE_HUB ; attachModel(MODEL_FLAT_RIGHT) ; } ...
be8a9dc9-6af7-408c-8ef6-e3b6eb2424dc
7
private ArrayList<String> splitMsg(String str) { ArrayList<String> array = new ArrayList<String>(); int curPos; int len = str.length(); int countLeft = 0, countRight = 0; int startIndex = 0; char ch; for (curPos = 0; curPos < len; ++curPos) { ch = str.charAt(curPos); ...
9cb2b466-4ce7-4e81-a96c-01eacd6727c5
3
@SuppressWarnings("resource") @Override public void run() { // TODO Auto-generated method stub int i=0; try{ ServerSocket listener = new ServerSocket(port); Socket server; while((i++ < maxConnections) || (maxConnections == 0)){ gameController.Print("Server: Waiting for Clients"); serv...
3c1c5ec7-37f7-4074-9630-1f06dddb0147
8
private static float rateHolding(Actor actor, Holding holding) { if (holding == null || holding.base() != actor.base()) return -1 ; final Series <Actor> residents = holding.personnel.residents() ; final int UL = holding.upgradeLevel(), maxPop = HoldingUpgrades.OCCUPANCIES[UL] ; final fl...
fe5e491f-d1db-42d2-95de-e72156daa1b7
6
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page ...
08da4f38-ae0e-47db-b73c-992fb7f51b88
4
private static char[] getColumn (Alignment layoutMap, int index) { List<Read> reads = new ArrayList<Read>(); for (Read lay : layoutMap.values()) { if (lay.getOffset() <= index && index < lay.getOffset() + lay.getLength()) { reads.add(lay); } } char[] column = new char[reads.size()]; for (int i = ...
276d253c-c084-461d-a6f0-70f925327715
6
private void funcBody() throws Exception { while(scan.sym == Token.var || scan.sym == Token.array) { varDecl(false); } if(scan.sym == Token.opencurly) { scan.next(); if(scan.sym != Token.closecurly) { statSequence(); } ...
be29fd7e-9fc3-422e-81f1-3366457a7f85
5
public void addHeapUsage(String name, float total, float used, long[] bound) { switch(name) { case "newGen": newGen = new HeapUsage(total, used, bound); break; case "oldGen": oldGen = new HeapUsage(total, used, bound); break; case "eden": eden = new HeapUsage(total, used, ...
b40b5728-c4d1-48dd-8aa7-510aad4b0fc8
7
private boolean hasEveryPlayerStartPositionAreaLightGrenade(Grid grid) { final int areaToCover = 5; for (Player player : grid.getAllPlayersOnGrid()) { boolean lightGrenadeFoundNearPlayer = false; for (int i = 0; i < (areaToCover * 2 + 1); i++) { for (int j = 0; j < (areaToCover * 2 + 1); j++) { ...
2c28cae2-8240-4b76-8d57-fed4b947b0f4
0
public int popRunTimeStack() { return runStack.pop(); }
7d3a725a-68d9-4a7e-8c2c-7a4361c03aff
3
private void shuffle(boolean new_discard){ //sanity check... assert(draw_count == 0 && discard_count != 0); shuffling = true; System.arraycopy(discard, 0, draw, 0, discard_count); //Simple Fisher-Yates shuffle for (int i=discard_count-1, idx; i>0; i--){ idx = rand.nextInt(i + 1); int temp = draw[idx];...
23561dfc-0c21-442c-b9d9-11dbe46d3f7d
4
public void update(GameContainer gc, int delta) throws SlickException { x = gc.getInput().getMouseX(); y = gc.getInput().getMouseY(); if (up) { y -= speed; } if (left) { x -= speed; } if (down) { y += speed; } if (right) { x += speed; } }
e43401c6-d898-4a99-bf85-b9c91b005bd1
5
protected void onRender(GraphicsHelper gh) { if (!copied) return; Progress progress = null; for (ResourceManager<?> manager : Terraria.managers) if (progress == null || progress.percent >= 1d) progress = manager.getProgress(); gh.g().setColor(Color.white); gh.g().drawString("Loading: "+progress.text,10,...
116a96b2-f1ca-478c-bd08-5e6847cccd06
6
public static Neuron makeNeuronofType(int type, GameState ref){ switch(type){ case 1: return new InputNeuron_Add(); case 2: return new OutputNeuron_Add(); case 4: return new DistanceThresholdChecker(ref); case 5: return new PitChecker(ref); case 6: ret...
0ba5839d-18f8-4162-b976-ea531c001044
6
public CardShape getShape() { boolean[] open = new boolean[4]; open[0] = getOpenings().isTop(); open[1] = getOpenings().isRight(); open[2] = getOpenings().isBottom(); open[3] = getOpenings().isLeft(); int indsum = 0; int anzop = 0; for (int i = 0; i < open.length; i++) { if (open[i]) { indsum +...
adc9a99d-7c63-49d6-9459-df0ed37988cb
8
public void drawPath(Graphics2D g) { int next = exit, last = exit; g.setColor(Color.RED); //g.fillRect(adjustx + exit % xTiles * tileSize + 2, adjusty + exit / xTiles * tileSize + 3, tileSize - 3, tileSize - 3); while (next != entry) { next = solver.camefrom[next / xTiles][next % xTiles]; //g.fillRect(adj...
16ff8119-81a9-40eb-9773-15d9c4cb4efb
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, ((Integer)value).intValue() + 1); } else if (value instanceof Long) { ...
7dadc620-9318-49be-9c4f-bbb8e05169e0
5
@Override public void keyPressed(KeyEvent e) { /* * Keys auswerten und an Modelaktionen weiterleiten. * TODO: Mapping Konfigurabel machen */ int keyCode = e.getKeyCode(); switch (keyCode) { case KeyEvent.VK_A: model.movePlayer(0, Model.Direction.LEFT); break; case KeyEvent.VK_D: m...
29147c09-f73f-4758-a128-f285ec9d5e05
8
public ArrayList<String> filterCovers(){ /* Sorts alphabetical or rating */ if(getSelectedSort().equals("Alphabetical")){ allMovies = bubblesrt(allMovies, "alpha"); } else{ allMovies = bubblesrt(allMovies, "release"); } /* Filters rating and genre */ ArrayList<String> covers = new ArrayList<Str...
daf2ab0f-0821-4460-b385-4e940bb095bf
0
public static void main(String[] args) { Node node1 = new Node("node1"); Node node2 = new Node("node2"); Node node3 = new Node("node3"); node1.next = node2; node2.next = node3; System.out.println(node1.next.next.data); System.out.println("---------------"); Node node4 = new Node("node4"); ...
447c00e6-fb5f-40ec-bba3-c86f6154fac8
0
public KeyStroke getKey() { return KeyStroke.getKeyStroke('t'); }
2f1c3176-f7d7-4a7f-961b-80d71c51ba12
9
private void updateStateTellTools(List<Keyword> keywords, List<String> terms) { //We should have come here by a keyword jump and the recipe shouldve been passed or set if (keywords != null && !keywords.isEmpty()) { for (Keyword kw : keywords) { if (kw.getKeywordData().getType() == KeywordType.RECIPE) { currR...
a8c05feb-06e2-439d-a0ee-7e5c967fdf48
7
public void computeValues() throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); String line; int val; int idx; int tmpVal; int prevVal; boolean negativeFlag; while ((line = br.readLine()) != null) { String[] params = line.split("\\s"); negativeFlag = false; idx...
20663a6a-663d-4467-b018-139e905281e5
5
public PowerUp(int type, int x, int y){ this.type = type; this.x = x; this.y = y; ImageIcon i = new ImageIcon(this.getClass().getResource(extraLife)); extraLifeImage = i.getImage(); ImageIcon i2 = new ImageIcon(this.getClass().getResource(machineGun)); machineGunImage = i2.getImage(); ImageIcon i3...
d3da8b52-c4f1-423d-8365-8dd2a6d01a5f
8
public static void main(String[] args) { // create a list of primes boolean[] primes = new boolean[20 * 52 + 1]; // start with everything true for sieve for (int i = 0; i < primes.length; ++i) primes[i] = true; // figure out which ones should be false; f...
3cdbd5bc-63b1-43b6-85b7-6e55f94d0a5c
8
private void initialize() throws PortInUseException, UnsupportedCommOperationException, IOException, PortNotFoundException { String testPort = System.getProperty("xwot.test.port"); logger.debug(testPort); if(testPort != null && !testPort.equals("")) { PORT_NAMES = new String[1]; ...
3b98be71-9263-4248-b4b8-d07365ab89a5
5
public static void main(String[] args) { //Test Class DataSet testDataSet = new DataSet(); //Test One System.out.println("DataSet:: GetData()"); Object[][] test1Object = testDataSet.GetData(); System.out.println("DataSet:: GetData() - Test Passed"); //Test Two System.out.println("DataSet:: GetAttirbutes...
4c25cf16-eeed-4607-ae13-1a9c54f01c64
1
@SuppressWarnings("unchecked") @Override public void validate(ProcessingEnvironment procEnv, RoundEnvironment roundEnv, TypeElement annotationType, AnnotationMirror annotation, ExecutableElement e) { AnnotationValue expectedExceptionTypes = AnnotationProcessingUtils .getAnnotationElementValue(procEnv, ann...
b9293c89-4980-429f-a6f0-2c634c95c9a3
1
@Override protected void onUserList(String channel, User[] users) { ChannelEventsListener listener = getChannelEventsListener(channel); if (listener != null) { MainWindow.User[] u = MainWindow.User.toUsers(users); listener.userListReceived(u); } }
ebec68da-02de-4e06-9190-7f8e5e9ee17c
2
public void setLookAndFeel(String clazz) { JFrame frame = (JFrame) SwingUtilities.windowForComponent(this); if (frame != null) { try { UIManager.setLookAndFeel(clazz); SwingUtilities.updateComponentTreeUI(frame); // Needs to assign the key bindings again keyboardHandler = new EditorKeyboa...
5db125ca-b2cd-4f28-b848-3e8e391e0fe8
2
private void copyEntry(final InputStream is, final OutputStream os) throws IOException { if (outRepresentation == SINGLE_XML) { return; } byte[] buff = new byte[2048]; int i; while ((i = is.read(buff)) != -1) { os.write(buff, 0, i); ...
326333ae-55b9-4b50-bf59-8c6271586da2
1
public static TextDistanceStrategy distanceUpdwards( final TextDistanceStrategy strategy ) { return new TextDistanceStrategy() { @Override public double getDistance( TextStrategyParameters parameters ) { double distance = strategy.getDistance( parameters ); Point2D normal = parameters.getPath().getNorma...
b608e07b-0116-431a-9611-b4b3572d47da
5
@Override public void execute(CommandSender sender, String worldName, List<String> args) { this.sender = sender; if (worldName == null) { error("No world given."); reply("Usage: /gworld setsticky <worldname> <true|false>"); } else if (!hasWorld(worldName)) { reply("Unknown world: " + worldName); } ...
e3a01506-abe9-4df0-9681-4d3e2a9cb18e
2
public List<AbstractInsnNode[]> findAll(String regex) { List<AbstractInsnNode[]> results = new ArrayList<AbstractInsnNode[]>(); try { Matcher regexMatcher = Pattern.compile(processRegex(regex), Pattern.MULTILINE).matcher(representation); while (regexMatcher.find()) results.add(makeResult(regexMatcher...
5cbf80a7-5553-495e-bd44-1d51e944ba86
7
protected void addAllCookies(HashMap<String, String> add){ for(Entry<String, String> entry : add.entrySet()){ //filter out special keys if(entry.getKey().equalsIgnoreCase("httponly") || entry.getKey().equalsIgnoreCase("secure") || entry.getKey().equalsIgnoreCase("expires") || entry.getKey().equal...
eb1505ee-3221-4d45-af60-9c5f7e331380
0
@Override public void windowActivated(WindowEvent arg0) { }
a83f7769-23ad-49ec-a656-46af03a499c4
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
75684367-b151-4fd4-907f-bdd113b40810
1
@Override public List<Integer> update(Criteria beans, Criteria criteria, GenericUpdateQuery updateGeneric, Connection conn) throws DaoQueryException { List paramList1 = new ArrayList<>(); List paramList2 = new ArrayList<>(); StringBuilder sb = new StringBuilder(UPDATE_QUERY); String ...
fab3b88b-acac-46d1-9c76-82deb4678a70
0
public int getRowCount() { return transitions.length; }
664879eb-4331-44a9-abbc-7f7e63321918
8
public boolean isOpen() { if ( STREAM_TYPE_MBUS_SERIAL == streamType || STREAM_TYPE_MBUS_TCP == streamType) { if ( null == mbus ) return false; return mbus.isOpen(); } if ( STREAM_TYPE_SOUNDMETER_CENTER == streamType ) { if ( null == sm ) return false; return sm.isOpen(); } if ( STREAM_...
d1b74c41-57b0-46ca-9a0c-9ecd220d6739
2
public boolean addCensoredWord(String word) { if (censorWords == null) censorWords = Lists.newArrayList(); if (censorWords.contains(word.toLowerCase())) return false; censorWords.add(word.toLowerCase()); return true; }
580951de-a5f3-4abd-8f9e-76a71e3139ea
0
private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed Cliente clienteNuevo = new Cliente( Integer.parseInt(idLabel.getText()),nombre.getText(), apellidos.getText(), apodo.getText(), especial.isSelected()); GestionarCliente modificar = new G...
59ba944e-0274-48a2-82eb-7f54bb216f95
1
public static Terrain fromRGB(int r, int g, int b) { int rgb = 256*256*r + 256*g + b; Terrain t = mapId.get(rgb); return t == null ? Terrain.OTHER : t; }
dd903d16-c136-4b4e-bb52-a288a0003ce2
8
public void actionPerformed(ActionEvent e) { //If the dice type JComboBox is used, record the user selected dice type if ("diceTypeSelected".equals(e.getActionCommand())){ selectedDiceType = (String) diceType.getSelectedItem(); } //If the dice quantity JComboBox is used, record the user selected dice quantit...
bfd4fc17-e858-4ecd-9ec9-d6b095d6ea14
6
public void move() { if (deadTime > 0) { deadTime--; if (deadTime == 0) { deadTime = 1; for (int i = 0; i < 8; i++) { world.addSprite(new Sparkle((int) (x + Math.random() * 16 - 8) + 4, (int) (y ...
4601bce1-a8a3-482d-bc98-920128370f90
3
public String toValue() { StringBuilder b = new StringBuilder("{" + this.getClass().getName() + " "); String fields = ""; for (Field f : this.getClass().getFields()) { try { fields += ", " + f.getName() + "=" + f.get(this.getClass()).toString(); } catch (IllegalArgumentException e) { // TO...
85204936-1007-43e3-8c79-a7fd55697293
9
public void actionPerformed( ActionEvent e ) { int answer = -1; String type = null; /* The user is promptet on exit if confirmdialogs are turned on in the GuiDconfig.xml file. */ if( e.getSource() == cmdQuit ) { answer = JOptionPane.showConfirmDialog( ...
b275bf82-49ff-465e-8e01-a2c7b72ad18c
0
@Override public void destroy() { super.destroy(); parent = null; }
0ed80523-f28e-4f57-95b7-d952c3f8a792
6
public int calculateMeleeDefence() { int defenceLevel = c.playerLevel[1]; int i = c.playerBonus[bestMeleeDef()]; if (c.prayerActive[0]) defenceLevel += c.getLevelForXP(c.playerXP[c.playerDefence]) * 0.05; else if (c.prayerActive[5]) defenceLevel += c.getLevelForXP(c.pla...
d6396c2a-cecb-4dc6-99c1-1c5f67378ed2
9
protected boolean resumeAfterRecovery() { if(!this.methodRecoveryActivated && !this.statementRecoveryActivated) { // reset internal stacks this.resetStacks(); this.resetModifiers(); /* attempt to move checkpoint location */ if (!this.moveRecoveryCheckpoint()) { return false; } // only look for head...
917695d5-0d99-4606-bc04-519b6a85e916
6
@Override public String toString() { switch(this) { case INT: return "int"; case VOID: return "void"; case UNDEFINED: return "undefined"; case INTARRAY: return "int[]"; case BOOL: return "boolean"; case FLOAT:...
6b509882-9d68-4d36-b79e-0d6f006248d9
2
public String[] originalItemNames(){ if(!this.dataEntered)throw new IllegalArgumentException("no data has been entered"); String[] ret = new String[this.originalNitems]; for(int i=0; i<this.originalNitems; i++)ret[i] = this.originalItemNames[i]; return ret; }
7f9386dc-8ceb-4ea1-9adf-9f93a45ce324
3
public void run() { String line = null; String Filtered = null; String Response = null; while (Util.ServerRunning && (line = Stream.GetString()) != null) { // Print line for console to see Logger.Common(line); // Filter for color codes Filt...
173e4c9e-278e-4617-8686-2e76b7018e66
1
private int score(int[] bowl){ int sum=0; for(int i=0;i<12;i++){ sum+=pref[i]*bowl[i]; } return sum; }
c12a3795-8e7e-48df-b0a2-f34bd7b49347
0
public int getCantCompany() { return CantCompany; }
690e9a5c-0ff2-43eb-ac9e-c7442c831ba6
1
public boolean isHunterAlive(AID senderAID) { Hunter hunter = getHunter(senderAID); if (hunter.getState().equals(WumpusConsts.STATE_ALIVE)) return true; else return false; }
1c086adf-6425-4dd4-a361-41beaff362de
6
public void writeThisSequenceToText( BufferedWriter writer, String tabString , boolean detailed) throws Exception { writer.write(tabString + sampleCounts.toString() + "\n"); if(detailed) { writer.write(tabString + getConsensus().toString() + "\n"); for( int x=0; x < this.columns.size(); x++) ...
1ce172f5-1c54-4fe2-bda1-04779ca34e64
6
public static boolean accepts(NetworkInterface current) throws SocketException{ if (!enabled) return true; boolean rejectedByName = false; String displayedName = current.getDisplayName(); for(String startsWith : namesToExclude){ if (displayedName.startsWith(startsWith)) { rejectedByName = true; break...
93a9f75c-408e-49d8-bed6-0548269d7a29
4
private synchronized void dequeue(PacketScheduler sched) { Packet np = sched.deque(); // process ping() packet if (np instanceof InfoPacket) { ((InfoPacket) np).addExitTime( GridSim.clock() ); } if (super.reportWriter_ != null) { super.write("dequeui...
46592cc4-f3c6-4ba6-941a-cb24b087001b
3
public static SplunkEventImpl fromLog(LogRecord lr) { ZonedDateTime eventTime = ZonedDateTime.ofInstant( Instant.ofEpochMilli(lr.getMillis()), ZoneOffset.UTC); //set fields Map<String, String> fields = new HashMap<>(); fields.put(...
b25f5181-389f-4b5c-b7b6-8a27d4cf860a
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj.getClass() != getClass()) { return false; } PhoneNumber otherPhoneNumber = (PhoneNumber) obj; return new EqualsBuilder().append(label, otherPhoneNumber.label).append(numbe...
afd64614-5d6a-48ae-a51c-d043e9edceb7
3
private static boolean isLongDistance(Location location, List<Player> players) { String world = location.getWorld().getName(); for (Player player : players) { Location playerLocation = player.getLocation(); if (!world.equals(playerLocation.getWorld().getName()) || playerLocation.distanceSquared(location) < 65...
e54b4e69-39a1-4d45-8501-1dd3a37ee9ec
0
public static String[] commaDelimitedListToStringArray(String str) { return delimitedListToStringArray(str, ","); }
8d281ac3-36e4-4a00-a253-273c8034c1b9
2
public void close() { connected = false; // We could join here, but should leave that to the programmer // Typically close should be preceded by a call to join if necessary try { if (sslsocket != null) sslsocket.close(); } catch (IOException e) { // Do nothing // e.printStackTrace(); }...
7ecec66f-41a4-4681-b7d8-7dcec26f27f5
5
public String processMessage(StompFrame msg) { String answer= ""; if (msg.getSTOMPType().equals("CONNECT")) answer= doWork((ConnectFrame)msg); else if (msg.getSTOMPType().equals("SEND")) answer= doWork((SendFrame)msg); else if (msg.getSTOMPType().equals("SUBSCRIBE")) answer= doWork((SubscribeFrame)msg)...
0c58bff0-bbe1-45d7-a7f1-768b1a2073d7
4
public void lue() { ObjectInputStream input = null; try { input = new ObjectInputStream(new FileInputStream(new File(elokuvanTiedot))); elokuvat = (ArrayList<Elokuva>) input.readObject(); } catch (IOException ex) { System.out....
15c25652-2492-463e-9e03-e6eaf5ce0d20
3
public void setSolvedState() { String[] face = {"F", "R", "B", "L", "U", "D"}; Color[] colors = {color_red, color_green, color_orange, color_blue, color_yellow, color_white}; for(int i=0;i<6;i++) { rubiks.setColor(face[i], colors[front[0][i]]); } for(int i=0;i<6;i++) {rubiks.setText(face[i]+":2...
bca35784-e51c-4b62-9659-7e35f65b6cc3
2
public void loadBrightnessContrast(float brightness, float contrast) { float slope = contrast > 0.f ? (1f / (1.0001f - contrast)): 1f + contrast; float offset = .5f - slope * .5f + brightness; for (int i=0; i<256; i++) { float x = i / 255.f; float y = x * slope + offset; table[i] = Math.min(255, Math...
c91b6378-7f37-44a8-a2b5-063f106da46f
8
@Override public Device getDeviceByID(int id) { Connection conn = null; PreparedStatement st = null; ResultSet row = null; try { conn = OracleDAOFactory.createConnection(); st = conn.prepareStatement(GET_DEVICE_BY_ID); st.setInt(1, id); row = st.executeQuery(); Device dev = null; if (row.next...
1f47bf4d-61a5-4ecd-a4a0-fb96c649e39d
9
public void pelaajaOnLounaassa() { Pelaaja kiekollinen = getKiekollinen(); int pelaajiaSuunnassa = 0; for (Pelaaja pelaaja : pelaajat) { if (kiekollinen.getY() < pelaaja.getY() && pelaaja.getX() < kiekollinen.getX()) { int x = kiekollinen.getX() - pelaaja.getX(); ...
a643cdf0-8ebd-470e-84be-b8917eb10a38
4
public void perform(GroupManager manager) { if (type == CommandType.ADD) { final String name = params[0]; final String description = params[1]; final boolean expectedResult = Boolean.valueOf(params[2]); assertEquals(manager.add(name, description), expectedResult, ...
061c9bca-f142-4ca5-82db-4a8fc12bd601
9
private static String getRuleName(RuleType combinator) { // fa ba fc bx gfc gbx conj switch (combinator) { case FA : return "fa"; case BA : return "ba"; case FC : return "fc"; case BX : return "bx"; case CONJ : return "conj"; case RP : return "rp"; case LP :...
beff8ea1-67ca-4de9-929a-7d7487684fd6
9
private User validateUser() { loginStatus = 5; updateProgressView(); User user = null; try { // Get all users Connection conn = (Connection) Controller.dbHandler.initiateSystemDBConn()[0]; ArrayList<User> users = Controller.dbHandler.initiateUserLis...
687f037c-75d2-4ac7-8cc4-8da2568110ce
6
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BoardType other = (BoardType) obj; if (code == null) { if (other.code != null) return false; } else if (!code.equals(other.code)) return false; ...
16281c4d-0abc-4bcc-865c-29bca6d7f886
2
public static List<Ville> rechercheVilleByCp(String name) throws SQLException { String query = null; List<Ville> ville1 = new ArrayList<Ville>(); ResultSet resultat; try { query = "SELECT * from VILLE where VICP like ? order by VINOM asc"; PreparedStatement p...
b3ac4a77-68e8-47a1-a24b-07d04bd64f0a
4
public ArrayList<Layer> load(String path) { //to-do ArrayList<Layer> itemList = new ArrayList<>(); try { FileInputStream inputFile = new FileInputStream(path); ObjectInputStream inputObject = new ObjectInputStream(inputFile); Object item = null; ...
29dedfed-1a9b-45aa-a32e-e9694d06d7bc
8
public void renderHead(IHeaderResponse response) { MySession sess = (MySession)getSession(); Board bd = sess.getBoard(); PlayerInfo nextplayer = sess.getTurn(); // イベント後に既に次のユーザーになっている // ゲーム中 if(bd.getGameStatus() == GameStatus.GAMING){ // 次のプレーヤーの置けるセルリストを取得 int[] putcandidatelist = bd.getPutCa...
a60f5396-e9e6-4797-a54d-c01db52c17e5
8
public boolean writeFile(String filename) { List<String> categories = this.reader.getTags(); try { FileWriter writer = new FileWriter(new File("./data/results/" + filename + ".txt")); BufferedWriter bw = new BufferedWriter(writer); for (int i = 0; i < this.results.size(); i++) { int j = 0; Stri...
6997daaf-d67e-4ab3-b162-8d4c2ca28e54
2
private void notifyObservers() { if(observers != null) for(PositionChangedObserver o : observers) { o.update(this); } }
f8908370-7e0a-473b-82d7-d60127a675f9
3
private String getReserveLabelText() { if(model.getRobot().getFuelTank().isInfinite()) { return "Reserves not needed: INFINITE FUEL."; } else { if(model.getRobot().getReserves() == 0) { return "You don't have any reserves!"; } else if(model.getRobot().getReserves() == 1) { return "You have 1 fuel r...
cd7cce2a-cc15-4ebd-8d41-333ae46ac773
2
@Override public int compareTo(Card o) { if (rank != o.rank) { return rank.compareTo(o.getRank()); } else { if (rank == Rank.JOKER) { return THE_SAME_VALUE; } else { return suit.compareTo(o.suit); } } }
bde3aa80-5985-40b8-9e3c-e9f1678623ac
4
public static GridPoint move(int x, int y, Direction d) { switch (d) { case UP: return new GridPoint(x, y - 1); case DOWN: return new GridPoint(x, y + 1); case LEFT: return new GridPoint(x - 1, y); case RIGHT: return new GridPoint(x + 1, y); default: return new GridPoint(x, y); } ...
cfb8db2c-830e-4698-9840-bfd12dd3ddf5
8
@Configuration(tests=200, size=100) @Test public void exceptionTest5(int[] intArray) { boolean exceptionRaised = false; Color[] colours = colourArray(20); if (intArray.length == 0) { try { theIterator = new Iterator(100, colours, intArray); fail( "My method didn't throw when I expected it to" ); ...
6964ba1a-9aac-4d30-a5a4-f289a69713aa
6
public void setMV(String mv) { if (mv == null) mvButtonGroup.clearSelection(); else if(mv.equals(AData.MENTAL)) mvButtonGroup.setSelected(mentalButton.getModel(), true); else if(mv.equals(AData.VITAL)) mvButtonGroup.setSelected(vitalButton.getModel(), true); else if(mv.equals(AData.SUPEREGO)) mvBu...
c871bb28-4bef-43e1-8be0-731e5b8ae318
9
public static EdgeAttribute weightedPairAverage(EdgeAttribute start, EdgeAttribute target, double position) { if (start == null && target == null) { System.out.println("Calculating point between two null edge attributes; returning null"); return null; } if (start == null...
1ccdaf71-e6ea-41fd-a1f2-9cf2d7bf2ebb
6
private void addRandomTile(){ List<Point> freeSpaces = new ArrayList<Point>(); for(int x = 0; x < GameState.FIELD_SIZE; ++x){ for(int y = 0; y < GameState.FIELD_SIZE; ++y){ if(gameState.getTile(x, y) == 0){ freeSpaces.add(new Point(x, y)); } } } if(freeSpaces.size() <= 0){ return; } Random ...
8a3c43f9-36bf-489d-9c0b-417bcf652133
9
private double[] createArray(HttpEntity entity) { double sentArray[] = new double[3]; try { String parseString = (new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"))).readLine(); JSONParser jparser = new JSONParser(); JSONObject dataObject = (JSONObject) jparser.parse(parseString...
c3505378-855e-4c7c-8b87-1e128e99d23b
8
private static void lookAt(int i, int j, int level) { if (level == 0) used[i][j] = true; cgrid[i][j] = '#'; int end_i = findend_i(i, j); int end_j = findend_j(i, j); if (level == 1) { total += (i - end_i) * (end_j - j); } else if (i -...
0e8c1bd9-652d-4d98-809b-fbb2e724579e
7
public void update() throws MaltChainedException { parentFeature.update(); FeatureValue value = parentFeature.getFeatureValue(); if (value instanceof SingleFeatureValue) { String symbol = ((SingleFeatureValue)value).getSymbol(); if (((FeatureValue)value).isNullValue()) { multipleFeatureValue.addFeatureV...
2bea2157-3e65-44d4-96fe-3045f8d5152d
1
protected String getAudioFileName() { String urlString = fileName; if (urlString==null) { urlString = getParameter(AUDIO_PARAMETER); } return urlString; }
acc345f0-778f-4cf6-b961-49076253a14b
7
private void powrotDoOknaGlownego() { widokOpisAplikacji.setVisible(false); if(oknoMacierzyste.equals("OknoGlowne")) widokOpisAplikacji.widokGlowny.setVisible(true); if(oknoMacierzyste.equals("OknoDolacz")) widokOpisAplikacji.widokGlowny.widokDolacz.setVisible(true); if(oknoMacierzyste.equals("OknoUtworz...
b397f9c1-50c0-4748-a651-cef20950e99f
8
public static Vector<String> MyHighligthOfACFirsttime(String id){ BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(id + "_problems.txt"))); String s,parts[]; Vector<String> probs = new Vector<>(); Vector<String> p...
4ce3afe7-86fa-43b4-95ed-d0cb6e839ae5
0
public direction getTurnDir() { return this.lr; }
08343910-1b89-4c8b-91f4-a064cfc7996d
9
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page ...
4aac373f-f56c-44f5-ae2b-1fcbf22d99b0
6
public static void writeNetworks(Config config, File archiveF) throws IOException, JSONException { ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(archiveF))); zos.putNextEntry(new ZipEntry("source.json")); zos.write(config.toJSON().toString(4).getBytes("UTF-8")); Hash...
783fda77-5c89-4012-ad25-94c152d2d0c3
8
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking,tickID)) return false; if(affected==null) return false; if(!(affected instanceof MOB)) return true; final MOB mob=(MOB)affected; MOB diseaser=invoker; if(diseaser==null) diseaser=mob; if((!mob.amDead())&&((...
2cd5587b-0bf6-485c-a2ef-ab1c3aaa5b8f
8
public int[] saisirCoordonnees() { int numLigne = 4; while ((numLigne < 0) || (numLigne > 2)) { System.out.println("Entrez le numéro de ligne :"); numLigne = m_scanner.nextInt() - 1; if ((numLigne < 0) || (numLigne > 2)) { System.err.println("Hors tabl...
40647325-3a9b-4395-bb76-11c30eecb5b9
6
protected int getSelectionState( ) { int p0 = fElement.getStartOffset(); int p1 = fElement.getEndOffset(); if (fContainer instanceof JTextComponent) { JTextComponent textComp = (JTextComponent)fContainer; int start = textComp.getSelectionStart(); int end = textComp.getSelectionEnd(); if( start<=p0 && ...