method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
8de31688-226a-44fa-ace8-d6de0a5f64a5 | 7 | @Override
public double timeToReach(Node startNode, Node endNode, Message msg) {
// TODO Auto-generated method stub
double dist = startNode.getPosition().distanceTo(endNode.getPosition());
/* Link rate | time arrive mSec | dist
* ----------------------------------------------------
* 11 | 2542 | 399
... |
9af8bfad-42ae-4eff-ac76-3dbd3056f746 | 4 | private boolean readFalse( StringBuffer b )
throws IOException,
JSONSyntaxException {
if( !readExpected('a',b) || !readExpected('l',b) || !readExpected('s',b) || !readExpected('e',b) )
throwJSONException( "Unexpected token: " + this.describeCurrentToken() + "; expected false." );
this.fireFalseRead( b... |
d85189bf-1536-443e-b684-cb301a210bd9 | 5 | @Override
public void initFromFields(Object[] fields) {
name = (String) fields[6];
ArrayList<Costume> c = new ArrayList<Costume>();
ArrayList<Sound> s = new ArrayList<Sound>();
Object[] media = (Object[]) fields[10];
for (int i = 0; i < media.length; i++) {
if (media[i] instanceof Costume) {
c.add((Co... |
c86fee51-d151-4772-911c-8aa06f2a90ea | 8 | private void loadImagesFile(String fnm)
/* Formats:
o <fnm> // a single image
n <fnm*.ext> <number> // a numbered sequence of images
s <fnm> <number> // an images strip
g <name> <fnm> [ <fnm> ]* // a group of images
and blank lines and comm... |
5afb149e-5917-4b99-9303-9d89e59372c8 | 8 | public void rescaleCenter(double minLevel, double maxLevel) {
double maxImage = -Double.MAX_VALUE;
double minImage = Double.MAX_VALUE;
byte[] slice;
for(int z=0; z<nz; z++) {
slice = (byte[])data[z];
for(int k=0; k<nxy; k++) {
if ((slice[k] & 0xFF) > maxImage)
maxImage = slice[k] & 0xFF;
if... |
1c1cd5e6-8ab0-43e6-915a-be705d46e1c4 | 9 | public void refresh() throws SSMException{
init();
log.info("START REFRESH");
log.info("Clean Member Set");
mbrSet.clear();
log.info("Get SMbrSet from Simple DB");
String sMbrList = getSMbrSet();
log.info("sMbrList : "+sMbrList);
ConcurrentSkipListSet<String> sMbrListSet;
log.info("Empty : "+sMbrList.... |
dcf6b30c-97b2-4044-bfaf-60f0d7956d8b | 4 | private void move789(FieldSlot player, FieldSlot enemy) {
if (tryWin(player) != 0) {
field.setSlot(tryWin(player), player);
} else if (tryWin(enemy) != 0) {
field.setSlot(tryWin(enemy), player);
} else {
for (int i = 1; i < 10; i++) {
if (field.getSlot(i) == FieldSlot.EMPTY) {
field.setSlot(i, p... |
113ae330-6c61-4833-8ba8-7952b3d80424 | 3 | public Combinaison obtenirCombinaison()
{
/**
* Combinaison servant a eter modifie par l'entree clavier
*/
String combinaisonEntreParLeJoueur = null ;
try
{
System.out.println(Couleur.listeCouleur());
combinaisonEntreParLeJoueur = this.lecteurDeLignesDeTexteSurLEntreeStandard.readLine();
... |
5f6a6c7b-e800-40bc-bdaf-4fd05acec55f | 4 | public static void privateMessage(Player player, String msg) {
Location pLoc = player.getLocation();
String _msg = ruChat.cfg.getString("private-chat-format");
_msg = replaceSpecials(_msg, msg, player);
double range = Math.pow(ruChat.cfg.getInt("private-chat-range"), 2);
for (Pl... |
dacacf70-fa04-4e74-84f7-bc5e71fe0947 | 8 | public static void main (String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
shell.setText ("Lazy Tree");
shell.setLayout (new FillLayout ());
final Tree tree = new Tree (shell, SWT.BORDER);
File... |
9f146c18-1871-48b3-b9ab-6bef9b12e9a9 | 2 | public final User[] getUsers(String channel) {
channel = channel.toLowerCase();
User[] userArray = new User[0];
synchronized (_channels) {
Hashtable users = (Hashtable) _channels.get(channel);
if (users != null) {
userArray = new User[users.size()];
... |
3561824a-a9e2-4807-a8e3-aed09c9dc5bf | 0 | public void resetVitesse() {
vitesse = vitesseBase;
} |
696a107b-379a-4a64-8e07-dcabd6919091 | 8 | @SuppressWarnings("unchecked")
private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException
{
HashMap map = new HashMap();
++offset;
ByteBuffer info_hash_bytes = null;
while(bencoded_bytes[offset] != (byte)'e')
{
//... |
48ff110e-2da1-4b5c-b987-7509f2e1b477 | 0 | public ErrorManager(){
ErrMessages=new HashMap<Integer,String>();
messagequeue=new ArrayList<Error>();
// Error Messages
ErrMessages.put(INVALID_OPCODE, "Unknown Opcode");
ErrMessages.put(LESS_OPERANDS, "Opcode requires more operands");
ErrMessages.put(MORE_OPERANDS, "Opc... |
283c0885-e867-482c-88d1-ef3c6c2436cf | 9 | private static int pwd() {
int rc, dot, dotdot;
int child = 0;
String relPath = ".";
List<String> path = new LinkedList<String>();
byte[] buf = new byte[blockSize];
for (;;) {
rc = Library.readdir(relPath, buf);
if (rc != 0) {
out.p... |
04409e49-b79f-477b-b620-581c0f996ee4 | 8 | public void execute() {
try {
if (!file.exists()) {
return;
}
List<Throwable> throwables = new LinkedList<Throwable>();
File[] files = file.listFiles();
if (null != files && files.length > 0) {
for (File file : files) {
try {
delete(file);
} catch (Exception e) {
throw... |
d197e2b5-9667-4319-8028-ebaed689a3aa | 7 | public ArrayList<Boolean> cantoTruco(){
ArrayList<Boolean> respuesta = new ArrayList<Boolean>();
boolean reTruco = false;
int resp = 0;
boolean respBoolean = false;
boolean error = true;
while(error){
Scanner sc = new Scanner(System.in);
try{
System.out.print("\n1-Quiero -- 2-No Quiero -- 3... |
4eb16ec3-8f52-4509-87cb-47da9543dad7 | 4 | public boolean equals(Object obj) {
Merchants merchant = (Merchants) obj;
if (this.merId != merchant.merId){
return false;
}
if (!this.merName.equals(merchant.getMerName())){
return false;
}
if (this.locationLong != merchant.getLocationLong()){
return false;
}
if (this.locationLat != merchant... |
96d77439-771b-4cb6-a6d6-ea11a9c796fa | 5 | @Override
public void run()
{
final Game game = new Game();
final Platform platform = new Platform();
//Frame
frame.add(game);
game.setVisible(true);
frame.revalidate();
frame.repaint();
System.out.println("Game started");
long lastTime = System.nanoTime();
double nsPerTick = 1000000000D/60... |
ffb9aa51-542d-4a2f-b17a-4b79abdd44f6 | 7 | public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... |
3d242065-f627-4054-9909-eeaacd42bd4f | 4 | public void saveWorldCheck(World world) {
FileOutputStream fileOut = null;
ObjectOutputStream out = null;
int overwriteAnswer = JOptionPane.showConfirmDialog(null, "Do you want to overwrite any current save");
if (overwriteAnswer == 0) {
try {
File ... |
6a7e5a0a-e6b5-4f39-abaa-afeb9b479544 | 8 | public void printUsage(OutputStream out) {
PrintStream p = new PrintStream(out);
p.print("Usage: " + name);
if (!options.isEmpty()) {
p.print(" [-options]");
}
if (!parameters.isEmpty()) {
Iterator<Parameter> i1 = parameters.iterator();
while (i1.hasNext()) {
Parameter param = (i1.next());
p.... |
37647b12-1c91-4882-93a4-65aa9b98571a | 1 | public Strichart neueStrichartErstellen(String strichbezeichnung, boolean zustand){
Strichart rueckgabe = null;
try {
rueckgabe = new Strichart(strichbezeichnung, zustand, db);
} catch (SQLException e) {
System.out.println("Zugriffschicht: neuerBenutzerErstellen: "+e);
}
return rueckgabe;
} |
7556c9f8-9bd6-4f67-beb9-372a0a283538 | 9 | private void doRunstats(String tableName) {
Table table = null;
for (Table t : tables)
if (tableName.equalsIgnoreCase(t.getTableName())) {
table = t;
break;
}
if (table == null) {
out.println("Table " + tableName + " does not exist in the database");
}
table.setTableCard(table.getData()... |
73caf19c-efca-402e-90da-024067712e14 | 3 | public static List<SpriterKeyFrame[]> generateKeyFramePool(SpriterData spriterData){
List<SpriterKeyFrame[]> keyframeList = new ArrayList<SpriterKeyFrame[]>();
List<Animation> animations = spriterData.getEntity().get(0).getAnimation();
for(Animation anim: animations){
SpriterKeyFrame[] keyframes = new SpriterK... |
2d4aa858-a7e1-4704-aa65-af50f43d4ee9 | 1 | public synchronized void editar(int i)
{
try
{
new FonteFinanciamentoView(this, list.get(i));
}
catch (Exception e)
{
}
} |
6dc47573-412b-4ccb-b587-9e14faa9f9c2 | 2 | public void testFactory_parseHours_String() {
assertEquals(0, Hours.parseHours((String) null).getHours());
assertEquals(0, Hours.parseHours("PT0H").getHours());
assertEquals(1, Hours.parseHours("PT1H").getHours());
assertEquals(-3, Hours.parseHours("PT-3H").getHours());
assertEqu... |
f7060060-c9d0-4576-b075-750b81b484de | 2 | public boolean authenticate(String username, String password){
boolean success = false;
NexusClient client;
try {
client = new NexusClient(GO_HOST, community);
success = client.authenticateUserPassword(username, password);
userFullname = client.getUserFullName();
userEmail = client.getUserEmail();
... |
6e5b13fc-e480-4d9d-86c5-1f18eb422e53 | 1 | static void write(String cmd) throws IOException {
if (allowed) {
debug.write(cmd);
debug.newLine();
debug.write("-------------");
debug.newLine();
debug.flush();
}
} |
8270f6de-dca9-4360-9d62-4c05300a7793 | 5 | private boolean valid() throws SimulationException {
int maxCarSpaces =Integer.parseInt(gui.maxCars.getText());
int maxSmallCarSpaces =Integer.parseInt(gui.maxSmallCars.getText());
int maxMotorCycleSpaces =Integer.parseInt(gui.maxMotorCycles.getText());
int maxQueueSize = Integer.parseInt(gui.maxQueue.getText()... |
cb4084d4-25c1-4c79-91be-3acf26ef2a28 | 0 | public Process(String[] args, int priority, long id)
throws ClassNotFoundException, IOException
{
this.args = args;
this.priority = priority;
this.id = id;
this.status = 2;
className = Class.forName("programs." + getName());
} |
784a10b2-f08b-40c8-84a6-67cfc7c77393 | 9 | private void setStateOfToggleButton(JToggleButton cb, boolean b, boolean noText) {
Action a = cb.getAction();
ActionListener[] al = cb.getActionListeners();
ItemListener[] il = cb.getItemListeners();
String s = cb.getText();
cb.setAction(null);
if (al != null) {
for (ActionListener i : al)
cb.remov... |
809fb136-cb5b-4b5e-9d4b-425291d4e8ab | 1 | public void clear() {
for(Action action : actions) {
action.invalidate();
}
actions.clear();
} |
c9ec2707-68c5-45e4-9e8e-5a50684b8d54 | 3 | @Test
public void hasNextUntilListIsOver()
{
for (int i = 0; i < 1337; i++)
list.add("bleep");
for (int i = 0; i < 1337; i++)
{
if (!list.hasNext()) assertTrue(false);
list.getNext();
}
assertTrue(!list.hasNext());
} |
01e50e81-e9e3-4a90-b3cd-1b37383cc682 | 5 | public synchronized static Form moveToLastForm(Point p) {
for (Form form: Forms.forms) {
if (p.x > form.getStart().x && p.y > form.getStart().y
&& p.x < form.getEnd().x && p.y < form.getEnd().y) {
Form temp = new Form(form);
Forms.forms.remove(form... |
2e5ab940-7579-4187-8174-b7aeb2035744 | 2 | synchronized void newSumLog(int n) {
if (n >= sumLog.length) {
// Copy and resize
double sumLogNew[] = Arrays.copyOf(sumLog, n + 1);
// Calc new values
for (int i = sumLog.length; i < sumLogNew.length; i++)
sumLogNew[i] = sumLogNew[i - 1] + Math.log(i);
sumLog = sumLogNew;
}
} |
a427797c-0798-4d1b-bc7e-78661f0beda5 | 0 | public boolean hasLegalMove(Board board, Field currentField) {
return !this.getLegalMoves(board, currentField).isEmpty();
} |
d5d4e06c-42bb-4618-a592-a22938975e02 | 6 | private boolean isColorful(URL img) {
try {
BufferedImage image = ImageIO.read(img);
float saturation = 0;
int threshold = 100;
if(image.getType() == BufferedImage.TYPE_BYTE_GRAY || image.getType() == BufferedImage.TYPE_USHORT_GRAY)
return false;
for (int x = 0; x < image.getWidth(); x++)
{
... |
74ee10b5-0ba8-4f04-a583-d2735084088d | 8 | public void process(Inverter inverter) throws IOException, SmajavaException, InterruptedException {
InputStream inputStream = Engine.class.getResourceAsStream(Configuration.getDataFilename());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
... |
af8df25f-e40f-43bf-b36a-c17ed21032be | 1 | public int[][][] getAccumulator() throws IllegalStateException {
if(!isDone) throw new IllegalStateException("accumulate() must be called before getAccumulator()");
return acc;
} |
d69cde2b-5a65-42cd-8bd5-fbdd02f053f7 | 4 | public int add(Student student) {
int i;
boolean error = false;
for (i = 0; i < getList().size(); i++) {
if (getList().get(i).getId() == student.getId()) {
error = true;
}
}
if (error) {
System.out.println("Error : Same ID in the Promotion !");
} else {
getList().add(student);
if (student... |
5cd006f4-69e6-4980-875d-90b4c2696e84 | 0 | public void setKeywords(String keywords) {
this.hostName = keywords;
} |
503e2aed-db88-4e64-b843-8f86542e8b83 | 8 | public static void main(String[] args) {
int timeout = DEFAULT_TIMEOUT;
if (!(args.length == 2 || args.length == 1)) {
System.err.println("Usage: java Pop3Server <port number> <timeout>");
return;
}
if(args.length == 2) {
timeout = convertStrToInt(a... |
0031c087-e9e8-4ac5-8166-1440ec3c6b2e | 4 | public boolean equals(MapData md) {
if (md.data.size() != this.data.size())
return false;
for (Tile t : md.data.keySet()) {
if (!this.data.containsKey(t) || !Arrays.equals(md.data.get(t), this.data.get(t)))
return false;
}
return true;
} |
0cf63aa9-ef24-4651-af13-f4bbf026a09d | 0 | public Integer getNumberOfSpheres() {
return numberOfSpheres;
} |
f5fdbe06-02e1-4faa-b465-56da89efce5a | 3 | public Shift getShift(int row, int col){
int startHour = 0;
int startMinute = 0;
int finishHour = 23;
int finishMinute = 59;
if(row%2 == 0)
{
startHour = timeToCode(tableData[row][col])/100;
startMinute = timeToCode(tableData[row][col])%100;
if(tableData[row+1][col] != null)
... |
b5d433ab-ea0b-4e1a-86f3-7f56bf6a59b0 | 5 | @Override
public Action getAction(GameState state) {
if(state.getRound() == Round.PRE_FLOP){
double prob = rollout.winRatio(state.getActivePlayerCount(), holeCard1, holeCard2);
if(prob > BET_THRESHOLD){
return Action.BET;
}else if(prob > CALL_THRESHOLD){
return Action.CALL;
}else{
return Acti... |
8f591325-c5e8-4976-b46b-2fefc125813e | 2 | public static void main (String args[]) throws Exception
{
int clientCount = 0;
port = Integer.parseInt(args[0]);
ServerSocket listener = new ServerSocket(port);
try
{
while (clientCount++ < maxConnections)
{
new ThreadServ (listener.accept(),clientCount).start();
}
}
catch (IOE... |
62b349aa-f936-4fc2-bc97-ac301d343f44 | 0 | public void setEnableCallbacks(boolean enableCallbacks) {
this.enableCallbacks = enableCallbacks;
} |
0c96c0fb-9d9a-4d5c-9bb5-5b43809939dd | 1 | private static void displayPatients(ResultSet rs)throws SQLException{
StringBuffer bf = new StringBuffer();
while (rs.next()){
bf.append(rs.getInt("pid")+": ");
bf.append(rs.getString("firstname")+" ");
bf.append(rs.getString("lastname"));
System.out.println(bf.toString());
bf.delete(0, bf.length(... |
e9a6b1d1-3220-4746-80b7-231ad3769603 | 5 | public void addEntry(String[] entry) {
float xPosition = x+cellMargin, yPosition = (y+(fontSize)+(cellMargin*2))+(((cells.size()/columns.size())-1)*(rowHeight+(2*cellMargin)))+cellMargin;
for (int i = 0; i < columns.size(); i++) {
float cellWidth = columns.get(cells.size()%columns.size()).getCellWidth();
addF... |
e5bdadba-c39b-4c5b-9a70-2212874a6d7f | 2 | public void localModifyLastUpdate(String local_path) {
DBLikeFileObject search = null;
Iterator<DBLikeFileObject> itr = localDB.iterator();
for (int i = 0; i < localDB.size(); i++) {
search = itr.next();
if (search.getLocalFilePath().equals(local_path)) {
search.setServerUpdateDate(search.getLastLocal... |
703fa983-f51f-4e00-ac09-126972591ef9 | 3 | public void rideBike()
{
bicycling=true;
messageBox=new ErrorWindow();
messageBox.addMessage("You ride on your Bicycle!","I love to ride my...");
messageBox.repaint();
while(messageBox.isVisible())
{
try
{
repaint();
Thread.sleep(10);
}
catch(Exception ignored){}
}
if(!forceBike)
... |
30cef2a4-4873-40c1-8cb6-7477224fbfe3 | 5 | private void checkKeys(){
if("space".equals(Greenfoot.getKey())){
moveCrane(0);
}
if(Greenfoot.isKeyDown("up")){
moveCrane(1);
}
if(Greenfoot.isKeyDown("down")){
moveCrane(2);
}
if(Greenfoot.isKeyDown("left")){
moveC... |
591d0f1d-b2d7-4ce0-b669-3817f8bf96cc | 9 | public <T> T deserialize(Class<? extends T> clazz, Map<String,String> row){
try{
Map<Field,ColumnSerializer> serializers = getConfiguration(clazz);
Constructor c = clazz.getDeclaredConstructor();
c.setAccessible(true);
T object = (T)c.newInstance();
for(Entry<Field,ColumnSerializer> entry:serializers.e... |
ad7e0222-4e86-408d-80c5-2fbc85110e9d | 2 | public void updateChatPersonList(List<ChatPerson> list) {
List<ChatPersonWrapper> betterList = new ArrayList<ChatPersonWrapper>(list.size()-1);
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getName().compareTo(agent.getName()) != 0)
betterList.add(new ChatPersonWrapper(list.get(i)));
}
ch... |
a8a54caf-5304-4e34-80a2-ba6e11cfd16b | 8 | public void run()
{
try {
while (!quit) {
final int c = is.read();
if (c > -1) {
if (c == ACK) {
if (state == ACK_PENDING)
synchronized (lock) {
state = OK;
lock.notify();
}
}
else if (c == START)
readFrame();
else if (c == START... |
71cb22c0-0111-487b-be33-09099eb965ff | 2 | private Criteria[] prepareUserUpdate(Criteria criteria, AbstractDao dao) throws DaoException {
Criteria[] crit = new Criteria[]{new Criteria(), new Criteria()};
crit[0].addParam(DAO_ID_USER, criteria.getParam(DAO_ID_USER));
crit[0].addParam(DAO_USER_SELECT_FOR_UPDATE, true);
List<User> u... |
fbb8eacd-0072-4b41-a004-3f4c6e877939 | 1 | public long skip(long count) throws IOException {
if (length < count) {
count = length;
}
count = super.skip(count);
length -= (int) count;
return count;
} |
457ea64f-0536-4e94-a312-1ba5e40256cb | 2 | public boolean equals(Object obj)
{
//standard equals()
if(((Piece) obj).body.length != this.body.length)
return false;
Collection setA = new HashSet();
Collection setB = new HashSet();
for (int i = 0; i < this.body.length; i++)
{
setA... |
2e236c61-be93-4f20-b961-e8c1cb91df97 | 3 | protected void deletarCrlv() throws ClassNotFoundException, SQLException{
int index = gCrlv.getTableGerenciarCrlvs().getSelectionModel().getLeadSelectionIndex();
if(index > -1){
int resp = JOptionPane.showConfirmDialog(mw, "Deseja realmente excluir o documento selecionado?");
if(... |
07d13520-2510-4b65-955b-a3c4594c471e | 0 | private long getAgeInSeconds(String dateAsString) throws ParseException {
Date date = getDateFromString(dateAsString);
return getTimeToTodayInSeconds() - getTimeToDateInSeconds(date);
} |
9e9141a0-25a0-4204-9f50-49a1fa76555a | 8 | public static Model sampleSpiderState() {
Model model = new Model();
ExpressionParser parser = new ExpressionParser();
model.setTitle("Spider");
model.setMinSize(new Dimension(320, 240));
model.setPreferredSize(new Dimension(800, 600));
for (int i = 0; i < 8; i++) {
for (int j =... |
517d3b2b-f058-41aa-b496-9e2a051b2839 | 0 | public List<Order> getAllOrders() {
return allOrders;
} |
fe1dc867-3d91-47d4-9c54-142198ad0364 | 7 | public ArrayList chooseFile(Component source, boolean fromPerformAction){
File tempFile = fileChooser.getCurrentDirectory();
fileChooser.setCurrentDirectory(tempFile.getParentFile());
fileChooser.setCurrentDirectory(tempFile);
fileChooser.rescanCurrentDirectory();
fileChooser.s... |
c83298c4-ba19-485a-996a-4a554672977a | 7 | public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedSecurity=true;";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
Res... |
c648e40f-cc04-4368-be04-1e143159df79 | 7 | public HashMap<String, Object> getForm(){
form = new HashMap<String, Object>();
Component[] fields = getComponents();
for(Component field: getComponents()){
if (field.getClass().getSimpleName().equalsIgnoreCase("JTextField")) {
JTextField f = (JTextField) field;
... |
9d18a2a1-b23a-47a5-9451-1aa2e4af6f42 | 1 | public String[] browse(){
String[] files = null;
try {
ftp.changeDirectory(fileRep);
files = ftp.directoryNameList();
}
catch (Exception e) {
e.printStackTrace();
}
return files;
} |
8d67e1c2-8aab-4e15-92fe-f8276cca8a76 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Item)) {
return false;
}
Item other = (Item) object;
if ((this.itemId == null && other.itemId != null) || (this... |
331e1d33-31d9-4b0f-9e01-f72ebfaa0c8f | 0 | public Block get(int x,int y,int z){
return blocks[x][y][z];
} |
dfab3adb-1ca5-41e8-be6b-6e24190d1b55 | 1 | @Override
public NoteElement completeWith(Element<?> element) {
completeStylesWith(element);
return this;
} |
b1982275-f71b-4edf-8f5c-13932df5f35f | 3 | private static int sort(int[] array) {
for (int i = 0; i < array.length - 1; i++) {
for (int j = 0; j < array.length - i - 1; j++) {
if (array[j] < array[j + 1]) {
int temp = array[j];
array[j] = array[j + 1];
array[j + 1] =... |
9b4c95aa-f24e-4887-88a0-ebad117cf7be | 0 | public static String getBook(int bookId) {
return bookContents[bookId-300];
} |
94487c23-9119-494c-bbc0-8485d62766ba | 8 | public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s) {
if (s.startsWith("\"") && s.endsWith("\"")) {
return s.substring(1, s.length() - 1);
}
if (s.startsWith("(") && s.endsWith(")")) {
return s.substring(1, s.length() - 1);
}
if (s.startsWith("[") && s.endsWith("]")) {
return ... |
fca2cce1-9e7e-428c-8844-8457e1717e7a | 6 | public static DefaultTableModel getTableModelForGuest(Guest guest){
Vector<Object> drinks = new Vector<Object>(); // to return
Vector<Object> drinkRow = new Vector<Object>(); // a row
Vector<Object> columns = new Vector<Object>(); // columns
int i = 0; // reusable iterator
try {
Connection conn = ... |
2545c8bf-c766-4d9c-899f-b95051b66bdc | 4 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String[] queue = plugin.queue;
if (args.length == 0) {
sender.sendMessage("Current queue:");
for (int pos=0; pos < queue.length; pos+=2) {
String form1 = queue[pos];
String form2 = queue[pos+1];
if (form1 ==... |
e8b61a3c-253a-4f22-903b-af8e992755d4 | 4 | public static int reverse(int x) {
int tmp_now = 0;
int tmp_prv =0;
int res = 0;
boolean fu = false;
if (x < 0) {
x = -x;
fu = true;
}
if(x<10){
return x;
}
res = x % 10;//calc first
x = x / 10;
while (x != 0) {
tmp_now = x % 10;
res = res*10 + tmp_now;
x = x / 10;
}
if (fu)
... |
0b3690dd-d40d-4d8e-8d66-892f951868a3 | 8 | public static InetAddress getByName(final String name)
throws DNSSECException, IOException {
final Name full = Name.concatenate(Name.fromString(name), Name.root);
System.out.println("Verifying record: "+ full);
//final String [] servers = ResolverConfig.getCurrentConfig().servers();
... |
96d04d88-5468-4210-a159-4a2d97ebe6ee | 8 | public static Post findByPostID(int id) throws SQLException, NamingException {
Connection conn = null;
PreparedStatement stmt = null;
Statement st = null;
ResultSet rs = null;
ArrayList<Comment> comment = new ArrayList<Comment>();
ArrayList<Graffiti> graffiti = new ArrayList<Graffiti>();
Post post = ne... |
b5893411-7a22-4292-a371-7997c8af5bb4 | 0 | public static void main(String[] args) {
boolean t = true, f = false;
System.out.println(t & f); // false
System.out.println(t | f); // true
System.out.println(t ^ f); // true
System.out.println(!t); // false
} |
0764182e-6416-4e93-a7ed-bd095f60a003 | 7 | public void newGame() {
firstStart = true;
desk = new Desk();
final Ball ball = new Ball(desk);
if (botChoosed == 0) {
bot = new DeskBot(ball);
} else {
bot = new DeskBotHard(ball);
}
ball.setBotDesk(bot);
BufferedImage tempReadBg =... |
774c25a1-411c-4899-a6ad-97b7c659a84a | 6 | public boolean check(StringBuilder aValue, String MAX_VALUE) throws UnsignedException {
if (aValue.charAt(0) == MIN_VALUE) {
throw new UnsignedException(); //is there a -
} else if (aValue.length() < MAX_VALUE.length()) { //less letters?
return false;
... |
6132df45-402a-44b3-a36e-419bffcd180b | 9 | @Override
public void run(String[] args) throws SQLException, InterruptedException {
if (args.length < 1) {
System.out.println("Arguments: config-file");
System.exit(1);
}
dbManager = createDatabaseManager(args[0]);
dbManager.setResultShipmentBatchSize(5000);
TableManager tableManager = new Table... |
886fc630-9d0a-45a7-9077-380a96503c9a | 5 | private static final void deleteBBSThread(final MapleClient c, final int localthreadid) {
if (c.getPlayer().getGuildId() <= 0) {
return;
}
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT threadid, postercid FROM bbs_threads WHERE guildid = ? A... |
b6178188-a0a0-4d46-95e9-75bb6c683956 | 4 | public String parseState(mxCellState state, boolean edge)
{
Map<String, Object> style = state.getStyle();
// Parses the bounds
state.setX(mxUtils.getDouble(style, "x"));
state.setY(mxUtils.getDouble(style, "y"));
state.setWidth(mxUtils.getDouble(style, "width"));
state.setHeight(mxUtils.getDouble(style, "... |
f2d3b392-2fba-4968-b765-86c438bcf81c | 4 | public boolean replicateFile(File master, int resID)
{
// check for errors first
if (master == null || resID == -1) {
return false;
}
File file = master.makeReplica(); // makes a replica of this file
int fileSize = file.getSizeInByte(); // size of the replic... |
a3558029-4afc-4db2-9d64-a67103f1aa7d | 1 | @Override
public void paintComponent(Graphics g)
{
try
{
BufferedImage card = ImageIO.read(getClass().getResource(path));
g.drawImage(card, x, y, null);
}
catch (IOException e)
{
g.drawString("UNKNOW", x, y);
}
} |
222c17dc-be3f-4f6f-9c22-90bd8e87385a | 9 | private boolean r_t_plural() {
int among_var;
int v_1;
int v_2;
int v_3;
int v_4;
int v_5;
int v_6;
// (, line 160
// setlimit, line 161
v_1 = limit - cursor;
... |
b2ee62f7-f4ba-44b3-aaee-b62d15d920c8 | 9 | @Override
public void happens() {
Character character = Game.getInstance().getCurrentCharacter();
int rollResult = character.getTraitRoll(Trait.SANITY);
if (rollResult >= 4){
character.incrementSanity();
} else if ((rollResult >= 2) && (rollResult <= 3)){
character.decrementSanity();
} else{
charact... |
43c82845-d302-4168-8125-6119034985e4 | 0 | public DebitCard(int amount) {
this.acceptability = new AcceptedEverywhere();
this.balance = amount;
} |
16b24e17-d932-41ea-8dd6-5919bf1700b5 | 4 | public String getWebPageGzipHTTP(String URI){
String renderedPage = "";
Variables.currentURI = URI; //store the current URI in our globals library
try {
URLConnection connect = new URL(Variables.currentURI).openConnection();
BufferedReader in = null;
connect.setReadTimeo... |
64bb7343-f774-4d63-850d-469a47b5d9d1 | 4 | public boolean opEquals(Operator o) {
if (o instanceof InvokeOperator) {
InvokeOperator i = (InvokeOperator) o;
return classType.equals(i.classType)
&& methodName.equals(i.methodName)
&& methodType.equals(i.methodType)
&& methodFlag == i.methodFlag;
}
return false;
} |
1ba6cbd8-f766-43b8-a60a-23dddb1da64f | 8 | private static int decode4to3(
byte[] source, int srcOffset,
byte[] destination, int destOffset, int options ) {
// Lots of error checking and exception throwing
if( source == null ){
throw new NullPointerException( "Source array was null." );
} // end if
... |
71cd8748-18c8-41ef-bf3e-7818ed56ec1f | 0 | public String getTip() {
return (String) getValue(SHORT_DESCRIPTION);
} |
27ef2c73-1b45-40bb-baac-7b2791bc3824 | 1 | public void visitVarInsn(final int opcode, final int var) {
if (mv != null) {
mv.visitVarInsn(opcode, var);
}
execute(opcode, var, null);
} |
444d5e84-03d9-4601-af0a-d25e566d5ce1 | 1 | @Override
public String toString() {
// StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
int counter = 0;
for (MatterInterval mi : intervals) {
// [counter]: [MatterInterval]\n
s.append(counter++);
s.append(String.valueOf... |
8a669e63-334c-4398-a306-2059ff39e88a | 5 | public String toString(){
String deckResult="Your deck"+"\n";
//Only one card to add to deckResult
if (deck.size()==1){
deckResult+=deck.get(0);
}
else{
for (int i = 0; i<deck.size(); i++){
//5 cards per line
if (i%5==0)
deckResult+="\n";
//No comma at the end of the string
if(i == deck.siz... |
f14cdad4-5862-4884-88a9-7197068b5c1a | 4 | @Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (onkoKirjautunut(request, response)) {
try {
asetaAsiakkaanTiedot(re... |
1bcf0981-1071-4cf0-bd9c-86e9d7810aa2 | 8 | public void initLake(Coordinate coord) {
Coordinate temp;
Coordinate coordNorth = coord.copy();
Coordinate coordEast = coord.copy();
Coordinate coordSouth = coord.copy();
Coordinate coordWest = coord.copy();
setCell(coord, Water.getInstance());
int direction;
int emission;
direction = (int) (Math.ran... |
30accdf8-5062-4a31-9813-04fcea36b11b | 7 | @Override
public void serialEvent(SerialPortEvent evt) {
if (evt.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
byte singleData = (byte) input.read();
if (singleData != NEW_LINE_ASCII) {
logText = new String(new byte[]{singleData});
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.