method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
3d4c330d-cbf0-4b2e-9418-39062ef9bc9d | 4 | public synchronized boolean isValid(){
try {
MessageDigest hasher = MessageDigest.getInstance("SHA");
byte[] result = hasher.digest(this.getData());
hasher.reset();
if(result.length != hash.length){
System.err.println("Hash check for piece " + this.index + " failed with hash length mismatch.");
re... |
2a17a4b4-7b63-4ba2-980d-f710154d5b14 | 4 | public static void chooseBestHand(BlackjackPlayer player) {
int playerDefaultScore = player.getDefaultScore();
int playerChangedAceScore = player.getChangedAceScore();
System.out.println("The score with the ace value as 1: " + playerDefaultScore);
System.out.println("The score with the ace value as 11: " + pla... |
8344f541-447e-4522-990c-e0c98deb1fcd | 3 | private synchronized void seed() {
// Silently ignore if we're already seeding.
if (ClientState.SEEDING.equals(this.getState())) {
return;
}
logger.info("Download of " + this.torrent.getPieceCount() +
" pieces completed.");
if (this.seed == 0) {
logger.info("No seeding requested, stopping client..... |
bd503b74-8ac1-4e2a-92ac-b075d333455f | 3 | public boolean isSpaceForCar(VehicleAcceptor r) {
List<Vehicle> cars = r.getCars();
if (cars == null) {
return true;
}
for (Vehicle c: cars) {
if (c.getBackPosition() <= this.getLength()) {
//System.out.println("Not Enough Room for " + this + " b/c " + c);
return false;
}
}
return true;
} |
a860fe86-ac3f-47fc-bbb0-4216792e2f55 | 6 | @EventHandler
public void WitchWaterBreathing(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getWitchConfig().getDouble("Witch.Wat... |
4dd8fecd-0327-4af8-96ff-c4a5769fb240 | 4 | @Override
public void run() {
while (!mainFrame.isGameOver()) {
try {
Thread.sleep(CYCLE_SLEEP_TIME);
if (!mainFrame.isPause()) {
cyclesCount++;
// move down if needed
int gravity = mainFrame.getLevel();
if (cyclesCount>=AUTO_MOVE_DOWN_MAX_CYCLES / gravity) {
cyclesCount = 0;... |
fb5fecc0-1d77-4ea9-aca3-425e4451d275 | 5 | private int calcPlusDef() {
if (plus <= 0 || plus > 15) {
return 0;
}
if (typ.equals(ItemTyp.PLATE)) {
return plus_plate[plus];
}
if (typ.equals(ItemTyp.HEAVY)) {
return plus_heavy[plus];
}
if (typ.equals(ItemTyp.LIGHT)) {
return plus_light[plus];
}
return plus_cloth[plus];
} |
0015c6ca-8db9-4012-ac6b-0f0ce5be277f | 4 | private void FormaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FormaActionPerformed
// TODO add your handling code here:
if((Vias.getSelectedItem()!="Vias de administracion") && (Forma.getItemCount())!=0){
if(Forma.getSelectedItem().equals("Forma")){
Tip... |
bd339773-38ee-4e3d-a3b2-fbcb2da16612 | 8 | @Override
public boolean equals(Object obj) {
if (!(obj instanceof Pair<?, ?>)) {
return false;
}
Pair<?, ?> otherPair = (Pair<?, ?>) obj;
return isEqualOrNulls(first, otherPair.getFirst())
&& isEqualOrNulls(second, otherPair.getSecond());
} |
6fb5ce87-2daf-43fb-939b-23a07e8229ec | 9 | public void invokeMain(String sClass, String[] args) throws Throwable {
Class<?> clazz = loadClass(sClass);
log("Launch: %s.main(); Loader: %s", sClass, clazz.getClassLoader());
Method method = clazz.getMethod("main", new Class<?>[] { String[].class });
boolean bValidModifiers =... |
cf3943da-8a25-4db2-bd81-0ea6834593b4 | 1 | public static void main(String[] args) {
ExecutorImplClassDemo executorImplClassDemo = new ExecutorImplClassDemo();
CompoundExecutorDemo compoundExecutorDemo = new CompoundExecutorDemo(executorImplClassDemo);
ExecutorImplClassDemo.RunnableImpl runnable = new ExecutorImplClassDemo.RunnableImpl();... |
9c5c86e8-4c5a-41da-8bb9-ab3ee8c95c3c | 4 | void updateButtons(Set<Direction> valids)
{
for ( DirectionButton b: this.buttons.values() )
b.setVisible(false);
if ( ( valids == null ) || ( valids.isEmpty() ) )
{
this.setVisible(false);
return;
}
for ( Direction d: valids )
... |
aca69516-f9ca-4d61-acce-f056235f44cd | 4 | public boolean isPressedOnce(int key) {
if (this.keys.containsKey(key) && this.keys.get(key)) {
if (!this.pressed.containsKey(key) || !this.pressed.get(key)) {
this.pressed.put(key, true);
return true;
}
}
return false;
} |
b5f86ad2-983c-4aed-8c59-a3e338ca9885 | 1 | private boolean jj_3_16() {
if (jj_3R_34()) return true;
return false;
} |
c267a66c-35f5-457b-8914-2bcb51dcd603 | 3 | private static int getBits(int i, BZip2BlockEntry blockEntry) {
int j;
do {
if (blockEntry.anInt577 >= i) {
int k = blockEntry.anInt576 >> blockEntry.anInt577 - i & (1 << i) - 1;
blockEntry.anInt577 -= i;
j = k;
break;
}
blockEntry.anInt576 = blockEntry.anInt576 << 8 | blockEntry.inputBuffe... |
b225bb0c-8dea-4982-8218-7e59a40942ff | 7 | public static void main(String[] args) throws Exception
{
HashMap<String, RawDesignMatrixParser> map = RawDesignMatrixParser.getByFullId();
List<String> bioinformaticsIds = RawDesignMatrixParser.getAllBioinformaticsIDs(map);
//for(String s : bioinformaticsIds)
// System.out.println(s);
List<String> tax... |
9c068fd1-1f49-45f4-9aef-e55b9c4bfc97 | 8 | public void replace(FilterBypass filterBypass, int offset, int length, String string, AttributeSet attributeSet)
throws BadLocationException {
super.replace(filterBypass, offset, length, string, attributeSet);
Document doc = filterBypass.getDocument();
_preText = doc.getText(0, doc.getLength(... |
82161579-84dc-4d1b-a157-8c7d6abdae74 | 0 | public void setTransforms(TransformsType value) {
this.transforms = value;
} |
4cf61499-d027-4e7b-85b2-a6f23fcf3a42 | 2 | @Override
public void show_TrisA(Integer value) {
PIC_Logger.logger.info("Showing Tris A");
int x=7;
for(int i = 0; i < 8; i++){
if( (value & (int)Math.pow(2, i)) == (int)Math.pow(2, i)){
regA.setValueAt("i", 0, x+1);
}
else{
regA.setValueAt("o", 0, x+1);
}
x--;
}
} |
4db66661-ef7a-44ad-922c-b43c0bf0f033 | 6 | String getSQLWhere() {
switch (relationship) {
case NOT_EQUALS: return columnName + " <> ?";
case GREATER_THAN: return columnName + " > ?";
case GREATER_THAN_OR_EQUALS: return columnName + " >= ?";
case LESS_THAN: return columnName + " < ?";
case ... |
b8d8c718-c37d-4739-8928-a2b7793aafa7 | 5 | public Packet read() {
try {
ByteBuffer header = ByteBuffer.allocate(4);
int code = socket.read(header);
if (code == 4) {
header.flip();
short id = header.getShort();
short len = header.getShort();
ByteBuffer data = ByteBuffer.allocate(len);
socket.read(data);
data.flip();
Packet ... |
4e25ba64-272d-4c9b-b213-4743f02a3e94 | 7 | public static boolean testCollectionofMemberOfP(Stella_Object member, Surrogate type) {
{ Object old$ReversepolarityP$000 = Logic.$REVERSEPOLARITYp$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setBooleanSpecial(Logic.$REVERSEPOLARITYp$, false);
Native.setSpecial... |
e6bbd0e7-71a5-453b-81e4-2b1043148f33 | 4 | public String get_field( String section, String field )
throws NoSuchKeyException, NoSuchSectionException {
Hashtable s;
String t;
if(section==null) {
throw new NoSuchSectionException();
}
if(field==null) {
throw new NoSuchKeyException();
}
s = (Hashtable) sections.get(section);
if( s == null) {
thr... |
745c69eb-2410-471e-8da0-95c1220cf17f | 4 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Rectangular that = (Rectangular) o;
if (length != that.length) return false;
return width == that.width;
} |
993ff938-523c-4383-9975-9fbb74a377f4 | 8 | public float [] compute(float [] x)
{
if (x.length != n)
throw new IllegalArgumentException("BIJfft not properly initialized");
float[] xre = new float[n];
float[] xim = new float[n];
for (int i = 0; i < n; i++)
... |
97e6d62c-6e6f-4137-80ba-a63ced72ff47 | 4 | protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
int b,c;
int[][] lookup = CHAR_TO_BYTE; // getfield bytecode optimization
int[] table;
int remaining = in.remaining();
while (remaining-- > 0) {
if (out.remaining() < 1)
... |
63c39ef8-0ffc-457a-9e0d-4abddc943ba5 | 3 | public RoomInfo(String mapName){
if(mapName.equals("Exterior1.tmx")){
upDoorPos = null;
downDoorPos = null;
leftDoorPos = new Vector2(1.25f,4.5f);
rightDoorPos = null;
upBoundry = 15f;
downBoundry = 1f;
leftBoundry = 1f;
... |
e161ae23-7ba0-4944-882a-6f2b1dfc45bb | 8 | @EventHandler(priority = EventPriority.LOW)
public void onExplosionEvent(final EntityExplodeEvent event) {
Location eventLocation = event.getLocation();
if (plugin.Blast_Mode.containsKey(eventLocation)) {
Integer BlastMode = plugin.Blast_Mode.get(eventLocation);
if (BlastMode == 0) {
... |
c6972875-34f9-466c-a3e6-a56da703a116 | 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... |
f4607e92-8e5f-4e2a-a8c7-560be8277875 | 0 | Point3 getVelocityTo(Obstacle o) {
Point3 velocity = o.getPosition().minus(myBeing.getPosition());
velocity.normalize();
return velocity;
} |
bf444d85-aa82-43a9-b154-7f2116a5b355 | 1 | public String getLinkName(Element tcElement){
if (tcElement.getName().equals("transitioncondition")){
Element source = (Element)tcElement.getParentElement();
return source.getAttributeValue("linkName");
}else{
return null;
}
} |
fed9971a-9c53-4576-b773-2314f375985a | 7 | public void sendFirst() {
System.out.println("-- Alice --");
if (betray) {
System.out.println("ACHTUNG: Betrugsmodus aktiv!!!");
}
// Hard coded messages M_0 and M_1
BigInteger[] M = new BigInteger[2];
M[0] = new BigInteger("11111111111111111111111111111111111111111111111111111111111");
... |
fa9e08ab-bbd1-4c1e-922b-49be66107400 | 3 | public List<Turma> pesquisaTurmasDoProfessor(String matriculaProf)
throws ProfessorInexistenteException {
List<Turma> turmasDoProfessor = new ArrayList<Turma>();
boolean flag = false;
for (Professor prof : this.professores) {
if (prof.getMatricula().equals(matriculaProf)) {
turmasDoProfessor = prof.tu... |
bd082cde-e67d-4582-9f28-fff8e417e533 | 5 | @RequestMapping(value = "del", method = RequestMethod.POST)
@ResponseBody
public Map del(@RequestParam int[] id) {
Map<String, Object> map = new HashMap<>();
List<String> l1 = new ArrayList<>();
List<String> l2 = new ArrayList<>();
List<String> l3 = new ArrayList<>();
f... |
b73b6f98-a561-4119-bf5b-a36c424d8f04 | 8 | public Item buildHouseplant(MOB mob, Room room)
{
final Item newItem=CMClass.getItem("GenItem");
newItem.setMaterial(RawMaterial.RESOURCE_GREENS);
switch(CMLib.dice().roll(1,7,0))
{
case 1:
newItem.setName(L("a potted rose"));
newItem.setDisplayText(L("a potted rose is here."));
newItem.setDescripti... |
558b87d7-f031-4feb-898c-2ca14005d993 | 1 | private void removeUseless(Grammar g)
{
UselessProductionRemover remover = new UselessProductionRemover();
Grammar g2 = UselessProductionRemover
.getUselessProductionlessGrammar(g);
Production[] p1 = g.getProductions();
Production[] p2 = g2.getProductions();
if (p1.length > p2.length) {
Gra... |
f1b10eef-c6e9-4c44-96b2-b0c8db249e47 | 2 | public static void invokeQuizRemoving(int id) {
for (QuestPoint q : campaign.getQuizes()) {
if (q.getId() == id) {
campaign.removeQuiz(q);
campaign.deleteTrue();
ProjectOptionsView.updateView();
break;
}
}
} |
f7bafed0-985e-4669-b597-911fb27a4889 | 4 | private void applyFileHandlers( Environment<String,BasicType> httpConfig )
throws ConfigurationException {
Environment<String,BasicType> httpSettings = httpConfig.getChild( Constants.KEY_HTTPCONFIG_FILEHANDLERS );
if( httpSettings == null ) {
this.getLogger().log( Level.INFO,
getClass().getName() + ".... |
2c70c9f6-2f99-4fbe-8fe9-8c9699419e9d | 3 | public static String filter(String str) {
String output = "";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
int asc = str.charAt(i);
if (asc != 10 && asc != 13) {
sb.append(str.subSequence(i, i + 1));
}
}
output = new String(sb);
return output;
} |
16b28d57-9c7d-42d4-bb1c-4b1323a23934 | 4 | static Object newObject(String className) {
if (Functions.isEmpty(className)) return null;
Class<?> c;
try {
c = Class.forName(cn(className));
} catch (Throwable e) {
return null;
}
Object returnObject;
try {
returnObject = c.newInstance();
} catch (Throwable e) {
return null;
}
return... |
8a8f840b-32d7-48ea-b248-841c382d4a7c | 7 | public static void main(String[] args) throws SlickException{
//establish game event factory
new ERGameEventFactory();
if(args.length==0){
args = new String[] {"-sc"};
}
if(args[0].equals("-s") || args[0].equals("-sc") ){//run the server on -s command
EmptyRoomServer serve... |
5a81d9cb-86c5-490f-af0b-492a68f92a4f | 5 | @Override
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets,
Rectangle bounds, TreePath path, int row, boolean isExpanded,
boolean hasBeenExpanded, boolean isLeaf) {
// if the given path is selected, ... |
e8201796-caf0-4d19-bd7a-b3ef0bc58eb8 | 0 | public PaymentEntity getPayment() {
return payment;
} |
736e573a-e468-43e2-8f26-088bd790d1a1 | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Subgoal subgoal = (Subgoal) o;
if (condition != null ? !condition.equals(subgoal.condition) : subgoal.condition != null) return false;
if (step... |
a883f3c4-70ce-468f-8cf1-aee1932408d9 | 5 | int unpack(Buffer opb){
int vendorlen=opb.read(32);
if(vendorlen<0){
clear();
return (-1);
}
vendor=new byte[vendorlen+1];
opb.read(vendor, vendorlen);
comments=opb.read(32);
if(comments<0){
clear();
return (-1);
}
user_comments=new byte[comments+1][];
com... |
c5aede06-0f68-44c7-92cc-17da95d77bd7 | 2 | public boolean clicked() {
if(key.isPressed() && !key.isHeld())
return true;
else
return false;
} |
1302face-2ebb-4347-8394-b5a63a243507 | 9 | public void update(int playerScores[]){
for(int i=0;i<playerScores.length;i++){
this.playerTotals[i] = playerScores[i];
this.l_playerTotals[i]
.setText(new Integer(playerScores[i]).toString());
}
p_playerScores.removeAll();
//f... |
125e5587-b4a7-48b1-a71b-0e6dcf90d4f3 | 8 | public static Color clipcol(int r, int g, int b, int a) {
if (r < 0)
r = 0;
if (r > 255)
r = 255;
if (g < 0)
g = 0;
if (g > 255)
g = 255;
if (b < 0)
b = 0;
if (b > 255)
b = 255;
if (a < 0)
... |
51ee3237-dc69-46d7-ba40-9627428200cf | 1 | private boolean jj_2_16(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_16(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(15, xla); }
} |
9cdaaa0e-f54b-4de5-a99c-7138bcc1404d | 2 | private void checkFolder() {
File KeywordFolder;
boolean stateKeywordFolder;
KeywordFolder = new File("./KeyWord");
stateKeywordFolder = KeywordFolder.exists();
if(stateKeywordFolder == false ){
System.out.println("The 'KeyWord' folder do not exist,trying to create one...");
stateKeywordFolder = Keywo... |
643ea2ec-cfa9-4040-9896-2abe27b8ae5b | 1 | private String pedirPista() {
if(pistasAgotadas()){
pistasUsadas++;
return diccionario.getPistaPalabraEspecifica(palabraActualObjeto)+"\n";
}
else{
return "Se agoto el numero de pistas";
}
} |
55a42b22-5872-44ec-be64-f1094b128a89 | 9 | private synchronized void unchokePeers(boolean optimistic) {
// Build a set of all connected peers, we don't care about peers we're
// not connected to.
TreeSet<SharingPeer> bound = new TreeSet<SharingPeer>(
this.getPeerRateComparator());
bound.addAll(this.connected.values());
if (bound.size() == 0) {
... |
915b71e4-690a-40cd-bfe9-c76565f8aa03 | 3 | public static void main(String[] args) throws KeyStoreException {
PlayerRepository<Schema.Player> repository = JacksonPlayerRepository.create("/master.player.json");
Iterable<? extends Player> players = Iterables.transform(repository.getPlayers(),Schema.TRANSFORM);
players = Iterables.filter(p... |
f879599c-42fc-4f1e-9da5-e445a3465577 | 8 | public void compile(String directory, String fileName) {
fileName = FileUtil.quoteFileName(fileName);
ConsoleDialog console;
if (editor != null) {
console = new ConsoleDialog(editor, "Compiling", false);
} else {
console = new ConsoleDialog();
}
console.setSize(500, 400);
console.setText("Compilin... |
b6f800be-090a-42a9-95f2-80fda1e0ee8d | 8 | public void processEvent(Event event)
{
if (event.getType() == Event.COMPLETION_EVENT)
{
System.out.println(_className + ": Receive a COMPLETION_EVENT, " + event.getHandle());
return;
}
System.out.println(_className + ".processEvent: Received Login Response..... |
e282bbc2-69a2-4133-9d1f-05549bbbc6d5 | 8 | public Node mergeNodes(Node node1, Node node2) {
Node superNode = new Node(node1.getId() + "-" + node2.getId());
addNode(superNode);
List<Node> connectedNodes = new ArrayList<Node>();
for (Node node : getAdjacentNodes(node1)) {
if (!node.equals(node1) && !node.equals(node2)) {
connectedNodes.add(node);
... |
011da0a0-84d8-448e-914d-3e0625c317e5 | 2 | public static List<Apple> filterGreenApples(List<Apple> inventory) {
List<Apple> filteredApples = new ArrayList<>();
for (Apple apple : inventory) {
if(Apple.AppleColor.GREEN.equals(apple.getColor())) {
filteredApples.add(apple);
}
}
return filtere... |
8d3506d4-81d6-4082-b5e7-9a63610c3268 | 6 | public void check() {
if (chrlist == null)
return;
if (selbtn == null)
return;
if (chr == null) {
chr = chrlist.opts.get(0).name;
} else {
String nm = null;
for (Listbox.Option opt : chrlist.opts) {
if (opt.disp... |
0c78e21a-0f56-4a3e-b232-805c33a86e22 | 1 | @Test
public void parseTestInfo() {
String str = Utils.getFileContents(TEST_INFO);
JSONObject testInfoJO = null;
TestInfo ti_actual = new TestInfo();
TestInfo ti_expected = new TestInfo();
ti_expected.setId("411711");
ti_expected.setName("load_test");
ti_expec... |
eba23f0d-72e8-46fa-bd0c-9f15dd9bd888 | 2 | public void createClient() {
Socket socket;
BufferedReader in;
PrintWriter out;
try {
socket = new Socket(InetAddress.getLocalHost(),5000);
System.out.println("Demande de connexion ...");
BufferedWriter w = new ... |
dfe81567-4091-4c56-9df4-07eb4e066531 | 3 | public boolean isTile(int x, int y)
{
return (x >= 0 && x < sea.length && y >= 0 && y < sea[0].length);
} |
fe2ba447-e758-4e0e-a28f-44bb97ccbe08 | 5 | @Override
public boolean isElementContentWhitespace() {
final String nodeValue = this.getNodeValue();
for (int i = 0, size = nodeValue.length(); i < size; i++) {
final char value = nodeValue.charAt(i);
if ((value > 0x20) || (value < 0x09)) return false;
if ((value != 0x0A) && (value != 0x0D)) return... |
96074fb8-d50e-49a8-af3e-1b8dc6f2e162 | 8 | public NewAd() {
setSize(new Dimension(620, 620));
setResizable(false);
setTitle("Edit Ad");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(200, 200, 620, 620);
setIconImage(Toolkit.getDefaultToolkit().getImage("ICON2_Scaled.png"));
contentPane = new JPanel();
contentPane.setBorder(new Lin... |
d620e92d-55ed-4f20-a30f-b83017c836e2 | 9 | private Collection<String> loadPrimaryColumns(String tableName) {
LinkedList<String> returnValue = new LinkedList<String>();
ResultSet rs = null;
try {
DatabaseMetaData metadata = connection.getMetaData();
SQLDatatbaseType sqlDatatbaseType = SQLDatatbaseType.getType(metadata.getURL());
/**... |
b9cfb760-bda4-486b-a5cc-f05e8de8be15 | 5 | private void load() {
long startTime = System.currentTimeMillis();
logger.info("Starting reload of soft state...");
// the next version of the soft state
final Map<KeyRegistrationRecord, Set<KeyRegistrationRecord>> topology = new ConcurrentHashMap<KeyRegistrationRecord, Set<KeyRegistrationRecord>>();
fi... |
c4f458c2-8a38-4583-8d23-4a4a587967b7 | 0 | public EditorPane(RegularExpression expression) {
// super(new BorderLayout());
this.expression = expression;
field.setText(expression.asString());
field.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
updateExpression();
}
});
field.getDocument().addDocum... |
6c06aa7a-9d54-40fb-8e3a-38c2c8e7ff79 | 7 | public static void main(String[] args) {
Client client = null;
try {
Socket socket = new Socket(host, port);
client = new Client(socket);
} catch (UnknownHostException ex) {
System.out.println("Don't know about server " + host + ":" + port);
... |
6c712180-3845-4560-bdf8-f01147585b0f | 4 | private int c2I(char c) {
int x = 0;
switch (c) {
case 'A': x = 0;
break;
case 'C': x = 1;
break;
case 'G': x = 2;
break;
case 'T': x = 3;
break;
default: x... |
e8e0adf3-bd11-4fda-ae36-bb9c35acf8f8 | 7 | public Perlin(int width, int height) {
random = new int[512];
Random r = new Random();
for (int i=0;i<512;i++) {
random[i] = r.nextInt(256);
}
data = new int[width][height];
for (int i=0;i<width;i++) {
for (int j=0;j<height;j++) {
... |
226692f5-48c6-499c-862d-62a40432e998 | 2 | public boolean Salvar(FormasPagamento obj){
PreparedStatement comando;
try{
if(obj.getId() == 0){
comando = banco.getConexao()
.prepareStatement("INSERT INTO tipos_pagamento "
+ "(nome,ativo) VALUES (?,?)");
coma... |
ad67e176-e959-42bd-a497-e6ca1c3a2ba0 | 5 | @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
HttpSession mensaje = request.getSession(true);
ResultSet respuesta=null;
PrintWriter out = response.getWriter();
... |
dc69e50a-f053-4885-903d-505435e0c5a6 | 9 | public void updateStates() {
for (Player p : players) {
if (p != null && !p.dead) {
p.update();
}
}
for (Attack a : attacks) {
if (a != null) {
a.update();
int y = a.getLoc().getY();
int x = a.getLoc().getX();
if (y < 0 || y > StartUp.height || x < 0 || x > StartUp.width) {
atta... |
f4e33b4b-a358-4214-a57e-a395c030ed9c | 6 | public void addNeuron(ArrayList<Connection> connects,Neuron neuron){
// THIS SHOULD NEVER RUN
if(connects.isEmpty()){
mutate();
return;
}
int connectionNum=rng.getInt(connects.size(),null,false);
Connection connection=connects.get(connectionNum);
/... |
2ccaceba-ad82-4c57-8212-7a194dba1a40 | 7 | public void jugarAjedrez(){
iniciarElTablero();
imprimirArreglo();
int aband;
setTurno1();
do {
try{
System.out.println("Es el turno del jugador "+getTurno());
System.out.print("Ingrese la Fila: ");
f... |
1ec9a631-a689-4091-8513-1b176adf95cb | 1 | public JSONObject toJson() {
JSONObject rtn = new JSONObject();
try
{
rtn.put("type", this.getClass().getSimpleName());
rtn.put("value", this.getValueForOutput());
} catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return rtn;
} |
b2cf49ce-f068-433b-980d-72e4d31703d4 | 2 | public Profile getProfile(String asAttendeeNumber) {
if (asAttendeeNumber == null || asAttendeeNumber.trim().length() == 0) {
throw new IllegalArgumentException("attendee num parameter is null");
}
return get(Profile.class, REST_URL_PROFILE + encode(asAttendeeNumber));
} |
ea7bae65-a459-4019-9e91-70574bece36d | 0 | public void onStop() throws JFException {
} |
d88c90f2-6453-4db6-854e-07f8f2a05b7b | 1 | public String getDescription() {
if(description==null)
return super.toString();
return description;
} |
6f901dfa-9919-431f-885a-3795eaa3a086 | 0 | public void setUnblocked(Account account){ account.setUnblocked(); } |
c3df7ba7-e0d6-41fe-887f-fd8af9a9f049 | 3 | public ArrayList<Team> getAllTeams(Connection con) {
ArrayList<Team> arrayTeams = new ArrayList();
String SQLString = "SELECT * "
+ "FROM Teams ";
PreparedStatement statment = null;
try {
statment = con.prepareStatement(SQLString);
ResultSet rs... |
6ebe42c1-5968-43f6-a25c-0559d61f2d4c | 8 | public static IntersectData colliders( Collider collider1, Collider collider2 )
{
if ( collider1 == null || collider2 == null )
return null;
if ( collider1.getType() == ColliderType.SPHERE && collider2.getType() == ColliderType.SPHERE )
return ( (SphereCollider) collider1 ).intersect( (SphereCollider) collid... |
d83108eb-e96f-4e6e-89bb-2f6e064f1c12 | 7 | public void drawMap(Graphics graphics){
if (this.background != null){
graphics.drawImage(background, this.position.x, this.position.y, null);
}
if ((grid != null) && (showGrid)){
grid.paintComponent(graphics);
}
if (showGridEditor... |
233663f3-3c7a-443c-b2c8-12657f759696 | 9 | private Resource parseText(String lineOfText) {
boolean done = false; // Indicates the end of parsing
String token; // String token parsed from the line of text
int tokenCount = 0; // Number of tokens parsed
int frontIndex = 0; // Front index or character position
int backIndex = 0; // Rear index or characte... |
766fe537-2056-4e68-9f3a-54b4eba1c10d | 5 | public Image getImage(final double W, final double H) {
final int WIDTH = (int) W;
final int HEIGHT = (int) H;
WritableImage DESTINATION = new WritableImage(WIDTH, HEIGHT);
final int[] IN_PIXELS = new int[WIDTH];
final int[] OUT_PIXELS = new int[WIDTH];
randomNumbers... |
155168d7-f1b4-4317-bc8b-a6ddd81e366f | 1 | public void setQty(int newQty) {
qty = newQty;
if (qty < 1) {
itemType = null;
qty = 0;
}
} |
c50d158a-99ad-4bff-995e-f67f5a7fd7f0 | 2 | @Override
public void run() {
long last = System.currentTimeMillis();
while (running) {
long now = System.currentTimeMillis();
long delta = now - last;
update(delta);
render();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
last = now;
}
} |
3e013735-40a6-4ed2-94b1-688be4da5e9f | 5 | public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, ((Integer) value).intValue() + 1);
} else if (value instanceof Long) {
... |
6e8096b7-4c73-40e8-8d07-e114498ffa39 | 2 | public void adjustSize(int width, int height) {
saving = true;
if(width > bi.getWidth() || height > bi.getHeight()) {
BufferedImage tempBi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tempBi.createGraphics();
this.paint(g);
g.dispose();
bi = tempBi;
} else {
Buffe... |
86d888d3-aeda-486f-a46a-37e0aba7f0e9 | 1 | @Override
protected void createReaderWriter() throws JoeException {
ourReaderWriter = new PdbTMReaderWriter() ;
if (ourReaderWriter == null) {
throw new JoeException(UNABLE_TO_CREATE_OBJECT) ;
}
} |
86e0ac38-5af0-47f3-a9e6-07b80eb1dd54 | 0 | private Set<Card> FourFlushWithWheelStraight() {
return convertToCardSet("JD,4S,8S,3S,5S,AC,2H");
} |
2e178fac-0d6d-478d-9291-bb4567262268 | 5 | public void dispatchEvent(Event event) {
if (!listeners.containsKey(event.getClass())) return;
Class<? extends Event> clazz = event.getClass();
while (clazz != null) {
for (Listener listener : listeners.get(event.getClass())) {
listener.onEvent(event);
}
... |
85a5bd60-8a9d-46af-b847-f196136705fd | 1 | public int getInt(String o) {
String i = ", ";
if (o.equals("avatarid"))
i = "}";
String v = Pattern.compile(o + ": ").split(line)[1];
return Integer.parseInt(v.substring(0, v.indexOf(i)));
} |
3a54687f-7833-4087-92b5-5eac5fbb1e1c | 7 | public void addCarriage(RollingStock newCarriage) throws TrainException {
if (train.isEmpty()) {
if (newCarriage instanceof Locomotive) {
train.add(newCarriage);
} else {
throw new TrainException(
"Invalid train configuration: Locomotive must be the first carriage.");
}
} else if (passenge... |
ffb7744b-579b-44b6-959a-3f9c47f1e168 | 8 | public static void main(String [] args) {
int[] d;
d = new int[10001]; // we'll ignore d[0];
for (int i = 1; i<10001; i++) {
// compute d(i)
int divisorSum = 0 ;
for (int j = 1; j<=1 + i/2; j++) {
if (i%j == 0) {
divisorSum += j;
}
}
d[i]=divisorSum;
}
int amicableSum = 0;
for ... |
6db4c48f-17aa-4f7d-8d73-25d10bc9b0f5 | 5 | private void rapatrierFormations() {
ArrayList<Formation> formations = new ArrayList<Formation>();
String req = "";
req = "select * from Formation";
ResultSet res = null;
try {
res = gestionUniversite.Connexion.getInstance().getStatement().executeQuery(req);
... |
478406df-4b74-4dcf-9fcd-7589b60b0532 | 3 | private void initialize()
{
setForeground(Color.white);
setOpaque(false);
setContentAreaFilled(false);
setBorderPainted(false);
if (name != null)
{
this.setText(name);
this.setToolTipText(name);
}
setVerticalTextPosition(SwingConstants.BOTTOM);
setHorizontalTextPositi... |
0346388f-62fc-446a-9c8c-1e48acd695b6 | 0 | public RegularGrammar getRegularGrammar() {
return (RegularGrammar) getGrammar(RegularGrammar.class);
} |
2a0c0e86-0a5c-4c5c-bf0d-9da8990fef13 | 5 | @Override
public void keyPressed(KeyEvent e) {
int keys = e.getKeyCode();
if (keys == KeyEvent.VK_ESCAPE) {
mainMenuObj.setMx(WINDOW_WIDTH);
currentMode = mode1;
ticTacToeFunctionsObj.clearPlayerScores(ticTacToePlayerObj);
for (int i = 0; i < 10; i++... |
a3a086bb-99e6-4017-ab67-f84343372774 | 0 | public String getBestScore() {
String res = "";
Collections.sort(scores);
res = scores.get(scores.size()-1);
return res;
} |
cba15ba8-e5e0-4659-af67-d82fde9a60b4 | 7 | public Copyable getVersion(Transaction me, ContentionManager manager) {
while (true) {
if (me != null && me.getStatus() == Status.ABORTED) {
throw new AbortedException();
}
switch (writer.getStatus()) {
case ACTIVE:
if (manager == null) {
throw new PanicExcept... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.