method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
fcba6912-297d-44da-8322-24b07936693d | 3 | public static Scanner scannerForWebPage(String page) {
try {
String filename = page.substring(page.lastIndexOf('/')+1);
File local = new File(filename);
if (local.isFile()) return new Scanner(local);
URL u = new URL(page);
FileOutputStream save = new FileOutputStream(local);
InputStream read = u.ope... |
7e65fa45-d840-4b7b-ab46-17a9d4f7a8af | 5 | private T NextLargestRec(T key, BTPosition<T> node) {
T found = null;
if (node.getLeft() != null) {
found = NextLargestRec(key, node.getLeft());
}
if (comp.compare(node.element(), key) > 0 && found == null) {
found = node.element();
}
if (node.getRight() != null && found == null) {
found = Next... |
aa6e0e9c-9b6b-4357-90f8-7779e9c94933 | 8 | @Override
public List<Map<String, ?>> Fotos_usuario(String idtr,String tipo) {
List<Map<String, ?>> lista = new ArrayList<Map<String, ?>>();
String tabla ;
if(tipo.equals("todo")){
tabla ="rhth_fotos_trabajador";
}else{
tabla ="rhtr_fotos_trabajado... |
4f6f0a17-1d30-443d-b601-15a3084765a6 | 5 | public boolean processMsg(CConnection cc) {
OutStream os = cc.getOutStream();
StringBuffer username = new StringBuffer();
StringBuffer password = new StringBuffer();
// JW: Launcher passes in username and password as properties of Options object,
// so there's no need to pop up a dialog asking for... |
6ec647df-5896-4230-a63b-e6406e423cc0 | 9 | public List<Entry> processData(Document doc) {
List<Entry> entryList = new ArrayList<>();
List<String> scriptures = new ArrayList<>();
List<String> topic = new ArrayList<>();
String date;
String content = null;
String scrip;
NodeList entry = doc.getEl... |
58e76988-eaa5-451f-acc7-2bcc8cb8cbac | 9 | public Array<Warp> createWarps(){
Array<Warp> warps = new Array<>();
MapProperties prop = tileMap.getProperties();
//create right warp
if(prop.get("next")!=null) {
String next = prop.get("next", String.class);
String nextWarp = prop.get("nextWarp", String.class);
int nextID = 0;
if(nextWarp!=null)... |
32b15526-4a32-4b46-974c-6ac2a537c172 | 5 | public Object [][] getDatos(){
Object[][] data = new String[getCantidadElementos()][colum_names.length];
//realizamos la consulta sql y llenamos los datos en "Object"
try{
if (colum_names.length>=0){
r_con.Connection();
String c... |
932ab287-a3b9-4870-be65-f1ed39107f2b | 9 | public static void startupWebtoolsSystem() {
synchronized (Stella.$BOOTSTRAP_LOCK$) {
if (Stella.currentStartupTimePhaseP(0)) {
if (!(Stella.systemStartedUpP("stella", "/STELLA"))) {
StartupStellaSystem.startupStellaSystem();
}
}
if (Stella.currentStartupTimePhaseP(1)) {
... |
750817e5-f10a-473d-99f2-96f1c2cbd892 | 2 | public static boolean isSection(String line){
if(line.charAt(0) == '[' && line.charAt(line.length() - 1) == ']'){
return true;
}
return false;
} |
fb6e3c7b-3cac-4190-af1f-0bf3e16cab80 | 3 | public String next()
{
if(console)
advance();
String ret = token;
String temp = line;
if(!console)
advance();
if(temp.equals(line))
line = line.substring(ret.length()).trim();
return ret;
} |
751a7982-b5ef-4c6c-9bff-8777708cd7ab | 0 | @Override
public User getUser() {
return user;
} |
2df09fd0-7145-4c9e-9a4f-0c29a94030a4 | 4 | @Override
public void run() {
try {
this.out = new DataOutputStream(socket.getOutputStream());
this.in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "US-ASCII"));
finishFlag = false;
while(!finishFlag) { ... |
1abfcd24-f5a8-4298-8c65-d08f103de13e | 7 | public void addLocus(Locus newLocus) throws Exception {
double tolerance = 1.0e-7;
newLocus.setChrom(this);
if (newLocus.getPosition()<headPos) {
if (newLocus.getPosition()<headPos-tolerance) {
throw new Exception("addLocus: position invalid");
}
... |
71596a62-8e6b-4d2c-9c87-5e77a09e9c02 | 3 | private void executeRemoving() {
if (action.contains("rooms")) {
}
else if (action.contains("corridors")) {
}
else if (action.contains("inner yards")) {
}
} |
358fa483-1417-46a2-a493-40f1476f1870 | 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... |
ed6e9f0e-cfaf-43ed-bbbe-c3c366dbf94d | 8 | public void optimizeParam(int numItns) {
assert wordTopicHist != null;
// update histograms
int njMax = wordTopicCountsNorm[0];
for (int j=1; j<T; j++)
if (wordTopicCountsNorm[j] > njMax)
njMax = wordTopicCountsNorm[j];
wordTopicNormHist = new int[njMax + 1];
for (int j=0; j<... |
ca507a64-80b0-436a-9cfe-47b8a25ca1d1 | 0 | public void mouseReleased(MouseEvent e)
{
} |
a9d1456d-4487-4f2b-b269-b91a44f86a0b | 2 | private void reloadBoardType(BoardTypeEnum myBoardType) {
String[] boardTypes = comboBoard.getItems();
String label = myBoardType.getLabel();
for (int index = 0; index < boardTypes.length; index++) {
if (label.equals(boardTypes[index])) {
comboBoard.select(index);
... |
acac9198-c4b4-47d8-a689-859bc17c132c | 5 | public static List<Integer> makeEratosthenesSieve() {
List<Integer> primes = new ArrayList<Integer>();
int upperBound = 10000;
int upperBoundSquareRoot = (int) Math.sqrt(upperBound);
boolean[] isComposite = new boolean[upperBound + 1];
for (int m = 2; m <= upperBoundSquareRoot; ... |
f3912f6c-5484-4bac-8bd3-10f916ef1ce4 | 8 | public boolean inDuelArena() {
if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
(absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
return true;
}
return false;
} |
1317f88a-dac3-48c8-8355-c17be5604a3e | 2 | @Override
//Disparado quando a tag de inicio eh encontrada
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
String tipo = getTipo();
if(tipo.equals("getCPU")){
switch(qName.toLowerCase()){ //tag atual. Ex.: <host.... |
0c48c93b-70ca-4645-83ec-065be1af21e3 | 0 | public void func() {
System.out.println(this + ".func() : " + data);
} |
ff188d01-f6b0-425b-8fae-d598fea213ec | 3 | public static Item[] getSortedList() {
Item[] inventoryList = Survivalist.getCurrentGame().getInventory().clone();
Item tempItem;
for(int i = 0; i < inventoryList.length - 1; i++) {
for (int j = i + 1; j < inventoryList.length; j++) {
if(inventoryList[i].getD... |
5cd263dd-8a06-463b-96c8-b4cee74f8834 | 0 | public void mouseExited(MouseEvent e) {
} |
009e381a-403e-4d4e-a58c-d5934108b378 | 3 | private static ArrayList<File> files(File dir)
{
final ArrayList<File> files = new ArrayList<File>();
if (!dir.isDirectory()) throw new IllegalArgumentException("dir Isn't a Directory! " + dir);
for (int i = 0; i < dir.listFiles().length; i++)
{
if (dir.listFiles()[i].isDirectory())
{
files.addAll(... |
a34d0e10-86a4-4afe-984d-a5cd66cc33d2 | 9 | public static void turn (char[][] game, int player){
int x, y;
//read in x & y coordinates
boolean valid_coord = false;
while (!valid_coord){
Scanner in = new Scanner(System.in);
System.out.println("Player " + player);
System.out.println("Please enter your x coordinate: ");
x = in.nextInt();
Syst... |
a8cf6629-70fd-466c-bdaf-c0c9038f5971 | 7 | protected void validateField() throws Exception {
// do some type checking here
if (m_fieldDefs != null) {
Attribute a = getFieldDef(m_fieldName);
if (a == null) {
throw new Exception("[FieldRef] Can't find field " + m_fieldName
+ " in the supplied field definitions");
}
... |
b23ca1b1-64a8-4731-8e9a-383ad79959ae | 2 | public void addFormVotingUser(int userId, int formId) throws ErrorAddingUserException {
try {
String q = "insert into ValidVoter values(?, ?);";
PreparedStatement st = conn.prepareStatement(q);
st.setInt(1, userId);
st.setInt(2, formId);
st.executeUpda... |
e240d2bc-187a-4dc0-bb71-094b6f7d9d0c | 9 | @EventHandler
public void onChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
ChatMode chatMode = ruChat.modes.get(player);
boolean isGlobal = event.getMessage().startsWith("!") && event.getMessage().length() >... |
a974b708-08b2-4d54-a374-d02ca9062f73 | 1 | @Override
public boolean register(Game g, Rack r) {
super.register(g, r);
no_progress = g.rack_size*2;
return random.register(g, r) && learner.register(g, r);
} |
3c9d259a-521b-412a-ac62-c8158b2be93b | 2 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try {
final XYDataset dataset = studyDatasetBaseLyon();
final JFreeChart chart = createSimpleChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
... |
56f28cfb-eade-43a4-b617-8d619aa7d149 | 3 | @Override
public boolean createTable(String query) {
Statement statement = null;
try {
if (query.equals("") || query == null) {
this.writeError("SQL Create Table query empty.", true);
return false;
}
statement = connection.createStatement();
statement.execute(query);
return true;
} catch ... |
6921e62d-4e14-42c6-8fa8-0fc1dda61127 | 7 | public static boolean setNewLeader(String[] args, CommandSender s){
//Various checks
if(Util.isBannedFromGuilds(s) == true){
//Checking if they are banned from the guilds system
s.sendMessage(ChatColor.RED + "You are currently banned from interacting with the Guilds system. Talk to your server admin if you be... |
aa10e6a1-70ed-4455-aab3-97b7128e38e1 | 2 | public CharSequence getNameSignature() {
String stereotypes = Stereotypes.toSignature(this.stereotypes);
if(stereotypes!=null && !stereotypes.isEmpty())
return stereotypes + " " + className;
return className;
} |
785eb9a6-dd96-4665-8009-4a897264ab21 | 7 | public static Territory[] getTerritories(String mapName) throws IOException{
File file = new File("WarbornData/maps/" + mapName + ".txt");
LineNumberReader lnr = new LineNumberReader(new FileReader(file));
lnr.skip(file.length()-1);
int lines = lnr.getLineNumber()+1;
BufferedReader in = new BufferedReader(... |
5faf3119-5118-4b40-865c-c1e2c2fd829b | 5 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(double1);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result
+ ((doubleObject == null) ? 0 : doubleObject.hashCode());
result = prime * result + Float.floatTo... |
aade8a15-0fd7-4a83-ac2d-d7065fe65a1e | 7 | private DataTelegram getDataTelegram(final long maximumWaitingTime, byte telegramType) {
long waitingTime = 0, startTime = System.currentTimeMillis();
long sleepTime = 10;
while(waitingTime < maximumWaitingTime) {
try {
synchronized(_syncSystemTelegramList) {
if(_disconnecting) throw new RuntimeExcept... |
033605bb-8ccc-4c85-b2e8-69c263dff9eb | 9 | static private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(2, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(3, active0);
return 4;
}
switch(curChar)
{
... |
9fb2a09d-101a-4691-adf2-58f1bc7579b0 | 9 | public ArrayList<Ticket> createTicketArrayListByQueue(int queueType) {
ArrayList<Ticket> result = new ArrayList<Ticket>();
ResultSet rs = null;
PreparedStatement statement = null;
try {
String sqlString;
switch (queueType) {
case 0:
sqlString = "select * from Tickets where Pending=true";
... |
4e5e3eb4-2ff5-4945-9713-369cdaa12a61 | 0 | private String replacePi(String calculation) {
return calculation.replaceAll("pi", Double.toString(Math.PI));
} |
1ca017b2-635d-4665-857f-705790ebc512 | 0 | public String getId() {
return id;
} |
c00d3dc8-7ea3-4746-8c09-29d8b8563db4 | 0 | @Test
public void validationDoubleWithDoublePositiveTest() {
view.getTimeStepTextField().setText("11.6");
view.getTimeStepTextField().getInputVerifier().verify(view.getTimeStepTextField());
assertTrue(view.getDrawButton().isEnabled());
} |
a45d851a-b8f7-4bd2-a3d8-8569a3d1f58e | 7 | @Override
public boolean perform(final Context context) {
// Example: /<command> format[ get][ <Player>]
int position = 2;
if (context.arguments.size() >= 2 && !context.arguments.get(1).equalsIgnoreCase(this.name)) position = 1;
OfflinePlayer target = Parser.parsePlayer(context, posi... |
6f28ba44-14c1-4ae9-824d-52a5fd593e78 | 3 | public void visitCheckExpr(final CheckExpr expr) {
if (expr instanceof ZeroCheckExpr) {
visitZeroCheckExpr((ZeroCheckExpr) expr);
} else if (expr instanceof RCExpr) {
visitRCExpr((RCExpr) expr);
} else if (expr instanceof UCExpr) {
visitUCExpr((UCExpr) expr);
}
} |
44c08255-656c-4a85-a2b6-e62142f7ac32 | 8 | public void handleKey(int action){
if(action<0 || current == 0){
if(action==current)
current=0;
return;
}
switch(current){
case InteractivePanel.LEFT:
properties.setLeftCtrl(action);
leftCtrl.setText(KeyEvent.getKeyText(action));
break;
case InteractivePanel.RIGHT:
properties.setRightCtr... |
bdc06262-4b54-4e73-8bbd-b416f40807eb | 9 | public static void registerSlot(Slot slot, String targetSignal, Class<?>[] params) throws IllegalArgumentException, InvalidReturnTypeException
{
SignalStructure struct = linker.get(targetSignal);
if (params == null)
{
if (struct.getInvokerParameters() != null)
{
throw new IllegalArgumentException("Erro... |
f6291e0c-b1e9-4604-ac7a-4e1d232551e4 | 3 | public void processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
{
if((inOff + len) > in.length)
{
throw new RuntimeException("output buffer terlalu sedikit");
}
if((outOff + len) > out.length)
{
throw new... |
f72c02bc-5e3f-4aee-af5f-5790ac0c084a | 2 | public void input(char input){
if(!running){
running=true;
player.charInput(input);
for(Enemy e: enimies){
//e.takeTurn();
}
running=false;
}
} |
460b0afa-fc16-4a68-b95f-384607651a75 | 4 | @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((password == null) ? 0 : password.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result
+... |
1659dd05-1d14-49d0-80b9-ea32c032c5f2 | 5 | public JdbcQueryTaskParameters(String sql, int fetchSize, boolean returnKeys, PreparedStatementCallback<?> action,
Object... args) {
int hashCode = 0;
this.sql = sql;
hashCode += sql.hashCode();
this.fetchSize = fetchSize;
hashCode += fetchSize;
this.returnKeys = returnKeys;
hashCode += (retu... |
0a0c25f6-fd8b-4f45-aad9-cf0bfccec62c | 7 | public boolean Hand1BeatsHand2(String hand1, String hand2) {
Hand firstHand = new Hand(hand1);
Hand secondHand = new Hand(hand2);
PokerHandValue firstHandRank = GetHandRank(firstHand);
PokerHandValue secondHandRank = GetHandRank(secondHand);
while (firstHandRank.compareTo(secon... |
d9dc9e98-72a0-4036-9700-29214b0c5167 | 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... |
b57caf2c-9c62-42da-bdf0-617051ce721f | 3 | public ArrayList<HashMap<String, String>> getOxima(int id){
/*
* epistefei ta stoixia enos sugkekrimenou oximatos
*/
ArrayList<HashMap<String, String>> oxima=new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
try {
pS = conn.prepareStatement("SELECT *... |
dd929af5-a779-497d-8b26-8459a77bf92a | 1 | public static InputStream loadResourceAsStream(String resourcePath) {
if(resourcePath.startsWith("/")){
return ResourceLoader.class.getResourceAsStream(resourcePath);
}else{
System.err.println("A resource path must(!) begin with a \"/\"");
return null;
}
} |
53da3d16-596f-4e3b-afbc-cde876b42684 | 4 | @Override
public Card chooseCard(Player player, Card[] cards, GameState state) {
//If there's only one choice, we have no choice but to do it
if(cards.length == 1)
{
return cards[0];
}
int alpha = Integer.MIN_VALUE;
int beta = Integer.MAX_VALUE;
Card choice = null;
ArrayList<Color> playerLi... |
32f4a4d9-293e-496b-ab3c-a9f58e8cd5aa | 0 | public int getS1() {
return this.state1;
} |
67e59c41-2705-48a2-8e26-9494a03cc6fe | 5 | final void method1228(int i, int i_63_, int i_64_, int[] is, boolean bool,
int[] is_65_) {
try {
if ((anInt2103 ^ 0xffffffff) != (i_64_ ^ 0xffffffff))
anInt2103 = i_64_;
anIntArray2092 = is;
if (i_63_ <= 54)
anIntArray2092 = null;
((Class154) this).anIntArray2095 = is_65_;
anInt2090++... |
901ea4f2-459f-4af5-b50b-80529a298e09 | 8 | public Expr array_length(Context ctx, HashMap<String, Expr> symbolTable) throws Z3Exception{
Expr ret = null;
if(this.a_inputs.get(0).leaf!=null && this.a_inputs.get(0).leaf.type.equals("string") && symbolTable.containsKey(((a_string)this.a_inputs.get(0).leaf).s)){
ret = ctx.MkConst((((a_string)this.a_inputs.get... |
3fec24d6-c762-4b8e-b43e-51abcdf323f0 | 0 | public int GetBusNumber()
{
return busNumber;
} |
5205066a-a84e-47be-8416-8bc0e067c4ed | 5 | private void recv(SyncPDU m) {
cancelTimerTask();
try {
byte type = m.getType();
boolean sv = false;
switch (type) {
case SyncPDU.REQALL:
respondSendAllItems(m);
break;
case SyncPDU.REQ:
... |
34e2189c-4818-4e38-bbb8-53bcba715c7c | 7 | public static boolean checkSudoku(int[][] matrix) {
ArrayList<HashSet<Integer>> rowsSets = new ArrayList<HashSet<Integer>>(9);
ArrayList<HashSet<Integer>> columnsSets = new ArrayList<HashSet<Integer>>(9);
ArrayList<HashSet<Integer>> subSets = new ArrayList<HashSet<Integer>>(9);
for(int i = 0; i < 9; i++) ... |
f29727c7-9ea0-4ee3-8803-2f84a00bf767 | 2 | private static void dfs(int n, ArrayList<ArrayList<Integer>> g, ArrayList<Integer> results, boolean[] visited){
visited[n]=true;
for(Integer neighbor:g.get(n)){
if(!visited[neighbor]){
dfs(neighbor, g, results, visited);
}
}
results.add(n);
} |
6d34e696-0da5-4ca7-a887-9ae3a6821530 | 3 | private void putInCache(String prefix, String uri) {
// Not already in cache
if (!uri2Prefix.containsKey(uri)) {
// Find an available default namespace
if (DEFAULT_NS.equals(prefix)) {
int index = 0;
while(prefix2Uri.containsKey(DEFAULT_NS + index)){
index++;
... |
fa808c75-20d1-4683-8237-52f63a4bcf92 | 6 | public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page ... |
9e4300e0-c24a-40d0-830c-91119dcffb12 | 7 | @Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
//------------------------------------------------------------------------------Painting the correct character
if (characterChosen == 1) {
g.drawImage(hero.image, heroCurrentX, heroCurrentY, 50, 50, null)... |
ed17dec7-15cc-488a-aa80-ef260bd715bb | 5 | public static Check getInstance(int checkType)
throws UnsupportedOptionsException {
switch (checkType) {
case XZ.CHECK_NONE:
return new None();
case XZ.CHECK_CRC32:
return new CRC32();
case XZ.CHECK_CRC64:
return n... |
fd774d16-3fe1-473f-bbff-38c91c739ac3 | 3 | private void loadSettings() {
if (settings.containsKey(Settings.THEME)) {
changeTheme((String)settings.get(Settings.THEME));
} else {
changeTheme(Utils.GUITHEME.Snow.name());
}
if (settings.containsKey(Settings.SCREEN_LOC_X)) {
int x = ((Number)settings.get(Settings.SCREEN_LOC_X)).intValue();
int... |
e05b2261-a9a3-4450-8340-b2f32560b545 | 3 | public static EnvironmentReasonEnumeration fromString(String v) {
if (v != null) {
for (EnvironmentReasonEnumeration c : EnvironmentReasonEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} |
20191cf9-9b30-4825-a903-88cf363bbf4d | 9 | public void keyReleased(KeyEvent Par1)
{
int Key = Par1.getKeyCode();
if(currentState == State.Game)
{
if(Key == KeyEvent.VK_W)
{
Character.setVelY(0);
Character.canMoveUp = true;
}
else if(Key == KeyEvent.VK_S)
{
Character.setVelY(0);
Character.canMoveDown = true;
}
... |
d24fa842-85e3-4b45-89bc-37ae1bb7deec | 5 | private void popAndDownload()
{
Downloadable downloadable;
while ((downloadable = (Downloadable)this.remainingFiles.poll()) != null) {
if (downloadable.getNumAttempts() > 5) {
if (!this.ignoreFailures) this.failures.add(downloadable);
//Launcher.getInstance().println("Gave up trying to d... |
21017e7b-4ac1-47d0-ad26-d3db9ad9b14a | 0 | public Timestamp getRegtime() {
return this.regtime;
} |
500b01e3-b8fe-4803-bd63-acb4fd9f7222 | 9 | public boolean isDefault(aos.apib.Base o) {
TrackerInfo__Tuple v = (TrackerInfo__Tuple)o;
if (v.id != __def.id) return false;
if (v.warningCount != __def.warningCount) return false;
if (v.upload != __def.upload) return false;
if (v.download != __def.download) return false;
if (v.isOnline != __def.isOnline) ... |
189d4382-7d0f-4a5e-94f1-ef9ca438fe8e | 7 | private String affectedFacialTarget(int affected)
{
switch(affected)
{
case 0:
return "outer-left character";
case 1:
return "inner-left character";
case 2:
return "inner-right character";
case 3:
... |
f58d8860-8875-4c6a-b028-206e23898459 | 1 | public void Login() throws IOException {
String urlString = "";
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// client.setCookies(connection, cookieJar);
connection.setDoOutput(true);
connection.setRequestMethod("POST")... |
3527d9e1-73c2-4c6c-91b8-0554c2c84430 | 7 | public int ladderLength(String start, String end, Set<String> dict) {
Queue<String> queue = new LinkedList<String>();
Set<String> visited = new HashSet<String>();
int level = 1;
int lastNum = 1;
int curNum = 0;
queue.offer(start);
visited.add(start);
while(!queue.isEmpty()){
String cur = que... |
ec1fe9de-fe6a-4a0c-9f35-f9d41137af5b | 6 | private void complExpAritmetica() {//ok
if (tipoDoToken[1].equals(" +")) {
if (!acabouListaTokens()) {
nextToken();
this.termoAritmetico();
if (!acabouListaTokens()) {
nextToken();
this.complExpAritmetica();
... |
bbfbaccd-25e6-4e4b-8985-47d5f884f728 | 9 | public TTTBoard() {
grid = new Grid();
ComputerPlayerMinMax computer = new ComputerPlayerMinMax(grid);
computer.setType(CellType.CROSS);
int firstPlayer = -1;
System.out.println("Your symbol is O and computer's symbol is X.");
System.out.println("Enter 0 to play first; 1 to let computer play first.");
... |
f4fddd89-70a3-4764-bb9b-6013d83a4f7e | 1 | @Override
public void clearAttributes() {
if (attributes != null) {
this.attributes.clear();
this.isReadOnly.clear();
}
} |
9aed8e8f-489c-4913-ad94-6a1f9cc19120 | 2 | public static void start(Component component, Cursor cursor) {
JRootPane rootPane = SwingUtilities.getRootPane(component);
if (rootPane != null) {
Component glassPane = rootPane.getGlassPane();
MouseCapture capture = new MouseCapture(glassPane, component);
glassPane.addMouseListener(capture);
glassPane.... |
eee958f5-86c4-4dd6-a156-a09e4098c3b3 | 5 | public AST rStatement() throws SyntaxError {
AST t;
if (isNextTok(Tokens.If)) {
scan();
t = new IfTree();
t.addKid(rExpr());
expect(Tokens.Then);
t.addKid(rBlock());
expect(Tokens.Else);
t.addKid(rBlock());
r... |
686346f8-f362-4858-8c96-fd0aef951adc | 0 | @Test
public void test_getSizeY(){
assertNotNull(pawn);
assertEquals(posY, pawn.getY());
} |
8b2afe38-fc75-43f0-a081-12d18b3bd253 | 1 | public static boolean isVandalism(int s) {
if(s==62977)
return true;
return false;
} |
8f8ecac8-4e6d-4312-aa87-d98d5b10a518 | 9 | private void Ok()
{
if(list == null)
{
setList();
}
if(loginTextField.getText().length() == 0)
{
JOptionPane.showMessageDialog(f, "Enter login");
return;
}
if(passTextField.getText().length() == 0)
{
JOptionPane.showMessageDialog(f, "Enter password");
return;
}
try {
ConnectMet... |
0a9614f4-4d2e-426a-983b-963c53f691b5 | 6 | private boolean isPic(String s) {
if(s.startsWith("http") && (s.contains(".jpg")||s.contains(".png")||s.contains(".bmp")||s.contains(".gif")||s.contains("jpeg"))){
return true;
}
else
return false;
} |
821d3788-5f65-4563-b177-550dc6224b4c | 3 | public static String escapeChars(final byte... bytes)
{
final StringBuilder buf = new StringBuilder();
for (byte b : bytes)
if (b >= 32 && b < 127)
buf.append(Character.toChars(b));
else
buf.append('.');
return buf.toString();
} |
2af95ddc-0015-447e-bf27-7bfb873ee3e7 | 9 | public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n==0)break;
int[] a = new int[n];
for(int i=0;i<n;i++)a[i]=sc.nextInt();
int s = a[0];
int t = a[0];
Queue<String> l = new LinkedList<String>();
for(int i=1;i<n;i++){
if(t+... |
a80e234f-2449-4134-aaed-7270006d8806 | 7 | public static void createTiles() {
try {
Tilelist = new ArrayList<Tile>();
SpriteSheet tiles = new SpriteSheet(PATH_TILE, TILEWIDTH, TILEHEIGHT);
tiles.setFilter(SpriteSheet.FILTER_NEAREST);
SpriteSheet walls = new SpriteSheet(PATH_WALL, WALLWIDTH, WALLHEIGHT);
walls.setFilter(SpriteSheet.FILTER_NEARES... |
29ca31da-647a-4842-8a11-4a48980460f6 | 8 | public static TreeNode getLastCommonParent(TreeNode root, TreeNode n1, TreeNode n2) {
if (root == null || n1 == null || n2 == null) {
return null;
}
ArrayList<TreeNode> p1 = new ArrayList<TreeNode>();
boolean res1 = getNodePath(root, n1, p1);
ArrayList<TreeNode> p2 = new ArrayList<TreeNode>();
boolean r... |
249e124c-8d37-41c6-b06e-1f519afccca5 | 7 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
int x1 = input.nextInt();
int y1 = input.nextInt();
int x2 = input.nextInt();
int y2 = input.nextInt();
if (x1 + x2 + y1 + y2 == 0) return;
int dx = x1 - x2;
i... |
259d444e-630f-42a9-9f44-00fefd88d94f | 1 | public Set<String> getURLs(String url) throws IOException {
Set<String> urls = new HashSet<>();
String content = getURLContent(url);
Matcher m = Pattern.compile(urlPattern).matcher(content);
while (m.find()) {
urls.add(m.group());
}
return urls;
} |
c6047eb2-eab2-4178-8b61-39bf39303f50 | 2 | public void flipHorizontal() {
byte image[] = new byte[width * height];
int off = 0;
for (int offY = 0; offY < height; offY++) {
for (int offX = width - 1; offX >= 0; offX--) {
image[off++] = pixels[offX + offY * width];
}
}
pixels = image;
offsetX = trimWidth - width - offsetX;
} |
54878e9f-6c43-4441-8651-58d9b7777c98 | 2 | public ArrayList<ArrayList<Integer>> permute(int[] num) {
LinkedList<int[]> mappers = search(num.length);
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
for (int[] mapper : mappers) {
ArrayList<Integer> tmp = new ArrayList<Integer>();
for (int... |
d6e36893-76b0-4525-9d4a-cbdfee89125e | 4 | public static VoteCast closePolls(){
open = false;
Broadcast.vote("Voting for next map is now closed.");
VoteCast win;
if(A >= B && A >= R) win = VoteCast.A;
else if(B > A && B >= R) win = VoteCast.B;
else win = VoteCast.R;
HotbarManager.clearAll();
return win;
} |
8a67558c-e3f5-40f1-9006-9d72fccbaee6 | 1 | @Test
public void clone_test() {
try{
double []mat1= {1.0,2.0,3.0,1.0};
double result[] = Vector.clone(mat1);
double exp[]= {1.0,2.0,3.0,1.0};
Assert.assertArrayEquals(exp, result, 0);
}
catch (Exception e) {
// TODO Auto-generated catch block
fail("Not yet implemented");
}
} |
b83251fb-194b-4b43-9a03-3418bcb482e4 | 2 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
if (this.troveKey == null){
Properties props = new Properties();
try{
// properties file should be put here (not included in repo)
props.loa... |
dea82c5b-7445-4458-aab8-8c88afb448c6 | 3 | public List<List<Object>> calculateMedianString() {
List<List<Object>> bestKMer = new ArrayList<List<Object>>();
List<String> allKMers = calculateAllKMers();
int smallestHammingDistance = allKMers.size();
for (String pattern : allKMers) {
List<Object> helpList = new ... |
ce4611f3-d0f5-48a4-81cc-0071c7beca9b | 9 | public boolean checkSetState(UnitState s) {
switch (s) {
case ACTIVE:
case SENTRY:
return true;
case IN_COLONY:
return !isNaval();
case FORTIFIED:
return getState() == UnitState.FORTIFYING;
case IMPROVING:
return location in... |
061a98b7-3ef9-4d95-ba28-e5a48d400bd6 | 8 | public boolean pickAndExecuteAnAction() {
if(!payments.isEmpty()){
for(Payment p: payments){
makeTransaction(p);
return true;
}
}
if(!marketpayments.isEmpty()){
synchronized(marketpayments){
for(MarketPayment m: marketpayments){
PayMarket(m);
return true;
}
}
}
... |
4fbbc036-2e92-4178-b64a-5f6b33d98e3e | 2 | @Override
public String makeMove(CardGame game, CardPanel panel) {
Hand hand = game.getHand();
List<List<Card>> board = game.getBoard();
Card fromDeck = game.getDeck().pop();
//Do this first in case we get the same index twice in a row!
if (hand != null && hand.getIndex() != ... |
8c244798-f344-4d79-b95a-8128bcce479f | 1 | public void testGet_DateTimeFieldType() {
DateMidnight test = new DateMidnight();
assertEquals(1, test.get(DateTimeFieldType.era()));
assertEquals(20, test.get(DateTimeFieldType.centuryOfEra()));
assertEquals(2, test.get(DateTimeFieldType.yearOfCentury()));
assertEquals(2002, tes... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.