text
stringlengths
14
410k
label
int32
0
9
@Override public AbstractConnection toItem( ConnectionData data, DefaultUmlDiagram diagram ) { AbstractConnection connection = connection( data.getConnectionType(), data.getKey(), diagram ); DefaultBox<?> source = diagram.getDefaultBox( data.getSource() ); DefaultBox<?> target = diagram.getDefaultBox( data.ge...
2
public void correr(JLabel min, JLabel seg, JLabel seg2, float dt) { segundos2 = (int) dt; if (segundos2 != segundosViejo) { segundosViejo = segundos2; segundos2Cambio = true; } if (segundos2 - valorCambioSeg == 10) { segundos++; segundos2 = 0; segundosViejo = 0; valorCambioSeg += 10; segun...
7
private void eat() { //eat a character if (state == State.END) { return; } matchFound = false; if (state == State.EAGER) { int curStrPosition = strPosition; int curPtnPosition = ptnPosition; strPosition++; ptnPosition...
5
protected void handleCommandResultWithoutWaitingForACommand(String commandResult) { if (commandResult != null) { if (!resultExpected.get() ) { if (proxyInjectionMode) { // This logic is to account for the case where in proxy injection mode, it is possible // that a page ...
8
public Account getAccount(int index) { if (index < 0 || index >= accounts.length) { throw new IllegalArgumentException("Cannot retrieve account #" + index); } return accounts[index]; }
2
public Double[] getConsumption() { ArrayList<Double> temp = new ArrayList<Double>(); int times = getOuterN(); if (times == 0) times = 2; // Number of repeats for (int i = 0; i < times; i++) { // System.out.println("Time: " + i); // Number of patterns in each repeat for (int j = 0; j < getPattern...
7
private <T> PlaybackOperation generateOperation(Action<T> action) { switch (action.type) { case BGPALETTE: return new WriteBgPaletteDirect(action.position, (Palette)action.value, true); case OBJPALETTE: return new WriteObjPaletteDirect(action.position, (Palette)action.value, true); case HRAM...
8
private static boolean isPrimitiveOrString(Object target) { if (target instanceof String) { return true; } Class<?> classOfPrimitive = target.getClass(); for (Class<?> standardPrimitive : PRIMITIVE_TYPES) { if (standardPrimitive.isAssignableFrom(classOfPrimitive)) { return true; ...
5
public CheckResultMessage checkTotal2(int i) { int r1 = get(6, 5); int c1 = get(7, 5); int r2 = get(8, 5); BigDecimal sum = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); for (int j = 1; j < r2 - r1; j++) { ...
7
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); Connection conn = null; Statement stmt = null; ...
8
public void printContacts(Set<Contact> returnContacts) { Iterator<Contact> it = returnContacts.iterator(); while (it.hasNext()) { Contact holder = it.next(); System.out.print("ID: "); System.out.print(holder.getId()); System.out.print(" Name: "); System.out.print(holder.getName()); System.out.pri...
1
@Override public void run() { while (this.isRunning()) { Socket sckt; try { sckt = ssckt.accept(); //Check if only local connections are allowed and whether this is a local one or not if ((this.conMan.getHot...
6
*/ public int getBulletType() { Element[] elem = getSelectedParagraphs(); if (elem == null || elem.length == 0) return -1; StyledDocument doc = getStyledDocument(); Element head = null; Icon[] icon = new Icon[elem.length]; for (int i = 0; i < elem.length; i++) { head = doc.getCharacterElement(elem[i]...
7
private PlayerSelectFrame(String prompt, String[] players) { super("Quantum Werewolves"); this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.players = players; this.label = new JL...
4
public AnnotationVisitor visitAnnotationDefault() { AnnotationVisitor av = mv.visitAnnotationDefault(); return av == null ? av : new RemappingAnnotationAdapter(av, remapper); }
1
public Object get(int index) { return vertices.get(index); }
0
private boolean numberInUse() { if (tfEmployeeNumber.getText().isEmpty() || !Utils.isNumeric(tfEmployeeNumber.getText())) { lblNumberInUse.setVisible(false); return true; } else { Employee existingEmployee = RoosterProgramma.getInstance().getEmployee(Integer.parseInt(...
6
@Override public Object getValueAt(Object node, int column){ if (column == 0) return node; else { DefaultMutableTreeTableNode ttNode = (DefaultMutableTreeTableNode) node; if (ttNode.getUserObject() instanceof Job) { Job job = (Job) ttNode.getUserObject(); switch (column) { case 1: retur...
9
public synchronized EquationBTreeNode getParent() {return parent;}
0
public void setTool(int i) { tool = i; if (tool == 3) l2 = 0; if (tool == 2) l = 0; }
2
public boolean isAlive() { if (getShip().isDead() || getShip().getId() == null) { status = PlayerStatus.DEAD; getShip().die(); ship = null; shipId = null; } return status == PlayerStatus.ALIVE; }
2
public static boolean ignoreSQLException(String sqlState) { if (sqlState == null) { //System.out.println("The SQL state is not defined!"); return false; } // X0Y32: Jar file already exists in schema if (sqlState.equalsIgnoreCase("X0Y32")) { return true...
3
void open() { // File parameters dirName = Gpr.dirName(fastqFile); ext = Gpr.extName(fastqFile); baseName = Gpr.baseName(fastqFile, "." + ext); // Open files try { file = new File(fastqFile); if (!file.canRead()) error("Cannot read file '" + fastqFile + "'"); raf = new RandomAccessFile(file, "r");...
2
public void setGuardAngle(float angle) { if(angle < 0) { guardAngle = angle + MathUtil.PI * 2; } else { guardAngle = angle; } }
1
public void renderObjects(){ for (GameObject gameObject : objectList) { gameObject.render(); } }
1
public void setLogLevel(final String name) { Level level; try { level = Level.parse(name); } catch (final Exception e) { level = CustomPlugin.DEFAULT_LOG; this.getLogger().warning("Log level defaulted to " + level.getName() + "; Unrecognized java.util.logging.Level: " + name + ";...
3
public Builder published(Date published) { this.published = published; return this; }
0
protected void initialize() { Robot.tilter.moveDown(); }
0
public void testSimulate(){ DebicccdGA g = new DebicccdGA(""); g.generateInitialPopulation(6); g.printPopulation(); g.simulatePopulation(""); g.generateNextPopulation("roulette"); System.out.println(); for(Double d : g.fitness) System.out.print(d + " : "); for(int i = 0; i < 1000...
3
public Socket close() { EventThread.exec(new Runnable() { @Override public void run() { if (Socket.this.readyState == ReadyState.OPENING || Socket.this.readyState == ReadyState.OPEN) { Socket.this.onClose("forced close"); logger.fin...
2
public StraightTrajectory(Lane lane) { fLane = lane; Point2D p1 = lane.getStart().getPosition(); Point2D p2 = lane.getEnd().getPosition(); double deltaX = p2.getX() - p1.getX(); double deltaY = p2.getY() - p1.getY(); if (deltaX != 0) { fA = (deltaY) / (deltaX); fB = p1.getY() - fA * p1.getX(); ...
9
public void draw(Graphics2D g) { for( int row = rowOffset; row < rowOffset + numRowsToDraw; row++) { if(row >= numRows) break; for( int col = colOffset; col < colOffset + numColsToDraw; col++) { if(col >= numCols) break; if(map[row][col] == 0) continue; ...
5
@Test public void runTestHashMapAccess1() throws IOException { InfoflowResults res = analyzeAPKFile("ArraysAndLists_HashMapAccess1.apk"); Assert.assertEquals(0, res.size()); }
0
public final boolean equals(Object o) { if (!(o instanceof Entry)) return false; Entry e = (Entry)o; Object k1 = Long.valueOf(getKey()); Object k2 = Long.valueOf(e.getKey()); if ((k1 == k2) || ((k1 != null) && (k1.equals(k2)))) { Object v1 = getValue(); Object v2 = e.ge...
7
public void testSetIntoIntervalEx_Object_Chronology2() throws Exception { MutableInterval m = new MutableInterval(-1000L, 1000L); try { StringConverter.INSTANCE.setInto(m, "/", null); fail(); } catch (IllegalArgumentException ex) {} }
1
protected String fetch(String url, String caller, boolean write) throws IOException { // check the database lag logurl(url, caller); do // this is just a dummy loop { if (maxlag < 1) // disabled break; // only bother to check every 30 seconds ...
8
public MergerView(Console consoleStream, DefaultListModel currentModel) { super("CWRC Data Merger"); this.setSize(1024, 768); this.consoleStream = consoleStream; this.currentListModel = currentModel; //Add the console output console = new JTextArea(); consoleSt...
7
public MetricsLite(Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin = plugin; // load the config configurationFile = getConfigFile(); configuration = YamlConfiguration.loadConfigura...
2
@Override public O_5x_AbstractDataType deserialize(ByteBuf bb) { String adc = Serialization.getString(bb); String oadc = Serialization.getString(bb); String ac = Serialization.getString(bb); Character nrq = Serialization.getCharacter(bb); String nadc = Serialization.getString(bb); Character nt = Serializat...
4
public void mouseEntered(MouseEvent e) { mouseMoved(e); }
0
protected void regraph() { if( site != null ) { site.regraph(); } }
1
@Override public String saveAnswer(Question question) { if(question == null){ return "Не передан объект вопроса"; } if (question.getIdTest() == null){ return "В переданом объекте отсутствует ссылка на тест"; } if (question.getIdQuestion() == null){ ...
6
public void saveGameState(ArrayList<InfoPacket> packets, String fileName) { String output = new String(); Iterator<InfoPacket> packetIter = packets.iterator(); InfoPacket pckt = null; while(packetIter.hasNext()) { pckt = packetIter.next(); Iterator<Pair<?>> namedValueIter = pckt.namedValues.iter...
5
public void ObtainPHPFileVariables(DatabaseAccess JavaDBAccess, String TargetPHPFileSelected) { int TARGET_PHP_FILES_ID = 0; PreparedStatement ps = null; String PHPFileText = "", PHPFileTextClean = ""; //The text of the PHP file where we want to inject the vulnerabilities String[] RegEx...
9
public static int readPackInt(DataInput br) throws IOException { int prefix = br.readUnsignedByte(); int bytes, value; if ((prefix & 0x78) == 0x78) { bytes = 4; value = (prefix & 0x7) << 32; } else if ((prefix & 0x70) == 0x70) { bytes = 3; ...
6
private void displayValidationErrorDialog(boolean creationAttempted, List<Invalid> errors) { if (!errors.isEmpty()) { JPanel content = new JPanel(new BorderLayout(0, 8)); JLabel label = new JLabel( (creationAttempted ? "Your game could not be created due to the following " : "Your game has the f...
5
@Override public Station[] getStations() { return this._stations; }
0
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setColor(getBackground()); g2d.fillRect(0, 0, getWidth(), getHeight()); if(list != null && list.size() > 0){ drawList(g2d, list); } }
2
public List<Fleet> MyFleets() { List<Fleet> r = new ArrayList<Fleet>(); for (Fleet f : fleets) { if (f.Owner() == 1) { r.add(f); } } return r; }
2
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Event other = (Event) obj; if (eventType == null) { if (other.eventType != null) return false; } else if (!eventType.equals(other.eventT...
6
public void setValidatorRHS(Validator<T> validatorRHS) { this.validatorRHS = validatorRHS; }
0
public static void paint(Ocean sea) { if (sea != null) { int width = sea.width(); int height = sea.height(); /* Draw the ocean. */ for (int x = 0; x < width + 2; x++) { System.out.print("-"); } System.out.println(); for (int y = 0; y < height; y++) { System...
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."); ...
7
@Override public void documentAdded(DocumentRepositoryEvent e) {}
0
public static void main(String[] args) { int counter = 0; for (int firstCard = 2; firstCard <= 14; firstCard++) { for (int secondCard = 2; secondCard <= 14; secondCard++) { if (secondCard == firstCard) continue; for (int firstSuit = 1; firstSuit <= 4; firstSuit++) { for (int secondSuit = firstS...
8
public MainUserWindow(int a) { cn = getContentPane(); cn.setLayout(null); accno = a; header = new JLabel("CUSTOMER", JLabel.CENTER); footer = new JLabel("Logged in with Account No : " + accno, JLabel.LEFT); bCheck = new JButton("View Customer Profile"); bView = new JButton("View Transactions"); bPa...
8
public Object[] list() { ArrayList<Object> ret = new ArrayList<Object>(); while(true) { if(off >= blob.length) break; int t = uint8(); if(t == T_END) break; else if(t == T_INT) ret.add(int32()); else if(t == T_STR) ret.add(string()); else if(t == T_COORD) ret.add(coord()); ...
7
@Override public void create(String name, String author, String website, Path img) throws IOException { if ((name == null) || name.equals("")) { IllegalArgumentException iae = new IllegalArgumentException("Name is null or empty!"); Main.handleUnhandableProblem(iae); } ...
5
public void food(int count, int recursive, int length) { while(recursive < 3) { if(foodSpaceClear == true) { for(int i = 0; i < length; i++) { world[randRow+count][i+randCol].setFood(true); //Creates the line in the centre and the lines world[randRow+count][i+randCol].setFoodAmount(5); //above the...
4
public static void main(String[] args) { double x=0,y=0; boolean entra=false; do{ try{ System.out.print("Valor x => "); x=Double.parseDouble(stdin.readLine()); System.out.print("Valor y => "); y=Double.parseDouble(stdin.readLine()); entra=false; }catch(Exception e){ System.out.println("Valor...
3
@Override public QL factor(DenseMatrix A) { if (Q.numRows() != A.numRows()) throw new IllegalArgumentException("Q.numRows() != A.numRows()"); else if (Q.numColumns() != A.numColumns()) throw new IllegalArgumentException( "Q.numColumns() != A.numColumns()"...
7
public Document toDOM(java.io.Serializable structure) { LSystem lsystem = (LSystem) structure; Document doc = newEmptyDocument(); Element se = doc.getDocumentElement(); // Add the axiom. se.appendChild(createComment(doc, COMMENT_AXIOM)); se.appendChild(createElement(doc, AXIOM_NAME, null, listAsString(l...
4
public void setRXAxisDeadZone(float zone) { setDeadZone(rxaxis,zone); }
0
public static final String toRoman(int number) { if (number < 1) { throw new IllegalArgumentException("Number must be greater than 0"); //$NON-NLS-1$ } String text = "I"; //$NON-NLS-1$ int closest = 1; for (int i = 0; i < ROMAN_VALUES.length; i++) { if (number >= ROMAN_VALUES[i]) { closest = ROMAN_V...
4
public MCTSNode UCTSelectChild() { MCTSNode selected = null; double best = -1; for (MCTSNode node : children){ if (node.getMove().getType().equals(MoveType.PASS) && selected == null){ selected = node; } else { //disincentivize playing on the edges double ratio; if (node.getMove().getX()==0 |...
8
public static int PovSwitch(int pov, int playerID) { if (pov < 0) return playerID; if (playerID == pov) return 1; if (playerID == 1) return pov; return playerID; }
3
private void airfieldJListSelectionChanged(ListSelectionEvent listSelectionEvent) { if(airfieldJList.getSelectedIndex() >= 0){ try{ Airfield theAirfield = (Airfield)airfieldJList.getSelectedValue(); currentData.setCurrentAirfield(theAirfield); cur...
4
private static String readField(FileInputStream in) throws IOException { String str = ""; for (char c = (char)in.read(); !Character.isWhitespace(c) && c != '\n'; c = (char)in.read()) str = str.concat(String.valueOf(c)); return str; }
2
public void receiveAcceptRequest(int uniqueId,BallotNumber proposal, double value) { if(value>0) senders.add(uniqueId); if(acceptedValues.containsKey(value)){ acceptedValues.put(value, acceptedValues.get(value)+1); } else { acceptedValues.put(value,1); } if(acceptedValues.get(value) >= quo...
7
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Category category = (Category) o; if (colorCode != category.colorCode) return false; if (id != category.id) return false; if (headLine ...
7
@Override protected List<ByteBuffer> onRelease() { List<ByteBuffer> dump = new ArrayList<ByteBuffer>(); ByteBuffer buffer; // For each pool of buffers... for (int i = 0; i < pool.length; i++) { // Pop every buffer off the current stack and add it to the list. while ((buffer = pool[i].pop()) != null)...
2
public Collection pdomChildren(final Block block) { if (domEdgeModCount != edgeModCount) { computeDominators(); } return block.pdomChildren(); }
1
public int getCellAddress(int n) throws Exception { if(n >= numSpillCells || n < 0) { throw new Exception("Invalid spill cell"); } return freeAddress + (n * Type.getWordSize()); }
2
public double associationClassesAttribute(double[][] counts){ List<Integer> supportSet = new ArrayList<Integer>(); List<Integer> not_supportSet = new ArrayList<Integer>(); double separability = 0; int numValues = counts.length; int numClasses = counts[0].length; int total = 0; double[]...
9
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((message == null) ? 0 : message.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); return result; }
2
@EventHandler(ignoreCancelled = true) public void reloader(ChunkLoadEvent event) { Chunk c = event.getChunk(); int x = c.getX(); int z = c.getZ(); String world = c.getWorld().getName(); Location loc; net.minecraft.server.v1_7_R1.World notchWorld; V10Dragon v10dragon; for(LivingEntity d: RideThaDragon.dragon...
5
public void getAllGenes() throws FileNotFoundException, IOException{ System.out.println("getting all genes from " + bed12Fname); allTranscr = new ArrayList(); geneLengths = new HashMap<String, Integer>(); TextFile bed12 = new TextFile(bed12Fname, false); String[] els = bed12.r...
3
@Override public IEmailKontakt last() throws NoEmailKontaktFoundException { EmailKontaktList emailContacts = readContacts(); if (emailContacts.getContactList().size() == 0) { throw new NoEmailKontaktFoundException("Kein Kontakt gefunden!"); } else return emailContacts.getContactList().get( emailContac...
1
public static Map<String, PropertyDescriptor> getPropertyDescriptors(Class<?> clazz) throws IntrospectionException { Map<String, PropertyDescriptor> propertyDescriptors = PROPERTY_DESCRIPTOR_CACHE.get(clazz); if (propertyDescriptors == null) { BeanInfo beanInfo = Introspector.getBeanInfo(clazz); propertyDesc...
3
void sortDescent (int [] items) { /* Shell Sort from K&R, pg 108 */ int length = items.length; for (int gap = length / 2; gap > 0; gap /= 2) { for (int i = gap; i < length; i++) { for (int j = i - gap; j >= 0; j -= gap) { if (items [j] <= items [j + gap]) { int swap = items [j]; items [j] = items ...
4
public synchronized boolean remover(int i) { try { new InstituicaoCooperadoraDAO().remover(list.get(i)); list = new InstituicaoCooperadoraDAO().listar(""); preencherTabela(); } catch (Exception e) { return false; } return true; }
1
public void set(Set productions, String variable, String lookahead) { int[] r = getLocation(variable, lookahead); entries[r[0]][r[1]].clear(); entries[r[0]][r[1]].addAll(productions); }
0
public void nextMove() { int direction = getDirection(); if (isMove && isAValidDirection(direction)) { progress(PIXELS); nextPhotogram(); } if (!isAValidDirection(direction) && nextDirection != direction) { setDirection(nextDirecti...
4
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equalsIgnoreCase("candy")) System.out.print("end candy"); }
1
public void add(String tableName, List<String> args) throws DBUnavailabilityException, DataBaseRequestException, DataBaseTableException { if (args.isEmpty()) { throw new DataBaseRequestException("zero args in request list"); } String key = args.get(0); if (key ==...
2
@Override public void actionPerformed(ActionEvent event) { try { commitEdit(); } catch (ParseException exception) { invalidEdit(); } }
1
@SuppressWarnings("unchecked") private static List<Operation> messageToOperationList(Object operationMessagesObj) { List<?> operationMessages = (List<?>) operationMessagesObj; List<Operation> operations = new ArrayList<>(); for (Object operationMessage : operationMessages) { operations.add...
3
public static String trimLeadingWhitespace(String str) { if (!hasLength(str)) { return str; } StringBuilder sb = new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) { sb.deleteCharAt(0); } return sb.toString(); }
3
public void darBajaUsuario(String nick){ try { String queryString = "DELETE FROM Usuarios WHERE nick=?"; connection = getConnection(); ptmt = connection.prepareStatement(queryString); ptmt.setString(1, nick); ptmt.executeUpdate(); System...
5
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
6
void doStand() { if (gameInProgress == false) { message = "Click \"New Game\" to start a new game."; repaint(); return; } gameInProgress = false; while (dealerHand.getBlackjackValue() <= 16 && dealerHand.getCardCount() < 5) dealerHand.addCard( deck.dea...
7
@Override public void mouseDragged(MouseEvent evt) { if (!SwingUtilities.isRightMouseButton(evt)) { return; } Point current = evt.getPoint(); double x = viewer.getCenter().getX() - (current.x - prev.x); double y = viewer.getCenter().getY() - (current.y - prev.y);...
4
void generateTree(int nNodes) { boolean [] bConnected = new boolean [nNodes]; // start adding an arc at random int nNode1 = random.nextInt(nNodes); int nNode2 = random.nextInt(nNodes); if (nNode1 == nNode2) {nNode2 = (nNode1 + 1) % nNodes;} if (nNode2 < nNode1) {int h = nNode1; nNode1 = nNode2; ...
8
public int getX(int index) { if(index <= this.index) return line[index][0]; else return -1; }
1
public void setReferenceList(ReferenceList value) { this.referenceList = value; }
0
public SOM(GridType gridType, int[] gridParams, Node.CostMethod costMethod, Node.UpdateMethod updateMethod, Node.NeighborhoodFunction neighborFunction, double initialLearningRate, DistanceFunction distFunction, double initialRadius, double timescale, int nIterations, TwoMomentEnsemble ensemble, String variableNam...
8
@Override public void processEntity(Entity entity) { // Ensure that we also remove any children entites owned by the parent Children childrenComponent = entity.getComponent(Children.class); if (childrenComponent != null) { for (Entity child : childrenComponent.children) { entityManager.removeEntity(child)...
2
public static int solution(int[] A) { if(A.length == 0) return -1; int[] temp = new int[A.length]; for(int i = 0; i < A.length; i++) temp[i] = A[i]; Arrays.sort(temp); for(int i = 0; i < A.length; i++) { int index = binarySearch(temp, 0, temp...
9
protected List<EmoteObj> parseEmotes() { if(emotes!=null) return emotes; broadcast=false; emoteType=EMOTE_TYPE.EMOTE_VISUAL; emotes=new Vector<EmoteObj>(); String newParms=getParms(); char c=';'; int x=newParms.indexOf(c); if(x<0){ c='/'; x=newParms.indexOf(c);} if(x>0) { final String oldParm...
9
public static Keyword oldInterpretOrScores(ControlFrame frame, Keyword lastmove) { if (lastmove == Logic.KWD_DOWN) { { PartialMatchFrame pmf = frame.partialMatchFrame; if (pmf == null) { ControlFrame.createAndLinkPartialMatchFrame(frame, Logic.KWD_OR); } else { { ...
9