method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
9b05d0c7-5415-4585-af6b-c7ebe385a8d7 | 4 | @Override
public boolean equals(final Object item)
{
if (this == item)
{
return true;
}
if (!(item instanceof Item))
{
return false;
}
final Item that = (Item) item;
/* @formatter:off */
return this.name == that.getName() ||
(null != this.name && this.name.equals(that.getName()));
/* @formatter:on */
} |
5ee45366-bfda-4aff-b587-280a1a0e572c | 8 | public ConsultaPerfil() {
initComponents();
CargarComboBox();
web.setVisible(false);
panel.setVisible(false);
// setLocationRelativeTo(null);
//super combo box
c_perfiles.getEditor().getEditorComponent().addKeyListener(new KeyAdapter(){
@Override
public void keyReleased(KeyEvent evt){
String cadenaEscrita=c_perfiles.getEditor().getItem().toString();
//limitar los eventos de las teclas usando el ACII
if(evt.getKeyCode()>=65 && evt.getKeyCode()<=90 || evt.getKeyCode()>=96 && evt.getKeyCode()<=105 || evt.getKeyCode()==8 ){
try {
c_perfiles.setModel(busqueda.getLista(cadenaEscrita));
if(c_perfiles.getItemCount()>0){
c_perfiles.showPopup();
if(evt.getKeyCode()!=8){
((JTextComponent)c_perfiles.getEditor().getEditorComponent()).select(cadenaEscrita.length(),c_perfiles.getEditor().getItem().toString().length());
}
else{
c_perfiles.getEditor().setItem(cadenaEscrita);
}
}
else{
c_perfiles.addItem(cadenaEscrita);
}
} catch (SQLException ex) {
Logger.getLogger(ConsultaPerfil.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
} |
45471993-d47a-46c0-be73-2b0d4ae636f0 | 9 | final boolean method793(int i) {
anInt1403++;
if (((NpcDefinition) this).anIntArray1377 == null) {
if ((((NpcDefinition) this).anInt1343 ^ 0xffffffff) == 0
&& (((NpcDefinition) this).anInt1364 ^ 0xffffffff) == 0
&& ((NpcDefinition) this).anInt1327 == -1)
return false;
return true;
}
for (int i_0_ = i; ((NpcDefinition) this).anIntArray1377.length > i_0_;
i_0_++) {
if ((((NpcDefinition) this).anIntArray1377[i_0_] ^ 0xffffffff) != 0) {
NpcDefinition class79_1_
= (((NpcDefinition) this).loader.getNpcDefinition
(((NpcDefinition) this).anIntArray1377[i_0_]));
if ((((NpcDefinition) class79_1_).anInt1343 ^ 0xffffffff) != 0
|| ((NpcDefinition) class79_1_).anInt1364 != -1
|| ((NpcDefinition) class79_1_).anInt1327 != -1)
return true;
}
}
return false;
} |
9934d7e0-bb7e-47ff-aec7-cec3e962dc4b | 3 | public void paivitaTuote(Tuote t) throws DAOPoikkeus{
Connection yhteys = avaaYhteys();
String muokkaaPizzaQuery = "UPDATE Tuote SET nimi=?, numero=?, hinta=?, aktiivinen=?,tuoteryhmaID=? WHERE TuoteID = ?";
String poistaTayte ="DELETE FROM TuotteenTayte WHERE tuoteID=?";
String lisaaTaytteet = "INSERT INTO TuotteenTayte (tayteID, tuoteID) VALUES(?,?)";
PreparedStatement lause;
ResultSet muokattuResult;
try {
lause = yhteys.prepareStatement(muokkaaPizzaQuery);
lause.setString(1, t.getNimi());
lause.setInt(2, t.getNumero());
lause.setDouble(3, t.getHinta());
lause.setBoolean(4, t.isAktiivinen());
lause.setInt(5, t.getRyhmaId());
lause.setInt(6, t.getId());
muokattuResult = lause.executeQuery();
// poistetaan vanhat täytteet
lause = yhteys.prepareStatement(poistaTayte);
lause.setInt(1, t.getId());
muokattuResult = lause.executeQuery();
if(t.getRyhmaId() == 1){
Pizza p = (Pizza) t;
lause = yhteys.prepareStatement(lisaaTaytteet);
// lisätään pizzan uudet täytteet
for (int i = 0; i < p.getTaytteet().size(); i++) {
List taytteLista = p.getTaytteet();
Tayte tayte = (Tayte) taytteLista.get(i);
lause.setInt(1, tayte.getId());
lause.setInt(2, p.getId());
muokattuResult = lause.executeQuery();
System.out.println(tayte.getId());
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
suljeYhteys(yhteys);
}
} |
f9d462dc-38cd-4c20-a70a-855a53301191 | 3 | private void closeConnection() {
logger.finer("Closing server connection");
synchronized(CONNECTION_LOCK) {
if(receivePacketThread != null)
receivePacketThread.stopReceiving();
if(timeoutThread != null)
timeoutThread.stopCheckingForTimeouts();
if(socket != null)
socket.close();
resetParameters();
}
} |
ad1d7e7b-84b9-4f0c-a293-0a93953cbfa2 | 0 | public void addChunk(Chunk C)
{
chunksLock.writeLock().lock();
try {
chunks.add(C);
} finally {
chunksLock.writeLock().unlock();
}
} |
c51f58db-8fd5-4229-a88f-fe9bc310a39f | 8 | static protected boolean isWhiteSpace(char ch) {
return (ch == ct || ch == lf || ch == tb ||
ch == fd || ch == cr || ch == nl ||
ch == zs || ch == zl || ch == zp);
} |
f27a0631-e987-40af-a3c6-ecf56ce51f22 | 2 | protected String makeResponseToken(WebSocketRequest requestInfo, byte[] token)throws NoSuchAlgorithmException {
MessageDigest md5digest = MessageDigest.getInstance("MD5");
for(Integer i = 0; i < 2; ++i){
byte[] asByte = new byte[4];
long key = (i == 0) ? requestInfo.getKey1().intValue() : requestInfo.getKey2().intValue();
asByte[0] = (byte) (key >> 24);
asByte[1] = (byte) ((key << 8) >> 24);
asByte[2] = (byte) ((key << 16) >> 24);
asByte[3] = (byte) ((key << 24) >> 24);
md5digest.update(asByte);
}
md5digest.update(token);
return new String(md5digest.digest());
} |
c93b73a2-68cf-4aca-9bfd-4727185be22b | 2 | public int getTotalNum() {
int num = 0;
for(ParkBoy boy : this.parkBoyList) {
num += boy.getTotalNum();
}
if(this.park != null) {
num += this.park.getTotalNum();
}
return num;
} |
e9b1c696-d09b-4b75-9197-453592a8c609 | 3 | public String findVappLink(String apiUrl, String vAppName) throws Exception {
String response = doGet(apiUrl + Utils.VAPPS_QUERY_SUFFIX);
Document doc = RestClient.stringToXmlDocument(response);
NodeList list = doc.getElementsByTagName(Constants.VAPP_RECORD);
String element = new String();
for(int i=0; i < list.getLength(); i++){
if(list.item(i).getAttributes().getNamedItem(Constants.NAME).getTextContent().trim().equalsIgnoreCase(vAppName)){
element = list.item(i).getAttributes().getNamedItem(Constants.HREF).getTextContent().trim();
}
}
if( element.isEmpty())
{
throw new Exception("No Vapp found that matches the given name: " + vAppName);
}
return element;
} |
ca35d11a-2e62-4d8f-a123-3c5a61eecc8f | 2 | private boolean toBoolean(final Properties azotProperties, final String key, final boolean defaultValue) {
boolean flag = defaultValue;
if (azotProperties.getProperty(key) != null) {
try {
flag = Boolean.parseBoolean(azotProperties.getProperty(key));
} catch (Exception e) {
e.printStackTrace();
}
}
return flag;
} |
5e209623-6557-4c9a-902d-72dae9a82bf4 | 6 | public int[] canMove() {
int[] movable = new int[] { 0, 0, 0, 0 };
if (this.nodesState[0] > dimension
&& this.nodesState[0] <= dimension * dimension)
movable[0] = 1; // 空白格可向上移
if (this.nodesState[0] >= 1
&& this.nodesState[0] <= dimension * (dimension - 1))
movable[1] = 1; // 空白格可向下移
if (this.nodesState[0] % dimension != 1)
movable[2] = 1; // 空白格可向左移
if (this.nodesState[0] % dimension != 0)
movable[3] = 1; // 空白格可向右移
return movable;
} |
33c19e44-c1b8-4f83-899b-0e4761ee9987 | 1 | public Member merge(Member detachedInstance) {
log.debug("merging Member instance");
try {
Member result = (Member) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
} |
5989dcad-3dab-4ca3-8027-07cd52545898 | 9 | @Override
public void mutateStackForInfixTranslation(Stack<Token> operatorStack, StringBuilder output) {
Token before;
while (!operatorStack.isEmpty() && (before = operatorStack.peek()) != null && (before instanceof OperatorToken || before instanceof FunctionToken)) {
if (before instanceof FunctionToken) {
operatorStack.pop();
output.append(before.getValue()).append(" ");
} else {
final OperatorToken stackOperator = (OperatorToken) before;
if (this.isLeftAssociative() && this.getPrecedence() <= stackOperator.getPrecedence()) {
output.append(operatorStack.pop().getValue()).append(" ");
} else if (!this.isLeftAssociative() && this.getPrecedence() < stackOperator.getPrecedence()) {
output.append(operatorStack.pop().getValue()).append(" ");
} else {
break;
}
}
}
operatorStack.push(this);
} |
f6b63272-6b6f-4b75-ad7d-ccb00d56564f | 6 | private static Object getNextMatchPosRegExImpl(String regEx,
CharSequence searchIn, boolean goForward,
boolean matchCase, boolean wholeWord,
String replaceStr) {
if (wholeWord) {
regEx = "\\b" + regEx + "\\b";
}
// Make a pattern that takes into account whether or not to match case.
int flags = Pattern.MULTILINE; // '^' and '$' are done per line.
flags |= matchCase ? 0 : (Pattern.CASE_INSENSITIVE|Pattern.UNICODE_CASE);
Pattern pattern = Pattern.compile(regEx, flags);
// Make a Matcher to find the regEx instances.
Matcher m = pattern.matcher(searchIn);
// Search forwards
if (goForward) {
if (m.find()) {
if (replaceStr==null) { // Find, not replace.
return new Point(m.start(), m.end());
}
// Otherwise, replace
return new RegExReplaceInfo(m.group(0),
m.start(), m.end(),
getReplacementText(m, replaceStr));
}
}
// Search backwards
else {
List matches = getMatches(m, replaceStr);
if (!matches.isEmpty()) {
return matches.get(matches.size()-1);
}
}
return null; // No match found
} |
5fe24843-7909-4c29-9a3c-de01e5a66423 | 4 | private List<Node> closestNodesNotFailed(String status)
{
List<Node> closestNodes = new ArrayList<>(this.config.k());
int remainingSpaces = this.config.k();
for (Map.Entry<Node, String> e : this.nodes.entrySet())
{
if (!FAILED.equals(e.getValue()))
{
if (status.equals(e.getValue()))
{
/* We got one with the required status, now add it */
closestNodes.add(e.getKey());
}
if (--remainingSpaces == 0)
{
break;
}
}
}
return closestNodes;
} |
0b168b84-3885-454c-8aa1-ee3e1a5df1d3 | 0 | @BeforeClass
public static void setUpClass() {
} |
f5658d1b-d39a-420a-9c40-6a6cabb401fc | 0 | public void add(Item item) {
Node<Item> oldfirst = first;
first = new Node<Item>();
first.item = item;
first.next = oldfirst;
N++;
} |
5894a06e-5d93-4eb2-829a-8fde51ba4043 | 5 | public String toString() {
E el;
// Search for maximum element length
// int maxlen = 0;
// int ellen;
//
// for (int i = 0; i < array.getSize(); i++) {
// el = array.getElement(i);
// if (el != null) {
// ellen = el.toString().length();
// maxlen = ellen > maxlen ? ellen : maxlen;
// }
//
// }
// Set spacer length
String space = " ";
String nullElemHolder = "....";
String outFormat = "[%2s]";
int index = 0;
int layerIndex = 1;
StringBuffer sb = new StringBuffer();
while (layerIndex <= capacityLayers) {
for (int i = 1; i < Math.pow(2, capacityLayers - layerIndex); ++i) {
sb.append(space);
}
for (int i = index; i <= Math.pow(2, layerIndex) - 2; ++i) {
el = array.getElement(i);
if (el != null) {
// sb.append(el);
sb.append(String.format(outFormat, el.toString()));
} else {
sb.append(nullElemHolder);
}
for (int k = 1; k < Math.pow(2, capacityLayers - layerIndex + 1); ++k) {
sb.append(space);
}
}
sb.append("\n\n");
++layerIndex;
index = (int) (Math.pow(2, layerIndex - 1) - 1);
}
return sb.toString();
} |
f375f529-0c46-4bf4-b69b-ca31f793fc5b | 7 | static void testConnection(String url, String query, int maxconn) {
if (url == null || url.length() == 0 || query == null
|| query.length() == 0 || maxconn <= 0) {
testError();
}
SimpleConnectionPool pool = null;
Connection con = null;
try {
pool = SimpleConnectionPool.getInstance(maxconn);
log.info("creating initial connections...");
con = pool.getConnection(url);
log.info("got a connection");
ResultSet rs = SimpleConnectionPool.doQuery(con, query);
log.info("statement created...");
log.info("executing query...");
int count = 0;
while (rs.next()) {
++count;
log.info("row " + count + ": " + rs.getString("productname"));
}
} catch (Exception e) {
log.warning("Error occurred trying to read table: "
+ e.getClass().getName() + " Message: " + e.getMessage());
}
finally {
pool.returnToPool(con, url);
}
pool.closeConnections();
} |
36803e2f-6617-4a0b-ac6a-e58e5d89ab85 | 7 | public void mouseReleased(MouseEvent evt) {
//Fill in pixels in between and connect the first to the last
int N = selectionBorder.size();
if (N == 0 || (state != SELECTING && state != DRAGGING))
return;
if (state == SELECTING) {
for (int n = 0; n < N; n++) {
int startx = selectionBorder.get(n).x;
int starty = selectionBorder.get(n).y;
int totalDX = selectionBorder.get((n+1)%N).x - startx;
int totalDY = selectionBorder.get((n+1)%N).y - starty;
int numAdded = Math.abs(totalDX) + Math.abs(totalDY);
for (int t = 0; t < numAdded; t++) {
double frac = (double)t / (double)numAdded;
int x = (int)Math.round(frac*totalDX) + startx;
int y = (int)Math.round(frac*totalDY) + starty;
selectionBorder.add(new Coord(x, y));
}
}
/*selection.clear();
for (int x = 0; x < Width; x++) {
for (int y = 0; y < Height; y++) {
if (mask[x][y])
selection.add(new Coord(x, y));
}
}*/
updateMask();
getSelectionArea();
state = DRAGGING;
dragValid = false;
dx = 0;
dy = 0;
}
else if (state == DRAGGING) {
dragValid = false;
updateMask();
}
canvas.repaint();
} |
99dee289-8ca1-40a7-88ba-a4c32a783ef0 | 2 | private static void initializeLogger() {
try {
FileHandler fh = new FileHandler(client.Main.class.getName()
+ ".log");
fh.setFormatter(new SimpleFormatter());
log.addHandler(fh);
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
log.setUseParentHandlers(false);
} |
9047b8a0-3f72-414b-bb46-7f04ec17f70e | 8 | public void action() {
ACLMessage msg = receive(MessageTemplate.MatchSender(controller));
if (msg == null) { block(); return; }
if (msg.getPerformative() == ACLMessage.REQUEST){
try {
ContentElement content = getContentManager().extractContent(msg);
Concept concept = ((Action)content).getAction();
if (concept instanceof CloneAction){
CloneAction ca = (CloneAction)concept;
String newName = ca.getNewName();
Location l = ca.getMobileAgentDescription().getDestination();
if (l != null) destination = l;
doClone(destination, newName);
}
else if (concept instanceof MoveAction){
MoveAction ma = (MoveAction)concept;
Location l = ma.getMobileAgentDescription().getDestination();
if (l != null) doMove(destination = l);
}
else if (concept instanceof KillAgent){
myGui.setVisible(false);
myGui.dispose();
doDelete();
}
}
catch (Exception ex) { ex.printStackTrace(); }
}
else { System.out.println("Unexpected msg from controller agent"); }
} |
d09c08ec-cf09-4576-835b-67f52ba81d90 | 5 | public void loadFile(String filename){
String path = "data/" + filename;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(path), "Shift_JIS"));
String line;
while ((line = br.readLine()) != null) {
// 空行を読み飛ばす
if (line.equals("")) continue;
// コメント行を読み飛ばす
if (line.startsWith("#")) continue;
String[] token = line.split(",");
// エフェクト情報を取得する
String name = token[0];
String image_name = token[1];
int animation_len = Integer.parseInt(token[2]);
int width = Integer.parseInt(token[3]);
int height = Integer.parseInt(token[4]);
int x = MainPanel.WIDTH / 2 - width / 2;
int y = MainPanel.HEIGHT / 2 - height / 2 - 50;
effects.put(name,new Effect(image_name,animation_len,x,y,width,height));
}
}catch(FileNotFoundException e){
System.out.println(e);
} catch (IOException e) {
e.printStackTrace();
}
} |
f753a3dd-1a9f-4a7c-aa24-d5e348ded5b2 | 7 | @Override
public void run() {
for(;;) {
// Se o socke esta fechado então terminar Thread.
if(socket.isClosed()) return;
try {
mensagemRecebida = (Mensagem) entrada.readObject();
switch(mensagemRecebida.getTipoMensagem()) {
case LISTA_ARQUIVOS:
enviarListaDeArquivos();
break;
case UPLOAD:
break;
case DOWNLOAD:
break;
case DELETAR:
break;
}
}
catch(Exception ex) {
// Caso hava um erro desconecta o servidor escravo...
desconectarServidorEscravo();
}
}
} |
0b7801a1-8778-4af8-806e-da693e8a5adb | 6 | private void unmountFoldersOnLinux() {
if (!getType().equalsIgnoreCase("smb")
&& !getType().equalsIgnoreCase("nfs")) {
// TODO: find better way to throw errors without needing to add
// throw declarations everywhere.
throw new RuntimeException("Nope, invalid mount type " + getType()
+ " on server [" + getName() + "]" + getIp());
}
for (String dir : this.getMountFolders()) {
switch(getController().unmount(getPath() + "/" + dir)) {
case 0:
log("removed mount " + getPath() + "/" + dir);
break;
case 1:
log("removed mount with lock-remove " + getPath() + "/" + dir);
break;
case -1:
log("Error removing mount " + getPath() + "/" + dir);
break;
}
}
} |
24441d9f-a712-4bc6-b3ff-d269ee67ce10 | 3 | @Override
public void deserialize(Buffer buf) {
senderName = buf.readString();
content = buf.readString();
timestamp = buf.readInt();
if (timestamp < 0)
throw new RuntimeException("Forbidden value on timestamp = " + timestamp + ", it doesn't respect the following condition : timestamp < 0");
channel = buf.readByte();
if (channel < 0)
throw new RuntimeException("Forbidden value on channel = " + channel + ", it doesn't respect the following condition : channel < 0");
fingerprint = buf.readString();
reason = buf.readByte();
if (reason < 0)
throw new RuntimeException("Forbidden value on reason = " + reason + ", it doesn't respect the following condition : reason < 0");
} |
2fcef0fd-8270-45cd-b7c6-cd25fe8a1f0b | 7 | public void pushSelection(Selectable s, boolean asRoot) {
if (asRoot) navStack.clear() ;
if (s != null) {
selected = s ;
if (s.subject().inWorld()) UI.camera.lockOn(s.subject()) ;
final InfoPanel panel = s.createPanel(UI) ;
final int SI = navStack.indexOf(selected) ;
Selectable previous = null ;
if (SI != -1) {
if (selected == navStack.getLast()) previous = null ;
else previous = navStack.atIndex(SI + 1) ;
while (navStack.getFirst() != selected) navStack.removeFirst() ;
panel.setPrevious(previous) ;
}
else {
previous = navStack.getFirst() ;
navStack.addFirst(selected) ;
panel.setPrevious(previous) ;
}
//I.say("Navigation stack is: ") ;
//for (Selectable n : navStack) I.add("\n "+n) ;
UI.setInfoPanel(panel) ;
}
else if (selected != null) {
navStack.clear() ;
selected = null ;
UI.camera.lockOn(null) ;
UI.setInfoPanel(null) ;
}
} |
9034fb07-5c7f-49ba-af23-17418ec9c0e9 | 8 | public void setOptions(String[] options) throws Exception {
String tmpStr;
tmpStr = Utils.getOption("mean-prec", options);
if (tmpStr.length() > 0)
setMeanPrec(Integer.parseInt(tmpStr));
else
setMeanPrec(getDefaultMeanPrec());
tmpStr = Utils.getOption("stddev-prec", options);
if (tmpStr.length() > 0)
setStdDevPrec(Integer.parseInt(tmpStr));
else
setStdDevPrec(getDefaultStdDevPrec());
tmpStr = Utils.getOption("col-name-width", options);
if (tmpStr.length() > 0)
setColNameWidth(Integer.parseInt(tmpStr));
else
setColNameWidth(getDefaultColNameWidth());
tmpStr = Utils.getOption("row-name-width", options);
if (tmpStr.length() > 0)
setRowNameWidth(Integer.parseInt(tmpStr));
else
setRowNameWidth(getDefaultRowNameWidth());
tmpStr = Utils.getOption("mean-width", options);
if (tmpStr.length() > 0)
setMeanWidth(Integer.parseInt(tmpStr));
else
setMeanWidth(getDefaultMeanWidth());
tmpStr = Utils.getOption("stddev-width", options);
if (tmpStr.length() > 0)
setStdDevWidth(Integer.parseInt(tmpStr));
else
setStdDevWidth(getDefaultStdDevWidth());
tmpStr = Utils.getOption("sig-width", options);
if (tmpStr.length() > 0)
setSignificanceWidth(Integer.parseInt(tmpStr));
else
setSignificanceWidth(getDefaultSignificanceWidth());
tmpStr = Utils.getOption("count-width", options);
if (tmpStr.length() > 0)
setStdDevPrec(Integer.parseInt(tmpStr));
else
setStdDevPrec(getDefaultCountWidth());
setShowStdDev(Utils.getFlag("show-stddev", options));
setShowAverage(Utils.getFlag("show-avg", options));
setRemoveFilterName(Utils.getFlag("remove-filter", options));
setPrintColNames(Utils.getFlag("print-col-names", options));
setPrintRowNames(Utils.getFlag("print-row-names", options));
setEnumerateColNames(Utils.getFlag("enum-col-names", options));
setEnumerateRowNames(Utils.getFlag("enum-row-names", options));
} |
ed223835-2972-4b44-bda0-8206fabde8ea | 9 | final void method401(int i, int j, int k, int l, int i1) {
if (composite == null) {
return;
}
if (!super.aBoolean2894) {
Animation animation = super.animation != -1 && super.animationDelay == 0 ? Class66.animationForID(super.animation) : null;
Animation animation_1 = super.anInt2948 != -1 && (super.anInt2948 != method450().anInt889 || animation == null) ? Class66.animationForID(super.anInt2948) : null;
Class39_Sub5 class39_sub5 = composite.method1153(animation_1, super.anInt2888, super.anInt2881, super.anInt2904, 0, super.anInt2928, super.anInt2936, super.aClass101Array2874, animation, super.anInt2943);
if (class39_sub5 == null) {
return;
}
method446(null, class39_sub5, true);
}
if (super.aClass4_Sub3_2886 != null) {
super.aClass4_Sub3_2886.method110(i, j, l, k, i1);
}
} |
813a5d78-36d5-4026-b1f5-1dfa2f6e033d | 2 | private StdImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?, ?> properties) {
super(cm, raster, isRasterPremultiplied, properties);
clear();
} |
a42db717-b2cc-4b0c-8e3d-95a8b3430033 | 6 | @EventHandler
public void BlazeJump(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getBlazeConfig().getDouble("Blaze.Jump.DodgeChance") / 100;
final double ChanceOfHappening = random.nextDouble();
if (ChanceOfHappening >= randomChance) {
dodged = true;
}
if (plugin.getBlazeConfig().getBoolean("Blaze.Jump.Enabled", true) && damager instanceof Blaze && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) {
Player player = (Player) e;
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, plugin.getBlazeConfig().getInt("Blaze.Jump.Time"), plugin.getBlazeConfig().getInt("Blaze.Jump.Power")));
}
} |
8abe8ff3-8250-4077-84d2-7cce6b7df5d6 | 1 | public void deleteMarker(int index)
{
for(int i=index;i<markers-1;i++)
{
marker[i]=marker[i+1];
}
marker[markers-1]=null;
markers--;
} |
5cba5251-7a58-48e1-9fa7-4c143e8cbc60 | 9 | public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
List<List<Integer>> result = new ArrayList<List<Integer>>();
if(root == null){
return result;
}
List<Integer> first = new ArrayList<Integer>();
first.add(root.val);
result.add(first);
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
LinkedList<TreeNode> childrenQueue = new LinkedList<TreeNode>();
queue.add(root);
int i =1;
while (!queue.isEmpty()) {
TreeNode node = queue.remove();
if(node.left!=null){
childrenQueue.add(node.left);
}
if(node.right!=null){
childrenQueue.add(node.right);
}
if(queue.isEmpty() && !childrenQueue.isEmpty()){
queue.addAll(childrenQueue);
LinkedList<Integer> childrenResult = new LinkedList<Integer>();
boolean flag = i%2==0?true:false;
for(TreeNode child : childrenQueue){
if(flag){
childrenResult.add(child.val);
}else{
childrenResult.push(child.val);
}
}
result.add(childrenResult);
childrenQueue.clear();
i++;
}
}
return result;
} |
765fa876-1794-44c5-ba9d-e95a283c9593 | 2 | static void printList(final PrintWriter pw, final List l) {
for (int i = 0; i < l.size(); ++i) {
Object o = l.get(i);
if (o instanceof List) {
printList(pw, (List) o);
} else {
pw.print(o.toString());
}
}
} |
3993bdf3-3cce-4919-a85b-b3c7f4f92053 | 2 | public boolean gayp() {
if (gay == -1)
gay = detectgay() ? 1 : 0;
return (gay == 1);
} |
5fda8935-3dca-4dd7-8920-08d80264672d | 0 | public String getId() {
return id;
} |
fa695519-a34a-4bcc-980f-380df88f60fc | 4 | @Override
public boolean setChartOption( String op, String val )
{
boolean bHandled = false;
if( op.equalsIgnoreCase( "SmoothedLine" ) )
{
fSmoothedLine = val.equals( "true" );
bHandled = true;
}
else if( op.equalsIgnoreCase( "ThreeDBubbles" ) )
{
f3dBubbles = val.equals( "true" );
bHandled = true;
}
else if( op.equalsIgnoreCase( "ArShadow" ) )
{
fArShadow = val.equals( "true" );
bHandled = true;
}
if( bHandled )
{
updateRecord();
}
return bHandled;
} |
b35bf6b2-016e-4e37-9fc6-af65825e3c94 | 7 | public static Rule_dirSubannotation parse(ParserContext context)
{
context.push("dirSubannotation");
boolean parsed = true;
int s0 = context.index;
ArrayList<Rule> e0 = new ArrayList<Rule>();
Rule rule;
parsed = false;
if (!parsed)
{
{
ArrayList<Rule> e1 = new ArrayList<Rule>();
int s1 = context.index;
parsed = true;
if (parsed)
{
boolean f1 = true;
int c1 = 0;
for (int i1 = 0; i1 < 1 && f1; i1++)
{
rule = Terminal_StringValue.parse(context, ".subannotation");
if ((f1 = rule != null))
{
e1.add(rule);
c1++;
}
}
parsed = c1 == 1;
}
if (parsed)
e0.addAll(e1);
else
context.index = s1;
}
}
rule = null;
if (parsed)
rule = new Rule_dirSubannotation(context.text.substring(s0, context.index), e0);
else
context.index = s0;
context.pop("dirSubannotation", parsed);
return (Rule_dirSubannotation)rule;
} |
a6cdbc9f-f2a7-4d3d-941d-012650f24ae5 | 5 | public void contextDestroyed(ServletContextEvent sce) {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
Object[] params = new Object[1];
params[0] = tccl;
// Walk up the tree of classloaders, finding all the available
// LogFactory classes and releasing any objects associated with
// the tccl (ie the webapp).
//
// When there is only one LogFactory in the classpath, and it
// is within the webapp being undeployed then there is no problem;
// garbage collection works fine.
//
// When there are multiple LogFactory classes in the classpath but
// parent-first classloading is used everywhere, this loop is really
// short. The first instance of LogFactory found will
// be the highest in the classpath, and then no more will be found.
// This is ok, as with this setup this will be the only LogFactory
// holding any data associated with the tccl being released.
//
// When there are multiple LogFactory classes in the classpath and
// child-first classloading is used in any classloader, then multiple
// LogFactory instances may hold info about this TCCL; whenever the
// webapp makes a call into a class loaded via an ancestor classloader
// and that class calls LogFactory the tccl gets registered in
// the LogFactory instance that is visible from the ancestor
// classloader. However the concrete logging library it points
// to is expected to have been loaded via the TCCL, so the
// underlying logging lib is only initialised/configured once.
// These references from ancestor LogFactory classes down to
// TCCL classloaders are held via weak references and so should
// be released but there are circumstances where they may not.
// Walking up the classloader ancestry ladder releasing
// the current tccl at each level tree, though, will definitely
// clear any problem references.
ClassLoader loader = tccl;
while (loader != null) {
// Load via the current loader. Note that if the class is not accessable
// via this loader, but is accessable via some ancestor then that class
// will be returned.
try {
Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory");
Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE);
releaseMethod.invoke(null, params);
loader = logFactoryClass.getClassLoader().getParent();
} catch(ClassNotFoundException ex) {
// Neither the current classloader nor any of its ancestors could find
// the LogFactory class, so we can stop now.
loader = null;
} catch(NoSuchMethodException ex) {
// This is not expected; every version of JCL has this method
System.err.println("LogFactory instance found which does not support release method!");
loader = null;
} catch(IllegalAccessException ex) {
// This is not expected; every ancestor class should be accessable
System.err.println("LogFactory instance found which is not accessable!");
loader = null;
} catch(InvocationTargetException ex) {
// This is not expected
System.err.println("LogFactory instance release method failed!");
loader = null;
}
}
// Just to be sure, invoke release on the LogFactory that is visible from
// this ServletContextCleaner class too. This should already have been caught
// by the above loop but just in case...
LogFactory.release(tccl);
} |
924964ef-ed90-48db-b25f-7731b97ca362 | 7 | public void arrayMakeRequirements() {
String temp;
int areaHours=0;
for (int i = 0; i < arrayCourseRefined.size(); i++) {
RequirementsStruct maker = new RequirementsStruct();
maker.requirementName = parse17(arrayCourseRefined.get(i).get(0), i);
maker.ID = i;
if(maker.requirementName.contains("AREA")&&(i!=0)){
areaHours=parseArea(arrayCourseRefined.get(i-1).get((arrayCourseRefined.get(i-1).size())-1));
}
else{
areaHours=0;
}
for (int j = 0; j < arrayCourseRefined.get(i).size(); j++) {
if ((arrayCourseRefined
.get(i)
.get(j)
.contains(
"auditLineType_25_noSubrequirementNeedsSummaryLine"))) {
//maker.requiremnetHours = parse25(arrayCourseRefined.get(i)
// .get(j));
}
}
if(maker.requirementName.contains("SAMEAS:")){
temp=maker.requirementName.replace("SAMEAS:", "").trim();
maker.sameAs=Integer.parseInt(temp);
}
else{
maker.sameAs=maker.ID;
}
if(areaHours!=0){
maker.requiremnetHours=areaHours;
}
arrayRequirments.add(maker);
}
} |
cc555c76-bab2-4ea9-8871-e79a3463f0df | 9 | public void test_loop() {
// loop round at least one 400 year cycle, including before 1970
LocalDate date = LocalDate.of(1960, 1, 5); // Tuseday of week 1 1960
int year = 1960;
int wby = 1960;
int weekLen = 52;
int week = 1;
while (date.getYear() < 2400) {
DayOfWeek loopDow = date.getDayOfWeek();
if (date.getYear() != year) {
year = date.getYear();
}
if (loopDow == MONDAY) {
week++;
if ((week == 53 && weekLen == 52) || week == 54) {
week = 1;
LocalDate firstDayOfWeekBasedYear = date.plusDays(14).withDayOfYear(1);
DayOfWeek firstDay = firstDayOfWeekBasedYear.getDayOfWeek();
weekLen = (firstDay == THURSDAY || (firstDay == WEDNESDAY && firstDayOfWeekBasedYear.isLeapYear()) ? 53 : 52);
wby++;
}
}
assertEquals(ISOWeeks.WEEK_OF_WEEK_BASED_YEAR.doRange(date), DateTimeValueRange.of(1, weekLen), "Failed on "
+ date + " " + date.getDayOfWeek());
assertEquals(ISOWeeks.WEEK_OF_WEEK_BASED_YEAR.doGet(date), week, "Failed on " + date + " " + date.getDayOfWeek());
assertEquals(date.get(ISOWeeks.WEEK_OF_WEEK_BASED_YEAR), week, "Failed on " + date + " " + date.getDayOfWeek());
assertEquals(ISOWeeks.WEEK_BASED_YEAR.doGet(date), wby, "Failed on " + date + " " + date.getDayOfWeek());
assertEquals(date.get(ISOWeeks.WEEK_BASED_YEAR), wby, "Failed on " + date + " " + date.getDayOfWeek());
date = date.plusDays(1);
}
} |
9dc697ad-a236-4ffb-8bba-12add06a5729 | 4 | public void implementFather() {
if(parents.size() == 0)
return;
else {
for(int i = 0; i < parents.size(); ++i) {
if(parents.get(i) != null)
parents.get(i).implementFather();
}
for(int i = 0; i < parents.size(); ++i)
attributes.addAll(parents.get(i).attributes);
}
} |
51323a69-6cbb-4356-9268-cf0fba3dc2d8 | 7 | @Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(!super.okMessage(myHost, msg))
return false;
if((msg.tool()==this)
&&(msg.targetMinor()==CMMsg.TYP_DAMAGE)
&&(msg.value()>0)
&&(msg.target() !=null)
&&(msg.target() instanceof MOB)
&&(weaponClassification()==Weapon.CLASS_THROWN))
{
msg.setValue(0);
}
return true;
} |
5eca334b-18ff-4170-a6eb-7e70da1b3f95 | 5 | public static AbstractForme creerForme(String chaineForme) {
DecodeurChaineForme decodeur = new DecodeurChaineForme(chaineForme);
IDLogger enregistreur = IDLogger.getInstance();
AbstractForme forme = null;
switch(decodeur.getTypeForme()) {
case CHAINE_CARRE :
forme = new Carre(decodeur.getNumeroSequence(),
new Integer[]{decodeur.getCoordonnees()[0], decodeur.getCoordonnees()[1]},
new Integer[]{decodeur.getCoordonnees()[2], decodeur.getCoordonnees()[3]});
break;
case CHAINE_RECTANGLE :
forme = new Rectangle(decodeur.getNumeroSequence(),
new Integer[]{decodeur.getCoordonnees()[0], decodeur.getCoordonnees()[1]},
new Integer[]{decodeur.getCoordonnees()[2], decodeur.getCoordonnees()[3]});
break;
case CHAINE_CERCLE :
forme = new Cercle(decodeur.getNumeroSequence(),
new Integer[]{decodeur.getCoordonnees()[0], decodeur.getCoordonnees()[1]},
decodeur.getCoordonnees()[2]);
break;
case CHAINE_OVALE :
forme = new Ovale(decodeur.getNumeroSequence(),
new Integer[]{decodeur.getCoordonnees()[0], decodeur.getCoordonnees()[1]},
decodeur.getCoordonnees()[2],
decodeur.getCoordonnees()[3]);
break;
case CHAINE_LIGNE :
forme = new Ligne(decodeur.getNumeroSequence(),
new Integer[]{decodeur.getCoordonnees()[0], decodeur.getCoordonnees()[1]},
new Integer[]{decodeur.getCoordonnees()[2], decodeur.getCoordonnees()[3]});
break;
}
enregistreur.logID(forme.getNoSequence());
return forme;
} |
36f8c0df-8973-4348-9a24-1585038460d6 | 6 | @Override
public void init(int l, int h) {
if(!(l%2 == 1 && h%2 == 1))
throw new PreConditionError("l and h must be odd");
if(!(l>0 && h>0))
throw new PreConditionError("l and h must be positive");
super.init(l,h);
if(!(super.getNombreColonnes()==l))
throw new PostConditionError("getNombreColonnes(init(l,h)) != l");
if(!(super.getNombreLignes()==l))
throw new PostConditionError("getNombreLignes(init(l,h)) != l");
} |
426c8d18-b8dc-48de-afab-c22f5f1ababa | 7 | public void setupWindow(JComponent component)
{
frame = new JFrame();
frame.add(component);
//frame.setUndecorated(slateSettings.getUndecorated());
frame.setUndecorated(true);
frame.setResizable(false);
// Shift to external display
//if (slateSettings.getExternalDisplay())
//{
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//frame.setLocation(screenSize.width, 0);
GraphicsConfiguration gc = device.getDefaultConfiguration();
frame.setLocation((int) gc.getBounds().getX(), (int) gc.getBounds().getY());
//System.out.println("(" + gc.getBounds().getX() + ", " + gc.getBounds().getY() + ", "
// + gc.getBounds().getWidth() + ", " + gc.getBounds().getHeight() + ")");
//}
frame.addWindowListener( new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
//reacTIVisionProcess.destroy();
System.exit(0);
}
});
frame.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_ESCAPE)
{
System.exit(0);
}
else if (evt.getKeyCode() == KeyEvent.VK_H)
{
slateSettings.setHelpParadigm(slateSettings.getHelpParadigm().next());
DataManager.saveSlateSettings(slateSettings);
}
else if (evt.getKeyCode() == KeyEvent.VK_L)
{
slateComponent.toggleEventLogger();
}
else if (evt.getKeyCode() == KeyEvent.VK_V)
{
Logger.toggleVerbose();
}
else if (evt.getKeyCode() == KeyEvent.VK_R)
{
slateComponent.reset();
//calibrationComponent.reset();
}
else if (evt.getKeyCode() == KeyEvent.VK_T)
{
changeMode(Mode.Toolkit_Calibration);
}
else if (evt.getKeyCode() == KeyEvent.VK_C)
{
changeMode(Mode.System_Calibration);
}
// TODO SELECT TOOLKIT OPTION
// TODO launch select toolkit dialog
// TODO should be TUIO-based, but we'll do it the simple way for now
//String toolkitName = slateSettings.getToolkit();
//destroyWindow();
//slateSettings.setToolkit(toolkitName);
//startSlateSession();
} });
} |
289da2b7-87b3-416e-9ffc-3e03d7beb79a | 6 | public void Process(int id){
switch(id){
case 1003:InsertDelayedOperationList(3);
break;
case 1004:InsertDelayedOperationList(4);
break;
case 1005:InsertDelayedOperationList(5);
break;
case 1006:InsertDelayedOperationList(6);
break;
case 1007:InsertDelayedOperationList(7);
break;
case 1010:InsertDelayedOperationList(10);
break;
}
} |
1d3b963c-a1d0-41ac-92be-edaf5a4827fa | 2 | public static void addItemTester(Item item){
if(item != null){
if(ItemStorageInventory.create().addItem(item)){
System.out.println("add "+ item.toString() + " successfully\n");
}else{
System.out.println("add "+ item.toString() + " failed\n");
}
}else
System.out.println("add item " + " failed\n");
} |
e4142c8d-e1ee-4ada-8e55-2617afe10daf | 1 | public String readString(String tag){
String s = "";
if(!data.containsKey(tag)){
System.out.println("The tag "+ tag + " did not exist.");
return s;
}
s = (String)data.get(tag);
return s;
} |
122aa418-ac1b-477a-84ac-b61b588df168 | 0 | @Override
public SkillsMain[] getSkillNames() {
return Constants.paladinSkillSkills;
} |
e59ae5ac-e5f3-469b-a226-30604d23c722 | 9 | public boolean next() throws IOException {
if (ia == null) {
return false;
}
try {
long crcValue = ia.readLong("crcvalue");
System.out.println("crcvalue: "+crcValue);
byte[] bytes = readTxnBytes(ia);
// Since we preallocate, we define EOF to be an
if (bytes == null || bytes.length==0) {
throw new EOFException("Failed to read " + logFile);
}
// EOF or corrupted record
// validate CRC
Checksum crc = makeChecksumAlgorithm();
crc.update(bytes, 0, bytes.length);
if (crcValue != crc.getValue())
throw new IOException(CRC_ERROR);
if (bytes == null || bytes.length == 0)
return false;
hdr = new TxnHeader();
record = deserializeTxn(bytes, hdr);
} catch (EOFException e) {
System.out.println("EOF excepton " + e);
LOG.debug("EOF excepton " + e);
inputStream.close();
inputStream = null;
ia = null;
hdr = null;
// this means that the file has ended
// we should go to the next file
if (!goToNextLog()) {
return false;
}
// if we went to the next log file, we should call next() again
return next();
} catch (IOException e) {
inputStream.close();
throw e;
}
return true;
} |
05a64a82-d97c-4408-8383-b4fdf678e3c1 | 1 | @Test
public void testFindNodes() throws Exception
{
NodeList nodes = _xpath.findNodes("//p");
Assert.assertEquals(2, nodes.getLength());
for(int i=0; i<nodes.getLength(); i++)
{
Assert.assertEquals("p", nodes.item(i).getNodeName());
}
} |
37f11724-d6d2-4057-b9c3-66bbfc77f3c9 | 5 | private static void parseJstatMetrics(String wholeJstatText, Task task) {
String[] lines = wholeJstatText.split("\\n");
if(lines.length < 5)
return;
String dateStrSec;
if(!lines[0].trim().startsWith("NGCMN"))
return;
String[] gccapacity = lines[1].trim().split("\\s+");
if(gccapacity.length != 16)
return;
GcCapacity gcCap = new GcCapacity(gccapacity);
task.addGcCapacity(gcCap);
dateStrSec = lines[2].trim(); //(Date s) 1351667183
JstatMetrics jsm = new JstatMetrics(dateStrSec);
for (int i = 4; i < lines.length; i++) {
String parameters[] = lines[i].trim().split("\\s+");
if (parameters.length == 16) // 16 parameters totally
task.addJstatMetrics(jsm.generateArrayList(parameters));
}
} |
b6f896e0-76a3-4837-a683-32b77b0df889 | 6 | public boolean take(int slot,int amount,String title){
//如果能成功拿走就返回true 否则返回false
//这个位置的物品的名字 如果不包含title 那么也会返回false
ItemStack item = inv.getItem(slot);
if((item==null)||(item.getType()==Material.AIR))return false;
if(!item.getItemMeta().hasDisplayName()) return false;
if (!item.getItemMeta().getDisplayName().contains(title)) return false;
if(item.getAmount()>=amount){
if(item.getAmount()==amount) {
item.setType(Material.AIR);
}else{
item.setAmount(item.getAmount()-amount);
}
inv.setItem(slot,item);
return true;
}
return false;
} |
581dfb12-70c4-461c-a030-1c9f11885d2e | 9 | public void update() {
time++;
// if time % 60 == 0 / = 1 second
if (time % (random.nextInt(50) + 60) == 0) {
xa = (random.nextInt(3) - 1) * speed; // speed=5 => -1, 0, 1 ;
// speed=0.5 => -0.5, 0, 0.5
ya = (random.nextInt(3) - 1) * speed;
if (random.nextInt(4) == 0) {
xa = 0;
ya = 0;
}
}
if (walking)
animSprite.update();
else
animSprite.setFrame(0);
if (ya < 0) {
animSprite = up;
dir = Direction.UP;
} else if (ya > 0) {
animSprite = down;
dir = Direction.DOWN;
}
if (xa < 0) {
animSprite = left;
dir = Direction.LEFT;
} else if (xa > 0) {
animSprite = right;
dir = Direction.RIGHT;
}
if (xa != 0 || ya != 0) {
move(xa, ya);
walking = true;
} else {
walking = false;
}
} |
ba3aaa3a-8d2c-4863-a0c4-5645dd783ffe | 9 | static String getQuadrant(String v, String h) {
int hor = Integer.valueOf(h);
int vert = 1;
if (v.equals("a")){
vert = 1;
}
else if (v.equals("b"))
vert = 2;
if (v.equals("c"))
vert = 3;
if (v.equals("d"))
vert = 4;
if (v.equals("e"))
vert = 5;
if (v.equals("f"))
vert = 6;
if (v.equals("g"))
vert = 7;
if (v.equals("h"))
vert = 8;
if (v.equals("i"))
vert = 9;
return (vert - 1) * 64 + "_" + (hor - 1) * 64;
//int x = (vert - 1) * 64;
//int y = (hor - 1) * 64;
} |
da5eac4a-9afe-4b0f-a1f2-6b78ffca24f7 | 4 | public void itemGiver(Chest chest) {
chest.getInventory().clear();
Inventory inv = chest.getInventory();
List<String> items = this.pl.getConfig().getStringList("configurations." + this.pl.ChosenConfiguration + ".items");
for (String item : items){
ItemStack newItem = parseItem(item);
if (newItem != null) {
inv.addItem(new ItemStack[] { newItem });
}
if (this.ChosenItems == this.pl.getConfig().getInt("configurations." + this.pl.ChosenConfiguration + ".maximum-items")){
break;
}
}
if (this.ChosenItems <= this.pl.getConfig().getInt("configurations." + this.pl.ChosenConfiguration + ".minimum-items") - 1) {
this.ChosenItems = 0;
returnItems(chest);
return;
}
this.ChosenItems = 0;
chest.getInventory().setContents(inv.getContents());
this.pl.itemchests.put(chest.getLocation(), inv);
} |
12e73aca-1a4a-4d56-932c-a7c523859195 | 1 | public void createPlaylist(BEPlaylist aPlaylist) throws Exception {
try {
ds.createPlaylist(aPlaylist);
} catch (SQLException ex) {
throw new Exception("Could not create playlist" + aPlaylist.getName());
}
} |
df1956c7-8190-4d05-8719-a20025cf7606 | 2 | public KingedChecker(int team){
super(team);
if(team == 1) {
setImage(new GreenfootImage("Crowned-Mario.png"));
} else if(team == 2) {
setImage(new GreenfootImage("Crowned-Wario.png"));
}
} |
1e999d2a-30bb-4fa4-8885-69ef7a1ffb89 | 3 | public void selectNext() {
selectedIndex++;
if(selectedItem != null)
selectedItem.deselect();
if(selectedIndex >= listItems.size()) {
boolean selectionRolloverHandled = handleSelectionRollover(SelectionRolloverDirection.Bottom);
if(selectionRolloverHandled)
return;
else
selectedIndex = 0;
}
selectedItem = listItems.get(selectedIndex);
selectedItem.select();
} |
9881c9ca-b3af-4489-b0e1-d6e4b5b852f0 | 4 | public void randomize() {
try {
if (sql.getConnection() == null) {
sql.connect();
}
sql.getVals();
// mathGame.sql.close();
} catch (Exception e) {
System.out.println("Get vals from DB failed");
e.printStackTrace();
}
System.out.println("\n\n\n\n*******GAMETYPE=="+gameType+"**********\n\n\n");
if (gameType == GameType.FRACTIONS) {
ArrayList<Double> newValues = randomFractionValues();
card1.setStrValue(convertDecimaltoFraction(newValues.get(0)));
card2.setStrValue(convertDecimaltoFraction(newValues.get(1)));
card3.setStrValue(convertDecimaltoFraction(newValues.get(2)));
card4.setStrValue(convertDecimaltoFraction(newValues.get(3)));
card5.setStrValue(convertDecimaltoFraction(newValues.get(4)));
card6.setStrValue(convertDecimaltoFraction(newValues.get(5)));
values.set(0, card1.getStrValue());
values.set(1, card2.getStrValue());
values.set(2, card3.getStrValue());
values.set(3, card4.getStrValue());
values.set(4, card5.getStrValue());
values.set(5, card6.getStrValue());
ans.setStrValue(sql.getAnswer());
System.out.println(newValues.get(0));
card1.setValue(String.valueOf(newValues.get(0)));
card2.setValue(String.valueOf(newValues.get(1)));
card3.setValue(String.valueOf(newValues.get(2)));
card4.setValue(String.valueOf(newValues.get(3)));
card5.setValue(String.valueOf(newValues.get(4)));
card6.setValue(String.valueOf(newValues.get(5)));
ans.setValue(String.valueOf(NumberCard.parseNumFromText(ans.getStrValue())));
// card1.parseNumFromText(newValues.get(3))
}
else if(gameType == GameType.DECIMALS) {
ArrayList<Double> newValues = randomDecimalValues();
card1.setStrValue(String.valueOf(newValues.get(0)));
card2.setStrValue(String.valueOf(newValues.get(1)));
card3.setStrValue(String.valueOf(newValues.get(2)));
card4.setStrValue(String.valueOf(newValues.get(3)));
card5.setStrValue(String.valueOf(newValues.get(4)));
card6.setStrValue(String.valueOf(newValues.get(5)));
values.set(0, card1.getStrValue());
values.set(1, card2.getStrValue());
values.set(2, card3.getStrValue());
values.set(3, card4.getStrValue());
values.set(4, card5.getStrValue());
values.set(5, card6.getStrValue());
ans.setStrValue(sql.getAnswer());
System.out.println(newValues.get(0));
card1.setValue(String.valueOf(newValues.get(0)));
card2.setValue(String.valueOf(newValues.get(1)));
card3.setValue(String.valueOf(newValues.get(2)));
card4.setValue(String.valueOf(newValues.get(3)));
card5.setValue(String.valueOf(newValues.get(4)));
card6.setValue(String.valueOf(newValues.get(5)));
ans.setValue(String.valueOf(NumberCard.parseNumFromText(ans.getStrValue())));
}
else{
ArrayList<Integer> newValues = randomIntegerValues();
card1.setStrValue(String.valueOf(newValues.get(0)));
card2.setStrValue(String.valueOf(newValues.get(1)));
card3.setStrValue(String.valueOf(newValues.get(2)));
card4.setStrValue(String.valueOf(newValues.get(3)));
card5.setStrValue(String.valueOf(newValues.get(4)));
card6.setStrValue(String.valueOf(newValues.get(5)));
values.set(0, card1.getStrValue());
values.set(1, card2.getStrValue());
values.set(2, card3.getStrValue());
values.set(3, card4.getStrValue());
values.set(4, card5.getStrValue());
values.set(5, card6.getStrValue());
ans.setStrValue(sql.getAnswer());
System.out.println(newValues.get(0));
card1.setValue(String.valueOf(newValues.get(0)));
card2.setValue(String.valueOf(newValues.get(1)));
card3.setValue(String.valueOf(newValues.get(2)));
card4.setValue(String.valueOf(newValues.get(3)));
card5.setValue(String.valueOf(newValues.get(4)));
card6.setValue(String.valueOf(newValues.get(5)));
ans.setValue(String.valueOf(NumberCard.parseNumFromText(ans.getStrValue())));
}
// Tag each card with "home" (cardPanel) being original location
card1.setHome("home");
card2.setHome("home");
card3.setHome("home");
card4.setHome("home");
card5.setHome("home");
card6.setHome("home");
ans.setHome("home");
} |
efb98bba-c766-4099-9d0e-2c9f025859c1 | 6 | public void render(Graphics g){
g.setColor(Color.BLACK);
g.setFont(JudokaComponent.bigFont);
JudokaComponent.drawTextBox(75, 50, 500, 35, g);
JudokaComponent.drawTextBox(75, 150, 500, 35, g);
g.drawString("Player1 Character Name", 80, 40);
g.drawString("Player2 Character Name", 80, 140);
g.setColor(new Color(210, 210, 210));
g.drawString("Player1 Character Name", 82, 42);
g.drawString("Player2 Character Name", 82, 142);
g.setColor(Color.BLACK);
g.drawString(player1Name, 80, 80);
g.drawString(player2Name, 80, 180);
if(selectedItem == 0){
if(timer % 60 < 30) g.fillRect(80 + player1Name.length() * 21, 54, 2, 30);
}else if(selectedItem == 1){
if(timer % 60 < 30) g.fillRect(80 + player2Name.length() * 21, 154, 2, 30);
}else if(selectedItem == 2){
g.setFont(JudokaComponent.hugeFont);
g.drawString("> Start <", 175, 280);
}
if(selectedItem != 2){
g.setFont(JudokaComponent.hugeFont);
g.drawString("Start", 241, 280);
}
} |
45422110-09b7-4a52-abad-39e48d6d74f5 | 0 | default void isNull(String str) {
System.out.println("Interface Null Check");
} |
4352c645-7fff-447f-8383-cb3fafed31f1 | 6 | public boolean gameCouldFinish() {
boolean allNullWord = true;
boolean weAreAlone = true;
for (Player p : playersList) {
if (p.isActive() && !p.isLastResponseWrong) allNullWord = false;
if (p.isActive() && p != localPlayer) weAreAlone = false;
}
return allNullWord || weAreAlone;
} |
7a6b7ead-e224-4df2-b3e7-fcf185a63bbd | 7 | public String longestPalindrome(String s) {
boolean[][] table = new boolean[s.length()][s.length()];
int max = 1;
int index = 0;
for (int i = 0; i < s.length(); i++) {
table[i][i] = true;
}
for (int i = 0; i < s.length() - 1; i++) {
if (s.charAt(i) == s.charAt(i + 1)) {
table[i][i + 1] = true;
max = 2;
index = i;
}
}
for (int len = 3; len <= s.length(); len++) {
for (int i = 0; i < s.length() - len + 1; i++) {
int j = i + len - 1;
if (s.charAt(i) == s.charAt(j) && table[i + 1][j - 1]) {
table[i][j] = true;
max = len;
index = i;
}
}
}
return s.substring(index, index + max);
} |
94eb931c-85e3-40f4-9efb-91536da23a52 | 1 | public String getString(int index) throws JSONException {
Object object = this.get(index);
if (object instanceof String) {
return (String) object;
}
throw new JSONException("JSONArray[" + index + "] not a string.");
} |
f96b9958-f9ea-4a22-8ede-44c65c8c9e1f | 5 | public WarriorsJourneyServer()
{
log.log(Level.FINE,"=== Warriors Journey Server Loading... ===");
config = new Config();
clientThreads = new WarriorsJourneyClient[Config.MAX_CONNECTIONS];
log.log(Level.FINE,"=== Loading Handlers ===");
mysqlData = new MysqlHandler();
log.log(Level.FINE,"=== Handlers ONLINE ===");
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
log.log(Level.FINE,"=== Warriors Journey Server Loading DONE ===");
log.log(Level.FINE,"=== Starting Listening on Port:"+Config.LISTEN_PORT+" ===");
try
{
sSocket = new ServerSocket(Config.LISTEN_PORT);
log.log(Level.FINER,"Listening start");
while(true)
{
for(int i = 0; i < Config.MAX_CONNECTIONS;i++)
{
if(clientThreads[i] == null)
{
Socket socket = sSocket.accept();
clientThreads[i] = new WarriorsJourneyClient(socket, this,i);
clientThreads[i].start();
log.log(Level.FINE, "New Connection! At thread: "+i);
break;
}
if(i == Config.MAX_CONNECTIONS)
log.log(Level.SEVERE,"Server FULL check max connection number!");
}
}
}
catch (IOException e)
{
log.log(Level.SEVERE, "Unable to start socket Listening please check the problem!",e.toString());
e.printStackTrace();
}
} |
7d294a53-5937-4e9f-be68-d31074e4cde2 | 3 | static Throwable getThrowableCandidate(Object[] argArray) {
if (argArray == null || argArray.length == 0) {
return null;
}
final Object lastEntry = argArray[argArray.length - 1];
if (lastEntry instanceof Throwable) {
return (Throwable) lastEntry;
}
return null;
} |
50dab67b-7856-4a4e-8183-7aaf4a74e298 | 6 | protected FSDirectory(File path, LockFactory lockFactory) throws IOException {
path = getCanonicalPath(path);
// new ctors use always NativeFSLockFactory as default:
if (lockFactory == null) {
lockFactory = new NativeFSLockFactory();
}
directory = path;
if (directory.exists() && !directory.isDirectory())
throw new NoSuchDirectoryException("file '" + directory + "' exists but is not a directory");
setLockFactory(lockFactory);
// for filesystem based LockFactory, delete the lockPrefix, if the locks are placed
// in index dir. If no index dir is given, set ourselves
if (lockFactory instanceof FSLockFactory) {
final FSLockFactory lf = (FSLockFactory) lockFactory;
final File dir = lf.getLockDir();
// if the lock factory has no lockDir set, use the this directory as lockDir
if (dir == null) {
lf.setLockDir(this.directory);
lf.setLockPrefix(null);
} else if (dir.getCanonicalPath().equals(this.directory.getCanonicalPath())) {
lf.setLockPrefix(null);
}
}
} |
d10aadaa-34b4-4d38-bc8b-08013dc20df7 | 4 | public static java.awt.Color getColorForPlayer(Player p) {
switch ( p ) {
case RED : return java.awt.Color.RED;
case BLUE : return java.awt.Color.CYAN;
case YELLOW : return java.awt.Color.YELLOW;
case GREEN : return java.awt.Color.GREEN;
}
return java.awt.Color.WHITE;
} |
374044e6-7ec0-46f4-b7ba-2eded389d554 | 2 | public int price(PointT finish) {
if (this.x == finish.x || this.y == finish.y) {
return 10;
} else {
return 14;
}
} |
218c3717-1f6d-43fd-863f-5264c8a250a0 | 3 | private void setLoggingLevel() {
final String name = Main.configurationFile.getConfig().getString("logLevel", "INFO");
Level level = MessageLevel.parse(name);
if (level == null) level = Level.INFO;
// Only set the parent handler lower if necessary, otherwise leave it alone for other configurations that have set it
for (final Handler h : this.getLogger().getParent().getHandlers())
if (h.getLevel().intValue() > level.intValue()) h.setLevel(level);
this.getLogger().setLevel(level);
this.getLogger().log(Level.CONFIG, "Logging level set to: " + this.getLogger().getLevel());
} |
0403b5c9-e6ab-48b6-9f13-4ec42116bf1a | 5 | private void searchMCVersions()
{
File file = new File(mineord, "versions");
if (file.exists())
{
File[] li = file.listFiles();
for (int i=0; i<li.length; i++)
{
File jarfile = new File(li[i], li[i].getName()+".jar");
File jsonfile = new File(li[i], li[i].getName()+".json");
if(jarfile.exists()&&jsonfile.exists()&&(!li[i].getName().equals("Modinstaller")))
{
offlineList.add(li[i].getName());
}
}
}
} |
0ade70a3-1707-444d-8afa-ae22fa1c76d0 | 4 | @Override
public boolean equals(Object o) {
if (!(o instanceof MoveAction)) { return false; }
MoveAction other = (MoveAction)o;
return (other.model == this.model) &&
(other.start.equals(start)) &&
(other.actor.equals(actor)) &&
(other.end.equals(end));
} |
8426d8df-e75d-4038-92b4-add887afd5bd | 1 | public static OptionsDialog getInstance()
{
if (instance==null)
{
instance=new OptionsDialog();
}
return instance;
} |
40ee28c3-5c38-4059-8826-cf13e11ab0d9 | 7 | private BufferedImage HorizontalFiltering(BufferedImage bufImage, int iOutW) {
int dwInW = bufImage.getWidth();
int dwInH = bufImage.getHeight();
int value = 0;
BufferedImage pbOut = new BufferedImage(iOutW, dwInH,
BufferedImage.TYPE_INT_RGB);
for (int x = 0; x < iOutW; x++) {
int startX;
int start;
int X = (int) (((double) x) * ((double) dwInW) / ((double) iOutW) + 0.5);
int y = 0;
startX = X - nHalfDots;
if (startX < 0) {
startX = 0;
start = nHalfDots - X;
} else {
start = 0;
}
int stop;
int stopX = X + nHalfDots;
if (stopX > (dwInW - 1)) {
stopX = dwInW - 1;
stop = nHalfDots + (dwInW - 1 - X);
} else {
stop = nHalfDots * 2;
}
if (start > 0 || stop < nDots - 1) {
CalTempContrib(start, stop);
for (y = 0; y < dwInH; y++) {
value = HorizontalFilter(bufImage, startX, stopX, start,
stop, y, tmpContrib);
pbOut.setRGB(x, y, value);
}
} else {
for (y = 0; y < dwInH; y++) {
value = HorizontalFilter(bufImage, startX, stopX, start,
stop, y, normContrib);
pbOut.setRGB(x, y, value);
}
}
}
return pbOut;
} // end of HorizontalFiltering() |
bc44f525-60d0-4c3b-965a-0db47893c7e7 | 5 | private static boolean isDelimiter(char c){
return c == ' ' || c == '\t' ||
c == '\n' || c == '\r' ||
c == '{' || c == '}';
} |
a10c3517-bc5c-4ec4-a67a-e4d7072c02c9 | 5 | public static void main(String[] args) {
int a[] = new int[101];
int i = 0;
int j = 0;
for (i = 1; i < 101; i++) {
a[i] = 1;
}
for (i = 2; i < 101; i++) {
if (a[i] != 0) {
for (j = i + i; j < 101; j++) {
System.out.println(i+"---"+j);
if (j % i == 0) {
a[j] = 0;
j = j + i;
}
}
}
}
// for (i = 2; i < 101; i++) {
// if (a[i] != 0) {
// //System.out.println(i);
// }
// }
} |
68b582b1-5a1d-4743-a09b-ffe7f82cdfb7 | 6 | public void merge(int A[], int m, int B[], int n) {
int a = n;
int b = 0;
int c = 0;
for (int i = m; i > 0; i--) {
A[i + n - 1] = A[i - 1];
}
while (a < m + n && b < n) {
if (A[a] < B[b]) {
A[c] = A[a];
a++;
} else {
A[c] = B[b];
b++;
}
c++;
}
while (c < m + n) {
if (b < n) {
A[c] = B[b];
b++;
} else {
A[c] = A[a];
a++;
}
c++;
}
} |
7f86fdac-f388-4cb6-b926-21b1ad5e7802 | 0 | public static void intro() {
GUI.log("Welcome to Corlanthia. To start, simply type a command into the input box below. For a list of available " +
"commands, type \"help\".\n" +
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" +
"\n\n" +
"You wake up in a daze, there is a lump on your head and you don't know how it got there. " +
"The last thing you can remember was drinking a lot with your mates and some unexpected " +
"visitors arrived.\n\n" +
"The room you are in seems like it's from the medeval era and all you can smell is decaying rats.");
start();
} |
b2c5a267-ed30-422f-a8d0-9919e5fdf020 | 0 | public double getDiag(){
return diag=Math.sqrt(this.getHig()*this.getHig())+Math.sqrt(rad*rad);
} |
89a5e4bd-3125-4bc4-a29e-a65aeb536c71 | 4 | public Path getRevisionInfo(long timestamp)
{
// Get the revision in question
DbConnection db = DbConnection.getInstance();
RevisionInfo revision = db.getSpecificRevision(file, timestamp);
Path pathToTempFile = null;
PrintWriter output = null;
// Figure out the extension. However, we only add the period (making it a "real" extension)
// if there actually was an extension (since splitting on periods will return a size 1 array
// if there are no periods)
String[] fileNameSplit = file.getFileName().toString().split("\\.");
String extension = fileNameSplit[fileNameSplit.length - 1];
if(fileNameSplit.length > 1)
{
extension = "." + extension;
}
try
{
// Create a temporary file for the revision
pathToTempFile = Files.createTempFile("revision", "." + extension);
// Write the diff or binary content to that temp file
if(revision.diff != null)
{
Files.write(pathToTempFile, revision.diff.getBytes());
}
else
{
Files.write(pathToTempFile, revision.binary);
}
logger.info("Created temporary file at " + pathToTempFile.toString() + " for revision "
+ file.toString() + " (" + timestamp + ")");
}
catch(IOException e)
{
Errors.nonfatalError("Could not create temporary file for revision.", e);
}
finally
{
if(output != null)
{
output.close();
}
}
return pathToTempFile;
} |
82f0a4d8-92c0-4552-8af5-f2a905ea0543 | 7 | public void setForecast(Iterator<Element>tempit,WeatherInfo tempweather){
Element tempelementRoot,tempElement;
/**tempit2: 每一个weather块<br>tempit3:day块和night块*/
Iterator<Element>tempit2,tempit3;
String temp;
int i=0,j;
while(tempit.hasNext()){
tempelementRoot=(Element)tempit.next();
tempit2=tempelementRoot.elementIterator();
j=0;
while(tempit2.hasNext()){
tempElement=tempit2.next();
temp=tempElement.getText();
switch(j){
case 0:tempweather.setForecastDate(i, temp);break;
case 1:tempweather.setForecastHign(i, Integer.parseInt(temp.substring(temp.indexOf(' ')+1, temp.indexOf("℃"))));break;
case 2:tempweather.setForecastLow(i, Integer.parseInt(temp.substring(temp.indexOf(' ')+1, temp.indexOf("℃"))));break;
case 3:setForecastDayAndNight(i,tempElement.elementIterator(), tempweather, 0);break;
case 4:setForecastDayAndNight(i,tempElement.elementIterator(), tempweather, 1);break;
}
j++;
}
i++;
}
} |
434ccc56-6003-4dfd-a8a0-ab80c7c69a5e | 3 | public ResultMap singleSelect(final String sql){
ResultMap result = new ResultMap();
Statement stmt;
try {
stmt = this.connetion.createStatement();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
System.out.println(rs.getString(i));
}
}
stmt.close();
} catch (SQLException ex) {
log.error("SQLException: " + ex.getMessage());
}
return result;
} |
2ec56f15-2dbe-4114-be93-829a6ea917e1 | 1 | public static void main(String[] args) {
try {
JConecta dialog = new JConecta();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
} |
ad6669c3-6461-41fa-8bee-307010b48327 | 3 | private void filter () {
displayedElements.clear();
if (filter != null)
for (int i = 0; i < source.getSize(); i++)
if (filter.accept (source.getElementAt (i)))
displayedElements.add (i);
fireContentsChanged (this, 0, getSize() - 1);
} |
47a22d8e-103f-431c-95ed-ded5be9cb10c | 9 | public static List<HueBridge> searchUPnP(int timeout, BridgeDiscoveryCallback callback) throws IOException {
// Send out SSDP discovery broadcast
String ssdpBroadcast = "M-SEARCH * HTTP/1.1\nHOST: 239.255.255.250:1900\nMAN: ssdp:discover\nMX: 8\nST:SsdpSearch:all";
DatagramSocket upnpSock = new DatagramSocket();
upnpSock.setSoTimeout(100);
upnpSock.send(new DatagramPacket(ssdpBroadcast.getBytes(), ssdpBroadcast.length(), new InetSocketAddress("239.255.255.250", 1900)));
// Start waiting
HashSet<String> ips = new HashSet<String>();
ArrayList<HueBridge> bridges = new ArrayList<HueBridge>();
long start = System.currentTimeMillis();
long nextBroadcast = start + 5000;
while (System.currentTimeMillis() - start < timeout) {
// Send a new discovery broadcast every 5 seconds just in case
if (System.currentTimeMillis() > nextBroadcast) {
upnpSock.send(new DatagramPacket(ssdpBroadcast.getBytes(), ssdpBroadcast.length(), new InetSocketAddress("239.255.255.250", 1900)));
nextBroadcast = System.currentTimeMillis() + 5000;
}
byte[] responseBuffer = new byte[1024];
DatagramPacket responsePacket = new DatagramPacket(responseBuffer, responseBuffer.length);
try {
upnpSock.receive(responsePacket);
} catch (SocketTimeoutException e) {
if (System.currentTimeMillis() - start > timeout) {
break;
} else {
continue;
}
}
final String ip = responsePacket.getAddress().getHostAddress();
final String response = new String(responsePacket.getData());
if (!ips.contains(ip)) {
Matcher m = Pattern.compile("LOCATION: (.*)", Pattern.CASE_INSENSITIVE).matcher(response);
if (m.find()) {
final String description = new HttpClient().get(m.group(1)).getBody();
// Parsing with RegEx allowed here because the output format is fairly strict
final String modelName = Util.quickMatch("<modelName>(.*?)</modelName>", description);
// Check from description if we're dealing with a hue bridge or some other device
if (modelName.toLowerCase().contains("philips hue bridge")) {
try {
final HueBridge bridgeToBe = new HueBridge(ip);
bridgeToBe.getConfig();
bridges.add(bridgeToBe);
if (callback != null) callback.onBridgeDiscovered(bridgeToBe);
} catch (ApiException e) {
// Do nothing, this basically serves as an extra check to see if it's really a hue bridge
}
}
}
// Ignore subsequent packets
ips.add(ip);
}
}
return bridges;
} |
245d249b-1298-490f-b432-65f7628ea1ed | 6 | public void procBtnRAZ() {
int compsSize = m_enregistreurDeComp.getCompetences().size();
if (!optEmploi.isSelected()
|| cmbReg.getSelectedIndex() != 0
|| jckbprox.isSelected()
|| !"0".equals(txtSalesp.getText())
|| cmbComp.getSelectedIndex() != 0
|| compsSize > 0) {
activerRAZ(true);
} else {
activerRAZ(false);
}
} |
2e4db602-0153-4c60-b5bc-8d69e7b8930b | 9 | private double getPreFlopDiscardOdds(int holeCardA, int holeCardB, int discardCard) throws IOException {
long wins = 0;
long gameCount = 0;
int[] cardsToRemove = {holeCardA, holeCardB, discardCard};
Integer[] newCards = getNewCards(cardsToRemove, ints);
int[] newCardsArray = new int[49];
for (int z = 0; z < 49; z++) {
newCardsArray[z] = newCards[z];
}
for (int a = 0; a < 49; a++) {
int enemyCardA = newCards[a];
for (int b = a+1; b < 49; b++) {
int enemyCardB = newCards[b];
int[] newCardsToRemove = {enemyCardA, enemyCardB};
Integer[] finalNewCards = getNewCards(newCardsToRemove, newCardsArray);
for (int c = 0; c < 47; c++) {
int boardCardA = finalNewCards[c];
for (int d = c+1; d < 47; d++) {
int boardCardB = finalNewCards[d];
for (int e = d+1; e < 47; e++) {
int boardCardC = finalNewCards[e];
for (int f = e+1; f < 47; f++) {
int boardCardD = finalNewCards[f];
for (int g = f+1; g < 47; g++) {
int boardCardE = finalNewCards[g];
int[] myHand = {holeCardA, holeCardB, boardCardA, boardCardB, boardCardC, boardCardD, boardCardE};
int[] enemyHand = {enemyCardA, enemyCardB, boardCardA, boardCardB, boardCardC, boardCardD, boardCardE};
int myRank = rankEngine.lookupHand7(myHand, 0);
int enemyRank = rankEngine.lookupHand7(enemyHand, 0);
if (myRank >= enemyRank) {
wins++;
}
gameCount++;
}
}
}
}
}
}
}
return ((wins*1.0)/gameCount);
} |
c9cb7440-c4ad-4faa-b2a8-5060f2ad2f31 | 8 | private boolean r_perfective_gerund() {
int among_var;
int v_1;
// (, line 71
// [, line 72
ket = cursor;
// substring, line 72
among_var = find_among_b(a_0, 9);
if (among_var == 0)
{
return false;
}
// ], line 72
bra = cursor;
switch(among_var) {
case 0:
return false;
case 1:
// (, line 76
// or, line 76
lab0: do {
v_1 = limit - cursor;
lab1: do {
// literal, line 76
if (!(eq_s_b(1, "\u0430")))
{
break lab1;
}
break lab0;
} while (false);
cursor = limit - v_1;
// literal, line 76
if (!(eq_s_b(1, "\u044F")))
{
return false;
}
} while (false);
// delete, line 76
slice_del();
break;
case 2:
// (, line 83
// delete, line 83
slice_del();
break;
}
return true;
} |
768c4023-392e-410f-9471-9303f8f721f8 | 4 | @Override
public Object getValueAt(int rowIndex, int columnIndex) {
assert rowIndex >= 0 && rowIndex < this.files.length;
IFile file = this.files[rowIndex];
switch (columnIndex) {
case 0:
return file.getName();
case 1:
return file.size();
case 2:
return new Date(file.lastModified());
default:
return file;
}
} |
ae4ab7b1-2e18-43b3-a7ac-1998fef1b777 | 3 | public void kasvataKulmaa(){
if (liikkuuko){
kulma = kulma + KULMAN_KASVATUS_VAKIO;
//pidä kulma nollan ja kaksipiin välillä
if (kulma > 2*Math.PI){
kulma -= 2*Math.PI;
} else if (kulma < 0) {
kulma += 2*Math.PI;
}
paivitaMinMax();
}
} |
4fd01f7f-1b25-4092-88b4-9dc4cb42c53f | 9 | boolean test (Instantiation inst)
{
if (prefix == '!')
{
if (model.getProcedural().whyNotTrace)
model.output (toStringFirstLine (null));
Vector<String> tokens = new Vector<String>();
for (int i=0 ; i<specials.size() ; i++)
{
String special = specials.elementAt(i);
if (Symbol.get(special).isVariable()) special = inst.get(Symbol.get(special)).getString();
tokens.add (special);
}
try
{
return Utilities.evalComputeCondition(tokens.iterator());
}
catch (Exception e)
{
return model.getTask().evalCondition (tokens.iterator());
}
}
else
{
Chunk bufferChunk = model.getBuffers().get (buffer);
if (bufferChunk!=null && prefix=='=')
inst.set (Symbol.get("="+buffer), bufferChunk.getName());
if (model.getProcedural().whyNotTrace)
model.output (toStringFirstLine (inst));
if (bufferChunk == null) return false;
return testBufferChunk (bufferChunk, inst);
}
} |
2fe2abf5-fbfd-4760-93ff-ed380061fb2e | 8 | public void renderMob(int xp, int yp, int dir, Sprite sprite){
for(int y = 0; y < sprite.size; y++){
int ya = y + yp;
int ys = y;
for(int x = 0; x < sprite.size; x++){
int xa = x + xp;
int xs = x;
if(xa < 0 || xa >= width || ya < 0 || ya >= height) continue;
int col = sprite.pixels[xs + ys * sprite.size];
if(col != 0xffff00ff && col != 0xff7f007f) pixels[xa + ya * width] = col;
}
}
} |
925daea6-bdd8-45b5-b065-733fb61efb09 | 3 | private boolean isCommonName(String p){
short i = 0;
for(Player s : this){
if(s.getName().startsWith(p)){
i++;
}
}
if(i > 1){
return true;
}
return false;
} |
ced79d27-5d89-46ae-9b0b-25c4e1de6501 | 9 | public void endElement( String uri, String localName, String qName ) {
// recognized text is always content of an element
// when the element closes, no more text should be expected
isStackReadyForText = false;
// pop stack and add to 'parent' element, which is next on the stack
// important to pop stack first, then peek at top element!
Object tmp = stack.pop();
if( localName.equals( "TSeq_gi" ) ) {
gi = tmp.toString();
}else if(localName.equals("TSeq_taxid")){
taxid = tmp.toString();
}else if(localName.equals("TSeq_orgname")){
orgname = tmp.toString();
}else if(localName.equals("TSeq_defline")){
defline = tmp.toString();
}else if(localName.equals("TSeq_length")){
length = tmp.toString();
if(Integer.valueOf(length) > lengthlim)
dontread = true;
else
dontread = false;
//System.out.println(length);
}else if(localName.equals("TSeq_sequence")&& dontread == false){
if(dontread == false){
sequence = tmp.toString();
printall();
}
}
else{
stack.push( tmp );
}
} |
1eeaa63d-e916-4d1e-a651-e70937694bf4 | 8 | protected boolean testMatrixMajor(Matrix A, Matrix B) {
boolean ret = false;
Matrix tmpC;
int i = -1;
int j = -1;
int r = A.getRowDimension();
int c = A.getColumnDimension();
if((r == B.getRowDimension())&&(c == B.getColumnDimension())) {
tmpC = A.minus(B);
ret = false;
for(i = 0; (i<r)&&(!ret); ++i) {
for(j = 0; (j<c)&&(!ret);++j) {
if(tmpC.get(i, j)>0) {
ret = ret || true;
}
}
}
}
return ret;
} |
2c4b91de-0542-41d8-b58b-e3bbd73a2dbc | 0 | public DoublyLinkedNode getSucc() {
return succ;
} |
16525c65-75c9-464b-9b0e-c1818cf5d662 | 2 | @Override
public int compareTo(InterpenetrationPoint o) {
return signedDistance == o.signedDistance ? 0
: signedDistance < o.signedDistance ? -1 : 1;
} |
Subsets and Splits