method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
46c2de9a-e6e0-4ef6-a3fd-08ec8e1269c8 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Name other = (Name) obj;
if (!Objects.equals(this.newName, other.newName)) {
return false;
... |
896a0f2d-2924-4451-9519-d3183170806d | 2 | private void jBtnBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBorrarActionPerformed
// TODO add your handling code here:
try {
jTextField1.setText("Buscar por Cliente");
String sql = "DELETE FROM pedidos WHERE idpedidos = ? ";
String sq... |
82a61ba3-0699-4fbe-91e3-7227a87030de | 5 | private static boolean checkMove(int inputX, int inputY, int [][] board, int playerNumber) {
if ((inputX <= 8 && inputX >= 1) && (inputY <= 8 && inputY >= 1) &&
(board[inputX-1][inputY-1]== 0)){
board[inputX-1][inputY-1] = playerNumber;
return true;
}
else{
return false;
}
} |
6856792f-5082-4ec5-baaa-a1d4c5298ffe | 3 | public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if (action.equals("Pausieren")) {
Status.pause = true;
Gui.stopButton.setText("Fortsetzen");
}
if (action.equals("Fortsetzen")) {
Status.pause = false;
Gui.stopButton.setText... |
a08fd0fc-71e4-482c-b2b7-30f8df48e69c | 2 | public void draw(Graphics g) {
for (GameElement gameElement : gameElements) {
gameElement.draw(g);
}
if (FPS_SHOW) {
g.setColor(Color.RED);
int position = unit.value * 2;
g.drawString("FPS: " + Integer.toString(fps), position, position);
}
} |
832a8953-a062-4677-87cc-d1fc21ad4a55 | 6 | private void createNewEnemies(){
enemies.clear();
Enemy e;
if(waveNumber == 1){
for(int i = 0; i<4;i++){
enemies.add(new Enemy(1,1));
}
}
if(waveNumber == 2){
for(int i = 0; i<8;i++){
enemies.add(new Enemy(1,1));
}
enemies.add(new Enemy(1,2));
enemies.add(new Enemy(1,2));
}
if(wa... |
1a877fea-15cc-4512-89ce-0226d7dcde57 | 9 | public void refreshField(){
this.removeAll();
for(int i = 0; i < 16; i++) {
for(int j = 0; j < 16; j++) {
blocks[i][j] = new Character();
blocks[i][j].setXPosition(i);
blocks[i][j].setYPosition(j);
}
}
String playerName;
for(Iterator<?> i = GameClient.gameState.getPlayers().keySet().it... |
e536a9a7-1172-495f-afdc-65fdb7f18d22 | 2 | public int desiredPrime(int num) {
// Create an array to hold primes
ArrayList<Integer> primeList = new ArrayList<Integer>();
int desiredPrime = 0;
for (int i = 2; primeList.size() < num; i++) {
if (isPrime(i)) {
primeList.add(i);
}
}
desiredPrime = primeList.get(primeList.size() - 1);
ret... |
52b688fd-ad5a-47dc-8692-da821bdcbc42 | 6 | @Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
boolean success;
if (!owningPlugin.isEnabled()) {
return false;
}
if (!testPermission(sender)) {
return true;
}
try {
success = executor.onCommand(sender, this, commandLabel, args);
} catch (Throwable... |
8c99ddd7-5b2c-473f-9c9a-a71807d6bd04 | 3 | public boolean matches() {
// How does this work?
// First, always check if the top matches, that is end of sequence and
// latest character
// then go back into history
// probably bad performance.
// TODO: I have a better idea with 2 arrays, 1 for the sequence and 1
// whether the specific character ma... |
b3474535-1bde-4063-bb58-07e93bd7feee | 6 | private Vertex[] parseData(String fileName) throws IOException {
BufferedReader read = new BufferedReader(new FileReader(fileName));
ArrayList<Vertex> vertices = new ArrayList<>();
String line = read.readLine();
lines += 1;
Vertex[] lastLine = new Vertex[1];
while (true) {
String[] parts = line.split(" "... |
c97ce1a5-14a5-4634-8e8d-c49267d32b4d | 1 | public void testSetStartMillis_long2() {
MutableInterval test = new MutableInterval(TEST_TIME1, TEST_TIME2);
try {
test.setStartMillis(TEST_TIME2 + 1);
fail();
} catch (IllegalArgumentException ex) {}
} |
d112fc72-96b0-44c7-8b4a-3a9c70e45085 | 5 | @Override
protected final boolean isMouseOnSelection(final SELECTION selection) {
final float x = Mouse.getX();
final float y = Mouse.getY();
float loc;
float size;
if (selection.equals(SELECTION.YES)) {
loc = 0.25f;
size = 2.0f;
} else if (selection.equals(SELECTION.NO)) {
loc = 0.5f;
size = 6... |
9e4bf086-2a2b-496d-8474-493ba12d36d2 | 9 | protected void loadFields(com.sforce.ws.parser.XmlInputStream __in,
com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException {
super.loadFields(__in, __typeMapper);
__in.peekTag();
if (__typeMapper.isElement(__in, CreatedBy__typeInfo)) {
... |
2f923927-3e5b-441c-af2c-ee6a3679de3b | 4 | public boolean[] classify(int datapoint) {
double hypothesis;
boolean[] class_list = new boolean[classes];
int c, f, i;
//System.out.println("Classifying:");
for (c = 0; c < classes; c++) {
hypothesis = 0;
//System.out.println(" "+data.classlist[c]+":");
for (f = 0; f < features; f++) {
//Sy... |
2edb76ca-4a7b-436e-b353-09fda801e294 | 5 | private void openCD() {
String dir;
while((dir=findCD()) == null);
System.out.println(dir);
InputStream toc = null;
try {
toc = cdda.getTocAsXml(dir);
//if(false) throw new IOException();
} catch (IOException e) {
e.printStackTrace();
} catch (RuntimeException e){
e.printStackTrace();
}
St... |
b13bb1b5-ade1-40c2-b354-c560b669455b | 7 | public CollisionBuffer(GameObject o1, GameObject o2) {
//Set member variables
obj1 = o1;
obj2 = o2;
obj1CollidedSide = new Vec(2);
obj2CollidedSide = new Vec(2);
obj1Heading = obj1.getForward();
obj2Heading = obj2.getForward();
//Get difference in left side of obj1 from right side of obj2 posit... |
d79c09b5-6c44-4d63-9a8d-e0ddef9c2c3a | 0 | private void reset() {
ball = getBall();
ball.setSpeed((int) (height * BALL_SPEED)); // 6
points = 0;
_points = 0;
down = networkGameType == NetworkGameType.MASTER;
player.setY(0);
ai.setY(0);
repaint();
} |
88107a29-8f1c-4082-ad9a-3d7dd6b77620 | 7 | public int getLastVisibleLine() {
int lastLine = textArea.getLineCount() - 1;
if (isCodeFoldingSupportedAndEnabled()) {
int foldCount = getFoldCount();
if (foldCount>0) {
Fold lastFold = getFold(foldCount-1);
if (lastFold.containsLine(lastLine)) {
if (lastFold.isCollapsed()) {
lastLine = ... |
81984ec1-b828-4553-831c-804d8434ce3c | 7 | private Color calcDestColor(Color sourceColor, Color backgroundColor, double lightValue) {
double sourceRed = (double) sourceColor.red / 255.0;
double sourceGreen = (double) sourceColor.green / 255.0;
double sourceBlue = (double) sourceColor.blue / 255.0;
double sourceAlpha = (double) so... |
26d54ffa-a200-4ea3-aeae-1f4efc030dd7 | 6 | @Override
public Group parse() {
if(!this.prepared) {
this.prepared = true;
StringBuilder sB = new StringBuilder();
sB.append("(");
Iterator<Object> elemIterator = this.elems.iterator();
while(elemIterator.hasNext()) {
Object eRaw = elemIterator.next();
if(eRaw instanceof Elem) {
... |
7552d33b-7012-4f98-9fe9-2a9ddf7daf7f | 3 | private void moveSelection(int xm) {
if (pressedTimer > 0) return;
selected += xm;
if (selected < 0) selected += selectionCount;
if (selected >= selectionCount) selected -= selectionCount;
pressedTimer += 10;
} |
326b1214-ea04-4a73-b9a6-6702a8bf06e7 | 6 | void createExampleWidgets () {
/* Compute the widget style */
int style = getDefaultStyle();
if (shadowInButton.getSelection ()) style |= SWT.SHADOW_IN;
if (shadowNoneButton.getSelection ()) style |= SWT.SHADOW_NONE;
if (shadowOutButton.getSelection ()) style |= SWT.SHADOW_OUT;
if (leftButton.getSelectio... |
980d5da5-7afe-4167-9611-a13772312c47 | 1 | public static void main(String[] args) {
Context context = new Context();
ArrayList<AbstractExpression> list = new ArrayList<AbstractExpression>();
list.add(new TerminalExpression());
list.add(new TerminalExpression());
list.add(new NonterminalExpression());
list.add(new ... |
eaa28564-633d-494e-a480-0bde7b95706b | 0 | @Override
public void keyReleased(KeyEvent e) {
myTank.keyReleased(e);
} |
0b76e004-b190-4781-99e0-4c9a628cd7e2 | 9 | public void level8()
{
wave++;
if ( wave == 1 )
{
for ( int k = 0; k < 6; k++ )
{
enemies.add( new SidewaysEnemy( k%2==0? true:false, 10 + (k * 120), 10, bullets, null ) );
enemies.add( new HomingCircleEnemy( k * -120, 90, 140, bullets,... |
203a9fcd-8339-4a45-b7ce-02c240817599 | 9 | private static boolean isValidUser(User user) {
if (user.getFirst() == null ||
user.getLast() == null ||
user.getLogin() == null ||
user.getEmail() == null ||
user.getPassword() == null) {
return false;
}
if (user.getFirst().isEmpty() || user.getLast().isEmpty()) {
return false;
}
if (!c... |
b8bb4b5e-5cac-4e17-9ff0-087344c771dc | 5 | @Override
public void run() {
try {
LOG.info("Starting ConnectionListener on port: " + listener.getLocalPort());
while (true) {
Socket client = listener.accept();
GameNetworkInterface gnet = Guice.createInjector(new GuiceConfig()).getInstance(GameNetwo... |
0b9c8897-1da1-410f-8935-6db86df7d973 | 6 | public List<List<Integer>> levelOrderBottom(TreeNode root) {
Queue<TreeNode> queue = new LinkedList<TreeNode>();
queue.add(root);
List<List<Integer>> result = new ArrayList<List<Integer>>();
List<List<Integer>> preResult = new ArrayList<List<Integer>>();
List<Integer> level = new ArrayList<Integer>();
if ... |
cdb1d0ef-d8c0-466c-862d-5c377641ddf9 | 3 | public static void main(String[] args) {
if(args.length == 0 ){
new Startup(true);
}
else if(args.length == 1 && checkBoolean(args[0]) == true){
new Startup(Boolean.parseBoolean(args[0]));
} else {
new Startup(true);
}
} |
8545590f-d17d-4a28-a160-30ae05d22116 | 6 | public static HashMap<String, String> listDirectory(String dirPath, int level) {
HashMap<String, String> listoffiles = new HashMap<String,String>();
try{
File dir = new File(dirPath);
File[] firstLevelFiles = dir.listFiles();
if (firstLevelFiles != null && firstLevelFiles.length > 0) {
... |
f6cc5267-1684-4e6b-a104-c9b5cb0ccd40 | 9 | public static String getFileSizeString(Long _size) {
String size = "";
long size_long = Math.abs(_size == null ? 0 : _size.longValue());
NumberFormat formatter = NumberFormat.getInstance();
formatter.setMaximumFractionDigits(2);
if (size_long > 700000000L) {
String[] args = { formatter.format(1.0 * size_lo... |
a7622b73-97b1-4c4c-89d2-2d291f380450 | 7 | private Pair<List<SimpleSelector>, PseudoElementSelector> parseSimpleSelectors() {
int pos = tokenizer.getPosition();
LinkedList<SimpleSelector> selectorSequence = new LinkedList<>();
PseudoElementSelector pseudoElement = null;
boolean empty = true;
Pair<String, Boolean> name =... |
32ecd69b-de25-4e40-89e1-70be563b8a35 | 6 | private void ShowQuestion(int i) {
Question cq = quiz.questionList.get(i);
QuestionPanel.removeAll();
AnswerButtons.clearSelection();
if (quiz.randomiseQuestions)
{
Collections.shuffle(cq.answers);
}
JLabel qtextLbl = new JLabel(cq.questionTex... |
d0feff99-0cd4-4640-8555-2ddd5eabe1e1 | 1 | public void toggleDrumPlayback() {
Sequencer sequencer = midiPlayer.getSequencer();
if (sequencer != null) {
sequencer.setTrackMute(DRUM_TRACK,
!sequencer.getTrackMute(DRUM_TRACK));
}
} |
f782248a-6e59-43be-b70a-7092dcd9db9f | 1 | public void testWithField2() {
DateMidnight test = new DateMidnight(2004, 6, 9);
try {
test.withField(null, 6);
fail();
} catch (IllegalArgumentException ex) {}
} |
6c7e3e0b-3820-4dee-8e05-f43d6f423881 | 3 | public Rectangle2D drawImage(PDFImage image) {
AffineTransform at = new AffineTransform(1f / image.getWidth(), 0,
0, -1f / image.getHeight(),
0, 1);
BufferedImage bi = image.getImage();
if (bi == null) {
// maybe it was an unsupported format, or somet... |
deff4c89-3d25-4eb4-b6a1-47dfea1a47e7 | 8 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(tickID==Tickable.TICKID_MOB)
{
if((affected!=null)
&&(affected instanceof MOB)
&&(invoker!=null))
{
final MOB mob=(MOB)affected;
if(((mob.amFollowing()==null)
||(mob.amDead())
||(!mob.isInCombat())
||(mob.location()!=... |
a9b2e1f0-cae2-40be-a10c-1481e6b701f7 | 0 | public GoToDialog() {
super(false, true, true, INITIAL_WIDTH, INITIAL_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT);
dialog = this;
} |
8626fddd-f17f-4e06-aaeb-59c96bb5f085 | 2 | public static Tva selectTvaById(int id) throws SQLException {
String query = null;
Tva tva = new Tva();
ResultSet resultat;
try {
query = "SELECT * from TVA where ID_TVA=? ";
PreparedStatement pStatement = ConnectionBDD.getInstance().getPrepa... |
80a96479-3d26-4709-830a-32bb49147bfb | 2 | private ArrayList<Integer> mergeWithFactorialFactors(ArrayList<Integer> list, int n) {
ArrayList<Integer> ret = list;
if (factorialFactors.containsKey(n)) {
ret = mergeSortedLists(ret, factorialFactors.get(n));
} else {
for (int i = 2; i <= n; ++i) {
ret ... |
332c65c2-5f2d-481d-9e97-843505436a83 | 3 | public void setTargetItem( DefaultBox<?> targetItem ) {
if( this.targetItem != null ) {
this.targetItem.removeDependent( this );
}
this.targetItem = targetItem;
if( this.targetItem != null ) {
this.targetItem.addDependent( this );
}
} |
7a1e69af-fbbc-410f-bf64-fa5d85e382b5 | 0 | public static void main(String[] args) {
//---------------------
// Stage 1 (4 Marks)
//---------------------
// part 2 stage 1
JFrame gui = new A1JFrame("A1 by qzhu496", 3, 3, JFRAME_AREA_WIDTH, JFRAME_AREA_HEIGHT);
} |
1a896172-4e43-4b87-9c6c-d7f6b63efc5f | 3 | @Override
public void mousePressed(MouseEvent evt)
{
boolean left = SwingUtilities.isLeftMouseButton(evt);
boolean middle = SwingUtilities.isMiddleMouseButton(evt);
boolean doubleClick = (evt.getClickCount() == 2);
if (middle || (left && doubleClick))
{
recenterMap(evt);
}
} |
d023136d-fba0-4bca-b49c-a2f2c90f08d3 | 4 | public static void main(String[] args) {
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e){}
f = new JFrame();
f.setLayout(new BorderLayout());
f.setTitle("Jeu De Dames");
f.setMinimumSize(new Dimension(700,700));
f.setLocationRelativeTo(null);
... |
f5344738-033f-4e6e-847d-0b8c377ebbaa | 6 | static String unEscape(String EscapeString)
{
String ResultString = "";
int i=0;
while (i < EscapeString.length())
{
if (EscapeString.charAt(i) == '\\')
{
i++;
switch (EscapeString.charAt(i))
{
case 'n':
ResultString = R... |
dab1edfd-b54c-44c2-a1ca-c71be9e7d471 | 8 | public void worldChanged() {
init();
for (Ant ant : owns.values()) {
if (phase<50 && ant.getId()>5) {
logger.info("Phase 1");
continue;
}
if (phase<100 && ant.getId()>9) {
logger.info("Phase 2");
continue;
}
if (phase<150 && ant.getId()>13) {
logger.info("Phase 3");
continu... |
864ac64a-fd41-4333-aefd-e229290b0e32 | 4 | public static Socket connect(int port) throws IOException {
Socket ret = null;
final int MAX_ATTEMPTS = 50;
int attempts = 0;
do {
try {
ret = new Socket("127.0.0.1", port);
} catch (ConnectException ce) {
try {
... |
a9e05daf-bab0-4a8e-8283-ceea3852c9a4 | 3 | public void startRepaintTimer() {
if (this.timer == null) {
if ((this.readThread == null) || !this.readThread.isAlive()) {
createBackgroundThread();
this.readThread.start();
}
this.timer = new Timer(GUIConstants.REPAINTTICK, new ActionListener... |
a1418f6a-a3d4-43c1-8dbc-fbfc4da7c2b9 | 5 | @Override
public String toString() {
String string = "";
if(style == 2)
string += "<i>";
if(privateMessage) {
string += "<b>";
if(outgoing)
string += "(to "+author+")";
else
string += "(from "+author+")";
... |
3d1a532f-faab-40f8-844b-dd9c6a99534d | 4 | public boolean checkPermission(CommandSender sender, String node)
{
if(Bukkit.getServer().getPluginManager().isPluginEnabled("PermissionsEx"))
{
//Pex only supports player check, no CommandSender objects
if(sender instanceof Player)
{
final Player p = (Player) sender;
final PermissionManager permi... |
b1bba4f4-40c7-4ac0-b1e1-1e5947f60f9d | 3 | @Override
public void run() {
try {
DatagramSocket socket = null;
socket = new DatagramSocket(6667);
while (true) {
DatagramPacket packet = new DatagramPacket(new byte[50],50);
try {
socket.receive(packet);
new Thread(new DatehandlerThread(packet,socket)).start();
} catch (Exception e)... |
1e617865-1330-40fd-b9de-0c3f85fd8529 | 6 | public HashMap<Integer, SSAorConst> copyPropagate(HashMap<Integer, SSAorConst> propagation) {
HashMap<Integer, SSAorConst> returnPropagation = new HashMap<Integer, SSAorConst>(
propagation);
Iterator<SSAInstruction> iter = instructions.iterator();
while (iter.hasNext()) {
SSAInstruction curIns = iter.next... |
76b71c99-7d3a-49aa-a580-7467a9d127b0 | 3 | @Override
public void update(Observable o, Object arg) {
if (presenter.getState().getStatus().equals("PlayerWaiting")) {
System.out.println("Updating Method called in PlayerWating Controller");
PlayerInfo[] pInfo = getPlayerInfoArray();
getView().setPlayers(pInfo);
if (numOfWaiting < pInfo.lengt... |
31d62a44-01c5-4fb8-a54b-9444e9c1699a | 8 | public Property or(final Property p) {
return fromGen(gen().bind(p.gen(), new F<Result, F<Result, Result>>() {
public F<Result, Result> f(final Result res1) {
return new F<Result, Result>() {
public Result f(final Result res2) {
return res1.isException() || res1.isFalsified() ? r... |
3a13269d-ca59-4951-a614-40fb7afe9fed | 7 | private Dimension layoutSize(Container target, boolean preferred)
{
synchronized (target.getTreeLock())
{
// Each row must fit with the width allocated to the containter.
// When the container width = 0, the preferred width of the container
// has not yet been calculated so lets ask for the maximum.
int ... |
f4608be2-4fef-460d-a0bb-de2811da1fa3 | 5 | protected boolean siirraPystysuunnassa(int napinKorkeus, int napinLeveys, int suunta) {
if ((suunta == 1 && napinKorkeus + 1 >= getKorkeus()) || (suunta == -1 && napinKorkeus - 1 < 0 )) {
return false;
}
if (getLauta()[napinKorkeus + suunta][napinLeveys].getTunniste() == -1)... |
65842108-e4b5-4725-967c-9354a7225c05 | 5 | public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel lbl = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if(value.toString().equals("Sent Items")) {
lbl.setIcon(SEN... |
63858176-dc60-4389-9b5b-57644bf14496 | 7 | private void resetCanBeAvail(final ExprInfo exprInfo, final Phi phi) {
phi.setCanBeAvail(false);
final Iterator blocks = cfg.nodes().iterator();
// Iterate over every PHI-statement, other, that uses the
// the "h" defined by phi as an operand...
while (blocks.hasNext()) {
final Block block = (Block) blo... |
30755e24-6724-4864-9c07-e74bc9f81378 | 2 | private String createUpdate() {
StringBuilder sb = new StringBuilder();
sb.append( "\n" );
sb.append( "\n" + TAB + "<update id=\"update\" parameterType=\"" + table.getPackage() + ".domain."
+ table.getDomName() + "\">\n" );
sb.append( TAB + TAB + "update " + table.getTab... |
4381a5a7-f241-438f-92e3-dfe56d736c7e | 1 | Tetromino draw() {
if (!hasNext()) {
refill();
}
Type value = tetrominos[pointer];
pointer++;
return Tetromino.getTetromino(value);
} |
a46bf6d4-60f1-4c57-8f31-1e33d97b5bad | 2 | public final double getDouble(int index) throws JSONException {
Object o = get(index);
try {
return o instanceof Number ?
((Number)o).doubleValue() :
Double.valueOf((String)o).doubleValue();
} catch (Exception e) {
throw new JSONException("... |
807bd47c-b8a0-4d70-966f-51303c6be1e8 | 8 | private void modificarTarea(String titulo) {
int indice;
Tarea t = null;
switch (jCBEstado.getSelectedIndex()) {
case 1:
indice = buscarTarea(this.proyectos.get(index).getProximo(), titulo);
if (indice != -1) {
t = this.proyectos.ge... |
79e48450-63c8-4f04-89ea-414e70631733 | 3 | public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int h = getHeight();
int w = getWidth();
ButtonModel model = getModel();
if (!model.isEnabled()) {
setForeground(Color.GRAY);... |
b4d449cb-245e-48de-a267-374bf2938008 | 3 | public void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
String itemText = (String) jComboBox1.getSelectedItem();
if (itemText.equalsIgnoreCase("Farenheit"))
{
String tester = itemText;
AskNumber test = new... |
f05fb16a-8a7e-46b3-bba1-3b8cce06e079 | 9 | public final GalaxyXLinkingParser.assignment_operator_return assignment_operator() throws RecognitionException {
GalaxyXLinkingParser.assignment_operator_return retval = new GalaxyXLinkingParser.assignment_operator_return();
retval.start = input.LT(1);
int assignment_operator_StartIndex = input.... |
839d5b8e-1eef-4202-9a05-f3aed226b487 | 4 | @Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Position other = (Position) obj;
return this.x == other.x && this.y == other.y;
} |
809d36b2-442b-4b25-abc2-480a77a55e6a | 5 | @Override
protected void setCompletion(final HTTPCompletion completion) {
super.setCompletion(new HTTPCompletion() {
@Override
public void failure(URLRequest request, Throwable t) {
if (completion != null) {
completion.failure(request, t);
... |
21a3b31c-5cbd-472c-89f0-c81fa961a789 | 8 | public static void main(String[] arg) {
ServerSocket s = null;
Socket incoming = null;
try {
s = new ServerSocket(8189);
incoming = s.accept();
Scanner scanner = new Scanner(incoming.getInputStream());
PrintWriter writer = new PrintWriter(incomin... |
6945e7fb-07e4-45f3-9738-151dfb513aab | 3 | public void drawNumber(Tile tile, Graphics2D g2) {
if (tile.getNumber() == 0) {
return;
}
int x = tile.getLocation().getXCoord();
int y = tile.getLocation().getYCoord();
Point p = findCenter(x,y);
g2.setColor(Color.BLACK);
if (tile.getNumber() == 6 || tile.getNumber() == 8)
g2.setColor(Color.RED)... |
a7e04965-fbe6-4b2c-a471-9cd967ac2f45 | 5 | public static ArrayList<Reservation> searchByType(String type) {
try {
if(conn == null || conn.isClosed()){
conn = DatabaseConnection.getConnection();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ArrayList<Reservation> reserv... |
97e9710e-efcd-4efc-8e23-b756a3e7f60a | 9 | public static boolean updateLocalSettings() {
//System.setProperty("ru.mrekin.sc.sclauncher.forceSettings", "true");
// System.getProperty("ru.mrekin.sc.sclauncher.forceSettings", "true");
boolean forceSettings = Boolean.getBoolean("ru.mrekin.sc.sclauncher.forceSettings");
log("Force setti... |
d7265dd6-4ba6-4000-9086-6d77349b0585 | 7 | public List<Item> extractPurchaseItems(String targetCode, List<Item> list,
int required) {
List<Item> result = new ArrayList<Item>();
int actualHitCount = 0;
for (Item i : list) {
if (targetCode.equals(i.getItemCode())) {
actualHitCount++;
}
if (actualHitCount == required) {
break;
}
}
... |
ea5e42b0-fb83-45be-bdee-892be2f53321 | 7 | private void convertToPolygon() {
if (polygon == null) {
polygon = new Polygon();
} else {
polygon.reset();
}
if (transform == null) {
transform = new AffineTransform();
} else {
transform.setToIdentity();
}
transform.setToRotation(theta, rx, ry);
PathIterator pi = ellipse.getPathIterator(... |
9aa6873a-eb2c-4d5e-9de6-d327abcbb38a | 3 | public TSLWriter putString(String name,String value) throws IOException
{
if(value == null)
{
return this;
}
TSLUtil.validateValueName(name);
if(closed)
{
throw new IllegalStateException(ERROR_ROOTCLOSED);
}
if(root_element)
{
closed = true;
}
writeSepara... |
c17b8e33-0780-4458-a51c-e73d475dfe4c | 7 | private Map<String,Double> parseAcceptEncodingRequest(String encDefStr) throws HTTPException
{
final String[] allEncDefs = encDefStr.split(",");
final Map<String,Double> encs = new TreeMap<String,Double>();
for(final String encDef : allEncDefs)
{
final String[] encDefParts = encDef.split(";",2);
if(encDe... |
4f9fe564-5ecc-4aae-a492-d6951f292212 | 0 | public float getA() {
return a;
} |
f9267364-fb19-4fda-aa6f-e5ed3f9f1c44 | 1 | public void update(){
super.update();
delta++;
if(!isDead()) move();
} |
dc3d8f78-9236-41bd-be9e-7d15a4faef54 | 9 | @SuppressWarnings({"BroadCatchBlock", "TooBroadCatch"})
private void createThumbnail(String serie, String albumString, int serieId, int albumId) throws IOException {
Logger.getLogger(ReportGenerator.class.getName()).entering(ReportGenerator.class.getName(), "createThumbnail", new Object[] {serie, albumStrin... |
5ddc11bb-77d6-4f21-a834-7bd93492b64c | 0 | public InputEvent peekAtEvent()
{
return unprocessedEvents.peek();
} |
bfc53f68-893c-4901-bcdb-00a8b50d12d7 | 8 | private void attack()
{
double x = (double) this.getXPosition();
double y = (double) this.getYPosition();
Place choosenCrossroad = new Place(0, 0);
double shortestDistance = Double.MAX_VALUE;
double h;
for(Place p : Empire.getInstance().CROSSROADS.values())
{
double pX = p.getXPosition();
... |
cddd6b83-70ec-44f8-92d3-42c92d55508c | 8 | @Override
public String process(HttpServletRequest request)
throws MissingRequiredParameter {
ResultSet resultSet = null;
String farmID = request.getParameter("farmID");
//String result = null;
JSONArray result = new JSONArray();
//String result;
try {
// Get Connection and Statement
connectio... |
cf405cae-aae1-40a0-8615-2b921ca255bb | 4 | @Override
public void execute(CharSequence str) {
if(str.equals(EditCommands.CURSOR_UP)) {
this.editor.moveCursor(-1, 0);
}
else if(str.equals(EditCommands.CURSOR_DOWN)) {
this.editor.moveCursor(1, 0);
}
else if(str.equals(EditCommands.CURSOR_LEFT)) {
this.editor.moveCursor(0, -1);
}
else if (st... |
7479c446-2697-44d1-89d5-554f4d6f6a10 | 5 | private static <KEY, VALUE, C extends Collection<VALUE>> void addToMapValueCollection(
ConcurrentMap<KEY, C> map, KEY key, VALUE value,
CollectionFactory<VALUE, C> factory) {
while (true) {
C values = map.get(key);
if (values == null) {
C newKeys = factory.create(value);
v... |
0b82db8f-fc36-4369-a83d-f692b9b47db4 | 5 | public static void buttonAction(int i, GameContainer container, Menu menu) {
switch(i) {
case 1:
GameStatus.gameState=1;
break;
case 2: break;
case 3: GameStatus.gameState=3;
break;
case 4: break;
case 5... |
5496c1ac-9785-4565-840c-980652b4f7b2 | 1 | public void visitEnd() {
super.visitEnd();
if (mv != null) {
mv.visitEnd();
}
} |
b9341338-bc37-4579-b2a7-4a861a503ec8 | 5 | public int getBorderSize()
{
int st = getBorderStyle();
if( st <= 4 )
{
return st + 1;
}
// otherwise, interpret style --> size???
if( st == 7 ) // hair
{
return 1;
}
if( (st == 6) || (st == 8) || (st == 0xC) )
{
return 3;
}
return 2;
} |
08abf266-09d5-4aa7-a726-50140be6aa6e | 8 | public Body createBody(World world, MapObject mapObject) {
MapProperties properties = mapObject.getProperties();
String type = properties.get("type", String.class);
if(!type.equals(aliases.body) && !type.equals(aliases.object))
throw new IllegalArgumentException("type of " + mapObject + " is \"" + type + "\"... |
6650d252-4f91-49a1-98f3-4cb939dfbdf6 | 9 | protected List<Match> growMatches(int threshold, boolean stopAtFirstMatch)
{
List<Match> result = new ArrayList<Match>();
/**
* The main process is the merging (growing) of matches.
* <p>
* Note that after each cycle, the chosen match will not exist any more - it is removed from the queue and from
* al... |
ae0e3b9f-a0e5-4a40-9540-8010b04d6723 | 4 | private boolean read() {
try {
final URLConnection conn = this.url.openConnection();
conn.setConnectTimeout(5000);
if (this.apiKey != null) {
conn.addRequestProperty("X-API-Key", this.apiKey);
}
conn.addRequestProperty("User-Agent", "U... |
0315f32d-305a-467c-b9d7-a4016e4b9cf4 | 3 | public void fireDflt(Point mousePoint) {
if (dflt == null)
return;
ActionListener[] al = dflt.getActionListeners();
if (al != null && al.length > 0)
al[0].actionPerformed(new MenuEvent(dflt, mousePoint));
} |
c444d022-63c4-47f4-b086-f40f7678ee66 | 1 | public void addToCar(int idCar, String participantName){
tx.begin();
Car car = manager.find(Car.class, idCar);
try {
Participant participant = (Participant) manager.createQuery(
"SELECT p FROM Participant p WHERE p.name='"+participantName+"'").getSingleResult();
participant.setCar(car);
car.getPasse... |
353c1bb9-f84f-48b3-9590-6fdaadd95515 | 6 | public Card(String suit, int point) {
if (point < 2 || point > 14) {
System.out.println("Error when creating Card. Invalid point!");
return;
}
if (!suit.equals("S") && !suit.equals("H") && !suit.equals("C") && !suit.equals("D")) {
System.out.println("Error when creating Card. Invalid suit!");
retur... |
85bd1fc5-be57-4dd5-84b2-c620f39164c0 | 9 | private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
... |
10d00932-823f-49ba-b9b3-2ebfc5fb3519 | 8 | public RoleSearchPane(Framework framework){
super();
this.Framework = framework;
/*Framework.Data.roleSearchList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Framework.Data.roleSearchList.setLayoutOrientation(JList.VERTICAL);
Framework.Data.roleSearchList.setBackground(new Color(32,32,32));
Frame... |
a08e2f3d-6e28-417a-944d-8cb1133ab78a | 9 | public Result run(Node start, Node end) {
if(start==null || end==null) throw new IllegalArgumentException("Start or end node not provided");
/*System.out.println("-------- Dijkstra Mono-Objectif ---------");
System.out.println("On cherche le plus court du " + start + " vers le " + end);*/
// Initialize al... |
7060fab0-5d5b-4207-b4d8-4b9b07e6ee43 | 9 | public Literal evaluate(ValueFactory valueFactory, Value... args)
throws ValueExprEvaluationException
{
try
{
if (args.length != 2) {
throw new ValueExprEvaluationException("equal requires 2 argument, got " + args.length);
}
Value firs... |
d78be411-b6e2-4579-b419-dc6d257d3eba | 2 | public void update(){
if(this.alive){
if(this.blink){
this.aux = blink(this.alpha);
}
}
else{
this.aux = 255;
}
} |
019d7ed6-a968-4b13-bac0-9cb3246e17db | 9 | public void run(BufferedImage image) {
if (image.getType() != BufferedImage.TYPE_BYTE_GRAY)
throw new IllegalArgumentException("input image must be greyscaled");
int width = image.getWidth();
int height = image.getHeight();
Raster source = image.getRaster();
... |
2e61a661-31aa-4d90-81fd-6899dab06c54 | 1 | @Override
public void update(GameContainer arg0, StateBasedGame arg1, int DELTA) throws SlickException {
if(elapsedTime >= 300){
trackSplash++;
elapsedTime = 0;
} else {
elapsedTime+=DELTA;
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.