text
stringlengths
14
410k
label
int32
0
9
@Override public void undo() { this.to.removePiece(this.promotionedPiece); this.to.addPiece(this.capturedPiece); this.from.addPiece(this.piece); this.piece.decreaseMoveCount(); }
0
@Override public int print(Graphics g, PageFormat pf, int page) throws PrinterException { // We have only one page, and 'page' // is zero-based if (page > 0) { return NO_SUCH_PAGE; } // User (0,0) is typically outside the // imageable area, ...
1
public static void main(String s[]) { testLoop: for (int bits = MIN_BITS ; bits <= MAX_BITS ; bits++) { final int period = (1 << bits) - 1 ; final boolean reg[] = new boolean[period] ; final LFSR lfsr = new LFSR(bits, 1) ; I.say("\nBeginning test for "+bits+" bit LFSR...") ; // /...
4
public void testIsAfter_YMD() { YearMonthDay test1 = new YearMonthDay(2005, 6, 2); YearMonthDay test1a = new YearMonthDay(2005, 6, 2); assertEquals(false, test1.isAfter(test1a)); assertEquals(false, test1a.isAfter(test1)); assertEquals(false, test1.isAfter(test1)); assert...
1
public void peliSykli() { while (jatkuu) { try { Thread.sleep(viive); } catch (Exception e) { status.setText("Jotain meni vikaan..."); } if (pause) { while (pause) { status.setText("Peli pysäytett...
7
public String openSEND() throws IOException{ Transporte t = new Transporte(initTransporteACKeSYN); Transporte t1 = new Transporte(initTransporteACKeSYN); seq = 0; //numero de sequencia por defeito para o cliente mtu = 1400; win = MINWIN; //criar SYN (dados ...
8
private static void removeFromTrees(TreeNode treeNode, List trees) { boolean found = false; // without this initialization, I get a compilation error // that says subTree may not have been initialized Tree subTree = new Tree(null, null, null); for (Iterator iter = trees.iterator(); iter.hasNext(); )...
3
@Override public Event next() { String input = null; try { input = br.readLine(); } catch (IOException e) { } if(input == null || input.equals("")){ return new DefaultState(as); } else{ return new UserHomeState(as, input); } }
3
public List<BipolarQuestion> getBipolarList(String oppositeFileName, String teamType) { List<BipolarQuestion> bipolarQuestionList = new ArrayList<BipolarQuestion>(); Element bipolarQuestionE; BipolarQuestion bipolarQuestion; BipolarQuestionDao parentBipoarQuestion = new BipolarQuestionDao(oppositeFileName); ...
4
public int h() { return _map == null?0:_map.length; }
1
public List<Location> adjacentLocations(Location location) { assert location != null : "Null location passed to adjacentLocations"; // The list of locations to be returned. List<Location> locations = new LinkedList<Location>(); if(location != null) { int row = location.ge...
9
public void setColor(int i) { String strat = agents[i].getStrategy(); for(int str = 0; str < scape.strategies.length; str++) { if(strat.equals(scape.strategies[str])) { style[(i + 2)] = colors[str]; } } }
2
public static NumberWrapper plusComputation(NumberWrapper x, NumberWrapper y) { { double floatresult = Stella.NULL_FLOAT; { Surrogate testValue000 = Stella_Object.safePrimaryType(x); if (Surrogate.subtypeOfIntegerP(testValue000)) { { IntegerWrapper x000 = ((IntegerWrapper)(x)); ...
6
Announce(SharedTorrent torrent, byte[] id, InetSocketAddress address) { //> obfuscated handshake extension this.torrent = torrent; this.id = id; this.address = address; this.listeners = new HashSet<AnnounceResponseListener>(); this.thread = null; this.register(this); }
0
public static void readFile(String filePath) { lineCode lineType = lineCode.amount; try { FileInputStream fstream = new FileInputStream(filePath); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine =...
7
public static ActionCom SelectActionComById(int id) throws SQLException { String query = null; ActionCom Action = new ActionCom(); ResultSet resultat; try { query = "SELECT * from ACTION_COM where ID_ACTION=? "; PreparedStatement pStatement = ConnectionBDD.getIn...
2
public void undo() { if (patchIndex == 0) { return; } UndoPatch p = undoPatches.get(--patchIndex); // Reverse patch int prow; for (prow = 0; prow < p.patchText.length; prow++) { if (prow >= p.oldText.length) { for (int da = p.patchText.length - prow; da > 0; da--) { ...
5
private void processInput(String incoming) { String[] split = incoming.split(";"); String command = split[0].toUpperCase(); if (command.equals("NEWUSER")) { this.clientCon.getUser().addUser(split); } else if (command.equals("MESSAGE")) { } else if (command.equals("LOGIN")) { this.clientCon.getUser().ve...
7
private static void initDisplay(boolean fullscreen) { DisplayMode chosenMode = null; try { DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if ((modes[i].getWidth() == targetWidth) && (modes[i].getHeight() == ta...
6
public static double getDamageModSlash(WeaponMaterial type) { switch (type) { case COPPER: return 0.5; case BRONZE: return 0.75; case SILVER: return 0.5; case IRON: return 1; case STEEL: ...
6
public JLabel getjLabel3() { return jLabel3; }
0
public void buildBoard(){ Wall wall; Cheese cheese; Intersection intersection; for(int i = 0; i < levelData.length; i++){ switch(levelData[i]){ case 1: wall = new Wall(i-((i/21)*21),i/21); collisionList.add(wall); paintList.add(wall); break; case 2: cheese = new Che...
9
public List<Author> getAuthor() { if (author == null) { author = new ArrayList<Author>(); } return this.author; }
1
public static int bitonicSearch(Comparable[] a, int lo, int hi, Comparable t) { if (lo > hi) { return -1; } int mid = (lo + hi) / 2; final int compareToT = a[mid].compareTo(t); if (compareToT == 0) { return mid; } else if (compareToT == 1) { // mid...
7
public void setAcceptByEmptyStack() { myAcceptance = EMPTY_STACK; }
0
public ColourMap(Colour[] colours, String name) { InitMap(); //First initialises array to null. if (colours.length <= m_mapSize) { /* Then if array parameter is <= max number of maps */ for (int i=0; i<colours.length; i++) { SetColour(i, colours[i]); //tr...
3
protected boolean isPrimitiveWrapper(Object input) { return input instanceof Integer || input instanceof Boolean || input instanceof Character || input instanceof Byte || input instanceof Short || input instanceof Double || input instanceof Long || input instanceo...
7
ArrayList<Row> getChildList() { return canHaveChildren() ? mChildren : null; }
1
static public void list() { String[] available_inputs = availableInputs(); String[] available_outputs = availableOutputs(); String[] unavailable = unavailableDevices(); if(available_inputs.length == 0 && available_outputs.length == 0 && unavailable.length == 0) return; System.out.println("\nAvailable MI...
9
public void stopListening() { listening = false; }
0
public void playerTurn() { int choice = 1; boolean readChoice = true; System.out.println("\n------------------------------"); System.out.println("PLAYER'S TURN"); System.out.println("------------------------------"); while (readChoice) { choice = getInt("Which column would you like to drop your pie...
4
@Override public void validate() { if (platform == null) { addFieldError("platform", "Please Select Platorm"); addActionError("Please Select Platorm"); } if (location == null) { addFieldError("location", "Please Select Location"); addActionEr...
4
static boolean nextPermutation(List<Integer> a){ int[]p = new int [a.size()]; for (int i = 0; i < p.length; i++) { p[i]=a.get(i); } int k,l,aux,i,j; for (k = p.length-1; k>0 && p[k-1]>=p[k]; k--); if (k!=0){ for (l = p.length-1; l>0 && p[k-1]>=p[l]; l--); aux=p[k-1]; p[k-1]=p[l]; p[l]=aux; for...
7
public static int partition(int[] records, int low, int high){ if(low > records.length - 1|| high > records.length - 1) { throw new IllegalArgumentException(); } int pivot = records[low]; while(low < high){ while (records[high] > pivot && low < high){ ...
7
private boolean jj_3R_55() { Token xsp; xsp = jj_scanpos; if (jj_3_62()) { jj_scanpos = xsp; if (jj_3_63()) { jj_scanpos = xsp; if (jj_3_64()) return true; } } return false; }
3
public void setjButtonNext(JButton jButtonNext) { this.jButtonNext = jButtonNext; }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Modul)) return false; Modul other = (Modul) obj; if (bezeichnung == null) { if (other.bezeichnung != null) return false; } else if (!bezeichnung.equals(other.bezei...
6
private static void addList(ArrayList<Node> list, ArrayList<Node> newList) { for (int i = 0; i < list.size(); i++) { if(list.get(i).getWeight() <= Config.size){ if (!newList.contains(list.get(i))) { newList.add(list.get(i)); if (table.containsKey(list.get(i).getWeight())) { if (!table.get(list.get(...
5
public void SetStopBusStop(int stopBusStop) { //set the person stop bus stop this.stopBustop = stopBusStop; }
0
public String getNumBalise() { return numBalise; }
0
public Connection getConnection() { try { if(connection==null||connection.isClosed()) connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/workdb"); }catch(SQLException ex) { ex.printStackTrace(); } return connection; }
3
private boolean jj_2_19(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_19(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(18, xla); } }
1
public ListNode deleteDuplicates(ListNode head) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode p = dummy; if(head == null) return head; while(p.next != null){ int cur = p.next.val; ListNode pp = p.next; if(pp.next == null || p...
6
public int length() { int length = 2 + 2 + 4 + code.length + 2 + handlers.length * 8 + 2; for (int i = 0; i < attrs.length; i++) { length += 2 + 4 + attrs[i].length(); } return length; }
1
@Override public List<AdminCol> getColSortList(String tblNm) { log.debug("get column sort list for table = " + tblNm); Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; ArrayList<AdminCol> list = new ArrayList<AdminCol>(); StringBuilder sql = new StringBuilder(); sql.app...
8
public void draw(Graphics2D g){ if(bulletTime&&btTimer > 0&&!btCooldown){ try { System.out.println("BULLET TIME"); Thread.sleep(btTime); } catch (InterruptedException e) { e.printStackTrace(); } }else if(btTimer == 0){ btCooldown = true; } if(gameStates[currentState] != null){ gameSta...
6
public IService getService(Type type) { switch (type) { case ALBUM: return new AlbumService(this.daoFactory.getAlbumDAO()); case ARTIST: return new ArtistService(this.daoFactory.getArtistDAO()); case TRACK: return new TrackS...
4
public static Cons collectStartupFormsFromSystemFile(SystemDefinition system) { { String systemfilename = Stella.makeSystemDefinitionFileName(system.name); Module module = null; Cons startupform = null; Cons startupforms = Stella.NIL; { Object old$Module$000 = Stella.$MODULE$.get(); ...
9
public static void main(String[] args) { int[][] array = new int[3][4]; int index=1; for(int i =0; i< 3;i++) for(int j =0; j < 4;j++){ array[i][j] = index++; } List<Integer> list = new Spiral_Matrix().spiralOrder(array); System.out.println...
2
private JSONWriter append(String string) throws JSONException { if (string == null) { throw new JSONException("Null pointer"); } if (this.mode == 'o' || this.mode == 'a') { try { if (this.comma && this.mode == 'a') { this.writer.write('...
7
public Action decideAction(Set<Being> beings, BehaviourType behaviourType) { Action a; double hunger = myBeing.getDynamicStats().get(StatType.D_HUNGER).getValue(); if (myBeing.childReady()) { if (Math.random() > 0.9) { a = new BearAction(myBeing); } else {...
5
public void printAnalysisResultsSummaryEP() { String string = ""; for (int i = 0; i < consumptionEnergyPoints.length; i++) string += "\t\tFR" + (i + 1) + ": " + consumptionEnergyPoints[i] + "EP\n"; string += "\n\t\tTOTAL : " + systemConsumptionEP + "EP"; System.out.println(string); }
1
public void loadAllGroups() { ResultSet data = query(QueryGen.selectAllGroups()); while (iterateData(data)) { HashMap<PermissionFlag, Boolean> flags = new HashMap<PermissionFlag, Boolean>(); String groupType = getString(data, "GroupType"); String groupId = getString(d...
5
@Override public void paint(Graphics g) { super.paint(g); for (JComponent voie : voies) { voie.paint(g); } }
1
@Override public void run() { playing = true; orderedStopped = false; try { if ((clip != null) && (applet instanceof Applet)) { if (url == null) clip = ((Applet) applet).getAudioClip(((Applet) applet).getCodeBase(), key); else clip = ((Applet) applet).getAudioClip(new URL(url + key)); ...
7
public static UUID toUUID(String value) { if (value == null || value.length() < 32) { return null; } try { if (!value.contains("-")) { String fixedString = value.substring(0, 8) + "-" + value.substring(8, 12) + "-" + value.substring(12, 16) + "-" + value.substring(16, 20) + "-" + value.su...
4
@Override public void validate(Object target, Errors error) { // TODO Auto-generated method stub Contact contact=(Contact) target; String firstName=contact.getFirstName(); String lastName=contact.getLastName(); if(firstName==null || firstName.trim().equals("")){ ValidationUtils.rejectIfEmpty(error, "fi...
8
public void setOption(int token){ if( token == 0){ if( this.option > 0) option -- ; else option = this.optionStr.length - 1 ; }else if( token == 1){ if( this.option < this.optionStr.length - 1) option ++ ; else option = 0 ; } }
4
@Override public XValue invoke(XRuntime runtime, XExec exec, int id, XValue thiz, XValue[] params, List<XValue> list, Map<String, XValue> map){ XObjectDataMap m = (XObjectDataMap)runtime.getObject(thiz).getData(); switch(id){ case 0: return getIndex(runtime, m, params[0]); case 1: return length(m); cas...
6
static void Bin2Dec(){ System.out.println(); System.out.print("Please enter a binary number containing only 0s and 1s: "); String binary = s.nextLine(); for(int i = 0; i < binary.length(); i++){ if(binary.charAt(i) != '0' && binary.charAt(i) != '1'){ ...
4
public static void main(String[] args) { JFrame frame = new JFrame("Ray Tracer"); CustomPanel panel = new CustomPanel(actualWidth, actualHeight, ANTIALIASING_AMOUNT); frame.setBounds(0, 0, width, height); frame.add(panel); frame.setVisible(true); frame.setFocusable(true); ...
6
private static void updateStringColumn(CyNetwork network, CyIdentifiable cyId, String columnName, List<CDDHit> hits) { List<String> dataList = new ArrayList<String>(); for (CDDHit hit: hits) { if (columnName.equals(CDD_ACCESSION)) dataList.add(hit.getAccession()); e...
5
public void transformCode(BytecodeInfo bytecode) { this.bc = bytecode; calcLocalInfo(); if ((GlobalOptions.debuggingFlags & GlobalOptions.DEBUG_LOCALS) != 0) { GlobalOptions.err.println("Before Local Optimization: "); dumpLocals(); } stripLocals(); distributeLocals(); if ((GlobalOptions.debuggingFl...
2
private void appendRowElements( final RowData rowData, final Set<CellKey> keys, final Map<RowElement,CellKey> rowElementKeyMap) { final List<Object> successors = rowData.getSuccessors(); if ( successors.isEmpty()) { // hat eine RowElement-Komponente final CellKey cellKey = rowData.getCellKey(); if ( k...
7
void Rendre() { // Début de la location int idCarte = Integer.parseInt(JOptionPane.showInputDialog("Numéro carte abonnée ?")); Utilisateur user = null; for (Utilisateur s : ConfigGlobale.utilisateurs) { if(s.getFk_id_carte()==idCarte){ user = s; ...
4
public void setSanic(){ sanic = true; if(!sanicd){ try{ BufferedImage spritesheet = ImageIO.read(getClass().getResourceAsStream("/Sprites/Sanic.png")); sprites = new ArrayList<BufferedImage[]>(); for(int i=0; i<4; i++){ BufferedImage[] bi = new BufferedImage[numFrames[i]]; for(int j = 0; j<...
5
public void setCallback(Callback callback) { this.callback = callback; }
0
public byte[] processBlock(byte[] in, int inOff, int len) throws InvalidCipherTextException { if (param instanceof BGV11LeveledPublicKeyParameters) { // Encrypt under input level parameters BGV11LeveledPublicKeyParameters pk = ((BGV11LeveledPublicKeyParameters) param); BGV11L...
8
@Override public Object getInvokeHandler() { return invokeHandler; }
0
private void affDonneesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_affDonneesActionPerformed afficherCarte(); }//GEN-LAST:event_affDonneesActionPerformed
0
public JSONWriter key(String string) throws JSONException { if (string == null) { throw new JSONException("Null key."); } if (this.mode == 'k') { try { this.stack[this.top - 1].putOnce(string, Boolean.TRUE); if (this.comma) { ...
4
public void sendDate() { final String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; tblCalendar.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) {// must be mouseReleased int pos =...
3
public UserControlParsePane(GrammarEnvironment environment, Grammar grammar) { super(environment, grammar, null); intializeGrammarTableSetting(); }
0
public void workWeek() { for (int i=0; i<5; i++) { this.shake(); } this.earnPaycheck(); this.setEffMult(1); }
1
public static Keyword continueExistsProof(ControlFrame frame, Keyword lastmove) { if (lastmove == Logic.KWD_DOWN) { return (Logic.KWD_MOVE_DOWN); } else if (lastmove == Logic.KWD_UP_TRUE) { { ControlFrame result = frame.result; if (result.partialMatchFrame != null) { result.pa...
8
@Override protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, TpURL tpURL, Invocation invocation) { int weight = 0; for (Invoker<T> invoker : invokers) { weight += this.getWeight(invoker, invocation); } int factor = random.nextInt(weight); for (Invoker<T> invoker : invokers) { weight = weigh...
3
public void tick() { // tykniecie arbitera manager.tick(); // wyluskiwanie widokow srodowiska RobotEnvironmentView robotEnvironmentView = environment.getRobotEnvironmentView(); StudentEnvironmentView studentEnvironmentView = environment.getStudentEnvironmentView(); // dzialanie na koordynatorach for (Coo...
8
public void process(Client sockector) { Response msg = sockector.getResponseMsgsNotCode().poll(); while(msg != null){ try{ if(sockector.isHandShak()){ broundMsg(sockector,msg); msg.bufferedContent();// 缓存内容 sockector.getResponseMsgs().add(msg); }else{ if(!sockector.isClient()){ ...
4
public synchronized void controllerUpdate(ControllerEvent event) { if (Debug.audio) System.out.println("CONTROLLER EVENT"); // If the player has just been realized, then create the control panel. if (event instanceof RealizeCompleteEvent){ // Now that the player is realized, get the gain controls to allow ...
8
public void fillDNA() { if (modelID < 0 || proteinID < 0) return; ModelCanvas mc = page.getComponentPool().get(modelID); if (mc == null) return; MoleculeCollection c = ((MolecularModel) mc.getMdContainer().getModel()).getMolecules(); if (c.isEmpty() || proteinID >= c.size()) { setDNA(null); return...
7
public static void main(String[] args) throws IOException { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); //TODO Loop for persons, inner loop images of persons /*List matchedPersons = new ArrayList<Person>(); // person loop for (Person person : result) { // image loop for (URL url : person.im...
4
public static void main(String[] args) { Simulation s = new Simulation(); // Clean up if control-C is pressed Runtime.getRuntime().addShutdownHook(s.new Cleanup()); if (args.length != 1) { System.err.println("Usage error: run as <program> <specfile> for a single XML...
9
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || this.length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this....
4
public void reorderList(ListNode head) { Stack<ListNode> stack = new Stack<ListNode>(); Queue<ListNode> queue = new LinkedList<ListNode>(); ListNode node = head; int size = 0; while(node != null){ size++; stack.add(node); queue.add(node); ...
3
public void run() { // Move all torpedoes and determine if they hit anything ArrayList<SpaceCraft> destroyed = spaceGameServer.sector.updateTorpedoes(); // Send remove messages for any ships of torpedoes // that are no longer in the game. if (destroyed != null ) { for ( SpaceCraft sc: destroye...
4
public void setId(int id) { this.id = id; }
0
private Stmt iterationStmt() throws SyntaxException { Stmt toBeReturned = null; if (isKind(currentToken, _while)) { consume(); match(LPAREN); Expr expr = expr(); match(RPAREN); match(LBRACE); ArrayList<Stmt> stmtList = new ArrayList<Stmt>(); // Stmt*. So check for // FIRST(Stmt) = { ;, IDEN...
6
private static void loadParameterFile(File file) { try { BufferedReader in = new BufferedReader(new FileReader(file)); int count; for (count = 0; in.ready(); count++) { String line = in.readLine(); if (line.compareTo("") == 0 || !loadParameter(line)) { in.close(); loadDefaults(); r...
6
private static Map<? extends Attribute, ?> fillattrs(Object... attrs) { Map<Attribute, Object> a = new HashMap<Attribute, Object>(std.defattrs); for(int i = 0; i < attrs.length; i += 2) a.put((Attribute)attrs[i], attrs[i + 1]); return(a); }
3
private String privateMethod() { return "private"; }
0
private static void dropDB(String dbName, String username, String password){ Connection conn = null; Statement stmt = null; String dbURL = "jdbc:mysql://localhost"; try{ //STEP 2: Register JDBC driver Class.forName("com.mysql.jdbc.Driver"); //STEP 3: Open a connection S...
6
@Override public boolean isConverted() { // TODO Auto-generated method stub return true; }
0
public List<Object> getContent() { if (content == null) { content = new ArrayList<Object>(); } return this.content; }
1
public boolean isInsideBounds(int x, int y) { return x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); }
3
public void setTotalNumberOfMatches(int totalNumberOfMatches) {this.totalNumberOfMatches = totalNumberOfMatches;}
0
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/mensaje.jsp"); ProfesorBean oProfesorBean = new ProfesorBean(); ProfesorParam oProfes...
1
final public void Variable_declaration() throws ParseException { /*@bgen(jjtree) Variable_declaration */ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLE_DECLARATION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { jj_con...
8
private int sendPacket(Packet packet) throws NotConnectedException, NullPacketException, CouldNotEncodePacketException, PacketIOException { int sequenceNumber = -1; synchronized(CONNECTION_LOCK) { //regardless of whether the packet is valid, if the client is not connected then throw a NotConnectedException if...
6
@Override public boolean editEmployeeSkills(UserSkillSet userSkillSet) { String userid = userSkillSet.getUserId(); List<SkillRating> updateList = userSkillSet.getSkills(); Connection connection = new DbConnection().getConnection(); PreparedStatement preparedStatement = null; boolean flag = false; try { ...
5
public JMenuItem mkMenuItem(ResourceBundle b, String menu, String name) { String miLabel; try { miLabel = b.getString(menu + "." + name + ".label"); } catch (MissingResourceException e) { miLabel=name; } String key = null; try { key = b.getString(menu + "." + name + ".key"); } catch (MissingResourceExceptio...
3