method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
3b6ec480-2825-4807-bb54-5d4c3393e3cd
6
public double[][] createStockLattice(int rows, int cols, double s0, double up) { stk_lat = new double[rows][cols]; //rev_lat = new double[rows][cols]; for(int i = 0; i <= stk_lat.length; ++i) { if(i > 0) { ...
f4492acd-d1a5-4c96-a45d-cced4730b0cd
2
@Deprecated public void onEvent(bluefrost.serializable.objects.v1.KeyObject event){ try{ synchronized(ClientManager.map.inverse().get(event.getSocketChannel())){ Client c = ClientManager.map.inverse().get(event.getSocketChannel()); if(c.isLoggedIn() == true){ c.setKey(Crypto.randomAESKey()); Mai...
396f4725-0508-4b93-9a1b-3140ee8afdaa
5
public byte[] getFileBytes(short fid) { byte[] result = filesBytes.get(fid); if (result != null) { return result; } InputStream in = getInputStream(fid); if (in == null) { return null; } ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buf = new byte[256]; while (true) { try { ...
9ec6db68-a770-418e-b891-84d746739545
1
private synchronized void resetPeerRates() { for (SharingPeer peer : this.connected.values()) { peer.getDLRate().reset(); peer.getULRate().reset(); } }
b0766da0-155c-49d4-a623-e6a5371a7c57
2
public StructuredBlock getNextBlock(StructuredBlock subBlock) { if (subBlock == subBlocks[0]) { if (subBlocks[1].isEmpty()) return subBlocks[1].getNextBlock(); else return subBlocks[1]; } return getNextBlock(); }
401f317f-362a-4a2f-8fa0-98c012e10992
9
TreeNode<K,V> getLcaWithoutParent(TreeNode<K,V> root, TreeNode<K,V> p, TreeNode<K,V> q){ if (root == null) return null ; TreeNode left = getLcaWithoutParent(root.left, p, q); TreeNode right = getLcaWithoutParent(root.right, p, q); // 5 cases ! if (root == p || root ...
ff58628a-f622-4532-85de-e60d84686d24
9
private void radiusSearchHelper(E target, KDNode top, double radiusSquare, PriorityQueue<E> neighbors, DistComparator<E> distComp) throws VariedDimensionException { Stack<KDNode> parents = new Stack<KDNode>(); findLeaf(target,top,parents); KDNode currentNode = null; KDNode lastNode = null; while (!parents....
d1bdaa02-7292-4538-84db-7a1c5680fb7e
8
public static void playSound(Sound sound, boolean important){ if(MyGame.mute) return; long currentTime = System.currentTimeMillis(); int newIndex = -1; float lowestTime = Float.MAX_VALUE; for(int i = 0; i < maxBufferSize; i++){ if(currentTime - soundTimer[i] > 3000 || soundBuffer[i] == null){ newInd...
4cf3d17b-654b-4e97-bcca-025dd430b530
4
private void paintAllShoots(Graphics2D g2) { for (Tower currentTower : board.getAllTowers()) { if (currentTower.hasTarget()) { // for (Placeable currentObj : currentTower.getPlacablesWithinRangeOfThisTower()) { for (Placeable currentObj : currentTower.getCurrentTargets...
67398ed7-c5af-4189-bb78-bb9a9b7015eb
2
private void arrayDeclaration() { if (accept(NonTerminal.ARRAY_DECLARATION)) { tryDeclareSymbol(current); expect(Token.Kind.IDENTIFIER); expect(Token.Kind.COLON); type(); expect(Token.Kind.OPEN_BRACKET); expect(Token.Kind.INTEGER); expect(Token.Kind.CLOSE_BRACKET); while (accept(Token.Kind....
28f33d81-6fd5-4009-840c-702f19f6a4cc
5
@Override public boolean updateProject(Long projectid, Long rowId, String newValue) { try{ Project project = entityManager.find(Project.class, projectid); if(rowId == 1){ project.setProjectname(newValue); }else if(rowId == 2){ Long newHostId = Long.parseLong(newValue); project.setHostid(newHostI...
385f3de8-46d9-42ee-9b8c-13112148b06f
5
public void setPower(double power) { if (power < 0 && getPotValue() >= FULL_FORWARD_POSITION || power > 0 && getPotValue() < FULL_BACKWARD_POSITION || Math.abs(power) < .1) { power = 0; } motor1.set(power); motor2.set(power); }
d9b75a1c-b900-4e2b-a371-b55c96262e3d
2
private static ShortImageBuffer fromBufferedImage(BufferedImage input) { int w = input.getWidth(); int h = input.getHeight(); ShortImageBuffer greyscale = new ShortImageBuffer(h, w); byte[] pixels = ((DataBufferByte) input.getRaster().getDataBuffer()).getData(); int index = ...
47c5cb86-b678-4679-9dc4-b8f9ae66cd60
0
public boolean addNode(Root node) { return false; }
b09f6136-1315-4dea-a25b-563b03fc3a3f
8
public Parser.Events parse() { int c = 0; boolean ret = true; try { while ((c = in.read()) != -1 && ret) { this.charsRead += 1; ret = this.updateState(c); if (ret) { updateEvent(); ...
ef773697-4ce9-4369-bf9c-44c4f40eb7fc
7
private void initParams(){ if(!iphoneParams.isEmpty()){ postURL = iphoneParams.getProperty("APPLESTORE_POST_URL"); originalPostURL = postURL; fromPageNum = iphoneParams.getProperty("APPLESTORE_FROM_PAGE_NUM"); ID = iphoneParams.getProperty("APPLESTORE_ID"); relative_URI = iphoneParams.getProperty("APPL...
e1592d0b-7572-4b25-873c-93eb0905dff4
9
private static void readBojarczukReports() throws FileNotFoundException { List<Integer> generations = new ArrayList<Integer>(); File[] reports = reportDir.listFiles(new FileFilter() { public boolean accept(File path) { return path.getName().startsWith("Iteration_0"); ...
29050cb6-d7a2-4916-ad7c-da71cd43df9d
1
public void setStatusToIdle(String username){ try { cs = con.prepareCall("{call setStatusToIdle(?)}"); cs.setString(1, username); cs.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }
5118b59d-92c1-486d-ae36-248138122f81
2
public ArrayList<String> getAllKeysInGroup(String group){ ResultSet rs; try{ String key; ArrayList<String> keys = new ArrayList<String>(); PreparedStatement prep = this.conn.prepareStatement("SELECT key FROM keyval WHERE collection = ?"); prep.setString(1, group); rs = prep....
cd589281-5dc2-436a-8ed2-e84ed4e6cb74
4
public static HashMap<ItemType, ItemData> loadItemStats(String xmlFilePath){ HashMap<ItemType, ItemData> statsMap = new HashMap<>(); NodeList types = getElements(xmlFilePath, "type"); for(int i = 0; i < types.getLength(); i++){ Element typeElement = (Element) types.item(i); Action action = null; if(typeE...
30d4ff0e-0a0e-40f1-9950-382cbf5100b2
1
public static void fixDirs(File target) { File parent = target.getParentFile(); if (parent != null) { parent.mkdirs(); } }
462b2c54-b799-45c5-af01-6111db301001
6
public void setMode(final Mode mode) { if (this.mode != mode) { clearMouseListeners(); } System.out.println("Set new mode: " + mode); this.mode = mode; switch (this.mode) { case LINE_DDA: addLineMouseListeners(); break; case LINE_BREZENHEM: addLineMouseListeners(); break; case LINE_WY: ...
3890c92d-679a-4717-a6ee-3746418b048e
9
@Override protected void track(int px, int py, int qx, int qy, int iterations) { dispose(); String[] splitted = Loader.getCurrentFile().getAbsolutePath() .split("/"); String fileName = splitted[splitted.length - 1]; int x = fileName.indexOf('.'); StringBuffer num = new StringBuffer(); boolean end = fa...
eb829486-6fa7-4286-b976-cdb3abafff71
9
public static Keyword rangeTypeSpecialist(ControlFrame frame, Keyword lastmove) { { Proposition proposition = frame.proposition; Stella_Object relation = Logic.argumentBoundTo((proposition.arguments.theArray)[0]); Stella_Object instance = Logic.argumentBoundTo((proposition.arguments.theArray)[1]); ...
7b7e7e48-dedb-44d1-8496-0e8f8a5a95b7
2
public TerritoriesLayout getSubset(PlayerColor owner){ TerritoriesLayout res = new TerritoriesLayout(); Iterator<Integer> iter = m_territories.keySet().iterator(); while(iter.hasNext()){ Integer key = iter.next(); if(m_territories.get(key).getOwner() == owner){ res.put(m_territories.get(key)); } } ...
3360bbdb-0ecc-4a9e-9c06-61ef686a2454
0
public DummyChannel() { dataSemaphore = new Semaphore(0); dataQueue = new LinkedList<Integer>(); is = new DummyInputStream(); os = new DummyOutputStream(); }
537d8fe6-a172-42ca-b8f9-a47e8893c3fc
2
private QuadTree initDataStructure() { getNodes(); getEdges(); //getStreets(); getCoast(); int i = 0; for (Edge edge : edges) { if (edge.getRoadType() != 74) { } //System.out.println(i++); } createQuadTree(); System.o...
f7c20eb6-b222-41cc-bb36-1eb5ebddfbce
1
public void releaseLock(){ synchronized (this) { if(lockedBy.equalsIgnoreCase("localhost")){ isLOcked = false; lockedBy = null; String msg = "Release_Lock" + ":" + lockName; manager.notifyAllRemoteListeners(new Message(msg, localhost)); } } }
5786671e-85eb-4f92-a5b7-c675249a0cc4
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 Recurso)) { return false; } Recurso other = (Recurso) object; if ((this.idRecurso == null && other.idRecurso !=...
3f153afa-3a75-43ef-94a2-5ffbab61453e
4
public void atCondExpr(CondExpr expr) throws CompileError { booleanExpr(expr.condExpr()); expr.thenExpr().accept(this); int type1 = exprType; int dim1 = arrayDim; String cname1 = className; expr.elseExpr().accept(this); if (dim1 == 0 && dim1 == arrayDim) ...
dd2de68b-e731-4381-8662-b87084d7f01c
1
@Test public void keonKasvatusToimiiOikeinTest(){ Siirto siirt1 = new Siirto(11,3,1,7,0, 0); // arvo 4 Siirto siirt2 = new Siirto(8,2,0,3,0, 0); // arvo -10 for (int i = 0; i < 10; i++){ keko.lisaa(siirt2); } keko.lisaa(siirt1); assertEquals(11, ke...
f9957cf9-3652-4cd5-ad26-3ada2b2e4472
3
protected void invalidate() { for(ComponentListener cl: componentListeners) cl.onComponentInvalidated(this); if(parent != null && parent instanceof AbstractContainer) { ((AbstractContainer)parent).invalidate(); } }
549015b9-3eaa-44fa-bdb8-229de133eeb5
2
public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) { Assert.notEmpty(interfaces, "Interfaces must not be empty"); Assert.notNull(classLoader, "ClassLoader must not be null"); return Proxy.getProxyClass(classLoader, interfaces); }
261339ad-eb05-46a8-9f9d-bcd8548dd7d4
0
public Node getNodeParent() {return this.hoistedNodeParent;}
b671d144-ff56-4c32-8706-e857806947e9
1
public Class<?>[] getInvokerParameters() { return this.invokerParameters; }
9a0fb70b-5e37-4d26-9040-930710d62c43
8
@EventHandler(priority = EventPriority.NORMAL) public void onBlockBreak(BlockBreakEvent event) { if (event.getBlock() != null) { // Will prevent an NPE if the user right-clicks air. if (event.getBlock().getState() != null) { if (event.getBlock().getState() instanceof Sign) { Sign sign = null; try { ...
571e2ae1-f5ea-4ba0-beed-32c90b19af94
1
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; httpRequest.getSession(); if (httpRequest.getSession().getAttribute("patron") == null) { httpRequest.setAttribute("l...
cea1b285-5001-46b7-8ab5-8413af4901b3
7
public void update(double diff) { switch (state) { case MAIN_SCREEN: break; case PLAYING: if (level.isCompleted()) { state = State.LOADING; return; } for (int i = 0; i < entities.size(...
289d1333-1197-427f-b415-796af0980947
4
public static BareBonesStatement InterpretLine(String[] Lines, LineReference currentLine, HashMap<String, Integer> Variables) throws BareBonesSyntaxException, BareBonesCompilerException { BareBonesStatement returnStatement = null; String workingLine = Lines[currentLine.getLineNumber()]; workingLine = remov...
f413de4f-dfcb-46af-8d9d-72d91f5f0eeb
5
private void dispatch(String[] commands, Socket s) throws IOException { PrintWriter writer = new PrintWriter(s.getOutputStream(), true); switch (commands[0]) { case AppConstants.GET: if (commands.length != 2) { LOG.warning("Insufficient parameters for GET...
bb6eb280-f81b-4cba-a728-0ea720d797a7
7
private String startSetToString() { StringBuffer FString = new StringBuffer(); boolean didPrint; if (m_starting == null) { return getStartSet(); } for (int i = 0; i < m_starting.length; i++) { didPrint = false; if ((m_hasClass == false) || ((m_hasClass == true) && (i !...
ab97f9d9-0f21-4aef-81b5-7ab69c96a8f4
0
public void showStars() { System.out.println("******"); show(); System.out.println("******"); }
8086382c-2fe6-4cd4-bf54-887d45af1841
3
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // client browser will request the page every 60 seconds HttpSession session = request.getSession(); Long times = (Long) session.getAttribute("times"); if (times == null) { session.setAttribute(...
2517aaf6-5160-4a47-b2fb-805f86d2c574
8
private void heapify(int i) { if (i <= 0 || i >= length) { return; } System.out.println("heapify " + i); int left = 2*i; int right = 2*i + 1; if (right < length) { //left is smaller if (heap[left].compareTo(heap[right]) < 0) { if (heap[i].compareTo(heap[left]) > 0) { switchTwo(i, lef...
f86c300d-3cab-4d9d-a8c3-45a077850833
8
public String convert(String str) { char[] cc = str.toCharArray(); StringBuilder sb = new StringBuilder(); for (char c : cc) { char newChar = c; if ((('A' <= c) && (c <= 'Z')) || (('a' <= c) && (c <= 'z')) || (('1' <= c) && (c <= '9')) || is2Sign...
1cd8c192-9ebd-4ee3-b1e0-d08779eb3726
8
private void mergeRegions(double alpha){ for (int i = 0; i < this.denseRegions.size(); i++) { DenseRegion r1 = this.denseRegions.get(i); for (int j = 0; j < i; j++) { DenseRegion r2 = this.denseRegions.get(j); if(r1.getIsInCluster() && r2.getIsInCluster() && (r1.getClusterID() == r2.getClusterID())...
51c1aead-adf1-408e-bf32-27a5cc0dee91
9
public boolean connect() { if (!notificationConnect()) { boolean redirected = notificationConnect(); if (!redirected) // try again { log.debug("MSN Connection failed"); return false; } else { log.debug("MSN connected!!"); } } SSLServerConnection sslConn = null; String strLoginS...
d3a11648-3b31-4afd-8487-84af845871fa
3
public int[][] getObfuscatedSea() { int[][] obfuscatedSea = new int[sea.length][sea[0].length]; for(int x = 0; x < sea.length; x++) { for(int y = 0; y < sea[0].length; y++) { obfuscatedSea[x][y] = sea[x][y]; if(sea[x][y] == SHIP) obfuscatedSea[x][y] = OCEAN; } } return obfuscatedSea; }
433588c0-5de4-4505-9eaa-083c88209c4e
2
public static TYPE find(String s) { if("file".equals(s.toLowerCase())) return FILE; else if("function".equals(s.toLowerCase())) return FUNCTION; return NONE; }
2c1c1f37-1bd9-4282-9b42-e812845fb269
7
public boolean download(File targetFile, String url, MavenArtefact artefact, String extension, String preresolvedVersion, boolean metafile) { try { buildParentDir(targetFile); //BUILD HTTP URL StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append(url...
bbfd8fd2-f453-49cf-9421-0137e3184add
9
private void cftbsub(int n, double[] a, int offa, int[] ip, int nw, double[] w) { if (n > 8) { if (n > 32) { cftb1st(n, a, offa, w, nw - (n >> 2)); if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) { ...
f0f9ee2d-807b-4a86-823d-fd9a43cd1ef9
4
private void processGridletSubmit(Sim_event ev, boolean ack) { try { // gets the Gridlet object Gridlet gl = (Gridlet) ev.get_data(); // checks whether this Gridlet has finished or not if (gl.isFinished()) { String name = G...
38d977ba-2084-4a6f-90f8-75d33fbb0ded
5
public void delete(String siteName) { AppUtils.setConsoleMessage("Nom du site : " + siteName, SQLiteDAO.class, MessageType.INFORMATION, 294, AppParams.DEBUG_MODE); dataDeleted = false; Connection c = null; PreparedStatement stmt = null; try { Class.forName("org.sqlite.JDBC"); c = Drive...
76ef2845-8bc4-4260-8e9b-922973cac1d3
7
public void drawSliders() { if (!Settings.displayGrid) { return; } int background = 0x151515; int bar = 0x666666; int thickness = 8; int start = 150; if (instance.mouseInRegion(0, instance.getCanvasWidth() - thickness, instance.getCanvasHeight() - thickness, instance.getCanvasHeight())) { if (instan...
5825d455-6e17-410a-8d8f-8dc318d65d2c
4
public XSSFWorkbook readWorkbook() { XSSFWorkbook wbDefault = new XSSFWorkbook(); try { String pathname = ""; // check what OS we are running on String os = System.getProperty("os.name").toLowerCase(); if(os.contains("win")) pathname = "I:\\c...
b5497295-ecf7-4be3-b3f8-ddef73e25c57
4
public int maxID(String table, String nameID) { int n = 0; try { con = DriverManager.getConnection(url, user, password); Statement stmt; stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery("select count(*) from " + table); r...
8fdf7e74-5a84-4c58-a5be-96a0661e1201
1
public boolean equals(Object o) { return (o instanceof TreeElement) && fullName.equals(((TreeElement) o).fullName); }
f217c9ad-3ed6-4f7a-8566-d9d5a1d924fa
1
@Override public void setSocket(Socket socket) { this.socket = socket; try { writer = new PrintWriter(socket.getOutputStream(), true); reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); } catch (IOException ex) { System.out.printl...
8f7e5f8b-e9e3-4ed1-b570-d09bd3cab353
4
void shiftPc(int where, int gapLength, boolean exclusive) { int n = tableLength(); for (int i = 0; i < n; ++i) { int pos = i * 4 + 2; int pc = ByteArray.readU16bit(info, pos); if (pc > where || (exclusive && pc == where)) ByteArray.write16bit(pc + gapL...
70adc460-d440-4515-b014-1eb072b63944
1
public static void main(String[] args) { LoadTexts lf = new LoadTexts(); for (String text : lf) { System.out.println(text); } }
bf4d61da-4c23-4f2e-ba81-70bc65927197
5
public ListNode reverseGroup(ListNode preNode, int k, boolean force) { ListNode tail = preNode.next; ListNode current = preNode.next; ListNode previous = preNode; ListNode next = current.next; int i = 0; for (i = 0; i < k && current != null; i++) { current.ne...
fd6716d8-57d1-45dd-b19e-f1afd5b466af
6
public static boolean threeOfaKind(Hand hand) { hand.sortByValue(); if( (hand.getCard(0).getValue() == hand.getCard(1).getValue()) && (hand.getCard(0).getValue() == hand.getCard(2).getValue()) || (hand.getCard(1).getValue() == hand.getCard(2).getValue()) && (hand.getCard(1).getValue() == hand...
9e4900f8-c0aa-4a70-a162-e55f2b3de94a
2
public boolean check(String t_name) { for (ClientInfo a : client_list) { if (a.name.equals(t_name)) return false; } return true; }
6c7100a2-5176-4f2c-a846-80dc34551a06
2
public Number max(){ Number max = stack.getFirst(); for (T t : stack){ if (max.doubleValue() < t.doubleValue()){ max = t; } } return max; }
1e9354e2-0b25-4bc2-9d93-6ec580deb723
0
public DVClient(int port) { this.port = port; }
942b4838-a2cf-4171-ad9a-2237837ba1ed
6
@Override public void execute (final char command) { switch (command) { case UP_MOVE: moveUp (); break; case DOWN_MOVE: moveDown (); break; case LEFT_MOVE: moveLeft (); break; case RIGHT_MOVE: moveRight (); break; ...
87cfae73-2097-4e95-b303-06cf62630424
0
@Override protected void setColoredExes() { coloredEx = LineGenerator.Brezenhem(begin, end); center = coloredEx.get((coloredEx.size() / 2)); }
cd509a73-a7a4-46be-9e3e-01ab102891f8
6
public Boolean findElement(int[][] arrA, int number) { // start from the left top corner, say ele; // if ele>number -> move left // if ele<number -> move right // if you cant move further to find the number , return false int row = 0; int col = arrA[1].length - 1; boolean numberFound = false; System.out...
79f8ae7d-cbd6-4466-89c0-7ec3ad337768
4
private double[][] getSimilarMatrix(IClusterCalculable[] oriData) { double[][] S = new double[dNum][dNum];//相似矩阵 ArrayList<Double> list_S = new ArrayList<Double>(); // double sum = 0; for (int i = 0; i < dNum; i++) { IClusterCalculable data_i = oriData[i]; for (int...
8176aad0-dfc2-41ec-9286-5553c17c8332
4
public void mouseClicked(int x, int y) { if(parent.activeBrush < 0){ if(!fill) drawTiles(currentLayer - 1, x, y); else fillTiles(currentLayer- 1, x, y); backUpTiles(); } else{ int tileSize = parent.tilePanel.getTileSize(); int tx = 0; int ty = 0; if(x > 0) tx = x/tileSize; if(y > 0) ty...
739a7e8e-688f-4f64-a555-400d8b78b985
1
public final void addGameLayer(GameLayer gameLayer) { if (!gameLayers.containsKey(gameLayer.getName())) { gameLayers.put(gameLayer.getName(), gameLayer); } else { logger.error("The gamelayer name, ", gameLayer.getName(), " was not added to the game screen ", getName(), " as it already exists within ...
a2a8e61b-2028-497a-b45b-57bde200cd71
3
private boolean acceptsMimeType(final Header header) { final String value = header.getValue(); if (value == null) { return false; } for (String mimeType : mimeTypesToInclude) { if (value.contains(mimeType)) { return true; } } return false; }
479781d4-c001-4819-bc5a-63183476d6e4
6
public void setConnectingFields() { for (int i = 0; i < con.getObjPanel().getPrimitiveObjectives().size(); i++) { JObjective obj = (JObjective) con.getObjPanel().getPrimitiveObjectives().get(i); BaseTableContainer btc = findPrimitive(obj.getName()); if (btc != null) { ...
96583cfc-e3e4-4bb9-8346-09f72e633611
0
public static boolean validateDepartment(){ boolean isValid=false; return isValid; }
0f0cfd98-ae9c-4237-98d9-65200672a06e
6
public void shutDownConnection() { System.out.println("Shutdown Connection"); try { if (out != null) out.close(); if (in != null) in.close(); if (fis != null) fis.close(); if (out != null) out.close(); if (socket != null) socket.close(); } catch (Exception e) { } }
8c3764cb-6220-4a40-9064-5190569b6f44
7
public String process(Payment payment, double amount) { String result="null"; PreparedStatement pst; PreparedStatement pset; ResultSet rs; Connection conn; Connection conn1; Payment detailsFromDb = new Payment(); try { conn = DBUtil.getDBConnection("Type4"); pst = conn.prepareStatement(" select...
b7d65b2a-cbfe-4997-96eb-9b897ec57946
4
@Override public Object getValueAt(int i, int i1) { Carpart carpart = carparts.get(i); switch (i1) { case 0: return carpart.getId(); case 1: return carpart.getName(); case 2: return carpart.getPrice(); ca...
a810bcf5-937f-4b25-8e35-9875912684bc
4
@Override public void close() { switch( channelType ) { case SoundSystemConfig.TYPE_NORMAL: if( clip != null ) { clip.stop(); clip.flush(); clip.close(); } brea...
b9b5a601-ee5d-46c2-863a-0608ddebbdaa
8
public void paint(Graphics g) { Color colors[] = null; ButtonModel model = getModel(); if (isEnabled()) { if (model.isPressed() && model.isArmed()) { colors = AbstractLookAndFeel.getTheme().getPressedColors(); } else { ...
a2626301-4967-4f98-8616-3e9aa645cc2a
9
private void deCryptString(String s, int year, String type) { double[] data = new double[12]; double[] coord = new double[2]; int i = 0; int idx = 0; for(int j=0; j<s.length();j++){ if(Character.isWhitespace(s.charAt(j))){ if(j>i && s.substring(i+1, j).length()>1){ if (idx>1){ data[idx-2] = ...
5bf21a9c-dcb7-49fa-958e-edac1fd8aa35
4
public static void main(String[] args) { Class c = null; try { c = Class.forName("com.thinkingjava.rtti.typeinfo.toys.FancyToy"); } catch (ClassNotFoundException e) { print("Can't find FancyToy"); System.exit(1); } printInfo(c); for (Class face : c.getInterfaces()) printInfo(face); Class up = ...
4508dda2-ea74-4efb-aea8-19a9b218b1fd
8
public void setWeapon(Ship host, GameRenderer renderer, String WeaponName, boolean allyControlled, boolean autonomous) { double prevWeaponYaw = 0; if (weapon != null) prevWeaponYaw = getWeapon().getYaw(); if (WeaponName.equals("TwinFiveInch")) { weapon = new TwinFiveInch(host, rende...
2f50849e-f9d2-4ee2-b20d-8a31c4d5c736
6
public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> result = new ArrayList<>(); if (root == null) return result; Queue<TreeNode> queue = new LinkedList<>(); queue.add(root); int currentLevel = 1; int nextLevel = 0; int lev...
4ebcb431-2886-46d2-bb07-700b922d47b7
5
public void leaveSomeOutSplit(int index, String filename) { List<Bookmark> trainLines = new ArrayList<Bookmark>(); List<Bookmark> testLines = new ArrayList<Bookmark>(); int currentUser = -1; int userIndex = 0; Collections.sort(this.reader.getBookmarks()); int cntUsers=0; for (Bookmark data : this.r...
11f759ec-fb87-4548-80c6-bacaf611d712
7
@SuppressWarnings("rawtypes") @Override public PduResponse firePduRequestReceived(PduRequest pduRequest) { // Check receiver type if(config.get("type").equals("MO")){ //Process MO parse // Check type of PDU if (pduRequest.getCommandId() == SmppCon...
f08968ce-2799-42f8-8bdf-51b682af294f
5
public void actionPerformed(ActionEvent ae) { String actionCommand = ae.getActionCommand(); if(MODIFY_NAME.equals(actionCommand)) { AccountActions.modifyAccountNames(tabel.getSelectedObjects(), accounts); } else if(MODIFY_TYPE.equals(actionCommand)){ AccountActions.modifyAccountTypes(tabel.getSelectedObject...
d7c8da81-6a53-49c9-9988-c52001d1d8a7
2
@Override public void receivePacket(Packet packet) { // TODO Auto-generated method stub if(packet instanceof TCPPacket) { //If the packet is TCP String[] dataArray = tcp2String(packet); //Call this method } else if(packet instanceof UDPPacket) { String[] dataArray = UDP2String(packet); } }
cf3f7ebc-7a1f-41e8-ad0c-fb823058d400
3
public static int stringToInt(String str){ int agentType=0; if(str.matches(".*R.*")) agentType = agentType+100; if(str.matches(".*B.*")) agentType = agentType+10; if(str.matches(".*P.*")) agentType++; return agentType; }
f870b1c6-b0f1-4789-8eb0-72bb0c7148f7
8
int readCorner2(int numRows, int numColumns) { int currentByte = 0; if (readModule(numRows - 3, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRows - 2, 0, numRows, numColumns)) { currentByte |= 1; } currentByte <<= 1; if (readModule(numRo...
8a99075f-ec9d-41f6-9fc2-65d08ff9214f
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...
79b74aba-d5a3-481a-803e-060b3df5db44
3
private Class defineClass(byte[] bytes) { try { Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", String.class /*name*/, byte[].class /*b*/, int.class /*off*/, int.class /*len*/); defineClass.setAccessible(true); return (Class) defineClass.invoke(classLoader, null, bytes, 0, ...
8db4d3bf-7813-445e-9613-dc0dd2a43d0a
3
private static MavenJarFile downloadAndUnzipJarForWindows(MavenJarFile mavenJarFile, URL jarRepository, FileDAO fileDAO, boolean cleanupZipFile) throws MalformedURLException, IOException, XMLStreamException { MavenJarFile newMavenJar; URL archiveURL = WebDAO.getUrlOfZippedVersion(jarRepository, ".zip", ...
38dcae84-38d5-4974-8629-0aa01c3c84ac
4
private void copyFile(File in, File out) throws IOException { FileChannel inChannel = new FileInputStream(in).getChannel(); FileChannel outChannel = new FileOutputStream(out).getChannel(); try { // magic number for Windows, 64Mb - 32Kb) int maxCount = (64 * 1024 * 1024) ...
0545a2ce-6401-4d7d-893c-7f2ed1eaf177
3
@Override public void prevChannel() { if (memorizedChannels.isEmpty()) { super.prevChannel(); return; } int idx = memorizedChannels.indexOf(channel); int nextIndex = 0; if (idx == 0) { nextIndex = memorizedChannels.size() - 1; } e...
8948316f-7326-4480-bad5-e29ae2ba62d9
2
private void addPackages(CoberturaData data, Document doc, Element packages) { for (String path : data.getPackageMap().keySet()) { Element packageElement = doc.createElement("package"); packages.appendChild(packageElement); packageElement.setAttribute("name", path); ...
059a4aa0-f9ec-4862-b5eb-14378d6927e9
9
public final TWS_SCHEDULESParser.calendarDefinition_return calendarDefinition() throws RecognitionException { TWS_SCHEDULESParser.calendarDefinition_return retval = new TWS_SCHEDULESParser.calendarDefinition_return(); retval.start = input.LT(1); Object root_0 = null; Token ID96=null; Token STRING_LITERAL97=...
3998025b-4646-4a17-89ae-891abaa7faf4
8
public static void main(String[] args) { Scanner in = new Scanner(System.in); // get the size of the matrix to rotate. String matrixSizeLine = in.nextLine(); Scanner matrixSize = new Scanner(matrixSizeLine); int width = matrixSize.nextInt(); int height = matrixSize.nextInt(); // Keep readi...
bc8fb585-44b9-4cc3-b35e-ecee0ca219da
1
private void processAddToDeck(MouseEvent e) { if (!game.hasDealt()) { activeMove.cardReleased(0, CardMoveImpl.MOVE_TYPE_TO.TO_DECK); processMoveResult(activeMove.makeMove(game, this), activeMove); System.out.println("Add to Deck" + activeMove); } }
508223d8-20b7-47c6-adef-2111ec175577
2
public static double asin(double a){ if(a<-1.0D && a>1.0D) throw new IllegalArgumentException("Fmath.asin argument (" + a + ") must be >= -1.0 and <= 1.0"); return Math.asin(a); }
e49f2f5f-4575-44cb-9490-d93b2d000e41
2
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((color == null) ? 0 : color.hashCode()); result = prime * result + id; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; }