method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0edf045f-7436-4707-9403-ca5687e38a9e
3
public void reset()throws TableException{ String createString; java.sql.Statement stmt; try{ createString = "drop table " + STOCK_ITEMS_TABLE_NAME + ";"; stmt = mysqlConn.createStatement(); stmt.executeUpdate(createString); } catch ...
025017c2-11bb-4626-aa19-a5eb390255dd
2
@Override public void draw(Graphics page) { for (int i=0; i<amountX; i++) { for (int j=0; j<amountY; j++) { oceanSprite.drawImage(page, xLocation+i*31, yLocation+j*32); oceanSprite.drawImage(page, xLocation+i*31, yLocation+j*32-480); oceanSprite.drawImage(page, xLocation+i*31, yLocation+j*32+48...
5d5fa8e8-3700-4248-b6cf-421d7eba309c
5
public static int pow(int base, int esp) { if (esp < 0) throw new IllegalArgumentException("Esponente negativo!"); if (base == 0 && esp == 0) throw new IllegalArgumentException("Base ed esponente nulli!"); int r = 1, p = base; while (esp > 0) { if ((esp & 0x00000001) == 1) r *= p; p *= p; esp = esp >> ...
2b007851-320e-4e42-9ea2-40a3edd74e9a
5
public static String[] split(String s){ if(s == null) return new String[0]; s = s.trim(); if(s.length() == 0) return new String[0]; Vector v = new Vector(); while(true){ int cut = s.indexOf(' '); if(cut == -1) break; v.addElement(s.substring(0, cut)); s...
7213b333-0554-45ec-893d-cf8bf92e474d
2
private static void writeTableRows(BufferedWriter out, Map<String, Row> dataInTable) throws IOException { Set<String> keySet = dataInTable.keySet(); for (String key : keySet) { Row row = dataInTable.get(key); List<String> r = row.getRow(); for (String elem : r) { ...
6d0c9783-fe82-4c45-a21c-42c676403e53
3
@Override public void invokeNext(Request request, Response response, ValveContext valveContext) throws ValveException { int subscript = stage; stage = stage + 1; // Invoke the requested Valve for the current request thread if (subscript < valves.length) { valves[subscript].invoke(this); } else ...
c19cb4e6-1a58-4f4a-8158-3823e8d47875
8
protected void getResponseBipolarDetail(String title) { if (title != null) { for (int i = 0; i < bipolarQuestionList.size(); i++) { if (bipolarQuestionList.get(i).getTitle().equals(title)) { if (!(bipolarQuestionList.get(i).getDescription() == null || bipolarQuestionList.get(i).getDescription().eq...
f4622325-22ae-4bdf-a40f-b413b62e1754
5
@Override public final SongDataEntry parse(final byte[] bytes) throws IOException { // TODO read as written to restore data final InputStream is = new ByteArrayInputStream(bytes); final Map<Integer, String> voices; final int idDir = is.read(); final String name = read(is); Path dir = Deserializer_0...
5aa7e0b0-09a4-4f05-b232-a689cb0bfc14
6
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } SpacingModel other = (SpacingModel) obj; if (space == null) { if (other.space != null) { return false; } } else if (!...
64687d07-4e1c-447b-b344-552636ecf36c
7
public void readConfig() { BufferedReader in = null; File config = new File("config.txt"); if (!config.exists()) return; try { in = new BufferedReader(new FileReader(config)); String c; while ((c = in.readLine()) != null) { String key = c.split(":")[0]; int value = Integer.parseInt(c.split("...
da070df9-f8e8-49ed-8597-f9ab4c0624be
8
public boolean containsValue( Object val ) { byte[] states = _states; V[] vals = _values; // special case null values so that we don't have to // perform null checks before every call to equals() if ( null == val ) { for ( int i = vals.length; i-- > 0; ) { ...
f50b27bb-c2fe-41b5-bea5-2f94d72be39a
2
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked // TODO add your handling code here: //connecting to the secondary video String linkSelected = jList2.getSelectedValue().toString(); for(int i=0; i<hyperLinks; i++){ ...
397eef29-734c-4e6f-89e5-082df61aea19
9
public void processClick(Country c) throws InterruptedException { switch (gameState) { case PRE_GAME: preGame(c); break; case REINFORCE: reinforce(c); break; case RECRUIT: recruit(c); break; case ATTACK_A: attackA(c); break; case ATTACK_B: attackB(c); break; case OCCUPY: occupy(c); break; case ...
33ae8cdf-fd6b-49d3-9c38-44bf451b1eeb
0
public int getSuit() { return suit; //You may need to change this }
71db955b-8475-45f4-bbd4-b0086bad5dd5
9
public String getColumnName( int column) { String nom=""; switch (column) { case 0: nom="ID"; break; case 1: nom="Descripcion"; break; case 2: nom="Color"; break; case 3: nom="Peso"; break; case 4: nom="Consumo"; break; case 5: nom="Costo"; break; case 6: nom="C...
f5b2f395-59fc-4854-ac2c-a996a7976b52
1
public static synchronized EventManager getInstance() { if (instance == null) { instance = new EventManager (); } return instance; }
efad109c-1b08-4165-a531-fb3f0459feaa
6
@EventHandler public void onMoonPhaseChange(MoonPhaseChangedEvent event) { for(BlockData data : blockData) { Block block = toBlock(data); if(isValid(block)) { if(block.getWorld() == event.getWorld()) { ...
d512397a-99f3-4df8-98e3-85b5debe27ad
0
protected Map<Integer, T> getEntities() { return entities; }
8f6e991f-9acc-4d92-826e-8dddea2293fb
3
public static void main(String[] args) throws ClassNotFoundException, IOException { HashMap<String, ArrayList<Integer>> map = readUrls("UrlsMap"); System.out.println(map.size()); int num_segments = 5; ArrayList<Integer>[] list = new ArrayList[map.size() / num_segments]; int top = 0; int cur = 0; File f...
2677b3a2-3f06-4bcf-a75f-8449a338a8cf
9
@Override public void insertUpdate(DocumentEvent ev) { if (ev.getLength() != 1) return; int pos = ev.getOffset(); // last letter of input String content = null; try { content = textField.getText(0, pos + 1); } catch (BadLocationException e) { e.printStackTrace(); } // Find where the word start...
1f2fdadc-23e8-4650-8b90-271b0389272a
1
@Override public void mouseClicked(MouseEvent e) { this.MouseInput.setButton(e.getButton()); if(this.UIManager != null) { this.UIManager.mouseDown(e); } }
efbaa70a-c175-4499-a513-6081609f8451
8
public static void main(String[] args) throws IOException { int[] letters = loadFile("assets/problem059.txt"); int counter = 0; for(int a = 97; a <= 122; a++) { for(int b = 97; b <= 122; b++) { for(int c = 97; c <= 122; c++) { StringBuilder full = new StringBuilder(); for(int i = 0; i < letter...
d637a016-4539-4c26-974d-4473a29546ba
2
public long getInfoInt(String key) { if (info == null) parseInfo(); String i = info.get(key); if (i == null) return 0; return Gpr.parseLongSafe(i); }
88ddd7ef-8388-4377-a3a2-b72cefae1628
9
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Candidature other = (Candidature) obj; if (this.idCandidat != other.idCandidat) { return fals...
b436dc42-0060-4462-b2b8-c79202454c8d
3
public static ArrayList<Carte> getAllCarte() { Statement stat; ArrayList<Carte> cartes = new ArrayList<>(); try { stat = ConnexionDB.getConnection().createStatement(); stat.executeUpdate("use nemovelo"); ResultSet res = stat.executeQuery("select * from carte"...
7d79f901-281f-46db-9d2f-eb8d1a00aea8
5
void changePidRecord(List<Map> data, String fieldName, String content) { for (Map m : data) { if (m.get(Strings.PID_RECORD_JSON_KEY) != null && m.get(Strings.PID_RECORD_JSON_KEY).equals(fieldName)) { if (content == null) { data.remove(m); ...
e29f06c1-7ebd-4762-9f8d-f84dd637d083
5
public static <T extends Comparable> Pair<T> minmax(T[] a) { if (a == null || a.length == 0) return null; T min = a[0]; T max = a[0]; for (int i = 1; i < a.length; i++) { if (min.compareTo(a[i]) > 0) min = a[i]; if (max.compareTo(a[i]) < 0) max = a[i]; } r...
67b71745-1388-4ae6-bebc-e4ed5005371f
5
protected final double filterGlow( double glow, double filter, double filterExpDistance, double distance ) { if( glow == 0 ) return 0; if( filter == 1 ) return glow * distance; assert glow >= 0; double add = glow * (filterExpDistance - 1) / Math.log(filter); if( add < 0 || Double.isNaN(add) || Double.isInf...
57ec463d-758b-4400-bff1-14b3ff2ba21d
5
@RequestMapping(value = "/tree/full", method = RequestMethod.GET) public String fullTree(ModelMap map) { if (Feat.getFeats().isEmpty()) { Feat.loadFromSQL(); } ArrayList<FeatNode> nodes = new ArrayList<FeatNode>(); ArrayList<Integer> tiers = new ArrayList<Integer>(); ...
d5d3bb69-0a89-416a-919f-40c556b14e0c
9
public final void conditional(String funcName) throws RecognitionException { TreeRuleReturnScope r1 =null; BasicBlock topBlock = currBlock; BasicBlock endThen; Jmp jmp; try { // C:\\eclipse-workspaces\\workspace1\\Compiler\\src\\edu\\calpoly\\mwerner\\compiler\\Contr...
e7aea34f-d172-4427-bc9d-2e56d968b41a
1
public void testConstructor_ObjectStringEx1() throws Throwable { try { new TimeOfDay("1970-04-06"); fail(); } catch (IllegalArgumentException ex) {} }
5de4f598-c2ad-4768-bca6-344549cf7763
0
public String toString(String input) { return name + calc(input); }
40e2a37b-7304-4fcf-a580-eead30417448
6
@Override public Iterable<EntityRef> getEntitiesWithComponents(Class<? extends Component> component, Class<? extends Component>... additionalComponents) { return Iterables.transform(Iterables.filter(entities, entity -> { if (!entity.entityValues.containsKey(component)) ...
9792ab98-0974-4a92-980d-41e0ba79c972
4
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GeetestLib gtSdk = new GeetestLib(GeetestConfig.getGeetest_id(), GeetestConfig.getGeetest_key()); String challenge = request.getParameter(GeetestLib.fn_geetest_challenge); String validate...
b781d6ca-c9e5-4b9c-9412-6bbb286cf9c8
9
public int numOfLiberties() { // For each piece in pieces for (Piece p : pieces) { // GEt the location int row = p.where.row; int col = p.where.col; // check to see wether the pieces are in certain positions(edges of the board) and // otherwise if there isnt anything next to that particular stone...
bd80a676-ee42-4261-abb7-318c8591a4df
5
public String buscarClientePorNombre(String name){ //##########################CARGA_BASE DE DATOS############# tablaDeClientes(); //##########################INGRESO_VACIO################### if(name.equals("")){ name = "No busque nada"; resultBu...
e9a972b1-839d-47d2-917e-ae280b4c59c7
9
public void run() { Runnable job = null; while (true) { while (true) { synchronized (_lock) { // Keep processing jobs until none availble if (_pendingJobs.size() == 0) { ...
4c5363e5-8cc5-4328-98b1-190ff569b9c5
5
private void checkForUpdate(){ try { BufferedReader webIn; webIn = new BufferedReader(new InputStreamReader(new URL("http://pastebin.com/raw.php?i=aXuwRyFM").openStream())); String version = webIn.readLine(); if (version.startsWith("<")) throw new Exception(); String link = webIn.readLine(); if (!ve...
d219c0b8-52b9-416a-a10b-bb7a1b7db327
9
@Override public long periodUntil(DateTime endDateTime, PeriodUnit unit) { if (endDateTime instanceof OffsetTime == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } if (unit instanceof ChronoUnit) { OffsetTime end = (OffsetTime) endD...
9b8a6e1a-2d4c-4a28-a13d-6c8778478511
8
private void generate() { State<Item> finalState = this.getAutomaton().getFinals().getFirst(); this.addAction(ActionType.ACCEPT, null, finalState.getId(), BigProductionGraph.END_MARKER); for (State<Item> state : this.getAutomaton().getStates()) { if (this.getAutomaton().isFinal(state)) continue; GSet<It...
9b382976-d555-46d7-bd4d-c7a0ceae36c5
8
public ArrayList<Reservation> ReservationsOneCustomerAllFranchises(int CustID) throws UnauthorizedUserException, BadConnectionException, DoubleEntryException { /* Variable Section Start */ /* Database and Query Preperation */ PreparedStatement statment = null; ...
cf6edf13-cd23-4cc8-9b52-efb494c14429
8
public void changeLevel() { currentMap++; if (currentMap < maps.length) { boat1 = new Boat(0, maps[currentMap].xBoat1, maps[currentMap].yBoat1, width*scale, height*scale, maps[currentMap], maps[currentMap].rotationBoat1); boat2 = new Boat(1, maps[currentMap].xBoat2, maps[currentMap].yBoat2, width*scale, heigh...
5eef7b77-12ee-4ac7-acd3-efb9e7b88c57
7
public int apoLookback( int optInFastPeriod, int optInSlowPeriod, MAType optInMAType ) { if( (int)optInFastPeriod == ( Integer.MIN_VALUE ) ) optInFastPeriod = 12; else if( ((int)optInFastPeriod < 2) || ((int)optInFastPeriod > 100000) ) return -1; if( (int)optInSlowPeri...
47506155-55a2-4b7d-b1f1-c345a9b7c06f
2
public String toStringWithoutSupport() { String itemSetContents = ""; int num = this.itemSet.size(); for (int i = 0; i < this.itemSet.size(); i++) { itemSetContents = itemSetContents + this.itemSet.get(i).toString(); if (i < num - 1) { itemSetContents = itemSetContents + " AND "; } } return itemS...
ff90591f-047a-4115-81fa-8c9924058fdb
4
@Test public void testBasicMethod() { final float[] weights = initWeights(1000); ChiVertex<Integer, Float> vert = new ChiVertex<Integer, Float>(0, new VertexDegree(0, weights.length)) { public Float getOutEdgeValue(int i) { return weights[i]; } ...
d3d393e9-4bed-4add-bfa0-d3520210302b
8
private static void runGA() { // *** CHANGE THE PARAMETERS OF THE GA ********************************************************************************************************* final int NUMBEROFINDIVIDUALS = 2000; // Number of individuals in a generation; must be >=1 final int NUMBEROFGENERATIONS = 100; ...
69b928e1-2da2-447b-ab4b-ee7fb7c9329d
9
public static void main(String[] arguments) { ArgumentList argumentList = new ArgumentList(arguments); Debug.init("DataGenerator", argumentList); debug = Debug.getLogger(); /* Vollständige Aufrufparameter-Zeile */ String[] originalArguments = new String[arguments.length]; for(int i = 0; i < arguments.lengt...
f4e8e323-1cbe-4f5d-bf92-15aae54c2993
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; BeanWithBoolean that = (BeanWithBoolean) o; if (bool != that.bool) return false; return !(boolObj != null ? !boolObj.eq...
4fedbdba-f34a-4671-9dca-7971c037f4e9
9
public Object make(HGPersistentHandle handle, LazyRef<HGHandle[]> targetSet, IncidenceSetRef incidenceSet) { if (graph.getHandleFactory().nullHandle().equals(handle)) return null; Record result = null; HGHandle [] targets = HGUtils.EMPTY_HANDLE_ARRAY; if (targetSet != null) ...
cb4ab24f-7428-4dad-bac0-0b07e2f393c3
9
private void setParameter(final String key, final String val) throws UnsupportedEncodingException { if ("xt".equals(key)) // eXactTopic { m_btih = val.substring("urn:btih:".length()); } else if ("dn".equals(key))// DisplayName { m_displayName = URLDecoder.decode(val, "UTF-8"); ...
7a03374c-81d0-4f0e-a4ad-e058d2319a72
7
@Override public int[] getInts(int par1, int par2, int par3, int par4) { int i1 = par1 - 1; int j1 = par2 - 1; int k1 = par3 + 2; int l1 = par4 + 2; int[] aint = this.parent.getInts(i1, j1, k1, l1); int[] aint1 = IntCache.getIntCache(par3 * par4); for (in...
bc7a1569-17b1-4128-a024-5e0a7e531465
8
public static void main(String[] args) { // Initialize the population PacManGeneticAlgorithm population = new PacManGeneticAlgorithm(POPULATION_SIZE); int generationCount = 0; float bestFitnessEver = 0; // we'll break out of this loop with a break statement from within it // when the worst and best...
87a0486e-e399-4ce2-9547-97b4995749cc
6
private static Moves performStep18(BotState state) { Moves out = new Moves(); for (Region opponentBorderingRegion : state.getVisibleMap().getOpponentBorderingRegions(state)) { // > 3 so not to small attack if (opponentBorderingRegion.getIdleArmies() > 3) { List<Region> opponentNeighbors = opponentBorderin...
bb6ff8a4-a8f0-41f7-ac55-f7355d670295
1
public CouldNotOpenSocketToServerException(SocketException e) { super("Could not open socket to server" + (e == null ? "." : "--" + e.getMessage())); wrappedException = e; }
d58fb041-e528-4a6b-996d-ed7991d2ebc0
0
public CbtMenuBar() { file = new JMenu("File"); help = new JMenu("Help"); this.add(file); this.add(help); setMenuItems(); }
b8a3285f-a971-4f9f-8b48-5bc826a8961e
4
public boolean loadConfig() { boolean isErrorFree = true; pluginVersion = FactionShield.getVersion(); new File(directory).mkdir(); if (configFile.exists()) { try { bukkitConfig.load(configFile); if (bukkitConfig.getString("Version", "").equals(pluginVersion)) { // config file exists and is up...
ef939993-8e41-4490-b843-555b259a2632
9
public static String convertPath(final Path PATH) { final StringBuilder fxPath = new StringBuilder(); for (PathElement element : PATH.getElements()) { if (MoveTo.class.equals(element.getClass())) { fxPath.append("M ") .append(((MoveTo) element).getX()).a...
147bfd94-c152-4a1b-84c2-b0571ae8f1de
6
public void writeLyrics() { int status = JOptionPane.YES_OPTION; if (destFile.exists()) { status = JOptionPane.showConfirmDialog(null, "File already exists!\nDo You want to overwrite?"); } else { try { destFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } if (...
0385308d-98f8-44a3-9ec0-789800a4a98c
4
protected long computeSVUID() throws IOException { ByteArrayOutputStream bos; DataOutputStream dos = null; long svuid = 0; try { bos = new ByteArrayOutputStream(); dos = new DataOutputStream(bos); /* * 1. The class name written using UTF...
8e8a9247-ef9b-4e25-9e6b-c60cdb966230
1
public void testGet_DateTimeField() { MutableDateTime test = new MutableDateTime(); assertEquals(1, test.get(ISOChronology.getInstance().era())); assertEquals(20, test.get(ISOChronology.getInstance().centuryOfEra())); assertEquals(2, test.get(ISOChronology.getInstance().yearOfCentury()))...
50d26909-63fa-41e8-b3a6-f3cabe2e86ef
4
public CodeMap4 set(final int index, final int value) { final int i0 = index >>> 24; int[][][] map1 = map[i0]; if (map1 == null) map[i0] = map1 = new int[MAX_INDEX][][]; final int i1 = (index >>> 16) & 0xff; int[][] map2 = map1[i1]; if (map2 == null) map1[i1] = map2 = new int[MAX_INDEX][]; final i...
94de5b43-d5e1-4838-b8a1-b4111f2787a3
3
public void distributeAllCardsToPlayers(List<Card> deck, HashMap<String, Player> players) { if (0 == deck.size() % players.size()) { int originalDeckSize = deck.size(); for (int i = 0; i < (originalDeckSize / players.size()); i++) { Iterator<Map.Entry<String, Player>> it...
3c522bf8-5b8c-4216-a7a3-a4020dd6865d
2
public void setfs() { GraphicsDevice dev = getGraphicsConfiguration().getDevice(); if (prefs != null) return; prefs = dev.getDisplayMode(); try { setVisible(false); dispose(); setUndecorated(true); setVisible(true); dev.setFullScreenWindow(this); dev.setDisplayMode(fsmode); } catch (Excep...
1e5a30be-dfe3-4477-b150-5cce0c82f44c
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...
ba4fc0a0-a6a9-4a30-a630-b2228156ed4b
0
public Grammar() { myVariables = new HashSet(); myTerminals = new HashSet(); myStartVariable = null; }
6707e49c-f3b6-4cdf-a14e-61760830ae5b
9
@Override public Plan findPath(SearchDomain map, State sNode, State tNode) { // Date inTime = Calendar.getInstance().getTime(); // If the destination is not traversible, there can be no path. Same applies to the start // node. if (map.isBlocked(sNode) || map.isBlocked(tNode)) { ...
26208295-e5d3-4563-a431-8406151bb580
5
public void handleRequest(R request) { boolean success = false; int numTries = 0; while(!success) { success = doHandle(request); if(!success) { // break chain if number of tries exceeds limit if(++numTries >= MAX_TRIES) { updateStatus(request, Status.COR_FAILED,"Handler.handleRequest: failure (...
a068a05c-93e7-496d-ae4b-9b60955ae08e
2
@Override public Status execute(String command)throws MenuException { switch (command) { case "C": reset(); return BEST_TIMES; case "M": return MAIN_MENU; default: ...
93418825-4588-4209-8b1b-ec4d6f4b4647
2
public String[] getWarpList(CommandSender arg0) throws SQLException { sql.initialise(); String[] list= new String[2]; list[0]=ChatColor.AQUA+"Warp List: "; list[1]=ChatColor.BLUE+"Private warps: "; ResultSet res = sql.sqlQuery("SELECT Name,Visible FROM BungeeWarps"); while(res.next()){ String name = res....
e1c1de9c-ae72-45f7-a838-f50a840568d6
9
public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT...
2c20f369-0f87-4561-a86a-5812e8f0711a
5
public boolean loadUser(String username, String password) { File file = new File("Users.txt"); Scanner scanner; try { scanner = new Scanner(file); while (scanner.hasNextLine()) { String lineFromFile = scanner.nextLine(); if(lineFromFile.contains(username)) { lineFromFile = scanner.nextL...
e6f4eb7a-4083-414f-bf2a-3401a7a63c3c
3
private String take() throws ApiConnectionException, ApiDataException { Object val = null; try { val = queue.take(); } catch (InterruptedException ex) { throw new ApiConnectionException("Interrupted while reading data from queue.", ex); } ...
2d9934fa-da2a-4cea-a071-8eeb0743787a
8
@Override public AdminCol getCol(String tblNm, String colNm) { log.debug("get column for table = " + tblNm + " and column = " + colNm); Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; AdminCol col = new AdminCol(); StringBuilder sql = new StringBuilder(); sql.append(" ...
5e791eda-51b1-47ac-8bd9-f0664e1c36fb
8
@Override public void mouseMoved(MouseEvent e) { pointMouseLast = null; DecimalFormat formatDistance = new DecimalFormat("#.0"); DecimalFormat formatError = new DecimalFormat("0.000"); if (main == null) return; if (main.map == null) return; Point2D.D...
bbde4707-a56f-4a1e-899d-6d6055ecdfc5
5
private Point[] getPointsAround(Point point){ Point[] res = new Point[8]; int n = 0; for (int i = -1; i < 2; i++){ for (int j = -1; j < 2; j++){ if (i != 0 || j != 0){ if (point.getLetter() != '*') { res[n] = getPoint(point....
08242dac-5c1a-4b72-88f0-a44c19fe026f
3
@Override public GameState doAction(GameState state, Card card, int time) { if(time == Time.DAY) { state = frenchDay(state, card, true); } else if(time == Time.DUSK) { PickTreasure temp = new PickTreasure(); state = temp.doAction(state, card, time); } else if(time == Time.NIGHT) { //Do n...
fe2e7817-2a5c-404d-a561-482e9a8e7076
6
@Override public Iterable<I> train(final Iterable<I> input) throws Exception { cv = new ArrayList<I>(); final Iterator<I> inputIterator = input.iterator(); Iterable<I> res = new Iterable<I>() { @Override public Iterator<I> iterator() { return new Itera...
9a3862ef-73af-49ca-adb5-be109cba1f88
7
public void AddMouseListener() { this.addMouseListener(new MouseAdapter(){ public void mousePressed(MouseEvent event) { if (TargetPin.this.isScrapper == true) { switch (gameState.getDifficultyLevel()) { case GameState.DIFFICULTY_EASY: ...
778a86a0-0c7b-4231-8829-89d5b462172b
6
public Employee getEmployeeDetails(String employeeId) { String uniqueUserSql = SELECT_EMPLOYEE_DETAIL + employeeId + "'"; Connection connection = new DbConnection().getConnection(); Employee employee = new Employee(); ResultSet resultSet = null; Statement statement = null; try { statement = connection.cr...
f76ecc7a-8a7a-474f-bb27-9d96aed61e20
7
static private int jjMoveStringLiteralDfa10_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(8, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(9, active0); return 10; } switch(curChar) { c...
d5a0ca62-c569-4197-b89d-4793775338e5
1
public boolean adicionarFornecedor(Fornecedor f){ if (!contensFornecedor(f.getNome())){ return fornecedores.add(f); } return false; }
0d9f89d6-594e-4be0-812f-8e6defd70367
1
@Override public void paintIcon( Component c, Graphics g, int x, int y ) { g.setColor( Color.black ); g.drawRect( x, y, size-1, size-1 ); if( null == color ) { g.drawLine( x, y+size-1, x+size-1, y ); } else { g.setColor( color ); g.fillRect( x+1, y...
16a33d03-d46c-498f-a5bc-d85057413053
5
protected void printTopKChild4Stn(String filePrefix, int topK) { String topKChild4StnFile = filePrefix + "topChild4Stn.txt"; try { PrintWriter pw = new PrintWriter(new File(topKChild4StnFile)); for (_Doc d : m_trainSet) { if (d instanceof _ParentDoc4DCM) { _ParentDoc4DCM pDoc = (_ParentDoc4DCM) d; ...
c2a48784-d113-4ae9-b456-87716c35f947
2
private static String randomMACAddress(){ Random rand = new Random(); byte[] macAddr = new byte[6]; rand.nextBytes(macAddr); macAddr[0] = (byte)(macAddr[0] & (byte)254); //zeroing last 2 bytes to make it unicast and locally adminstrated StringBuilder sb = new StringBuilder(18); for(byte...
1ef0895f-4bd9-4442-8794-dfbefadcfa67
1
@Override public void setEventBus(EventBus eventBus) { super.setEventBus(eventBus); try { eventBus.connectProcessors(processors); } catch (Exception e) { e.printStackTrace(); } }
b612d249-4304-489c-8a55-cdb3b79fbfc7
8
public boolean isFinal() { // The following is borrowed from John Tromp and modified. // http://homepages.cwi.nl/~tromp/c4/fhour.html // It would have taken us some ugly loops to implement this function. long board = red; long y = board & (board>>6); if ((y & (y >> 2*6)) != 0) // check diagonal \ retur...
cbbef014-782b-4c1d-a8fa-9fc560c62009
0
@Override public void setName(String name) { this.name = name; }
df013f4f-8f55-46a8-be94-715a0117359b
3
public static ByteBuffer getByteBuffer(BufferedImage image){ int[] pixelArray = new int[image.getWidth()*image.getHeight()]; for(int y = 0; y < image.getHeight(); y++){ for(int x = 0; x < image.getWidth(); x++){ pixelArray[(y*image.getWidth()) + x] = image.getRGB(x, y); ...
4e667d1a-0368-45c8-847e-a2c8b1a4f27b
6
public String selectSingleValue(String query) throws SQLException { Connection connection = null; Statement statement = null; ResultSet result = null; String value = ""; try { Class.forName(driver); connection = DriverManager.getConnection(url, username, passwd); statement = connection.createStat...
e1b31136-de8d-4bb2-b8b6-458bbebe14fd
0
Playback(Socket s){ this.s=s; }
e58a92e5-6d10-4fe6-bfba-68135ddad572
2
public static void createFile(String realpath) throws UtilException { File file = new File(realpath); if (!(file.exists())) { try { file.createNewFile(); } catch (IOException e) { throw new UtilException("创建文件失败:", e); } } }
d5554be3-b218-4668-b17c-f007fdd6443b
2
public void setOperandAt(final Block block, final Expr expr) { final Expr operand = (Expr) operands.get(block); if (operand != null) { operand.cleanup(); } if (expr != null) { operands.put(block, expr); expr.setParent(this); } else { operands.remove(block); } }
4c4010a0-ccd9-47b5-8820-214a90b7f142
7
@Override public int hashCode() { int result = pathToSvn != null ? pathToSvn.hashCode() : 0; result = 31 * result + (repositoryUrl != null ? repositoryUrl.hashCode() : 0); result = 31 * result + (repositoryRoot != null ? repositoryRoot.hashCode() : 0); result = 31 * result + (timeRange != null ? timeRange.hashC...
cb9dd3e5-d63b-4dfa-9faa-e88e4557d3b9
3
public boolean isGameOver() { for (int i = 0; i < YARD_COL; i++) { if (blocks[0][i] == true) { gameOver = true; if (showGameOverMessage == true) { showGameOverMessage = false; //提示对话框只出现一次 JOptionPane.showMessageDialog(this, "Game Over!按F2重新开始"); } return true; } } gameOver...
bb630846-5bab-4382-99e6-0c1deb62370c
1
@Override public <T> T addElement(Class<T> clazz, Map<String, String[]> valuesOfFields) { if (clazz == Faculty.class){ return (T)addFaculty(valuesOfFields, null); } throw new RuntimeException("Incorrect class"); }
1ed9a6bb-d2c8-4c1b-9648-1c4451b4558b
4
public void extractFieldsFromFiles(WebSite webSite) throws FileNotFoundException, JSONException, Exception { // File inputDir = new File(this.inputDir); File inputDir = new File(ExtractorUtils.getInputDir(webSite)); checkInputDir(inputDir); File outputDir = new File(this.outputDir); checkOutputDir(outputDi...
74fd413c-23de-4f93-94bd-d1e92fa2e473
1
private void disp(int[] bowl) { String str = "|"; for (int i = 0; i < bowl.length; i++) { str += " " + bowl[i] + " |"; } str += "\n"; System.out.println(str); }
e67c9a06-0539-40ca-b1f4-fb7ab5b3a31f
2
public Rijksdriehoeksmeting(){ //if (!(x>10000 && x<290000 && y>300000 && y<630000)) return;//XY are out of range // x = inX; // y = inY; //LatlngpqK[] latpqK = new LatlngpqK[12]; for(int i=1;12>i;i++)latpqK[i]=new LatlngpqK(); latpqK[1].p=0;latpqK[1].q=1;latpqK[1].K=3235.65389; latpqK[2].p=2;latpqK[2].q=0;...
86fbf164-5d19-4bfc-a90f-e0d083afc6d1
4
@Override public void run() { while (isRunning) { if (this.deadly == false) { this.edibleLifeRemaining--; if (this.edibleLifeRemaining <= 0) { this.deadly = true; } } pastRow = ghostRow; pa...
bece4fff-c171-47f9-a314-b82865fa8e51
4
private void closeTab(String actionCommand) { String[] parseInputAC = actionCommand.split(":"); if(parseInputAC == null || parseInputAC.length != 2) { System.err.println("Error closing tab"); return; } NetworkSharedUser nsu = Users.getUserByName(parseInputAC[0]); // Nsu will be null if the user disconne...