method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5123b89f-c7a9-408e-88a8-087f6c339c8d | 5 | private static boolean onScreen(int x, int y, int z) {
int l = y * curveSineX + x * curveCosineX >> 16;
int i1 = y * curveCosineX - x * curveSineX >> 16;
int j1 = z * curveSineY + i1 * curveCosineY >> 16;
int k1 = z * curveCosineY - i1 * curveSineY >> 16;
if (j1 < 50 || j1 > 3500)
return false;
int l1 = ... |
ea92cac7-2dd7-44c8-bf93-074fcda99015 | 9 | static int countParametersFromSignature(String signature)
{
if (signature.charAt(0) != '(')
{
throw new IllegalStateException("Invalid signature: " + signature);
}
int count = 0;
for (int i = 1; i < signature.length(); i++)
{
if (signature.charAt(i) == ')')
... |
4a2b1751-c135-44c0-88a9-a6a7c6867c98 | 6 | private void rejectGroupCheckCollision(ACLMessage msg, ProposedPlace place) {
int studentsNo = mysql.getStudentsNumberOfGroup(place.getGROUP_SYMBOL());
int negotiationLevel = mysql.getNegotiationLevel();
int collisionStudentsNumber;
ArrayList<Integer> studIds = new ArrayList<>();
... |
9fb738e9-6394-44cc-8f3f-6f2621a40bc9 | 3 | private void updateForecast(Sim_event ev) {
int pktID = (Integer) ev.get_data(); // ID of flow to be updated
FlowPacket fp = null; // Reference to flow packet that needs forecast update
double duration = 0.0; // New forecast duration from current Gridsim.clock()
long remSizeOld = 0; // P... |
6ebd3bc5-eaf8-488f-ac61-0f13776a7597 | 1 | public void addFeature(String name, Feature<?> ft) {
features.put(name,ft);
} |
4084e8e7-4d6c-4a26-bcd7-4138cd7111ff | 3 | private static String readStringFromReader(BufferedReader br)
{
StringBuilder sb = new StringBuilder();
try
{
boolean done = false;
do
{
String s = br.readLine();
if (s == null)
{
done = true;
}
e... |
5dd34bb1-0a4c-4a82-828a-80553813259d | 7 | public void run() {
Mod.config = new Config();
try {
Mod.config.load(new File("mods.cfg"));
} catch (Exception e) {App.getApp().handle(e);}
File dirMods = new File("mods");
dirMods.mkdirs();
List<File> lookIn = new ArrayList<File>();
lookIn.add(dirMods);
while (!lookIn.isEmpty()) {
File chec... |
c1f87ae6-f6a1-40ef-8cd6-aaf9e1056102 | 2 | protected boolean isArrayValue(final Value value) {
Type t = ((BasicValue) value).getType();
return t != null
&& ("Lnull;".equals(t.getDescriptor()) || t.getSort() == Type.ARRAY);
} |
f0309834-d700-469c-b23e-925acd9c67ea | 7 | protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, thrower), 0);
}
for (int i = 0; i < 32; i++)
{
... |
e62485fb-4491-4d92-ad83-87808554c1e6 | 1 | @Override
public void actionPerformed(ActionEvent e) {
// if we're not in a totally-maximized state
// [which would make this all pointless] ...
if (!Outliner.desktop.isMaximized()) {
// grabaholda the topmost doc
OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTou... |
356c5500-5429-4409-9db4-c0c60922c33c | 5 | public void compute() {
if (opponent == null)
return;
Vector3D myLocation = getLocation();
Vector3D opponentLocation = opponent.getLocation();
float myX = myLocation.getX(), myY = myLocation.getY();
if (myX > opponentLocation.getX())
myX += 1;
else if (myX < opponentLocation.getX())
myX -= 1;
if ... |
09d0118e-aa14-4b7b-ba62-a56aa447d844 | 9 | public static List<Vector> getCircleVectors(Vector vector, int radius, int hight, boolean hollow, boolean sphere)
{
List<Vector> vectors = new ArrayList<Vector>();
int cx = vector.getBlockX();
int cy = vector.getBlockY();
int cz = vector.getBlockZ();
for (int x = cx - radius;... |
e75d2e4c-f566-42f4-a76f-d6fb593b2cb8 | 8 | private byte[] getClassData(String name) {
if (!validFiles.contains(name)) {
return null;
}
ByteArrayOutputStream ret = new ByteArrayOutputStream();
try (DataInputStream din = new DataInputStream(getClass().getResourceAsStream("/" + name.replace('.', '/') + ".class")); DataO... |
24e2b943-9bfd-4403-b926-ea0f4f485665 | 8 | private void processCollisions() {
//Quad Tree implementation
//*
QuadTree qt = new QuadTree(0, new Rectangle(0, 0, 1280, 720));
for(Entity e : entities) {
if(e.hitbox != null) {
qt.insert(e);
}
}
for(Entity e : entities) {
if(e instanceof Collidable && e.hitbox != null) {
List<Entity> l... |
6ca2fa8b-9375-4ab5-8495-482f5e831ccd | 3 | public boolean withdrawChallenge(Challenge c) {
boolean flag = false;
Element challengeE = (Element) document
.selectSingleNode("//challenge[@id='" + c.getId() + "']");
if (challengeE != null) {
challengeE.element("dialogState").setText(c.getDialogState());
// Write to xml
try {
XmlUtils.write2Xm... |
2d82e7e7-aef1-4743-baa7-ec9612f8bc20 | 1 | public void initRoute()
{
route = new Point[getHeight()][];
for (int i=0; i<getHeight(); ++i) {
route[i] = new Point[getWidth()];
}
} |
2eeaf9f9-b62d-4b40-8c51-3afeb7ee9992 | 4 | private void initAliens(){
// Set Aliens
if(LEVEL < 7){
if(aliens.size()< 10) stars = r.nextInt(650)+30;
for(int i=0;i<(10-aliens.size());i++){
aliens.add(new AAlien(stars,-10,LEVEL));
}
} else {
if(BOSSTRIG == false){
... |
7be6ded3-8168-4d17-901d-e595ead1e83b | 9 | public Object getValueAt(int row, int col) {
// Fermentable m = (Fermentable) data.get(row);
try {
switch (col) {
case 0: // steep
return new Boolean(data.get(row).getSteep());
case 1: // mash
return new Boolean (data.get(row).getMashed());
case 2 :
return data.get(row).getName();... |
5cd8c75e-6b22-47f6-8022-8d3a2cde6a82 | 5 | private void setupBoard() {
final Point[] doubleLetterLocations = {new Point(2,2), new Point(4,6), new Point(6,4)};
final Point[] tripleLetterLocations = {new Point(0,4), new Point(1,1), new Point(2,6), new Point(3,3), new Point(4,0),
new Point(5,5), new Point(6,2)};
final Point[] doubleWordLocat... |
cff1cb8f-3922-4e11-a800-7d4cc1487a67 | 7 | public void mainButtonAction() {
if (!textField1.getText().equals(null) && !textField1.getText().equals("") && !textField2.getText().equals(null) && !textField2.getText().equals("")) {
boolean result = false;
long startTime,endTime;
if ( validateTextFields() == true ) {
... |
71ed8598-6c0d-4eee-b82c-cde5a8d70bbe | 5 | public void loadWorldFromImage(String filepath){
try {
BufferedImage image = ImageIO.read(World.class.getResourceAsStream(filepath));
width = image.getWidth();
height = image.getHeight();
data.clear();
for(int x = 0; x < image.getWidth(); x++){
for(int y = 0; y < image.getHeight(); y++)... |
73353cc2-14a4-4a8c-b9d9-a4777e284ed3 | 3 | private byte[] loadClassData(JarFile jarFile, JarEntry jarEntry) throws IOException {
long size = jarEntry.getSize();
if (size == -1 || size == 0) {
return null;
}
byte[] data = new byte[(int) size];
InputStream is = jarFile.getInputStream(jarEntry);
try {
... |
0c8c0046-a5ca-46a4-9552-70c9afa2fddf | 6 | private static void process(String line, SearchEngine engine) {
String[] splt = line.split("\\s");
if (splt.length == 0) {
return;
}
if (splt[0].equals("index")) {
engine.doIndex(splt[1]);
System.out.println("Indexing done.");
return;
... |
3020dc8a-6c3f-4eed-a952-f4a1f7288e73 | 7 | static int countPrimes(int n) {
if (n <= 2) return 0;
boolean [] primes = new boolean[n];
for (int i = 2; i < n; i++) {
primes[i] = true;
}
for (int i = 2; i * i < n; i++) {
if (primes[i]) {
// primes[i + i * ii] already marked,ii = 2, ... i - 1, so we start with i * i
// for example, when i ... |
8f6eee3d-49ad-4cd9-b5f8-cc8738aa01ce | 7 | @Override
protected void etick() {
if(attacked){
if(attackFactor == attackMax){
attacked = false;
attackFactor = 0;
} else {
attackFactor++;
}
if(attackRedFactor < attackRedMax)
attackRedFactor+=.01;
} else {
if(attackRedFactor > 0)
attackRedFactor-=.01;
}
if(blinkVisibleFact... |
71585ab5-cab6-47c2-8676-ad675f25c910 | 9 | public static String serialize(TreeNode root) {
if (root == null)
return "";
StringBuilder sb = new StringBuilder();
int numInLevel = 1, thisLevel = 1, nextLevel = 0;
Queue<TreeNodeWrapper> queue = new LinkedList<>();
TreeNodeWrapper rootWrapper = new TreeNodeWrapper(root, true);
queue.add(rootWrapper);
... |
785e4fb9-ac66-4c64-bad6-fa854cd286d5 | 3 | @Override
public void mouseMoved(MouseEvent ev)
{
FunctionEditor old = e.hovered;
e.hovered = null;
int x = ev.getX();
int y = ev.getY();
e.mx = x;
e.my = y;
for(FunctionEditor ed : e.editors)
if(ed.can... |
8c00f8e1-ce36-4877-b974-6fde9df4730e | 4 | private void updatePosition() {
if (direction == 1) {
pos_y--;
}
if (direction == 2) {
pos_x--;
}
if (direction == 3) {
pos_y++;
}
if (direction == 4) {
pos_x++;
}
System.out.println(name + ": new position (up) " + pos_x + " " + pos_y);
} |
dbe8fe2f-8676-44b5-8e63-fe9737f4ad34 | 1 | public int getNeededPlayerCount(){
int playerCount = 0;
for (Team t : alstTeams) {
playerCount+=t.getTeamSize();
}
return playerCount;
} |
94e7605e-4282-4561-a9da-c5630da07c09 | 6 | public static boolean isPalindrome(int x) {
if (x < 0) return false;
if (0 == x) return true;
int n = x;
int len = 0;
while (0 != n) {
len = len + 1;
n = n / 10;
}
int devide = 10;
int qrt = 1;
for (int i = 1; i < len; i++) {
q... |
5015d6c0-0c59-43b5-b54a-5bc9c7671749 | 0 | private InterestedMessage(ByteBuffer buffer) {
super(Type.INTERESTED, buffer);
} |
6b056e97-724c-4711-9289-473b416ef19e | 2 | public void compile()
{
System.out.println("Compile()");
this.outputWindow.setEditable(true);
if(this.openedFile !=null && this.openedFile.exists())
{
this.outputWindow.setText(null);
this.javaCompiler.compile(this.openedFile.getAbsolutePath());
... |
80f0d68d-6a20-44f0-9b00-b087c8d95e7b | 2 | @Override
public List Listar() {
Session session = null;
List<Liga> liga = null;
try {
session = NewHibernateUtil.getSessionFactory().openSession();
Query query = session.createQuery("from Liga");
liga = (List<Liga>) query.list();
} catch (Hibernat... |
1f7e3fcf-fcae-458a-8336-e6cad58f2897 | 9 | private void decodeHeader(BufferedReader in, Properties pre,
Properties parms, Properties header)
throws InterruptedException {
try {
// Read the request line
String inLine = in.readLine();
if (inLine == null)
return;
StringTokenizer st = new StringTokenizer(inLine);
if (!st.hasMoreT... |
78f61339-c2cf-4072-9957-e2a1b46aff91 | 9 | private Tile tilePosition(Boardable b, Mobile client) {
if (b == null) return null ;
if (client == null || b.allowsEntry(client)) {
if (b instanceof Venue) return ((Venue) b).mainEntrance() ;
if (b instanceof Tile) {
final Tile t = (Tile) b ;
return t.blocked() ? null : t ;
}
... |
f100e25f-8f3e-40d9-a08a-9ff65e8b1d46 | 1 | public void songSkip()
{
//Test if current song is available
if (currentSong > -1)
{
currentSong++;
}
} |
5523d4b8-c88c-44bf-94b6-ecd1b3d9172c | 7 | protected static Fauna nextHandled(SurveyStation station) {
for (Item match : station.stocks.matches(REPLICANTS)) {
if (match.refers instanceof Fauna) return (Fauna) match.refers ;
}
final World world = station.world() ;
final Tile e = world.tileAt(station) ;
//final Ecology ecology = wor... |
7628d21a-1344-4482-adec-2be52bb9b28d | 4 | private String download( String fileName, Socket socket) {
try {
System.out.println("DOWNLOADING FILE");
String[] d = fileName.split("!#!");
System.out.println("SPLIT");
System.out.println(d[0]);
FileOutputStream outStream = new FileOutputStream("down... |
8ca4387c-4240-4344-af2f-da2ce6b99095 | 8 | private void makewt(int nw) {
int j, nwh, nw0, nw1;
double delta, wn4r, wk1r, wk1i, wk3r, wk3i;
double delta2, deltaj, deltaj3;
ip[0] = nw;
ip[1] = 1;
if (nw > 2) {
nwh = nw >> 1;
delta = 0.785398163397448278999490867136046290 / nwh;
d... |
78c2985a-3cd1-4c82-83ca-c0b6df0ec1f4 | 5 | public ArrayList<Rod> getMaximumRevenueRods(int totalLength, ArrayList<Rod> rodList) {
this.totalLength = totalLength;
// Similar to Knapsack, we make a list of possibilities to choose from which is large
// than the total length of the rod (same as objects exceeding knapsack capacity)
createNodePossibilities(r... |
43b5c9f3-09c1-49bc-8a95-e1070868f8fd | 8 | protected boolean isEmptyCluster(Hashtable<String,GrinderRoom> processed, int x, int y, int z)
{
for (final Enumeration<GrinderRoom> e = processed.elements(); e.hasMoreElements(); )
{
final GrinderRoom room = e.nextElement();
if ( ( ( (room.xy[0] > x - CLUSTERSIZE) && (room.xy[0] < x + CLUSTERSIZE))
&&... |
62cf10d2-5658-4f54-8ce0-680f1d53939a | 4 | public boolean collision(double x, double y) {
boolean solid = false;
for (int c = 0; c < 4; c++) {
double xt = (x - c % 2 * 16) / 16;
double yt = (y - c / 2 * 16) / 16;
int ix = (int) Math.ceil(xt);
int iy = (int) Math.ceil(yt);
if (c % 2 == 0) ix = (int) Math.floor(xt);
if (c / 2 == 0) iy = (int... |
a3fde767-d3f6-4c64-8366-ec9fa47a6370 | 1 | @Test
public void zerarQuantidadeNegativaDosProdutos() throws ExceptionGerenteEstoque{
Produto p = adicionarProdutoNaFaixada("Feijão","123");
p.setQuantidadeemEstoque(-2);
Produto p2 = adicionarProdutoNaFaixada("Arroz","321");
p2.setQuantidadeemEstoque(-8);
faixada.zerarQuantidadeNegativa();
assertTrue("De... |
0d8c0c5c-71ba-4a8a-99df-fa0302f3aaeb | 7 | @Override
public void execute(CommandSender sender, String gateName, List<String> args) {
this.sender = sender;
String gateTarget = (args.size() > 0 ? args.get(0) : null);
if (gateName == null || gateTarget == null) {
error("No gate(s) given.");
reply("Usage: /gate unloop <gatename> <target_gatename>");... |
8a0cee16-8d3f-492c-9c6d-48b1aac0017a | 9 | @Override
public void sendGMCPEvent(final String eventName, final String json)
{
if((!getClientTelnetMode(TELNET_GMCP))||(gmcpSupports.size()==0))
return;
try
{
final String lowerEventName=eventName.toLowerCase().trim();
final int x=lowerEventName.lastIndexOf('.');
if((x<0)&&(!gmcpSupports.containsK... |
1fce3057-15d3-43da-9538-331eb8a8b7ca | 7 | public String simplifyPath(String path) {
String[] metaPath = path.trim().split("/+");
Deque<String> stk = new ArrayDeque<String>();
for(String meta : metaPath){
if(meta.isEmpty()) continue;
if(meta.equals("..")){
if(!stk.isEmpty()) stk.removeLast();
... |
e3cad1a2-3396-4d83-957c-984efd147765 | 0 | public Component getComponentBefore(Container container, Component component) {
return cycle(component, -1);
} |
4d924585-0b56-4834-a476-09853161fa31 | 6 | private synchronized void finishBootstrap()
{
if(serverRespons && (prevNodeRespons || firstNetworkNode))
{
timeOut.stopTimer();
client.unbindRMIservice("Bootstrap_" + client.getHostname());
if(firstNetworkNode) //First node creates the file agent
{
client.setFileAgentMaster();
client.crea... |
c32d3dd8-3480-464c-93b6-8980a4b04b99 | 8 | public void testRF(String outputPrefix, int noTrees) throws FileNotFoundException {
if (noTrees == 0) {
noTrees = Integer.MAX_VALUE;
}
double sumacc = 0.0;
double acc = 0.0;
for (int i = 0; i < noFold; i++) {
System.out.println("################ Fold no " ... |
6998a27c-a506-4ce5-b9e8-a1a537708c50 | 9 | public Tag findNextTagByName(String name, Tag found) {
if (type != Type.TAG_List && type != Type.TAG_Compound) {
return null;
}
Tag[] subtags = (Tag[]) value;
for (Tag subtag : subtags) {
if ((subtag.name == null && name == null) || (subtag.name != null && subtag.... |
7749c97f-e431-4064-a746-8a14e8aadff9 | 0 | @Test(expected=IllegalNumberOfOperandsException.class)
public void testIllegalNumberOfOperandsMinus(){
calculator.pushOperand(7.0);
calculator.pushMinusOperator();
calculator.evaluateStack();
//assertTrue("An IllegalNumberOfOperandsException should heve been thrown here.", false);
} |
f30b58fb-b3d6-48cb-82e1-1b1a1bf37f9c | 9 | public final void gen_for() throws RecognitionException {
try {
// Python.g:433:8: ( 'for' exprlist 'in' or_test ( gen_iter )? )
// Python.g:433:10: 'for' exprlist 'in' or_test ( gen_iter )?
{
match(input,82,FOLLOW_82_in_gen_for3855); if (state.failed) return;
pushFollow(FOLLOW_exprlist_in_gen_for3857)... |
a431f475-a914-4e1a-8c23-1dfc0f90d695 | 0 | public Player getPlayer() {
return player;
} |
218e1864-d881-4069-880a-33858fd12753 | 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... |
28b4855e-3df2-4a05-8a20-eea79e7b42ca | 0 | public void setProfessorId(int professorId) {
this.professorId = professorId;
} |
86dbddc1-f062-44bc-a42b-6f639c29e423 | 1 | private static boolean deletePatient(Patient bean, PreparedStatement stmt) throws SQLException{
stmt.setInt(1, bean.getPid());
int affected=stmt.executeUpdate();
if(affected==1){
System.out.println("Patient with ID "+bean.getPid()+" has been Removed from database.");
} else {
System.out.println("un... |
4a1a981a-fe35-47be-9833-e3155bb985b3 | 1 | public static boolean sqlConnect() {
try
{
Class.forName("com.mysql.jdbc.Driver");
Properties connectionProps = new Properties();
connectionProps.put("user", "114509");
connectionProps.put("password", "cuizheng");
connect =
DriverManager
.getConnection("jdbc:mysql://johnserver0.youmu.moe/... |
1854d00b-ea2c-414d-8cef-eb6c48bb498e | 3 | public boolean equals(Object o)
{
if(!(o instanceof Coordinate))
return false;
Coordinate c = (Coordinate)o;
if(c.x == x && c.y == y)
return true;
return false;
} |
4d06e4f1-fa44-4dd6-b4f2-a532de898f98 | 9 | public static void load(){
File dir = new File(BetterLamps.p.getDataFolder(), "lamps");
if(!dir.exists()){
dir.mkdir();
}
String[] files=dir.list();
for(String sfile:files){
File file=new File(BetterLamps.p.getDataFolder()+"/lamps",sfile);
if(file.isFile()){
FileConfiguration configFile... |
ba76d567-5b24-444d-a39c-31c1bc51c9c0 | 9 | public Object getValueAt(int rowIndex, int columnIndex) {
assert((columnIndex >= 0) && (columnIndex <= 2));
Iterator i = scoreSet.iterator();
int j = 0;
while(i.hasNext()) {
if(j == rowIndex) {
Object... |
fb87bd46-e191-4eb3-a747-af881d93efcf | 2 | @Test
public void testOutputPastMeetings() throws IOException {
cm.addFutureMeeting(contacts, new GregorianCalendar(2015,3,2));
cm.addNewPastMeeting(contacts, new GregorianCalendar(2013,5,3), "meeting one");
cm.addNewPastMeeting(contacts, new GregorianCalendar(2013,6,3), "meeting two");
cm.addNewPastMeeting(co... |
32d4c24c-a18e-47ab-a9ca-0861ae828cbd | 2 | public String getValueAsString() throws IllegalArgumentException {
if (!isOptionAsString(code)) {
throw new IllegalArgumentException("DHCP option type ("+ this.code +") is not String");
}
if (this.value == null) {
throw new IllegalStateException("value is null");
}
... |
2be17c51-47b8-4b52-84e4-b693ec85377c | 2 | private static void readRestResult (String affiliate_url, String restResult) throws JsonParseException, JsonMappingException, IOException, ParseException {
// ObjectMapperを作成
ObjectMapper mapper = new ObjectMapper();
// mydata.jsonからルートノードを取得
JsonNode rootNode = mapper.readValue(restResult, JsonNode.class);
... |
d0c43f54-9d90-4864-8da3-8a8633a60611 | 6 | public StairsTile(int dir) {
super(new SpriteBody());
this.dir = dir;
Random random = new Random(1000);
int w = 6;
int h = 8;
double ws = 1.0 / (w);
double hs = 1.0 / (h);
for (int x = -1; x < w + 1; x++) {
for (int z = 0; z < w * 3; z++) {
... |
59ba368e-8832-44bf-9f5c-f9447d96e57a | 1 | private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
} |
89a5493e-09c6-4008-9b4a-25c416f17422 | 2 | private static int compareLong(final long l1, final long l2)
{
return l1 == l2 ? 0 : l1 < l2 ? -1 : 1;
} |
23b09afb-723d-4e86-9a24-1a9e072e926f | 2 | public void heita(){
for(int i=0; i<nopat.length; i++){
if (nopat[i].getLukitus()==false){ // Jos noppaa ei ole lukittu, heitetään
nopat[i].heita();
}
}
} |
5484d2aa-ced6-4ad6-a510-bc4c3f6e9565 | 2 | private Gene matchingGeneSelect_firstMethod(Gene par1, Gene par2) {
double averWeigth = (par1.getLink().getWeight() + par2.getLink().getWeight()) / 2;
int x = (Math.random() < 0.5) ? 0 : 1;
if (x == 0) {
Link copyLink = new Link(averWeigth, par1.getLink());
Gene g = new G... |
33c90747-5ec8-4e37-92b7-395df6eb7b8d | 8 | private static String toLowerCamel(Context context, String name) {
StringBuilder sb = context.getLocalCache().getCachedBuffer();
boolean toUpperCase = false;
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (c == ' ' || c == '_' || c == '-') {
toUpperCase = true;
} else if (toUpp... |
fc2d8495-3267-4040-bf7f-36e04c30cc42 | 1 | public static String[] parseArrayElement(String src) {
Matcher matcher = pattern.matcher(src.trim());
List<String> a = new ArrayList<String>();
while (matcher.find()) {
a.add(matcher.group(0));
}
return a.toArray(new String[0]);
} |
9e58ee8b-b7e4-4952-9a77-f267693b21ad | 1 | public void setActiveAsInt(int active){
if(active == 0){
this.active = false;
}else{
this.active = true;
}
} |
a1ab49aa-ca62-4850-bbc2-03d7547970c4 | 8 | private void initContent() {
setBounds(100, 100, 450, 306);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(null);
lblName = new JLabel("Name:");
lblName.setFont(new Font... |
a9fc0858-0449-4931-9b97-5d90f1749b0b | 3 | @Override
public void addPerson(Person person) throws SQLException {
Connection dbConnection = null;
java.sql.Statement statement = null;
try {
dbConnection = PSQL.getConnection();
statement = dbConnection.createStatement();
String addPerson = "insert into person(id_person, name, surname, date_of_bi... |
ebb783ab-52e2-4744-aff5-9f5e3ca8fc27 | 5 | public static int minValue(Node root) {
if(root == null)
return (~0);
else if(root.left == null && root.right == null)
return root.data;
else if(root.left == null)
return Math.min(root.data, minValue(root.right));
else if(root.right == null)
return Math.min(root.data, minValue(root.left));
else
... |
7da0bce6-eeea-48c5-8477-5b2b7637cb87 | 2 | private void saveFile(File file) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
for (WordStructure word:wordList) {
writer.write(word.getWord()+"/");
writer.write(word.getTranslation()+"/");
writer.write(wor... |
4376362a-4f25-48a3-a477-c6348de747fe | 9 | @Override
public Class getColumnClass(int indiceColonne){
//System.out.println("ModeleListeLocations::getColumnClass()") ;
switch(indiceColonne){
case 0 :
return Integer.class ;
case 1 :
return String.class ;
case 2 :
return String.class ;
case 3 :
return String.class ;
case 4 :
... |
5926a2e7-0e5f-403e-9ef2-52041e46c813 | 4 | public double rawPersonMinimum(int index){
if(!this.dataPreprocessed)this.preprocessData();
if(index<1 || index>this.nItems)throw new IllegalArgumentException("The person index, " + index + ", must lie between 1 and the number of persons," + this.nPersons + ", inclusive");
if(!this.variancesCalc... |
0d47b59a-e7c4-4a3b-ae1c-fdc2ccaf0519 | 7 | public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Verwendung: <blocksize> <Generierungsgröße>/<Eingabedatei>");
}
int blocksize = 0;
try {
blocksize = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.err.println("Blockgröße muss eine Zahl sein!... |
25683648-8c22-41d7-98dd-4ca9d926cf00 | 8 | public static void floyd() {
for (int i = 0; i < nodes; i++) {
dis[i][i] = 0;
for (int j = 0; j < nodes; j++) {
parent[i][j] = i;
if (dis[i][j] == INF || i == j) {
parent[i][j] = -1;
}
}
}
for (int k = 0; k < nodes; k++)
for (int i = 0; i < nodes; i++)
for (int j = 0; j < nodes; j... |
a66d5fea-53ab-4a81-9069-0abbb0fbc0c5 | 0 | public String getDireccion() {
return direccion;
} |
4ad9ce20-9f3c-4c31-9836-f9ca93b92839 | 5 | public boolean crosses(WordSpan s) {
int sstart = s.getStart();
//either s's start is in this or this' start is in s
return !this.contains(s) && !s.contains(this) &&
(getStart() <= sstart && sstart < getEnd() ||
sstart <= getStart() && getStart() < s.getEnd());
} |
ad5d96d2-2f82-4081-87fa-b0273e16ed63 | 3 | public String consumeTagName() {
int start = pos;
while (!isEmpty() && (matchesWord() || matchesAny(':', '_', '-')))
pos++;
return queue.substring(start, pos);
} |
d8664c39-ea9f-4595-9f5a-83c7cbcf0635 | 5 | public final WFrame setOrientation(Orientation orientation) {
if (this.orientation != orientation) {
this.orientation = orientation;
switch (orientation) {
case TOP:
((FlowLayout) super.getLayoutManager()).setFlowType(FlowLayout.VERTICAL_FLOW);
... |
e0c9ee25-9754-4fde-9b7e-952086ed096d | 6 | public ArrayList<SimulatorRobot> deploy() throws Exception {
int W = Board.WIDTH - 30;
int H = Board.HEIGHT - 30;
posXs.add(Math.random() * W + 1);
posYs.add(Math.random() * H + 1);
for (int i = 0; i < this.selectedRobots.getSize(); i++) {
RobotPiece body = null;
... |
d06c6326-c581-4d12-be31-604a0ccf35e0 | 1 | @Override
public void rollbackTrans() throws Exception {
try {
oConexionMySQL.rollback();
} catch (SQLException e) {
throw new Exception("Mysql.rollbackTrans: Error en rollback: " + e.getMessage());
}
} |
f203572c-7e59-4a15-a9d1-97b70fc68346 | 8 | @SuppressWarnings("rawtypes")
public static boolean modifyPomVersion(String dirPath, String versionNo) {
if (dirPath.indexOf(versionNo) > -1) {
return false;
}
String pomXML = dirPath + File.separator + "pom.xml";
SAXReader saxReader = new SAXReader();
Document document = null;
try {
document = saxRe... |
386dc938-56f4-4ee4-adbd-4c2d6cb1659d | 2 | public void run()
{
while(true)
{
hack=true;
moveCursor();
checkLocation();
try{Thread.sleep(10);}catch(Exception ignored){}
repaint();
}
} |
5488e77c-8c2f-496f-a7f5-a328df742f48 | 2 | public final String getCRC32(String str)
{
String string = new String(str);
String crc2 = null;
long value = 0;
try
{
byte buffer2[] = string.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(buffer2);
CheckedInputStream cis ... |
9de4b461-62a7-49d8-9462-525500ac241e | 2 | public void resize() {
if (!isLeftPaddle) {
x = CardsPanel.FRAME_WIDTH - 30;
}
length = FRAME_HEIGHT / 5;
v = FRAME_HEIGHT / 25;
duration = 0;
if (y + length > FRAME_HEIGHT) {
y = FRAME_HEIGHT - length;
}
} |
d5260229-218d-4f19-8536-83a44da3557d | 7 | public void createTaskTray(String title, Image image, final ITaskTrayEvent event) throws AWTException {
if (!SystemTray.isSupported() && event != null) return;
PopupMenu menu = new PopupMenu();
if (event.synchronizedExitVisibled()) {
MenuItem exit = new MenuItem("Exit");
... |
f8aa7c59-9237-432d-bbb4-2820514de1bb | 7 | static final public int one_line() throws ParseException {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case MINUS:
case CONSTANT:
case 12:
sum();
jj_consume_token(11);
{if (true) return 0;}
break;
case 11:
jj_consume_token(11);
{if (true) return 1;}
break;
defau... |
70b3d0f2-7851-470a-8e7f-679ce837011c | 9 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
int region = 1;
while ((line = in.readLine()) != null && line.length() != 0) {
int[] v = readInts(line);
if (v[... |
9315d1d1-0981-492a-a757-9603072bf741 | 4 | public static <T extends Comparable<T>> T findMin(List<T> al){
T min=null;
//remember to test if null or empty-throw an exception-index out of bounds used here
if((al==null)||(al.isEmpty())){
throw new IndexOutOfBoundsException("Empty or non-existent list");
}
else{... |
bf7ac6ff-4b41-4e0b-be6f-ed4d5bc2f77a | 0 | public void move(int x, int y) {
f.format("%s The Turtle is at (%d,%d)\n", name, x, y);
} |
0fd3d107-01c1-4920-8a60-7d86a1e0e468 | 7 | private TaskStatus parseTaskStatus(String status) {
if (status.equals("Submitted")) {
return TaskStatus.Submitted;
} else if (status.equals("Queued")) {
return TaskStatus.Queued;
} else if (status.equals("InProgress")) {
return TaskStatus.InProgress;
} else if (status.equals("Completed")) {
return T... |
bb4387c4-34ba-422a-9dd5-3f96cd1e3537 | 5 | protected String readLine() throws IOException {
if (nextLine != null) {
String nl = nextLine;
nextLine = null;
return nl;
}
nextLine = reader.readLine(); // Read a line (only if needed)
// Remove trailing '\r'
if ((nextLine != null) && (nextLine.length() > 0) && nextLine.charAt(nextLine.length() -... |
06cb5658-4c8d-4478-8f2c-d91d542c7307 | 7 | public void move() {
if(pause<=0){
x += stepX;
y += stepY;
stepsLeft--;
if(amountToTransfer!=0){
if(isPowerBar) {
finalPosX = transferPowerTo.getBarPos()[0];
} else {
finalPosX = transferXPTo.getB... |
25689679-1847-462c-a994-4eeb2bbda4c5 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if(super.checkStop(mob, commands))
return true;
verb=L("bonding");
bonding=null;
final String str=CMParms.combine(commands,0);
MOB M=super.getTarget(mob, commands, givenTarget);
if(M==null... |
6316237b-25d8-4f5b-b70c-8d25ac5a0e78 | 3 | public boolean execute(CommandSender sender, String[] args) {
String groupName = args[0];
GroupManager groupManager = Citadel.getGroupManager();
Faction group = groupManager.getGroup(groupName);
if(group == null){
sendMessage(sender, ChatColor.RED, "Group doesn't exist");
return true;
}
String send... |
05ca43d9-cf2d-441c-a0fd-aaba51b46278 | 4 | private static void skipThisWord(InputStreamReader br) throws IOException {
int character = br.read();
while((character>=0)&&(character!=' ')&&(character!='\n')) {
character=br.read();
}
if(character==' ') {
skipThisWord(br);
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.