method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
2477ce91-be93-4c74-8458-79a1671f7ad5 | 4 | public String getScrambledWord(int idx) {
String c = WORD_LIST[idx];
Random rnd = new Random();
String[] a = new String[c.length()];
char f = 0;
String g = "";
String[] b = new String[100];
String e = "";
for(int i = 0; i<c.length();i++){
f=c.c... |
da3e85cf-1ad7-4bdb-9ba8-926b93b06402 | 3 | public int sizeOfWsFrameLength(byte type, int length) throws IOException {
// one bite for the type
int size = 1;
// Encode length.
int b1 = length >>> 28 & 0x7F;
int b2 = length >>> 14 & 0x7F;
int b3 = length >>> 7 & 0x7F;
if (b1 == 0) {
if (b2 == 0) {
if (b3 == 0) {
size += 1;
} else {
... |
94bb8384-e001-45fa-b7d9-eff605c826c2 | 8 | public void paint ()
{
int i, j;
dl_atom dla = null;
dl_bond dlb = null;
Vector dlist = new Vector ();
if (showForces)
computeForces ();
for (i = 0; i < atomList.size (); i++)
{
dla = new dl_atom ((atom) atomList.elementAt(i), v);
dlist.addElement (dla);
}
for (i =... |
0bfe628b-2dc4-437f-8dd5-d9628d08f729 | 3 | public void CheckCommands(String channel, String sender, String login, String hostname, String message)
{
if(!message.startsWith("!"))
return;
String params[] = message.split(" ");
String commandName = params[0].substring(1).toLowerCase();
... |
545c6f90-e6e6-4b15-9ea0-e170a8ef25e6 | 7 | private static<T extends Comparable<? super T>> void merge(T[] data, T[] tmp, int leftPos, int rightPos, int rightEnd) {
int leftEnd = rightPos - 1;
int tmpPos = leftPos;
int leftPos2 = leftPos;
while (leftPos <= leftEnd && rightPos <= rightEnd) {
if (data[leftPos].compareTo(... |
4a40366a-ad6c-47e1-b2f6-5c150fc05560 | 1 | public int minDepth(TreeNode root) {
if(root == null)
return 0;
deepTree(root,1);
return minDeep;
} |
ca74427d-fee9-4867-8eaf-3a113fdc88dc | 6 | public BagOfTiles() {
_tileBag = new ArrayList<Tile>();
_pointValueMap = new HashMap<Tile, Integer>();
String[] s = null;
@SuppressWarnings("resource")
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("Txt/Characters"));
} catch (FileNotFoundException e) {
// TODO Auto-genera... |
ec14af58-421f-4fc5-91a4-0d23aef14807 | 1 | public CtClass getCtClass() {
if (resolved != null)
return resolved.getCtClass();
return Type.OBJECT.getCtClass();
} |
7a772e4e-c8b6-494d-b75a-92f56b68c717 | 0 | public FindReplaceResultsDialog() {
super(false, false, false, INITIAL_WIDTH, INITIAL_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT);
} |
2a3ba6fa-c3ff-48a8-ad1b-76d70bde583e | 4 | public void collision(PhysicsCollisionEvent event) {
Spatial nodeA = event.getNodeA();
Spatial nodeB = event.getNodeB();
String nameA = nodeA.getName();
String nameB = nodeB.getName();
if(Meteor.NAME.equals(nameA) && "Me".equals(nameB)){
may... |
343ee113-080a-4408-b54b-3a76456b2cf9 | 8 | public void addEvent(Event event) {
events.add(event);
switch (event.getType()) {
case Event.BIRTH:
if (birth == null)
birth = event;
break;
case Event.BAPTISM:
if (baptism == null)
baptism = event;
break;
case Event.DEATH:
if (death == null)
death = event;
break;
... |
6e253bc7-7bed-4ad5-8dfa-46921cfbe925 | 1 | void printStdout(String text) {
if (text.lastIndexOf("%r") > 0) {
stdout.replaceRange(text.substring(text.lastIndexOf("%r") + 2),
stdout.getText().lastIndexOf('\n') + 1,
stdout.getText().length());
} else {
stdout.append(text);
... |
34557551-734f-49fc-80f9-38b35f1b6066 | 2 | public void update() {
speedX = bg.getSpeedX() * 5;
tileX += speedX;
r.setBounds(tileX, tileY, 40, 40);
if (r.intersects(Robot.yellowRed) && type != 0) {
checkVerticalCollision(Robot.rectBody, Robot.rectLegs);
checkSideCollision(Robot.rectLeft, Robot.rectRight, Robot.footleft,
Robot.footright);
}
... |
99163706-233b-4b92-ac05-f9859b011141 | 1 | public boolean Salvar(T obj) {
try{
//salva o objeto
manager.merge(obj);
return true;
}catch (Exception ex){
System.out.println(ex.getMessage());
return false;
}
} |
beb00a16-803f-4b17-8510-3f05521a5ade | 6 | void setExampleWidgetBackground () {
if (colorAndFontTable == null) return; // user cannot change color/font on this tab
Control [] controls = getExampleControls ();
if (!instance.startup) {
for (int i = 0; i < controls.length; i++) {
controls[i].setBackground (backgroundColor);
}
}
// Set the backg... |
9aa9c7a4-d582-492d-8ea1-485dfb4b8033 | 9 | public void actionPerformed(ActionEvent e) {
MindMapNodeModel node = (MindMapNodeModel) mMindMapController
.getSelected();
// if something is wrong, abort.
if (mMindMapController.getMap() == null || node == null
|| node.isRoot()) {
mMindMapController.... |
e725cb4c-dd6c-4041-b0bf-df26a9325822 | 9 | public void subSolve(ArrayList<String[]> resArr, int[] res, int n, int x) {
if (x > n - 1) { // DONE
String[] tmp = new String[n];
for (int i = 0; i < n; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < n; j++) {
sb.append(j == res[i] ? 'Q' : '.');
}
tmp[i] = sb.toString()... |
772427c5-1fa8-48f3-bdbc-c4b5849c917b | 9 | public boolean updateOneSymbol(Investment oneInvestment) {
boolean flag = false;
int type = getInvestType(oneInvestment.getSymbol());
String typeTable;
if (type == 0) {
typeTable = "stock";
} else {
typeTable = "mutual_fund";
}
Timestamp stamp = getLatestTimestamp(oneInvestment.getSymbol(), ty... |
7e308a26-097a-4e38-b08d-060b7860a9f9 | 3 | public static String selectListParam(Map<String, Object> paramMap) throws SQLException{
@SuppressWarnings("unchecked")
java.util.Map<String,Object> sqlWhereMap = (Map<String, Object>) (paramMap.get("sqlWhereMap")==null ? "": paramMap.get("sqlWhereMap"));
BEGIN();
SELECT(User.COLUMNS);
FROM(User.T... |
0e28881d-bd18-40a2-8ba8-2e57a5816624 | 3 | public TreeNode sortedListToBST(ListNode head) {
int count = 0;
ListNode p = head;
while (p != null) {
count++;
p = p.next;
}
int[] num = new int[count];
p = head;
count = 0;
while (p != null) {
num[count] = p.val;
... |
db72443c-bf76-4419-8ed2-285b399d2a43 | 4 | public ArrayList<String> anagrams(String[] strs) {
HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
ArrayList<String> result = new ArrayList<String>();
for (String str : strs) {
String min = toSmallest2(str);
ArrayList<String> tmp = map.g... |
694d9baa-da14-4701-9dcf-d76325d0197c | 7 | public void render(int x, int y, Renderable rend){
if(rend == null){
ErrorHandler.nullRenderableInterface(this, "@ render (line ~90");
return;
}
for(int yy = 0; yy <= rend.getHeight(); yy++){
int yp = yy + y;
for(int xx = 0; xx <= rend.getWidth(); x++){
int xp = xx + x;
if(xp < 0 || xp > this... |
46bb856f-da6c-41b5-9ace-7c2047b1ca0a | 8 | private void renderAttributes(PrintWriter out,
String labelName, Map<String, String> attributes) {
if ((labelName == null) && (attributes == null)) {
return;
}
out.print(" [ ");
if ((labelName == null) && (attributes != null)) {
labelName = attributes.get(... |
f189dbd4-30a8-4974-9ac0-ee9009f2b122 | 5 | @Override
public void detectAndHandleCollisions(EntityGrid grid, CollisionHandler physics, float dt) {
nearestEntity = grid.getNearest(this);
if (physics.boxCollisionTest(this, nearestEntity)) {
if (nearestEntity instanceof PlayerEntity) {
handlePlayerIntersection((Pla... |
cdbd60be-8ea0-4f50-9bc6-89d7055930c9 | 5 | public static String getAppPath(String type) throws UnsupportedEncodingException{
String appRoot = "";
String path = "";
String slash = System.getProperty("file.separator");
String jpath = new File(SBStringUtils.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getPath();
... |
bd300deb-3c0c-4ea6-8f70-658276bc959c | 0 | public void setSelect(boolean select) {
selected = select;
} |
4953c286-2944-4451-acc0-0452e76af42e | 9 | private void readInputAndUpdateCamera(Camera cam) {
int angle = mDemoKeyListener.getKeyDirectionAngle();
if (mDemoKeyListener.getMoveState()) {
switch(angle) {
case 0:
cam.x += 1;
break;
case ... |
f8481a5a-91cb-4f80-ab5a-b33340c5bd58 | 2 | public int maxSubArray(int[] A) {
int max = A[0];
int sum = 0;
for (int sell = 0; sell < A.length; sell++) {
sum = sum + A[sell];
max = Math.max(sum, max);
if (sum < 0)
sum = 0;
}
return max;
} |
3b03d685-776b-4a2f-8224-66c6a0c13dcb | 4 | public void doTestParsers() {
final int repeat = ConsoleMenu.getInt("How many Rows?", 1000);
final int numberOfCols = ConsoleMenu.getInt("How many columns?", 100);
final boolean qualif = ConsoleMenu.getBoolean("With qualifier?", true);
final StringBuffer aRow = new StringBuffer();
... |
73713e46-f75a-407a-a7c8-dbebcdc457b7 | 5 | public void testit( String argstr )
{
WorkBookHandle book = new WorkBookHandle();
// IMPORTANT PERFORMANCE SETTINGS!!!
book.setDupeStringMode( WorkBookHandle.SHAREDUPES );
book.setStringEncodingMode( WorkBookHandle.STRING_ENCODING_COMPRESSED );
WorkSheetHandle sheet = null;
try
{
sheet = book.get... |
cfc617fc-a8dc-449a-980c-1d3c6bc96c4e | 1 | private void createMenu() {
menuBar = new JMenuBar();
setJMenuBar(menuBar);
mnProject = new JMenu("Projekt");
menuBar.add(mnProject);
JMenuItem mntmNewProjectItem = new JMenuItem("Nowa gra");
mnProject.add(mntmNewProjectItem);
JMenuItem mntmSaveProjectItem = new JMenuItem("Zapisz grę");
mnProject.a... |
7b4cd0a1-eeeb-4b71-a27e-0f089eb3efd4 | 1 | public void actionPerformed(ActionEvent ae) {
if (((MenuItem)ae.getSource()).equals(importMenuItem)) {
importAgents();
} else {
exportAgents();
}
} |
5f0ec01d-8d94-4137-a726-6462789e1114 | 5 | @Override
public void changedStatus(boolean running, boolean connected){
String icon;
if(running){
if(connected){
this.status.setText("Status: " + STATUS_CONNECTED);
icon = GREEN_ICON;
}else{
this.status.setText("Status: " + STATUS_WAITING);
icon = YELLOW_ICON;
}
toggleBtn.setText("D... |
4d5b1356-b7f5-4d73-8362-70d9c8cbe4bd | 9 | private IntegerAggregate setDistance(Node start, Node finish, IntegerAggregate distance)
{
IntegerAggregate oldValue = distances.get(NodePair.get(start, finish));
boolean addDistance = oldValue == null || (oldValue.isNonterminating() && !distance.isNonterminating());
if (addDistance)
distances.put(... |
5d33cec2-fcb9-4da3-9013-bf1093ea4650 | 9 | public int nextopt() {
int argChar = -1;
for (int counter = this.argindex; counter < this.args.length; ++counter) {
if ((args[counter] != null) && (args[counter].length() > 1)
&& (args[counter].charAt(0) == '-')) {
int charIndex = 0;
argChar = args[counter].charAt(1);
charIndex = this.opt... |
8a135839-58dc-4616-8f47-c20225c2ea63 | 8 | public synchronized static boolean updatePollAnswer(String pollID, String recipientID, String answerID) {
boolean retValu = false;
XStream xstream = new XStream(new DomDriver());
Polls[] allPolls = new Polls[0];
try {
File file = new File((String) Server.prop.get("pollFilePath"));
allPolls = (Polls[]) ... |
d39d97c7-7986-4a5c-aee8-dfaed92a5c84 | 2 | private void determineNextToken() {
if (dfa.isInReturnState())
executeReturn();
else if (dfa.didJumpOccur())
executeJump();
else
moveToNextToken();
} |
7b264b54-4fd8-458f-8b5a-f2df3a7e9ac2 | 6 | @Override
public void run() {
while(true){
if(Keyboard.isKeyPressed(KeyEvent.VK_SPACE)){if(energie > 0){energie -= 1;}}
if(energie < 100 && Keyboard.isKeyPressed(KeyEvent.VK_SPACE) == false){energie += 0.25;}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
... |
c98516ca-2cf6-45bf-a356-2faf5be22477 | 9 | public static Lexical scanLexicon(String lexFilePath){
String line= "";
iIdentifier out;
PScanner scan = new PScanner(lexFilePath);
HashMap<String, CharacterC> chars = new HashMap<String, CharacterC>();
ArrayList<TokenC> tokens = new ArrayList<TokenC>();
int state = 0; //state 0 = first comments, 1 = i... |
881df745-879d-4826-ac23-a42ab5bc3f65 | 5 | public void makeColorKeyPixelsTransparent(BufferedImage img, Color colorKey)
{
// NOW MAKE ALL PIXELS WITH COLOR (64, 224, 224) TRANSPARENT
WritableRaster raster = img.getRaster();
int[] dummy = null;
for (int i = 0; i < raster.getWidth(); i++)
{
for (int j = 0; j... |
db8e3ccf-4f20-4b03-83bc-c8a848043bba | 9 | private void posizionaComponenti()
{
// Prepara il GroupLayout
this.remove(pannello); // Rimuove il pannello
pannello = new JPanel(); // Ne crea uno nuovo
GroupLayout layout = new GroupLayout(pannello); // Crea un nuovo Grou... |
73a4a8b2-66bc-45d0-90a8-5d7eb8bdf1a3 | 7 | public static void openFile(File file, Codec[] codecs) {
ParseException p = null;
for (int i = 0; i < codecs.length; i++) {
try {
Serializable object = codecs[i].decode(file, null);
if (openOrRead && !(object instanceof TuringMachine)) {
JOptionPane.showMessageDialog(null,
... |
957f4932-d744-47e5-bbd2-8a1d30d2b7b5 | 6 | public boolean satisfy(TagNode tagNode) {
if (tagNode != null ) {
for(Map.Entry<String, String>entry: tagNode.getAttributes().entrySet()) {
if ( (attNameRegex == null || attNameRegex.matcher(entry.getKey()).find()) && (attValueRegex == null || attValueRegex.matcher( entry.getValue() ... |
87bf7370-7bd3-4379-8391-9c5dd5bcfbd9 | 3 | public void actionPerformed(java.awt.event.ActionEvent e) {
// Selecting an item results in an actioncommand "comboBoxChanged".
// We should be reacting to these since the drop down doesn't update immediately.
// Hitting enter results in an actioncommand "comboBoxEdited"
// But checking for isValid() tells us... |
24a79e9d-a7da-4a84-977d-9a1a13725ff1 | 9 | public int strStr(String haystack, String needle) {
if (haystack == null || needle == null
|| needle.length() > haystack.length()) {
return -1;
}
if (haystack.isEmpty() && needle.isEmpty()) {
return 0;
} else if (needle.isEmpty()) {
return 0;
}
char[] sr = haystack.toCharArray();
char[] nd = ... |
4defe826-f3a0-45ff-b32a-318ce8bfc4dd | 7 | public static int jump(int[] A) {
int len = A.length;
if(len < 2) {
return 0;
}
int currentPosition = 0;
int scope = A[0];
int count = 0;
while(currentPosition+scope < len-1) {
if(scope == 0) {
break;
}
int ma... |
ac4d1e02-b094-4df5-bfd2-0b06f7186214 | 4 | public void mergeWithChunkOnEdge(Chunk chunk, Edge edge){
//get the reads
Read rightReadInThisChunk = this.reads.get(this.reads.size() - 1);
Read leftInOther = chunk.reads.get(0);
//establish a connection between them, reuse the edge
edge.setIdA(rightReadInThisChunk.getId());
edge.setIdB(leftInOther.getId()... |
57c5bb0c-0a71-45fa-beda-21b85cf7a6c5 | 5 | private int getOption()
{
while (true)
{
try
{
System.out.print("\nEnter option: ");
int option = new Scanner(System.in).nextInt();
if (option >= 1 && option <= menuItems.length
|| option == EXIT_OPTION)
... |
e1b062d8-840d-4374-811d-b1dab715f308 | 4 | public static void main(String[] args) {
OptionParser optionParser = new OptionParser() {
{
accepts(USE_CONFIG)
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(Defaults.USE_CONFIG)
.... |
ff46db44-9480-41a0-998d-70d935909c6a | 2 | public Builder addAllPerson(
java.lang.Iterable<? extends protocols.ChatProtocol.ChatPerson> values) {
if (personBuilder_ == null) {
ensurePersonIsMutable();
super.addAll(values, person_);
onChanged();
} else {
personBuilder_.addAllMessages(values);
... |
45f6a5e2-eedc-4eff-af74-1db9238be588 | 6 | public boolean isConstant() {
if ((Options.options & Options.OPTION_ANON) == 0)
return super.isConstant();
ClassInfo clazz = getClassInfo();
InnerClassInfo outer = getOuterClassInfo(clazz);
ClassAnalyzer clazzAna = methodAnalyzer.getClassAnalyzer(clazz);
if (clazzAna != null && outer != null && outer.oute... |
d6440ee0-ca56-46fb-9641-57de9dc04532 | 3 | private void displayItem()
{
Statement st = null;
ResultSet rs = null;
try {
st = custConn.getConnection().createStatement();
System.out.println(customerID);
String qry = "select * from ShoppingCart sc where sc.customer_ID = '" + customerID + "'";
rs = st.executeQuery(qry);
while(rs.next())
{
Sys... |
e2f1897a-db7c-40ca-91f2-99fb5bb9bbc3 | 9 | protected void stepBackward() {
CellElement currentCell;
switch (m_currentPhase) {
case PHASE_CALC_GRID:
m_currentStep--;
if (m_currentStep <= 0) {
stepZero();
return;
}
Point realD = getCoordsByStep(m_currentStep);
... |
492f8c7c-2b0d-4f8e-9412-48d1f60a050e | 6 | static public Object deserializeArray(InputStream in, Class elemType, int length)
throws IOException
{
if (elemType==null)
throw new NullPointerException("elemType");
if (length<-1)
throw new IllegalArgumentException("length");
Object obj = deserialize(in);
Class cls = obj.getClass();
... |
746033d9-6764-4a27-bea5-f0e262729542 | 8 | public void render(int[] pixels, int offset, int row)
{
for (int yTile = yOffset >> 3; yTile <= (yOffset + height) >> 3; yTile++)
{
int yMin = yTile * 8 - yOffset;
int yMax = yMin + 8;
if (yMin < 0) yMin = 0;
if (yMax > height) yMax = height;
... |
8ccb400a-490d-4380-becd-0ebdf2508ab1 | 0 | public void setTwitter_user_name(String twitter_user_name) {
this.twitter_user_name = twitter_user_name;
} |
69824919-d305-460d-abe4-5bc04db508b9 | 0 | @Override
public void windowDeiconified(WindowEvent e)
{
} |
b4cf789f-605a-4aad-a80b-571fe9879798 | 3 | public static void main(String[] args) throws IOException {
MelonSearch search = MelonSearch.getinstance();
search.setOrder(MelonSearch.POPULAR);
search.setMaxSize(100);
search.setMinSize(1);
search.setSongName("괜찮아");
search.Search();
search.getSIDList();
... |
8e38d0d0-f991-4975-99b7-b6d1bcccc6e9 | 7 | public static Rarity fromString(String s) throws IOException {
if (s.equalsIgnoreCase("basic")) {
return BASIC;
} else if (s.equalsIgnoreCase("fine")) {
return FINE;
} else if (s.equalsIgnoreCase("masterwork")) {
return MASTERWORK;
} else if (s.equalsIgnoreCase("rare")) {
return RARE;
} else if (s... |
387447a0-ae0b-42fa-bfed-60750cc320e5 | 8 | private void fillStatement(PreparedStatement stmt, Object... params)
throws SQLException {
// check the parameter count, if we can
ParameterMetaData pmd = null;
if (!pmdKnownBroken) {
pmd = stmt.getParameterMetaData();
int stmtCount = pmd.getParameterCount();... |
13c32328-76d9-419c-bb76-e56ee6b5b24e | 2 | protected HttpEntity toJsonEntity(final Object obj) {
String json = toJson(obj);
try {
return new JsonEntity(json);
} catch (Exception ex) {
Class clazz = null;
if (obj != null) {
clazz = obj.getClass();
}
throw new Ru... |
b667dccf-5db9-44a3-8e53-61dfe53fa3fe | 9 | @Override
public void QuitNetGame() throws IOException {
int i, j;
if (eval(debugfile))
try {
debugfile.close();
} catch (IOException e) {
e.printStackTrace();
}
if (!netgame || !usergame || consoleplayer == -1 || demoplay... |
be4e9bc1-f4c5-4004-b052-e36a39554144 | 5 | public boolean onCommand(Player player, String[] args) {
File fichier_language = new File(OneInTheChamber.instance.getDataFolder() + File.separator + "Language.yml");
FileConfiguration Language = YamlConfiguration.loadConfiguration(fichier_language);
if(player.hasPermission(getPermission())){
if(args.length >... |
897a1770-886c-4a76-97e4-422876d1cd4d | 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 fe... |
29163c16-57ba-46e3-82bb-5cf6da80c33a | 7 | public boolean SEEK()
{
if(order.length()>0)
{
idx O = ( Cdx==null ? Idx :
( Cdx.I>=0 ? Cdx.Idx[ Cdx.I ] : null ));
if(O!=null)
{
PREPARE_KEY_FROM_DATA( O );
if(Idx!=null) Idx.seek(false);
else Cdx.seek(false);
go_recno( O.found || (O.sRecno>0) ? O.sRecno : reccount+1 ... |
2ff0cc60-02ab-4be5-add2-9bcbd860382d | 6 | private void construire(){
this.setLayout(new BorderLayout(0,0));
JPanel semaine = new JPanel(new GridLayout(1, 7));
JPanel mois = new JPanel(new GridLayout(6, 7));
String[] nomsJours = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"};
// Affichage des ... |
894af1fc-9860-4d52-983a-9e3102c37041 | 6 | public static boolean wordBreak(String s, Set<String> dict) {
boolean[] isWord = new boolean[s.length()+1];
isWord[0] = true;
for( int i = 0; i< s.length(); i++) {
// start from the matching word
if(!isWord[i]) {
continue;
}
fo... |
c2eab32a-7a13-46ab-8c53-69deb01b4f39 | 8 | public void Start() {
if (Running)
return;
Running = true;
BanHandler.init();
es = new EventSystem(this);
startLogger();
Log("Starting..");
ch = new CommandHandler(this);
Group.Load(this);
p = Properties.init(this);
loadSystemProperties();
pm = new PacketManager(this);
pm.StartReading();
Lo... |
83a0ba8e-cabb-4015-b752-6350314a5cd2 | 6 | public static void load() {
// Create the connection to
ExecutorService pool = Executors.newFixedThreadPool(1);
Thread th = new Thread() {
public void run() {
int i = 0;
while (i++ < 10) {
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
... |
828e93f6-82ef-4e43-ad81-023e91f66bfd | 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... |
a2a70423-630c-4e5c-b715-64a83a4e11f3 | 3 | void addIfTestMethod(Method m) {
if(m.getAnnotation(Test.class) == null)
return;
if(!(m.getReturnType().equals(boolean.class) ||
m.getReturnType().equals(void.class)))
throw new RuntimeException("@Test method" +
" must return boolean or void");
m.setAccessible(true)... |
ab496652-4a1e-4719-8106-5ad50e648771 | 1 | private String getDescription() {
String desc = "@MongoCount(" + this.getParsedShell().getOriginalExpression() + ")";
if (!StringUtils.isEmpty(globalCollectionName)) {
desc = ",@MongoCollection(" + globalCollectionName + ")";
}
return desc;
} |
c243076a-f97c-483f-8a0b-e1d732983496 | 1 | private int getMachineIndexBySelectedRow(JTable table){
InputTableModel model = (InputTableModel) table.getModel();
int row = table.getSelectedRow();
if(row < 0) return -1;
String machineFileName = (String)model.getValueAt(row, 0);
return getMachineIndexByName(machineFileName);
} |
f766744e-8751-4579-a13a-232a7b414f00 | 1 | public boolean distributionStrategy(int[] bowl) {
predictDistribution();
double expectedScore = calculateExpectedScore();
// Take a bowl greater than your expected score based on the distribution
if (bowlScore(bowl) > expectedScore + .05 * expectedScore)
return true;
... |
640c1315-8194-4ecb-b93e-6455c172637f | 3 | public static int[][] textToGrid(String text) {
int[] nums = stringToInts(text);
if (nums.length != SIZE*SIZE) {
throw new RuntimeException("Needed 81 numbers, but got:" + nums.length);
}
int[][] result = new int[SIZE][SIZE];
int count = 0;
for (int row = 0; row<SIZE; row++) {
for (int col=0; col<S... |
d5af1cb2-051c-4c87-ae75-db8f44ab4490 | 2 | public static Storeable deserialize(Table table, String value) {
if (value == null) {
return null;
}
Storeable result = new MyStoreable(table);
JsonArray array = (new JsonParser().parse(value)).getAsJsonArray();
for (Integer i = 0; i < array.size(); ++i) {
... |
83385961-7524-4932-a2a8-b83518ef0dec | 0 | protected Environment getEnvironment() {
return environment;
} |
33954f2a-b93c-47a4-8ea1-23b34c0d1d06 | 4 | @Override
public Line getNextFromTitle() {
Title title = (Title) this.getParent();
if (title.getParent().isVisible()) {
if (title.getParent().getTextIntro().getLineNb() > 0) {
return title.getParent().getTextIntro().getFirstLine();
}
else if(title.getParent().getNextSection() != null){
return... |
ee21ffa0-25f6-4e59-8173-ccd23367d903 | 2 | private static Connection getDBConnection() {
Connection dbConnection = null;
url = "jdbc:oracle:thin:@" + server + ":" + port + ":" + sid;
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
try {
... |
52780b30-fa5a-417c-bf5c-d7c8fcbe34be | 7 | public void Tick()
{
//MOVEMENT
boolean[][]RoomUnitMap = new boolean[this.GrabModel().MapSizeX][this.GrabModel().MapSizeY];
for(Session mSession : this.GrabParty().values())
{
if(mSession.GrabActor().NeedsPathChange) //Give them .5 of a second to get ready for their new path
{
Collection<byte[]> Pa... |
a9bc46ce-b580-4a06-b86e-88a62e9f8df0 | 4 | public String retrieveOrderInfo(String supName,int orderID) throws SQLException{
String orderInfo = null;
try{
databaseConnector=myConnector.getConnection();
stmnt=(Statement) databaseConnector.createStatement();
SQLQuery="SELECT orderInfo FROM familydoct... |
a5ecc3c4-de8c-4afc-8bb3-cc0463b4be27 | 0 | public int[] getRange()
{
return myRange;
} |
37dec7d6-b3af-4bab-99b0-246d01d3bf0a | 0 | public void createMemento() {
c.saveMemento(new Memento(state));
} |
33eda525-27f3-4ef1-b41f-42c0ba827e10 | 7 | public Coordinate move(String commands) {
move:
for(int i = 0; i < commands.length(); i++) {
Coordinate newPosition;
switch(commands.charAt(i)) {
case 'l':
turnLeft();
break;
case 'r':
turnRight();
break;
case 'f':
newPosition = grid.getNewPosition(currentPosition, ... |
39b0487c-8b8c-4fcf-877b-42fa26353120 | 5 | public static void main (String[] args)
{
if (args.length != 1) {
System.err.println("Uso: java LectorMatrizXML <archivo>");
System.exit(1);
}
try {
LectorMatrizXML lector = new LectorMatrizXML(args[0]);
int i;
System.out.println("Default "+l... |
e3555639-1471-4b1f-bc93-320969cb1f1a | 0 | @Override
public void metaData(String[] args) {
MetaData.main(args);
} |
f494f9c9-25e7-4d99-a4ec-6624c37ff98a | 1 | public void propertyChange(PropertyChangeEvent evt) {
if(evt.getPropertyName().equals("money")) {
update();
}
} |
eb0261c9-6a83-4772-8ae2-dddb37fb8fcb | 0 | public int getPartsSize(){
return parts.size();
} |
ecb2acd4-d91e-4c43-b105-f6e228f79256 | 7 | private TimeSerieRange findBiggestTimeSerieRange() {
if (this.timeSeriesConfigs != null) {
TimeSerieRange result = new TimeSerieRange();
if (this.timeSeriesConfigs.size() >= 1) {
TimeSerieRange tscRange = this.timeSeriesConfigs.get(0).getTimeSerie().getRange();
result.setMinX(tscRange.getMinX());
re... |
75f093ce-1d77-47af-b963-66ea6aaa9ad6 | 8 | private int getMMC(int valor1, int valor2) {
int n = 2;
int resultado = 1;
valor1 = valor1 < 0 ? valor1*-1: valor1;
valor2 = valor2 < 0 ? valor2*-1: valor2;
while(valor1 != 1 || valor2 != 1){
while(valor1 % n != 0 && valor2 % n != 0){
n++;
}
if(valor1 % n == 0){
valor1 = valor1 / n;
}
... |
304afa10-1c09-4830-8022-11cfde3e2e3a | 1 | @Test
public void scale_test() {
try{
double [][]mat1= {{1.0,2.0}, {3.0,1.0}};
double factor= 2;
double[][]result = Matrix.scale(mat1, factor);
double exp[][]={{2.0,4.0},{6.0,2.0}};
Assert.assertArrayEquals(exp, result);
}
catch (Exception e) {
// TODO Auto-generated catch block
fail("Not ye... |
e0db0cc1-c1fa-479b-8d67-6e5c7ec6392a | 8 | private boolean backtracking(ArrayList<Clausula> clau, Quadricula qu, int j) {
if (clau.size() == j) { // Tenim una solucio
return true;
} else {
Clausula c = clau.get(j);
for (ClausulaNom cn : c.getClausula()) {
Element e = new Element();
... |
6544f93a-e40c-4182-aeb1-bf187b1f9de0 | 9 | void parseFields()
{
int ndx = 0;
for (Field field : actualClass.getDeclaredFields()) {
if (!Modifier.isStatic(field.getModifiers())) {
JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
int hash = (jsonProperty != null ? jsonProperty.name().hashCode() :... |
b4bc23cc-29ad-4e97-a710-bccee15dd5d9 | 2 | private void MovieTitleRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MovieTitleRemoveButtonActionPerformed
String delMovie = MovieTitleRTextField.getText();
out.println("4!" + delMovie);
try {
String delRecord = in.readLine();
if (delRecor... |
524e55c9-ecff-436c-9054-6379ab58ac0f | 2 | public void setVisible(boolean isVisible) {
if (!isVisible && superGroup != null) {
superGroup.setNewGroupBounds();
}
this.isVisible = isVisible;
} |
1babaaa4-ba3f-4526-8830-a7c00e7ffff0 | 5 | private String getStartButtonTooltips(){
StringBuffer sb = new StringBuffer();
if(isGameReady()){
sb.append( "Start the Scrabble Game with: ");
for(Player p : players){
sb.append(p.getName()+" ");
}
}
else{
sb.append("Invalid player number. Must have 2 - 4 players.");
if(players == null || pl... |
85a2dde7-8331-4b85-8c92-5e1a960e8029 | 3 | public ArrayList<Object> upperOutliersAnscombe_as_double(double constant) {
switch (type) {
case 1:
double[] dd = this.getArray_as_double();
upperOutlierDetails = upperOutliersAnscombeAsArrayList(dd, constant);
break;
case 12:
BigDecimal[] bd = this.getArray_as_BigDecimal();
ArrayList<Object> ret ... |
21b4cf8f-0176-4b44-992e-1097ae82d9be | 1 | public short getShort(Object key) {
Number n = get(key);
if (n == null) {
return (short) 0;
}
return n.shortValue();
} |
c8373ab1-e3a7-411d-8b7e-2895c51bdc9e | 1 | public final void setRootAction(Action a) {
if(a == null)
rootAction = defaultRootAction;
else
rootAction = a;
} |
e58eabe4-8319-47d3-98e7-048fc802ae1c | 6 | public List<IPEntry> getIPEntries(String s) {
List<IPEntry> ret = new ArrayList<IPEntry>();
try {
// 映射IP信息文件到内存中
if (mbb == null) {
FileChannel fc = ipFile.getChannel();
mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, ipFile.length());
mbb.order(ByteOrder.LITTLE_ENDIAN);
}
int endOffset = (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.