method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
f3044239-2037-41e8-ae74-3bea9e6a47ae
4
@Override public int hashCode() { int result = firstName != null ? firstName.hashCode() : 0; result = 31 * result + (secondName != null ? secondName.hashCode() : 0); result = 31 * result + (email != null ? email.hashCode() : 0); result = 31 * result + (phone != null ? phone.hashCode(...
683787ce-458f-41b4-92c3-7d2bc706a486
8
public List<Product> viewProduct(int offSet, int noOfRecords, String category){ List<Product> productList = new ArrayList<Product>(); Product product = null; connMyDB = new ConnectDatabase(); try { connMyDB.connect(); productDataset = connMyDB.query(getQuery(category, offSet, noOfRecords)); while(p...
11abb5ca-0497-44ee-a814-431426e1e0e7
7
protected LoginResult loginEmailPassword(final LoginSessionImpl loginObj, final Session session) throws IOException { final String input=loginObj.lastInput.toUpperCase().trim(); if(input.startsWith("Y")) { String password=loginObj.player.password; if(CMProps.getBoolVar(CMProps.Bool.HASHPASSWORDS)) { ...
52b47bc8-029d-40ac-84a2-f741c756ba29
8
private int optional (int optional) throws KryoException { int remaining = limit - position; if (remaining >= optional) return optional; optional = Math.min(optional, capacity); int count; // Try to fill the buffer. count = fill(buffer, limit, capacity - limit); if (count == -1) return remaining == 0 ...
899db1ef-aa1d-4b41-8a86-3fe00cc2dbed
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double)o).isInfinite() || ((Double)o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
c169b246-8bf9-4e6e-aa07-d94e21a112ed
8
public static NumberWrapper divideComputation(NumberWrapper x, NumberWrapper y) { try { { double floatresult = Stella.NULL_FLOAT; { Surrogate testValue000 = Stella_Object.safePrimaryType(x); if (Surrogate.subtypeOfIntegerP(testValue000)) { { IntegerWrapper x000 = ((IntegerWrapp...
e660e0b6-ae27-4c0f-83ce-d535967bd979
5
public CheckResultMessage check24(int day) { int r1 = get(2, 5); int c1 = get(3, 5); int r2 = get(39, 5); int c2 = get(40, 5); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); b = getValue(r1 + 1...
3e141a46-2818-424b-b9e7-cc98eaee61dd
8
@Test public void testPlayersQueriedInOrder() { // This tests that the players are surveyed in order to see if they hold the cards. ArrayList<Player> playersTest = board.getPlayers(); ArrayList<Card> hold3 = playersTest.get(3).getCards(); ArrayList<Card> newHand = new ArrayList<Card>(); newHand.add(new Card(ty...
6d20caea-8421-4f21-bdc6-ca21cc143c51
2
public FlowBlock getNextFlowBlock(StructuredBlock subBlock) { if (subBlock == subBlocks[0]) { if (subBlocks[1].isEmpty()) return subBlocks[1].getNextFlowBlock(); else return null; } return getNextFlowBlock(); }
80947ee9-ce56-4956-8af5-0f384c4427f8
4
public boolean canMove(int oldX, int oldY, int newX, int newY, boolean isNewSpotEmpty) { int deltaX; int deltaY; deltaX = Math.abs(newX-oldX); deltaY = Math.abs(newY-oldY); if (deltaX == 2 && deltaY == 1){ return true; } else if (deltaX == 1 && deltaY == 2) { return true; } return fals...
6588cbea-c8a9-4865-9824-b6fac1eb40d9
3
private int read() throws IOException{ if(re){ re = false; }else if(un){ current = unBuffer[uni--]; if(uni==-1){ uni = 0; un = false; } }else{ current = input.read(); } return current; }
72390326-57b3-4b83-8f38-9e51cd01e40c
7
public static void main(String[] args) { // Create Display try { Display.setDisplayMode (new DisplayMode(800, 600)); Display.create (); Display.setTitle("Hello!!"); } catch (LWJGLException ex) { Logger.getLogger(LWJGL_Example1.cl...
213c4aee-4dfb-4d84-abf0-cd3a2f14fddb
7
private String getPartOfDate(Integer hourOfDay){ if(hourOfDay >= 7 && hourOfDay <= 12){ return "morning"; } else if(hourOfDay > 12 && hourOfDay <= 18){ return "afternoon"; } else if(hourOfDay > 18 && hourOfDay <= 23 || hourOfDay == 0){ return "evening"; } else { return "night"; } }
05fac63d-bd27-4bba-a52a-59c54e3c03e8
7
public String CaptureStillImage(String UrlParameter) { if (Parent.GetNoCameraParameter()) { return ""; } String ReturnValue = ""; try { String param_url = ""; URLConnection conn = null; BufferedReader data = null; String line; ...
9bfa6fe0-ffbb-4e94-964d-fcdc14e17b5c
7
public int sortHardwareAlternatives() { int maxDepth = 1; for (HardwareSet hardwareSet : hardwareSets) { maxDepth = hardwareSet.getCpuAlternatives().size() > maxDepth ? hardwareSet.getCpuAlternatives().size() : maxDepth; maxDepth = hardwareSet.getHddAlternatives().size() > maxDepth ? hardwareSet.getHddAlterna...
9c9861a9-f682-419e-9e0f-3ec27312e1a2
8
public void paint(Graphics2D g2) { if ( nd_gc.powered && nd_gc.mode_map ) { // only in map modes, not in PLAN, APP CTR, VOR CTR //float current_altitude = this.aircraft.indicated_altitude(); float current_altitude = this.aircraft.altitude_ind(); float target_alt...
ff38acb3-01cc-49a7-8d8d-c0d97d02c472
3
@Override public void onEnable() { if (!this.loaded) { this.getLogger().log(Level.SEVERE, "Disabling plugin; Dependencies not met during plugin load"); this.setEnabled(false); return; } this.reloadConfig(); Main.courier = ConfigurationCourier.Fact...
8a8c3936-6557-447b-bf5c-96863b9a7221
1
public void atualizar(AreaConhecimento areaconhecimento) throws Exception { String sql = "UPDATE areaconhecimento SET nome = ?, ciencia = ?, areaAvaliacao = ? WHERE id = ?"; try { PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql); stmt.setString(1, areaconhecimento.getNom...
a346ce99-854a-4130-b83a-a86206c9af8e
0
@Test public void testIncrementWins() { assertNotNull(_underTest); int x = _underTest.getNumberOfWins(); // current count of wins, expected // to be 0 _underTest.incrementWins(); assertEquals(x + 1, _underTest.getNumberOfWins()); ...
6ed6e7f5-f0fc-4d2a-97cf-055d9b95a8db
5
private void tarkistaJaToimi(int miinojaInteger, int kentanKokoInteger) { if (miinojaInteger < kentanKokoInteger*kentanKokoInteger){ String profiiliNimiString = this.profiiliNimi.getText(); if (profiiliNimiString.length()<11 && profiiliNimiString.length() >0 && !this.nakyma.getPeliProfii...
9aa81f74-71fa-4131-839e-59fc2921d99b
3
@Override public boolean containsAll(Collection<?> c) { for (Object o : c) { if (!contains(o)) { return false; } } return true; }
395a3ba6-1a0a-49cc-a58f-33408a494795
5
public void archiveQueueFailures(int time) throws VehicleException, SimulationException { int maxTime = Constants.MAXIMUM_QUEUE_TIME; for(int i =0; i < queue.size(); i++){ int arrivalTime = queue.get(i).getArrivalTime(); if(!(queue.get(i).isQueued()) || time > Constants.CLOSING_TIME || time < 0){ throw ne...
fc115e5b-65ca-41bc-89c2-ecca450d0e1a
8
@Override public void startElement (String uri, String localName, String qName, Attributes attributes) { logger.info ("startElement, qName = " + qName); if ("events".equals (qName)) { startEventsElement (attributes); } else if ("event".equals (qName)) { ...
8c87b864-268b-4d7f-be8b-a553682537a8
9
public void run(String arg) { // 1 - Obtain the currently active image if necessary: ImagePlus imp = IJ.getImage(); if (null == imp) return; int stackSize = imp.getStackSize(); if (imp.getBitDepth()!=8) { IJ.showMessage("Error", "Only 8-bit images are supported"); return; } ImageStatistics stats...
57a326b6-c09f-4780-95f9-ac0e465898d8
8
public static Texture getDudeImage(int dir){ Image dude = null; if(dir == 0){ dude = textures.getSubImage(0, 0, 25, 49); }else if(dir == 1){ //dude = textures.getSubImage(0, 25, 25, 49); }else if(dir == 2){ }else if(dir == 3){ }else if(dir == 4){ }else if(dir == 5){ }else if(dir ==...
2c61d05d-9e6d-447d-8a84-48f748604e7b
9
private static final boolean isClassnamePart(char c) { if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) return true; switch (c) { case '.': case '$': case '_': return true; default: return false; } }
29bf7a9c-62d1-4e98-8b86-16aba6086c81
7
@Override public ReturnStruct parse(String[] lines) { int i = 0; int c = 1; ArrayList<String> code = new ArrayList<String>(); while (i < lines.length) { String line = Parser.clean(lines[i]); if (line.startsWith("if ") || line.startsWith("for ") || line.startsWith("while ") || line.startsWith("f...
0e0da287-64be-42ef-8ee4-9e3a237d7113
4
public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int opcao; int valor; Personagem personagem = new Personagem(); Personagem sistema = new Personagem(); do{ System.out.println("************"); Syste...
0491a816-2950-4b50-a096-29f4db46e309
9
public String dumpCircuit() { int i; int f = (showCurrent) ? 1 : 0; f |= (smallGrid) ? 2 : 0; f |= (showVoltage) ? 0 : 4; f |= (showPowerDissipation) ? 8 : 0; f |= (showValues) ? 0 : 16; // 32 = linear scale in afilter String dump = "$ " + f + " " ...
1aaa54b5-81e3-4aed-9de1-70bee93aca44
3
public void actionPerformed(ActionEvent ev) { try { PalavraChave objt = classeView(); if (obj == null) { long x = new PalavraChaveDAO().inserir(objt); objt.setId(x); JOptionPane.showMessageDialog(null, "Os dados foram inseridos com sucesso", "Sucesso", JOptionPane.INFORMATION_MESSAGE); ...
9ef6355d-5197-4757-935a-be1a3217f5f9
9
public void removeDraggableComponent(DraggableComponent component) { if (component != null && draggableComponentList.contains(component)) { //component.abortDrag(); int index = layoutOrderList.indexOf(component.getComponent()); component.removeListener(draggableComponentListener); if (compon...
9f8ecb58-b8a9-4603-8c1e-9ec5ef214212
8
public static void needHelp(CommandSender sender, String cmd, String label, String[] args) { // command String command = cmd.toLowerCase(); // player Player player = (Player) sender; // root command split for public and moderator access! if (command.equalsIgnoreCase("help")) { try { showHelpPage(pla...
47ab0def-f97b-4ebb-9cfe-c6de1981c60d
4
private void getImageTest(String asImageType, String asLastMod, int aiMaxSize, boolean abIncludeEncodedData) { ArrayList<Image> laImages = null; System.out.println("Running for LastMod: " + asLastMod + " and MaxSize: " + aiMaxSize); ImageList laImageList = laClient.getImages("Registrant Photo", abInc...
079794ac-7d1d-44e6-bd51-f8019e030b4a
3
static boolean schrikkelJaar(int jaar) { boolean schrikkel; if(jaar % 4 == 0) schrikkel = true; else if(jaar % 100 == 0) schrikkel = true; else if(jaar % 400 == 0) schrikkel = true; else schrikkel = false; return schrikkel; }
3e95fcaf-2133-40d2-867d-c7f5b076d880
9
private void map(Map<?, ?> map) { add("{"); Iterator<?> it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry<?, ?> e = (Map.Entry<?, ?>) it.next(); value(e.getKey()); add(":"); value(e.getValue()); if (it.hasNext()) add(',')...
4857c253-b1ed-4cb0-bf0b-9a55ae7ee931
8
private void updateDisplayString(){ PlayerBattleState playerState = null; TargetableState targetState = null; ObjectState pState = Directory.profile.getPlayer().getState(); //Get the player's state if(pState != null && pState instanceof PlayerBattleState) { playerState = (PlayerBattleState) pState; ...
8f59ca9f-726a-43ec-8098-67877bc3a9b5
0
public List<TravelTrip> findType(boolean typeBusiness){ //Query travelTripByType = em.createNamedQuery("TravelTrip.findByTripType"); TypedQuery<TravelTrip> travelTripByType = em.createNamedQuery("TravelTrip.findByTripType", TravelTrip.class); travelTripByType.setParameter("business", typeBusiness);...
b103cb2e-f9fe-4cd5-9969-82bb80189917
3
@Override public int compareTo(Joueur o) { SimpleDateFormat formater=new SimpleDateFormat("dd/MM/yy HH:mm:ss"); Date dateO1 = null,dateO2 = null; try { dateO1=formater.parse(this.getDateJeu()); dateO2=formater.parse(o.getDateJeu()); } catch (ParseException e) { JOptionPane.showMessageDialog(n...
dae4fb5d-047b-4c1c-bcfc-4fb893e62933
3
public static void main(String[] args) { try { if (args.length != 2) { System.err.println("USAGE: java RenderMap map.txt image.png"); System.exit(1); } Game game = new Game(args[0], 100, 0, null); if (game.Init() == 0) { System....
e7158b76-17f3-458b-aa18-f294b9fc1d4e
1
public CurrentPlayerRenderer(Game game, JPanel panel, JLabel actions) { super(game, panel); if (actions == null) throw new IllegalArgumentException("The given actions left panel is invalid!"); this.actionsLeft = actions; }
cc10de9f-cd8a-4bb6-a5ea-521900d0e347
5
private void initialize() { frame = new JFrame(); frame.setTitle("The Dungeon of Zelda"); frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Menu.class.getResource("/background/icon.jpg"))); frame.setBounds(100, 100, 600, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Adds the layout : ...
48ce0cd4-6d76-4ba6-87f1-f4a1c628e3c2
9
public void useDice(int itemId, boolean clan){ if (System.currentTimeMillis() - c.diceDelay >= 3000) { c.sendMessage("Rolling..."); c.startAnimation(11900); c.diceDelay = System.currentTimeMillis(); c.cDice = itemId; c.clanDice = clan; switch (itemId) { //Gfx's case 15086: c.gfx0(2072)...
a9a70b98-b2cb-4ac8-9d87-46ace132635f
2
@Test public void testViewDetailsForAllQueues() throws LuaScriptException { List<String> noKeys = new ArrayList<String>(); List<String> args = Arrays.asList(JQlessClient.getCurrentSeconds()); String json = (String) _luaScript.callScript(this.scriptName(), noKeys, args); List<Map<String, Object>> queueDet...
031f26d6-921b-4855-b31a-df03b04110fc
5
private void highlightButton(Graphics g) { Rectangle bounds = null; g.setColor(Color.red); // check which button is selected if (selected == ButtonSelected.NEW) { bounds = getButtonBounds(BUTTON_X_START_PROPORTION, NEW_PLAYER_Y_PROPORTION); } else if (selected == ButtonSelected.LOAD) { bounds = ge...
2c3373fa-eda1-4bae-963f-fc543f8fa9f0
9
public boolean onCommand(CommandSender sender, Command cmd, String label,String[] args){ if(sender instanceof Player && cmd.getName().equals("public")){ Player p = (Player) sender; if(this.listener.isPrivate(p)){ this.listener.removePrivate(p); p.sendMessage(ChatColor.DARK_PURPLE+"[Chat]"+ChatColor.WHIT...
937023f8-a554-488b-babe-4d6e321d12f2
5
public void performStepp(int Stepps, Vector2 Position) { for(int i = 0; i < Stepps; i++) { if(Position.getX() > this.TargetLocation.getX()) { Position.addX(- 1); } else if(Position.getX() < this.TargetLocation.getX()) { ...
d584f57d-2660-4fb0-a22f-5d1341cc0424
2
public Type getType(Identifier id) { // traverse the list of types backwards for(int i = types.size() - 1; i >= 0; i--) { Type rval = types.get(i).get(id); if(rval != null) { return rval; } } // exited the search without finding the Identifier, return null return null; }
a898ba29-5e41-4be9-8811-5b33b93f8b6b
6
public static Surrogate verifyType(Surrogate self) { if ((self.surrogateValue != null) && (!Stella_Object.stellaClassP(self.surrogateValue))) { { Stella.STANDARD_WARNING.nativeStream.println("Warning: Illegal object `" + self.surrogateValue + "' found"); Stella.STANDARD_WARNING.nativeS...
b6169971-e3d9-4b49-a03a-438014301978
2
public PDAStepByStateSimulator(Automaton automaton) { super(automaton); /** default acceptance is by final state. */ Object[] possibleValues = {"Final State", "Empty Stack"}; Object selectedValue = JOptionPane.showInputDialog(null, "Accept by", "Input", JOptionPane.INFORMATION_MES...
b0b5d50a-3571-47b6-be59-ee982d96c603
2
private static boolean isNumber(String s) { if (s == null) return false; try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; } }
276f42aa-3400-4f0f-a3ed-41ea36a8bd38
7
static final void method2092(int i, int i_25_, int[] is, int i_26_, Object[] objects) { try { int i_27_ = -92 / ((i_26_ - -55) / 57); if ((i ^ 0xffffffff) < (i_25_ ^ 0xffffffff)) { int i_28_ = (i + i_25_) / 2; int i_29_ = i_25_; int i_30_ = is[i_28_]; is[i_28_] = is[i]; is[i] = i_30_; Object...
16a0d4e4-12bd-421c-a242-3bb5c649035f
0
public ServerListener(int port) { serverPort = port; list = new ClientListManager(); }
ca3d42d5-4675-4d8c-b9fd-0b30e7801495
0
public PartnerListResponse( final Boolean success, final String errorMessage, final List<Partner> partnerList ) { super(success, errorMessage); this.partnerList = partnerList; }
3c7bcea2-a202-4055-b726-4a861e719950
1
public boolean equals(Point o) { return o.x == x && o.y == y ; }
51caeb92-29e9-440d-b027-f63838908831
3
public void use(int slot) { if (slot < 0 || slot > 2) return; if (equipped[slot] != null) { equipped[slot].use(player); } }
a125545a-509f-43cf-b8b1-54da8a149b92
4
public static void main(String[] args) { // TODO code application logic here String palabra=""; int brin=0; char letra = 0; int cantidad=0; int opcion; Scanner teclado=new Scanner(System.in); do{ System.out.println("D...
3db4ae14-a7e6-4f1b-bf2c-95959cfe6d7f
4
protected static Ptg calcAverageA( Ptg[] operands ) { Ptg[] alloperands = PtgCalculator.getAllComponents( operands ); double total = 0; for( Ptg p : alloperands ) { try { Object ov = p.getValue(); if( ov != null ) { if( String.valueOf( ov ) == "true" ) { total++; } e...
c0df5151-f125-438e-8ba0-814442070cb0
5
@Override public List<MetaObject> getGroupMetaData() { List<MetaObject> list = new ArrayList<MetaObject>(); Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(...
ab13e694-4dd4-4b2b-af4e-dda1976d0937
9
final public void exportDiagram(OutputStream os, StringBuilder cmap, int index, FileFormatOption fileFormatOption) throws IOException { List<BufferedImage> flashcodes = null; try { if ("split".equalsIgnoreCase(getSkinParam().getValue("flashcode")) && fileFormatOption.getFileFormat() == FileFormat.PNG) { ...
1f31dc1e-841f-4bb3-b46d-02e310e263f9
4
public Boolean subTaskDateChecker(Date supTaskStartDate, Date supTaskEndDate, Date parentStartDate, Date parentEndDate) { Boolean result = true; if (supTaskStartDate.before(parentStartDate) || supTaskStartDate.after(parentEndDate) || supTaskStartDate.after(supTaskEndDate)...
ad7995e7-7a85-4ac1-b924-066bc5ff2b78
9
public void paintComponent(Graphics g) { g.setColor(Color.black); g.fillRect(0, 0, getHeight(), getWidth()); g.setColor(Color.white); int[][] joints = moc.joints; if (joints != null) { try { for (int skelIndex = 1; skelIndex <= 2; skelIndex++) { ...
ba35f00a-82c8-4786-ad90-82e6cbcacaf8
1
private void drawRestOfJPanelDisplay(Graphics g) { userCard.drawCard(g, this); int numberLeftInPack = cardStack.size(); if (numberLeftInPack > 0) { aFaceDownCard.drawCard(g, this); drawNumberInsideCardArea(g, aFaceDownCard); } drawGameInformation(g); }
1123456f-c86d-4d4d-aeea-162b86a1125c
5
public static String longestPalindromeByMid(String s, int i, int j) { if (i != j && i != j - 1) { return null; } int l = i, r = j; while (l >= 0 && r < s.length() && s.charAt(l) == s.charAt(r)) { l--;r++; } return s.substring(l+1, r); }
7d84e45c-e5df-4c56-b46d-ee6cd394ba56
6
@Override public Color getDominantClusterInNeighbourhood(Node node) { Set<Node> neighbors = IteratorUtils.toSet(this.LPAClusteringEngine.getGraph().getNeighbors(node).iterator()); Color currentNodeCluster = this.LPAClusteringEngine.getNodeClusterMapping().get(node); if (nei...
51123e44-28a4-44ca-9ca0-1037bc9e3436
9
public String sample_frequency_string() { switch (h_sample_frequency) { case THIRTYTWO: if (h_version == MPEG1) return "32 kHz"; else if (h_version == MPEG2_LSF) return "16 kHz"; else // SZD return "8 kHz"; case FOURTYFOUR_POINT_ONE: if (h_version == MPEG1) return "...
1ec0a668-94b9-41a0-898c-554a2449505b
1
@Override public int getRow() { ensureOpen("getRow"); //return cursor; return (cursor < 0) ? 0 : cursor + 1; }
f446dae1-20e1-4e41-bc76-88646335f44b
2
private static int partition(int[] array, int start, int end) { int pivot = array[end]; int smallerIndex = start - 1; for (int i = start; i < end; i++) { if (array[i] <= pivot) { smallerIndex++; swap(array, smallerIndex, i); } } smallerIndex++; swap(array, smallerIndex, end); return...
1c65bc49-e882-4fd0-b61c-659ff46ece2d
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 Orders)) { return false; } Orders other = (Orders) object; if ((this.orderId == null && other.orderId != null) ...
c2274678-1bbf-4fcd-b548-e1dc1f6a9160
4
public static String getTimestamp(int format) { switch(format) { case SHORT: return shortFormat.format(new Date()); case MEDIUM: return mediumFormat.format(new Date()); case LONG: return longFormat.format(new Date()); case FULL: return fullFormat.format(new Date()); ...
6f53eeb4-4d01-4593-a211-defc112226ac
1
public void acquirePacketsTimed(final List<Packet> buffer, final int count, long milliseconds) { Thread sniffer = acquirePackets(buffer, count); try { Thread.sleep(milliseconds); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } done = true; }
3a0e1506-43fe-49c6-be3f-19b62e04a093
7
boolean validateMove(movePair movepr, Pair pr) { // This is also from dumbPlayer, and seems like something we won't have to use Point src = movepr.src; Point target = movepr.target; boolean rightposition = false; if (Math.abs(target.x-src.x)==Math.abs(pr.p) && Math.abs(target.y-src.y)==Math.abs(pr.q)) { ri...
6a70eaa7-bdd3-4786-ac86-555c6fc0cdd6
6
public static String numberToString(Number number) throws JSONException { if (number == null) { throw new JSONException("Null pointer"); } testValidity(number); // Shave off trailing zeros and decimal point, if possible. String string = number.toString(); ...
b353ed84-63e3-4bf5-9177-ae5fdde75970
9
public static String stringFor_cl_program_info(int n) { switch (n) { case CL_PROGRAM_REFERENCE_COUNT: return "CL_PROGRAM_REFERENCE_COUNT"; case CL_PROGRAM_CONTEXT: return "CL_PROGRAM_CONTEXT"; case CL_PROGRAM_NUM_DEVICES: return "CL_PROGRAM_NUM_DEVICES"; ...
f314f0bc-5e18-4552-b293-431cb8d46770
7
final static public char[] trim(char[] chars) { if (chars == null) return null; int start = 0, length = chars.length, end = length - 1; while (start < length && chars[start] == ' ') { start++; } while (end > start && chars[end] == ' ') { end--; } if (start != 0 || end != length - 1) { return subarray(c...
7ec5726c-e60b-4f3d-a5fd-b9bebe8e40ea
6
public void setGain(float gain) { if (gain != -1) { if ((gain < 0) || (gain > 2)) { throw new IllegalArgumentException("Volume must be between 0.0 and 2.0"); } } this.gain = gain; if (outputLine == null) { return; } try { FloatControl control = (FloatControl) outputLine.getControl(F...
81ab2550-48ff-41a8-bc6f-1429bf1dedf8
2
public void testPropertySetMinute() { LocalTime test = new LocalTime(10, 20, 30, 40); LocalTime copy = test.minuteOfHour().setCopy(12); check(test, 10, 20, 30, 40); check(copy, 10, 12, 30, 40); try { test.minuteOfHour().setCopy(60); fail(); ...
72147177-19fe-44ca-bd43-601600a62047
8
public void startGameForClients(MiniServer player[]) { this.clientPlayersPlaying = player; //Disallow the player array from having nulls in between players: //TODO: test this loop this.numberOfPlayers = 0; for(int i=0; i<this.clientPlayersPlaying.length; i++) { if(this.clientPlayersPlaying[i] == null...
8ac5e9fd-d617-4905-b344-a434b1516996
4
public Main() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); String url = "jdbc:mysql://localhost:3306/coffeebreak"; conn = DriverManager.getConnection(url, "root", ""); //doInsert("chocolat", 5); //doInsert("capuccino", 6); ...
fdd2bf1f-c713-4750-aab0-cd420a89424a
3
public void setEntryText(String text, int pos) { int current = 0; for (Widget i = wdg().child; i != null; i = i.next) { if (i instanceof TextEntry) { current++; if (current == pos) { TextEntry te = (TextEntry) i; te.settext(text); return; } } } }
f19b5ac0-aef5-49bf-9643-410b54965b15
3
public static void main(String[] args) { // TODO Auto-generated method stub DataModel model = null; try { model = new FileDataModel(new File("/home/naren/projects/minhash/user_brands.csv")); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } UserSimilarity similarit...
27db1c29-b8cd-4da9-9e7e-9890ed62fd32
1
public static void main(String[] args) { ExecutorService ctp = Executors.newCachedThreadPool(new ThreadFactory() { private AtomicInteger count = new AtomicInteger(); public Thread newThread(Runnable r) { int c = count.incrementAndGet(); ...
bac1b93d-a497-462a-b22a-4789fa6d19b2
3
public static Matrix3D getRotationMatrix(double angle, int axis) { double cos = Math.cos(angle); double sin = Math.sin(angle); switch (axis) { case AXIS_X: return new Matrix3D(1, 0, 0, 0, cos, -sin, 0, sin, cos); case AXIS_Y: return new Matrix3D(cos, 0, sin, 0, 1, 0, -sin, 0, cos); case AXIS_Z: re...
a5158256-ca25-46ed-8688-93bdc4b76b2f
7
private static void test2_4() throws FileNotFoundException { String test1 = "new game\n"+"examine room\n"+"quit\n"+"yes\n"; HashMap<Integer, String> output = new HashMap<Integer, String>(); boolean passed = true; try { in = new ByteArrayInputStream(test1.getBytes()); System.setIn(in); out = new Pr...
23e72260-b1ca-4e50-b8da-e40b48f682e5
3
public ButtonPanel () { super (null); try { background = ImageIO.read (new File ("LoLTeamBuilder" + File.separator + "images" + File.separator + "button_background.png")); } catch (IOException e) { e.printStackTrace(); } Dimension size = new Dimension (1000, 94); setPreferredSize (size); setMa...
4e779409-3c49-4fe0-b2c5-641d6b7e3b63
3
public void update() { for (int row = 0; row < ROWS; row++) { for (int col = 0; col < COLS; col++) { Tile current = board[row][col]; if (current == null) continue; current.update(); resetPosition(current, row, col); } } }
617e65ab-f770-4777-9085-b3e8aebe149c
3
private ArrayList methodParams(final MethodEditor method) { final ArrayList locals = new ArrayList(); int index = 0; if (!method.isStatic()) { // Add the this pointer to the locals. final Type type = method.declaringClass().type(); final LocalVariable var = method.paramAt(index++); locals.add(new Lo...
374c25f4-1d8c-4570-beec-e023d6d596a0
4
@Override public void itemStateChanged(ItemEvent e) { if (e.getSource() == easy && e.getStateChange() == ItemEvent.SELECTED) { whatIsDifficulty = 0; } if (e.getSource() == hard && e.getStateChange() == ItemEvent.SELECTED) { whatIsDifficulty = 1; } }
4f030f91-f769-405d-9be8-17eeb9776d91
9
private void initTimeline() { timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); KeyFrame kf = new KeyFrame(Config.ANIMATION_TIME, new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if (state == STATE_SHOW_TITLE) { ...
b7b94846-8bf2-4916-9900-0c8158ba57b4
3
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || this.getClass() != obj.getClass()) { return false; } Plan other = (Plan) obj; /* * Not sure why, but the favourite flag differs between raw plan and expanded plan. * That is, "plan/DMW-MOBI...
7c1dc2f7-e151-4fe2-8e3f-20cbf52fc3c2
1
private void start() { player.playTrack(TrackType.START); while (player.isPlaying()) { } timer = new Timer(TURN_DURATION, this); timer.start(); }
054af135-751b-4e13-b41c-c86a7fb620b8
3
@Override public boolean isCompleteMatch(List<Character> currentMatching) { if(currentMatching.size() != 2) return false; if(currentMatching.get(0) != KeyMappingProfile.ESC_CODE) return false; if(currentMatching.get(1).charValue() > 26) return false; ...
b0844372-e019-4335-a9f7-8debd7a0b0b7
1
private void copyRandom(RandomListNode headNew, RandomListNode head) { while(head != null){ headNew.random = (RandomListNode) map.get(head.random); head = head.next; headNew = headNew.next; } }
6b19272f-140b-459f-a244-dcf289827915
1
public String getNumberFormatParse() { NumberFormat nf = NumberFormat.getInstance(); Object obj = null; try { obj = nf.parse("1234,56"); } catch (Exception e) { System.out.println(e.getMessage()); } return (obj.toString()); }
fcba1ea4-3d51-4486-a01c-03662e93ad88
1
public static UsersReader getInstance() throws IOException { if (instance == null) instance = new UsersReader(); return instance; }
477e97a1-e41c-4ec1-a7d6-35bca5c5b334
4
@Test public void getFutureMeetingListPerContactSortedTest() { contacts2 = generateListOfContacts2(); Contact c = null; Calendar may25_1430=Calendar.getInstance(); Calendar may25=Calendar.getInstance(); may25_1430.set(2014, Calendar.MAY, 25, 14, 30); may25.set(2014, C...
ede5070e-0305-4177-a5c8-3b596f6100d5
8
@Override public void serialize(T t, JsonGenerator jg, SerializerProvider sp) throws IOException, JsonProcessingException { jg.writeStartObject(); if (t.getId() != null) { jg.writeStringField("id", t.getId().toString()); } Set<TKey<?, ?>> keys = t.getAvailableKeys(); ...
0c1cac53-b657-4084-8aa5-4fea1d7adea2
4
protected void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String error = "Unsuccessful purchase"; HttpSession session = req.getSession(true); if (session.getAttribute("currentSessionUser") == null) { res.sendRedirect("login"); } else { try { String ...
e7436290-3150-4cd4-b7dd-7a1b3bb46b33
8
public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) { if (averageGroundLevel < 0) { averageGroundLevel = getAverageGroundLevel(par1World, par3StructureBoundingBox); if (averageGroundLevel < 0) { ...
63eb9878-e833-40ee-bed4-622a77d332f0
1
private void calculatePrefixCode(PrefixTreeNode t, String s) { if (t instanceof PrefixTreeLeaf) { code.put(((PrefixTreeLeaf)t).letter, s); return; } calculatePrefixCode(((PrefixTreeNode) t).left, s + '0'); calculatePrefixCode(((PrefixTreeNode) t).right, s + '1'); }
a2dc89d4-ee52-4081-93f9-7052348ebd05
3
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf8"); InvertedIndex.tryInit(getServletContext()); String userRequest = req.getParameter("q"); ArrayList<String> urs = tokenize(userReq...