method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
62f7c9a1-0fb8-4db1-8c8b-9a3bf1a4d674 | 7 | public final void operateImpl() throws IOException {
final Pattern splitter = Pattern.compile(" ");
String currentLine;
while ((currentLine = readInputLine()) != null) {
final String[] numbers = splitter.split(currentLine);
if (numbers.length != 2) {
throw new IllegalArgumentException("Invalid number of input parameters : " + numbers.length);
}
final long start = (long) Math.ceil(Math.sqrt(Double.parseDouble(numbers[0])));
final long end = (long) Math.floor(Math.sqrt(Double.parseDouble(numbers[1])));
long count = 0;
for (long i = start; i <= end; i++) {
if (hasHighDigits(i) || !isAPalindrome(i)) continue;
if (isAPalindrome(i * i)) count++;
}
if (testMode) {
results.add(count);
}
emitOutputLine(Long.toString(count));
}
} |
a52bba57-30bb-4330-a63c-b681350c6f61 | 9 | private LevelObject getObject(Color colour) {
switch (colour.getBlue()) {
case 0:
return null;
case 1:
return new Block(this, blockTileSheet.getImage(colour.getRed(), colour.getGreen()), getBlockBounds(colour));
case 2:
return descent.getPlayer();
case 3:
return new BreakableBlock(this, breakableBlockTileSheet.getImage(colour.getRed(), colour.getGreen()), getBlockBounds(colour));
case 4:
return new LaserPickup(descent, this, pickupImage);
case 5:
return new LifePickup(descent, this, pickupImage);
case 6:
return new SceneryObject(this, scenerySpriteSheet.getSprite(0, 0, 5));
case 7:
return new SceneryObject(this, scenerySpriteSheet.getSprite(0, 1, 5));
case 8:
return new ArtefactPickup(descent, this, pickupImage);
default:
return null;
}
} |
d4a0124c-ef87-46a1-b377-de444274352c | 5 | public void addHighscore(String player, String levelUuid, Integer score) {
Properties properties = new Properties();
try {
// load the score file from the profile folder
properties.load(new FileInputStream(basepath + DEL + player + DEL
+ highscore + DEL + filename));
// check if there is already a score and if the new score is lower than the existing
String existingProp = properties.getProperty(levelUuid);
if (existingProp != null && existingProp.isEmpty() == false) {
Integer oldScore = new Integer(existingProp);
// we have already a score that better or equal to the new one: quit!
if (oldScore <= score) {
return;
}
}
// add the new score
properties.setProperty(levelUuid, score.toString());
// save the properties file
properties.store(new FileOutputStream(basepath + DEL + player + DEL
+ highscore + DEL + filename), null);
LOG.debug("Score of " + score + " added for player " + player
+ " and level " + levelUuid);
} catch (FileNotFoundException e) {
LOG.error(e);
} catch (IOException e) {
LOG.error(e);
}
} |
8b998f45-85ea-4cab-af24-aba899a2cd6d | 0 | public void setAgents (Vector v) {
agents = v;
} |
ff2dc88e-7749-4946-83e6-f1fc75294b48 | 4 | private void paintContainer(Graphics g) {
int xStart = getWidth() / 3;
int yStart = getHeight() / 3;
// create the images
Image slot = containerSlot.getScaledInstance(SLOT_SIZE, SLOT_SIZE, 0);
Image selectedSlot = selectedContainerSlot.getScaledInstance(SLOT_SIZE,
SLOT_SIZE, 0);
// initial slot
int row = 0;
int column = 0;
int xPos = xStart;
int yPos = yStart;
paintExitButton(xPos, yPos, g);
yStart = yStart + SLOT_SIZE / 2;
// draw each slot and its item
for (int i = 0; i != maxItems; i++) {
// get the position of the slot
xPos = xStart + column * SLOT_SIZE;
yPos = yStart + row * SLOT_SIZE;
// if this slot is selected
if (i + 1 == selectedItem) {
// draw with the selected image
g.drawImage(selectedSlot, xPos, yPos, null, null);
} else {
// otherwise draw with normal image
g.drawImage(slot, xPos, yPos, null, null);
}
// draw the item if there is one
if (items.get(i) != null) {
Image item = items.get(i).imgs[0];
drawItem(item, xPos, yPos, g);
}
// now increment the row and column
if (column + 1 < MAX_COLUMN) {
column++;
} else {
column = 0;
row++;
}
}
} |
c51ac198-df3d-41bf-9509-edc81ee69785 | 4 | public void MergeTable(Table table)
{
int newAttributes = table.ColSize();
AttributeNames.addAll(table.GetAllAttributeNames());
this.nColumns += newAttributes;
int i=0;
for (;i<table.RowSize();i++)
{
if (i<=this.nRows-1)
{
this.Entries.get(i).Data.addAll(table.GetRow(i).Data);
} else
{
String[] data = new String[nColumns];
Arrays.fill(data, "");
for (int j=nColumns-newAttributes;j<nColumns;j++)
data[j] = table.GetCellContent(newAttributes-(nColumns-j), i);
this.Insert(data);
}
}
// continue fill empty on the other (right) side
for (;i<this.RowSize();i++)
{
String[] data = new String[newAttributes];
Arrays.fill(data, "");
Entries.get(i).Data.addAll(Arrays.asList(data));
}
} |
aa43f33d-c142-45bb-9654-0d603405f113 | 2 | public LocalVariablesSorter(final int access, final String desc,
final MethodVisitor mv) {
super(mv);
Type[] args = Type.getArgumentTypes(desc);
nextLocal = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;
for (int i = 0; i < args.length; i++) {
nextLocal += args[i].getSize();
}
firstLocal = nextLocal;
} |
0321ad12-9833-46a0-b9d7-075f269fb0b7 | 6 | public static String find(BinaryTree<String>.Node<String> root, String character, String pattern) {
if(root.data.compareTo(character)==0) {
return pattern;
}
if(root.data.contains(character)){
if(root.left!=null && root.left.data.contains(character)){
return find(root.left, character,pattern+"0");
}
if(root.right!=null && root.right.data.contains(character)){
return find(root.right, character,pattern+"1");
}
}
return null;
} |
95d197a7-298b-43a2-813c-73c53bc96f45 | 1 | public Placeable getPlaceableById(String id) {
if (placeables.containsKey(id)) {
Placeable placeable = placeables.get(id);
return placeable;
} else {
return null;
}
} |
80d7f1b5-c084-478e-9e67-81b6d1cb511d | 8 | public void send_packet(RdpPacket_Localised data) throws RdesktopException, IOException, CryptoException
{
if(Common.secure == null) return;
int length = data.size();
int data_offset = 0;
int packets_sent = 0;
int num_packets = (length/VChannels.CHANNEL_CHUNK_LENGTH);
num_packets += length - (VChannels.CHANNEL_CHUNK_LENGTH)*num_packets;
while(data_offset < length){
int thisLength = Math.min(VChannels.CHANNEL_CHUNK_LENGTH, length - data_offset);
RdpPacket_Localised s = Common.secure.init(Constants.encryption ? Secure.SEC_ENCRYPT : 0, 8 + thisLength);
s.setLittleEndian32(length);
int flags = ((data_offset == 0) ? VChannels.CHANNEL_FLAG_FIRST : 0);
if(data_offset + thisLength >= length) flags |= VChannels.CHANNEL_FLAG_LAST;
if ((this.flags() & VChannels.CHANNEL_OPTION_SHOW_PROTOCOL) != 0) flags |= VChannels.CHANNEL_FLAG_SHOW_PROTOCOL;
s.setLittleEndian32(flags);
s.copyFromPacket(data,data_offset,s.getPosition(),thisLength);
s.incrementPosition(thisLength);
s.markEnd();
data_offset += thisLength;
if(Common.secure != null) Common.secure.send_to_channel(s, Constants.encryption ? Secure.SEC_ENCRYPT : 0, this.mcs_id());
packets_sent++;
}
} |
4b6f716f-78b8-44b0-837c-ac60fc573b36 | 9 | public boolean editVariable(String[] args, CommandSender sender) {
String groupName = plugin.groups.searchInGroups(args[1]);
List<String> variableResult = new ArrayList<String>();
int counter = 3;
String resultString = "";
String variable = args[2].toLowerCase();
if (groupName == null) {
sender.sendMessage(ChatColor.RED + "Group '" + args[1] + "' is not defined!");
return false;
}
if (!plugin.CommandExecutor.hasPermission("staffinfo.groups.edit." + groupName, sender)) return true;
if (plugin.getConfig().get("Groups." + groupName + "." + variable) == null) {
sender.sendMessage(ChatColor.RED + "'" + variable + "' is not a valid variable!");
return false;
}
if (variable.equalsIgnoreCase("members")) {
sender.sendMessage(ChatColor.RED + "The member variable cannot be changed this way!");
sender.sendMessage(ChatColor.BLUE + "Use /staff add <playername> <groupname> to add someone to members!");
return false;
}
for (int i=0;i<(args.length - 3);i++) {
variableResult.add(args[counter]);
++counter;
}
for (int i=0;i<variableResult.size();i++) {
if (i == 0) {
resultString = resultString.concat(variableResult.get(i));
}
else {
resultString = resultString.concat(" " + variableResult.get(i));
}
}
if (variable.equalsIgnoreCase("visible")) {
if (resultString.equalsIgnoreCase("true")) {
plugin.getConfig().set("Groups." + groupName + "." + variable, true);
resultString = "true";
}
else {
plugin.getConfig().set("Groups." + groupName + "." + variable, false);
resultString = "false";
}
}
else {
plugin.getConfig().set("Groups." + groupName + "." + variable, resultString);
}
plugin.saveConfig();
plugin.reloadConfig();
sender.sendMessage(ChatColor.GREEN + variable + " of " + groupName + " has been set to: '" + resultString + "'.");
return true;
} |
b141ee55-a0fe-48e4-b2ca-8c9255847694 | 1 | public String toString() {
Class<?> cl = getClass();
StringBuilder sb = new StringBuilder();
sb.append(getFullName(cl));
sb.append("\n---\n");
sb.append(mkString(getProperties(cl), "\n"));
return sb.toString();
} |
62e4b98b-4f7b-4363-8193-bae6df3429bd | 5 | private static void setTreatment(String s, String obj) {
String [] split = null;
if(s.contains("*")){
split = s.split("\\*");
}else if(s.contains("&")){
split = s.split("\\&");
}
String newComp = "";
HashMap<String,String> hash = new HashMap<String,String>();
for(int i = 0 ; i < split.length ; i++){
if(split[i].contains("SET")){
hash.put("SL"+count, split[i]);
split[i] = "SL"+count;
count++;
}
newComp+= split[i] + " *";
}
newComp = newComp.substring(0, newComp.length()-1);
createComposant(newComp,obj);
for(String e : hash.keySet()){
String res = hash.get(e);
res = res.replaceFirst("\\(", "").replaceFirst("SET", "").replace(" ", "");
res = res.substring(0,res.length()-1);
String newRule = e + "::=" + res + " * <-1> + " + res +" * "+e +" * <-1>;";
parseLine(newRule);
}
} |
0cca9855-f327-491e-b663-1fba930fc3ff | 1 | public boolean ModificarDetallePunto(DetallePunto p){
if (p!=null) {
cx.Modificar(p);
return true;
}else {
return false;
}
} |
9f254215-6e9c-4dee-88cc-d66204ecb372 | 7 | public void renderTile(int xp, int yp, Tile tile) {
xp -= xOffset;
yp -= yOffset;
for(int y = 0; y < tile.getSprite().height; y++) {
int ya = y + yp;
for (int x = 0; x < tile.getSprite().width; x++) {
int xa = x + xp;
/* TODO */ if (xa < -tile.getSprite().width || xa >= width || ya < 0 || ya >= height) break;
if (xa < 0) xa = 0;
pixels[xa + ya * width] = tile.getSprite().pixels[x + y * tile.getSprite().width];
}
}
} |
c470fb5f-b194-4106-aafe-f5fa6da118ad | 0 | @BeforeClass
public static void setUpClass() {
} |
9f1bcac4-9a3b-4c3c-95c8-7d493751f1db | 6 | private void method394(int i, int j, byte abyte0[], int k, int l, int i1, int j1) {
int k1 = j + l * width;
int l1 = width - k;
int i2 = 0;
int j2 = 0;
if (l < topY) {
int k2 = topY - l;
i1 -= k2;
l = topY;
j2 += k2 * k;
k1 += k2 * width;
}
if (l + i1 >= bottomY)
i1 -= ((l + i1) - bottomY);
if (j < topX) {
int l2 = topX - j;
k -= l2;
j = topX;
j2 += l2;
k1 += l2;
i2 += l2;
l1 += l2;
}
if (j + k >= bottomX) {
int i3 = ((j + k) - bottomX);
k -= i3;
i2 += i3;
l1 += i3;
}
if (k <= 0 || i1 <= 0)
return;
method395(abyte0, i1, k1, pixels, j2, k, i2, l1, j1, i);
} |
51a09d73-583e-4fc3-b766-2cbbf9fe359f | 4 | public void relayout() {
if(mScreen == null || mDocument == null) {
return ;
}
restoreFlags(mDocument.getRootConstruct(), false);
Dimension size = getSize(mDocument.getRootConstruct());
float ratio = (float)size.width / (float)mScreen.width;
while(ratio > mConstructRatioWidth) {
if(!layout(mDocument.getRootConstruct())) {
break;
}
size = getSize(mDocument.getRootConstruct());
ratio = (float) size.width / (float) mScreen.width;
}
} |
2bea63cb-241c-4bc4-a8fa-abdbecaf05d6 | 0 | public void dump(FileOutputStream out) throws Exception {
out.write(packet_tag & 0xff);
out.write(packet_length & 0xff);
out.write(version & 0xff);
out.write(key_id & 0xff);
out.write(s2k & 0xff);
out.write(cipher_text, 0, packet_length);
} |
70f63f6d-5d68-408d-b678-e3a400f2d486 | 6 | @Override
public int getPixel(int x, int y)
{
if (x < 0 || x >= width)
return 0;
if (y < 0 || y >= height)
return 0;
int val = getPixelVal(x, y);
if (format == 1)
val &= 0x1F;
if (format == 6)
val &= 0x07;
return val;
} |
cb5226aa-e1a2-409a-aabd-36bc1256396a | 7 | public void collide(TreeSet<Planes> planeSet) {
// disables in the plane is landing
if (landing) {
return;
}
Iterator<Planes> planeSetIter = planeSet.iterator();
warning = false;
collide = false;
while (planeSetIter.hasNext()) {
Planes nextPlane = planeSetIter.next();
if (nextPlane == this) {
continue;
}
float distance = Position.distance(this.pos,
nextPlane.getPosition());
if (distance < 25 && !nextPlane.isLanding()) {
collide = true;
} else if (distance < 75 && !nextPlane.isLanding()) {
warning = true;
}
}
} |
7b386b9b-8930-435c-9586-92fe4959bfc0 | 2 | public BigDecimal getResult() throws CalculatorException, BinaryOperatorException {
while (!expressionStack.operatorStack.isEmpty()) {
evaluateOperator();
}
if (!expressionStack.bracketStack.isEmpty()) {
throw new BinaryOperatorException("missing closed bracket");
}
BigDecimal res = expressionStack.operandStack.pop();
return res;
} |
a2264ad3-bf7f-4f52-8667-efd007622339 | 9 | @POST
@Path("{id}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response editSensorById(
@PathParam("id") int id,
@FormParam("unity") String unity,
@FormParam("name") String name,
@FormParam("statementFrequency") long statementFrequency,
@FormParam("samplingFrenquency") long samplingFrequency ) {
Sensor sensor = sensorDao.getOne(id);
if(sensor != null){
if(!unity.equals("-1") && !unity.equals(sensor.getUnity())) sensor.setUnity(unity);
if(!name.equals("-1") && !name.equals(sensor.getName())) sensor.setName(name);
if(samplingFrequency != -1 && samplingFrequency != sensor.getSamplingFrequency()) sensor.setSamplingFrequency(samplingFrequency);
if(statementFrequency != -1 && statementFrequency != sensor.getStatementFrequency()) sensor.setStatementFrequency(statementFrequency);
sensorDao.update(sensor);
return Response.status(Response.Status.OK).entity("Data saved : " + sensor).build();
}
return Response.status(Response.Status.BAD_REQUEST).entity("Data saved : " + sensor).build();
} |
d78c2070-aa06-44f0-ae05-8c5ceca4b853 | 0 | public String getPatientID(){
return HKID;
} |
c59106cd-aea1-484b-8d32-85133e6ec26f | 5 | private void generateModeConflictRules(List<CtModeConflictRule> modeConflictRules) {
if (null == modeConflictRules || modeConflictRules.size() == 0) return;
for (CtModeConflictRule conflictRule : modeConflictRules) {
List<String> conflictList = conflictRule.getConflictWIth();
if (null == conflictList || conflictList.size() == 0) continue;
String[] conflictModes = conflictList.toArray(new String[conflictList.size()]);
String mode = conflictRule.getMode();
theory.addModeConflictRules(mode, conflictModes);
}
} |
3c4b6f81-74f3-4c80-869d-c95925ef4d5d | 4 | public LinkedList<IndexCluster> getClusters(String query) {
LinkedList<IndexCluster> clusterList = new LinkedList<IndexCluster>();
try {
// URL obj = new URL(solrURL + "/collection1/dismax?q=" + query
// + "&wt=xml&rows=100");
String queryEnc = URLEncoder.encode(query, "UTF-8");
URI uri = new URI("http", null, "localhost", 8983,
"/solr/collection1" + request_handler, "q=" + queryEnc
+ "&wt=xml&" + "rows=" + CLUSTER_ROWS, null);
HttpURLConnection con = (HttpURLConnection) (uri.toURL())
.openConnection();
con.setRequestMethod("GET");
// Parse the XML given as result
DocumentBuilderFactory dbFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(con.getInputStream());
doc.getDocumentElement().normalize();
Node response = doc.getElementsByTagName("response").item(0);
NodeList children = response.getChildNodes();
Node clusters = children.item(3);// "clusters" node
NodeList clusterNodes = clusters.getChildNodes();// all its elements
for (int i = 0; i < clusterNodes.getLength(); i++) {
NodeList info = clusterNodes.item(i).getChildNodes(); // All the
// cluster's
// info
Node labels = info.item(0);
if (labels.getTextContent().equals("Other Topics")) {
break;
}
NodeList docs = info.item(2).getChildNodes();
IndexCluster cl = new IndexCluster();
cl.label = labels.getTextContent();
for (int j = 0; j < docs.getLength(); j++) {
cl.solrID.add(docs.item(j).getChildNodes().item(0)
.getTextContent());
}
clusterList.add(cl);
}
con.getInputStream().close();
} catch (Exception e) {
System.err
.println("Could not cluster. Error in getClusters(query) in Index:");
System.err.println(e.getMessage());
}
return clusterList;
} |
44a7c047-b917-4166-9030-2ecd78e47c3b | 0 | public String getType()
{
return TYPE;
} |
1cf87430-df2d-471b-bd2d-feedc1835aaf | 9 | @SuppressWarnings("deprecation")
public void run() {
Date now =new Date();
byte[] buf =new byte[32];
boolean send;
// System.out.println("IRQ");
for (int it=0;it<size();it++) {
// System.out.println("Check "+get(it).getType());
send=false;
if (IECMap.IEC_M_Type.contains(get(it).getType())) {
if((get(it).getType()!=IECMap.IECType.M_IT_NA)&&(get(it).getType()!=IECMap.IECType.M_IT_TB)) {
boolean Valuechange = get(it).iob(0).getValue() != get(it).iob(0).VALUE_TX;
boolean QUchange = get(it).iob(0).getQU() != get(it).iob(0).QU_TX;
if (Valuechange | QUchange) { // send an M_Type on change
send =true;
}
} else { // send an M_Type Counter only once a minute
// System.out.print("Counter to send ? last send min:"+get(it).iob(0).Time_TX.getMinutes());
if (now.getMinutes()!=get(it).iob(0).Time_TX.getMinutes()) {
send = true;
}
}
if (iectcactionlistener !=null) {
if (send) {
buf = get(it).getStream();
iectcactionlistener.sendByteArray(buf,buf.length);
get(it).iob(0).VALUE_TX = get(it).iob(0).getValue();
get(it).iob(0).QU_TX = get(it).iob(0).getQU();
get(it).iob(0).Time_TX = now;
}
iectcactionlistener.doUpdate(it);
}
}
}
if (old_size != size()) {
old_size=size();
}
} |
4063aa35-cc59-44ab-8937-7c02cb14f706 | 1 | private byte[] parse(String s) {
byte[] b = new byte[s.length() >> 1];
for (int i=0, j=0; j<s.length(); i++, j+=2)
b[i] = (byte)Long.parseLong(s.substring(j, j+2), 16);
return b;
} |
87889ce9-7200-41bb-8f7c-5211ff6c4263 | 7 | public boolean checkIngredients(ItemStack[] matrix) {
List<ItemStack> list = getIngredientList();
int usedItems = 0;
int matrixItems = 0;
for (ItemStack item : matrix) {
if (item != null && item.getTypeId() != Material.AIR.getId()) {
for (ItemStack recipeItem : list) {
if (recipeItem.getTypeId() == item.getTypeId()) {
usedItems++;
list.remove(recipeItem);
break;
}
}
matrixItems++;
}
}
if (usedItems == matrixItems && 0 == list.size()) {
return true;
} else {
return false;
}
} |
c1bc6289-1ba5-4d5a-81d4-fc36194ed04c | 7 | boolean checkStrandComplementarity() {
if (strands[DNA_STRAND_BASE] == null || strands[DNA_STRAND_COMPL] == null)
return false;
if (strands[DNA_STRAND_BASE].getLength() != strands[DNA_STRAND_COMPL].getLength())
return false;
int len = strands[DNA_STRAND_BASE].getLength();
for (int i = 0; i < len; i++) {
Nucleotide n1 = strands[DNA_STRAND_BASE].getNucleotide(i);
Nucleotide n2 = strands[DNA_STRAND_COMPL].getNucleotide(i);
if (n1 == null || n2 == null)
return false;
Nucleotide nc = n1.getComplementaryNucleotide();
if (nc != n2)
return false;
}
return true;
} |
c665e64d-b35a-4e52-8b67-a699ea8717f7 | 0 | public void playStartSound()
{
startClip.start();
} |
92f00600-4c32-41a1-bc67-495e3614d506 | 1 | public void remover(long pesquisaId) throws Exception
{
String sql = "DELETE FROM pesquisalocal WHERE id1 = ?";
try
{
PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql);
stmt.setLong(1, pesquisaId);
stmt.execute();
}
catch (SQLException e)
{
throw e;
}
} |
b93d152f-0b17-455c-9c90-64b4d3f4d30b | 8 | @SuppressWarnings("incomplete-switch")
/* package */void processOutputMessage (BitTorrentMessage msg) {
assert msg != null;
switch (msg.getMessageType()) {
case HANDSHAKE_START:
HandShakeStart hss = (HandShakeStart) msg;
localFlags.or(hss.getFlags());
localHash = hss.getHash();
localProtocol = hss.getProtocolName();
localHandShakeStarted = true;
break;
case HANDSHAKE_END:
HandShakeEnd hse = (HandShakeEnd) msg;
localPeerId = hse.getPeerId();
localHandShakeFinished = true;
break;
case CHOKE:
localChoking = true;
break;
case UNCHOKE:
localChoking = false;
break;
case INTERESTED:
localInterested = true;
break;
case UNINTERESTED:
localInterested = false;
break;
case HAVE:
localClaimedPieces.set(((HaveMessage) msg).getPieceIndex());
break;
case BITFIELD:
localClaimedPieces.or(((BitFieldMessage) msg).getBitField());
break;
}
} |
674e4243-92f9-48bf-ab30-7aa691508e83 | 9 | Expr unary()throws Exception{
Token tmp = look;
switch(look.tag) {
case '-' :case '+' :
case Tag.TAN:case Tag.EXP:
case Tag.SIN:case Tag.COS:
case Tag.LOG:case Tag.LN :
case Tag.SQR:
move();
return new Unary(tmp,unary());
default:
return factor();
}
} |
b65345d0-dee1-4fee-a651-74c2eca25746 | 3 | private boolean updateClient( Client c )
{
if (c.isClosed())
{
listener.onClientClose( this, c, null );
return false;
}
try
{
c.read();
c.update();
listener.onClientUpdate( this, c );
if (c.isReadyToSend())
{
c.send();
}
return true;
}
catch (Exception e)
{
listener.onClientClose( this, c, e );
c.close();
return false;
}
} |
67339cfa-ea60-4d2c-951b-cdec63e12850 | 0 | public String getAuthority() {
return this.authority;
} |
1adfd910-7b6d-4518-8e69-12ceada5e7ab | 0 | public static void main(String[] args) {
maze = new Maze(BobsMaze.class.getClassLoader().getResource("bobsMaze/maze_01_15x10.txt").getPath());
pop = new Population<>(POPULATION_SIZE, CROSSOVER_RATE, NUM_ELITE,
makeRandomIntChromo, computeIntFitness, mutateIntGenes);
launch(args);
} |
7888d583-0654-46ea-bd5e-38ec93c8c332 | 7 | public List<String> getWords(String s, Set<String> dict)
{
if(s==null||s.equals("")) return null;
List<String> rt = new ArrayList<String>();
Iterator<String> it = dict.iterator();
while(it.hasNext())
{
String d = it.next();
if(isStart(s, d))
{
List<String> after = getWords(s.substring(d.length()), dict);
if(after==null) {
rt.add(d);
}
else if(after.size()>0){
for( int j = 0;j<after.size();j++)
{
rt.add( d+" "+ after.get(j));
}
}
}
}
return rt;
} |
b510b5b7-31d3-4f9c-bb4a-1c39ec58d721 | 8 | private void edgeMethodFailure(Method method, Graph<?, ?> graph, String validVertex, String invalidVertex)
throws IllegalAccessException {
try {
method.invoke(graph, validVertex, null);
fail();
} catch (InvocationTargetException e) {
checkCause(e, NullPointerException.class);
}
try {
method.invoke(graph, null, validVertex);
fail();
} catch (InvocationTargetException e) {
checkCause(e, NullPointerException.class);
}
try {
method.invoke(graph, null, null);
fail();
} catch (InvocationTargetException e) {
checkCause(e, NullPointerException.class);
}
try {
method.invoke(graph, null, invalidVertex);
fail();
} catch (InvocationTargetException e) {
checkCause(e, NullPointerException.class);
}
try {
method.invoke(graph, invalidVertex, null);
fail();
} catch (InvocationTargetException e) {
checkCause(e, IllegalArgumentException.class);
}
try {
method.invoke(graph, invalidVertex, validVertex);
fail();
} catch (InvocationTargetException e) {
checkCause(e, IllegalArgumentException.class);
}
} |
d43912d7-a810-49b7-8d89-f47308e7f2c6 | 3 | public static void removeFileNameFromList(DocumentInfo docInfo) {
// check to see if this file is in frameInfoList
int position = NOT_THERE;
String filename = PropertyContainerUtil.getPropertyAsString(docInfo, DocumentInfo.KEY_PATH);
for (int i = 0, limit = frameInfoList.size(); i < limit; i++) {
if (PropertyContainerUtil.propertyEqualsAsString(((DocumentInfo) frameInfoList.get(i)), DocumentInfo.KEY_PATH, filename)) {
position = i;
}
}
// if it's not in frameInfoList ...
if (position == NOT_THERE) {
return;
}
// move it to the tail of the list
StanVectorTools.moveElementToTail(frameInfoList, position);
// cut off the tail
frameInfoList.setSize(frameInfoList.size() - 1);
// sync
recentFilesList.syncTreeSet();
recentFilesList.syncMenuItems();
} |
62f6f87c-13d0-48c4-ac9c-e1ebbadf9ccd | 7 | static void dradf4(int ido, int l1, float[] cc, float[] ch, float[] wa1,
int index1, float[] wa2, int index2, float[] wa3, int index3) {
int i, k, t0, t1, t2, t3, t4, t5, t6;
float ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4;
t0 = l1 * ido;
t1 = t0;
t4 = t1 << 1;
t2 = t1 + (t1 << 1);
t3 = 0;
for (k = 0; k < l1; k++) {
tr1 = cc[t1] + cc[t2];
tr2 = cc[t3] + cc[t4];
ch[t5 = t3 << 2] = tr1 + tr2;
ch[(ido << 2) + t5 - 1] = tr2 - tr1;
ch[(t5 += (ido << 1)) - 1] = cc[t3] - cc[t4];
ch[t5] = cc[t2] - cc[t1];
t1 += ido;
t2 += ido;
t3 += ido;
t4 += ido;
}
if (ido < 2) {
return;
}
if (ido != 2) {
t1 = 0;
for (k = 0; k < l1; k++) {
t2 = t1;
t4 = t1 << 2;
t5 = (t6 = ido << 1) + t4;
for (i = 2; i < ido; i += 2) {
t3 = (t2 += 2);
t4 += 2;
t5 -= 2;
t3 += t0;
cr2 = wa1[index1 + i - 2] * cc[t3 - 1] + wa1[index1 + i - 1] * cc[t3];
ci2 = wa1[index1 + i - 2] * cc[t3] - wa1[index1 + i - 1] * cc[t3 - 1];
t3 += t0;
cr3 = wa2[index2 + i - 2] * cc[t3 - 1] + wa2[index2 + i - 1] * cc[t3];
ci3 = wa2[index2 + i - 2] * cc[t3] - wa2[index2 + i - 1] * cc[t3 - 1];
t3 += t0;
cr4 = wa3[index3 + i - 2] * cc[t3 - 1] + wa3[index3 + i - 1] * cc[t3];
ci4 = wa3[index3 + i - 2] * cc[t3] - wa3[index3 + i - 1] * cc[t3 - 1];
tr1 = cr2 + cr4;
tr4 = cr4 - cr2;
ti1 = ci2 + ci4;
ti4 = ci2 - ci4;
ti2 = cc[t2] + ci3;
ti3 = cc[t2] - ci3;
tr2 = cc[t2 - 1] + cr3;
tr3 = cc[t2 - 1] - cr3;
ch[t4 - 1] = tr1 + tr2;
ch[t4] = ti1 + ti2;
ch[t5 - 1] = tr3 - ti4;
ch[t5] = tr4 - ti3;
ch[t4 + t6 - 1] = ti4 + tr3;
ch[t4 + t6] = tr4 + ti3;
ch[t5 + t6 - 1] = tr2 - tr1;
ch[t5 + t6] = ti1 - ti2;
}
t1 += ido;
}
if ((ido & 1) != 0) {
return;
}
}
t2 = (t1 = t0 + ido - 1) + (t0 << 1);
t3 = ido << 2;
t4 = ido;
t5 = ido << 1;
t6 = ido;
for (k = 0; k < l1; k++) {
ti1 = -hsqt2 * (cc[t1] + cc[t2]);
tr1 = hsqt2 * (cc[t1] - cc[t2]);
ch[t4 - 1] = tr1 + cc[t6 - 1];
ch[t4 + t5 - 1] = cc[t6 - 1] - tr1;
ch[t4] = ti1 - cc[t1 + t0];
ch[t4 + t5] = ti1 + cc[t1 + t0];
t1 += ido;
t2 += ido;
t4 += t3;
t6 += ido;
}
} |
3162c73a-89f2-4dc2-8823-6c091a3d44f1 | 0 | public long getFileSize() {
return this.fileSize;
} |
d3a4e4b9-7ab8-4e94-84a2-0aa773db8ac0 | 5 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
config = plugin.getConfig();
if (commandLabel.equalsIgnoreCase("Eventjoin")) {
if (args.length == 1){
if (sender instanceof Player) {
if (sender.hasPermission("EventManager.Ejoin")){
File locations = new File (plugin.getDataFolder() + ("locations.yml"));
FileConfiguration spawns = YamlConfiguration.loadConfiguration(locations);
Set<String> locs = spawns.getConfigurationSection("players").getKeys(false);
Object[] alocs = locs.toArray();
Arrays.sort(alocs);
Boolean wait = true;
while (wait == true){
}
}
}
}
}
return true;
} |
84cd781a-3f74-459a-b3db-051e8dd61d48 | 4 | public supplier browseSupplier(String supplierName) throws SQLException{
supplier searchedSupplier=null;
try{
databaseConnector=myConnector.getConnection();
stmnt=(Statement) databaseConnector.createStatement();
SQLQuery="SELECT * FROM familydoctor.supplier WHERE Name="+"'"+supplierName+"'";
System.out.println(SQLQuery);
dataSet=stmnt.executeQuery(SQLQuery);
while(dataSet.next()){
name=dataSet.getString("Name");
contactDetails=dataSet.getString("ContactDetails");
phnNo=dataSet.getInt("phnNo");
mail=dataSet.getString("mail");
amount= dataSet.getFloat("Amount");
searchedSupplier=new supplier(name, contactDetails, phnNo, mail);
searchedSupplier.setAmount(amount);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally {
if (stmnt != null) {
stmnt.close();
}
if (databaseConnector != null) {
databaseConnector.close();
}
}
return searchedSupplier; //return the raws as a resultSet
} |
dc83d4ae-a91f-4d97-9cfb-cea992f20543 | 5 | public void move(String deplacement){
Vehicule v = getVehicule(deplacement.substring(0,1));
int postX = v.getX();
int postY = v.getY();
if(deplacement.substring(1,2).equals("L")){
postX -= Integer.parseInt(deplacement.substring(2));
postX = 4+postX*30;
}
else if(deplacement.substring(1,2).equals("R")){
postX += Integer.parseInt(deplacement.substring(2));
postX = 4+postX*30+v.getLongueur()*30;
}
else if(deplacement.substring(1,2).equals("D")){
postY += Integer.parseInt(deplacement.substring(2));
postY = 4+postY*30+v.getLongueur()*30;
}
else if(deplacement.substring(1,2).equals("U")){
postY -= Integer.parseInt(deplacement.substring(2));
postY = 4+postY*30;
}
if(ParkingController.checkOutBounds(v.getNom(),postX,postY)){
getVehicule(deplacement.substring(0,1)).deplacer(deplacement.substring(1,2),Integer.parseInt(deplacement.substring(2)));
}
} |
35e2f32f-775e-4ede-a2dc-848f37f06869 | 5 | public static void main(String[] args) {/*
byte[] i = {0,0,0,0,0,0,0,0};
ArrayList<byte[]> hashes = new ArrayList<byte[]>();
for (int k = 0; k<1000; k++) {
//while (true) {
if(i[7] == 0) System.out.printf("0x%02x%02x%02x%02x%02x%02x%02x%02x\n", i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]);
byte[] chash = Tworojok64.computeDigest(i);
if (test(hashes, chash))
System.out.printf("!!! Collision detected @ 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]);
hashes.add(chash);
if (++i[7] == 0 && ++i[6] == 0 && ++i[5] == 0 && ++i[4] == 0 && ++i[3] == 0 && ++i[2] == 0 && ++i[1] == 0) i[0]++;
}
*/
int found = 0;
ArrayList<byte[]> hashes = new ArrayList<byte[]>();
long[] current = {0};
//for (int k = 0; k<1000; k++) {
while (true) {
if(current[0]%100 == 0)
System.out.println("(" + found + ") " + current[0]);
byte[] c = Utils.createBytes(current);
int idx;
for(idx = 0; idx < 8; idx++)
if(c[idx] != 0) break;
byte[] c1 = new byte[8-idx];
System.arraycopy(c, idx, c1, 0, 8-idx);
byte[] chash = Tworojok64.computeDigest(c1);
if(test(hashes, chash) >= 0) {
System.out.println("!!! Collision detected @ " + current[0] + " == " + test(hashes, chash));
found++;
}
hashes.add(chash);
current[0]++;
}
} |
1b53f71c-c098-4b8d-ace5-1318130a81e0 | 6 | public static void render(int x, int y){
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(0.5f, 0.5f, 0.5f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40-2, y + Game.SCREEN_HEIGHT/2-5*36-2);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2+5*40+2, y + Game.SCREEN_HEIGHT/2-5*36-2);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2+5*40+2, y + Game.SCREEN_HEIGHT/2+5*36+2);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40-2, y + Game.SCREEN_HEIGHT/2+5*36+2);
GL11.glEnd();
GL11.glColor3f(0.3f, 0.3f, 0.3f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40, y + Game.SCREEN_HEIGHT/2-5*36);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2+5*40, y + Game.SCREEN_HEIGHT/2-5*36);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2+5*40, y + Game.SCREEN_HEIGHT/2+5*36);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40, y + Game.SCREEN_HEIGHT/2+5*36);
GL11.glEnd();
int size = 32;
int index = 0;
for (int j = 0; j <= 8; j++){
for(int i = 0; i <=9 ; i++){
GL11.glColor3f(0.5f, 0.5f, 0.5f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size/2, y + Game.SCREEN_HEIGHT/2+5*36 - 25 - j*4 - j*size);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size*3/2, y + Game.SCREEN_HEIGHT/2+5*36 - 25 - j*4 - j*size);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size*3/2, y + Game.SCREEN_HEIGHT/2+5*36-25- j*4 -j*size - size);
GL11.glVertex2f(x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size/2, y + Game.SCREEN_HEIGHT/2+5*36-25- j*4 - j*size - size);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(1, 1, 1);
int itemX = x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size/2;
int itemY = y + Game.SCREEN_HEIGHT/2+5*36 - 25 - j*4 - j*size - size;
if(inventory[index] != null){
Item item = inventory[index];
item.render(x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size/2, y + Game.SCREEN_HEIGHT/2+5*36 - 25 - j*4 - j*size-size);
String stacks = Integer.toString(inventory[index].getStacks());
if(inventory[index].isStackable()) Font.render(stacks,x + Game.SCREEN_WIDTH/2-5*40 + i*4 + i*size + size/2 + 32 - 8*stacks.length(), y + Game.SCREEN_HEIGHT/2+5*36 - 25 - j*4 - j*size-size);
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
index++;
}}
GL11.glEnable(GL11.GL_TEXTURE_2D);
if(hoveredItem != null) ItemInfo.render(hoveredItem);
if(hoveredArmor != null) ArmorInfo.render(hoveredArmor);
String msg = "- I N V E N T A R -";
Font.render(msg,x + Game.SCREEN_WIDTH/2 - msg.length()*4, y + Game.SCREEN_HEIGHT/2+5*36-16);
} |
07f24f01-9c56-402e-ba4b-e295bd1668a7 | 4 | public Integer getMajorityGreaterThan(){
int maxKey = Integer.MIN_VALUE;
int maxValue = Integer.MIN_VALUE;
boolean greaterThan = false;
for (Map.Entry<Integer, Integer> e : counts.entrySet()) {
if ( e.getValue() > maxValue ) {
maxValue = e.getValue();
maxKey = e.getKey();
greaterThan = true;
}
else if (e.getValue() == maxValue) {
greaterThan = false;
}
}
if ( greaterThan == true )
return maxKey;
else
return null;
} |
da9db72d-92d8-4e3a-a668-530ff4b536db | 3 | public static String replaceSize(String dp) {
Map<String,String> sizeMap = new LinkedHashMap<String,String>();
if (dp == null) return "";
sizeMap.put("whuxga","7680x4800");
sizeMap.put("whsxga","6400x4096");
sizeMap.put("wquxga","3840x2400");
sizeMap.put("wqsxga","3200x2048");
sizeMap.put("wsxga+","1680x1050");
sizeMap.put("sqcif","128x96");
sizeMap.put("wqvga","240x400");
sizeMap.put("qqvga","120x160");
sizeMap.put("hqvga","240x160");
sizeMap.put("fwvga","480x854");
sizeMap.put("wsvga","1024x576");
sizeMap.put("wuxga","1920x1200");
sizeMap.put("1020i","1920x1020");
sizeMap.put("1080p","1920x1020");
sizeMap.put("qwxga","2048x1152");
sizeMap.put("wqxga","2560x1600");
sizeMap.put("qsxga","2560x2048");
sizeMap.put("quxga","3200x2400");
sizeMap.put("whxga","5120x3200");
sizeMap.put("hsxga","5120x4096");
sizeMap.put("huxga","6400x4800");
sizeMap.put("wxga+","1440x900");
sizeMap.put("sxga+","1400x1050");
sizeMap.put("qcif","176x220");
sizeMap.put("svga","800x600");
sizeMap.put("wvga","480x800");
sizeMap.put("qvga","240x320");
sizeMap.put("hvga","480x320");
sizeMap.put("dvga","640x960");
sizeMap.put("wxga","1280x768");
sizeMap.put("xga+","1152x864");
sizeMap.put("sxga","1280x1024");
sizeMap.put("uxga","1600x1200");
sizeMap.put("720p","1280x720");
sizeMap.put("wqhd","2560x1440");
sizeMap.put("qfhd","3840x2160");
sizeMap.put("qxga","2048x1536");
sizeMap.put("hxga","4096x3072");
sizeMap.put("nhd","640x360");
sizeMap.put("qhd","960x540");
sizeMap.put("fhd","1920x1080");
sizeMap.put("uhd","7680x4320");
sizeMap.put("vga","640x480");
sizeMap.put("xga","1024x768");
sizeMap.put("hd","1280x720");
for (Map.Entry<String,String> entry : sizeMap.entrySet()) {
String nickname = (String) entry.getKey();
String dimension = (String) entry.getValue();
if (Functions.stripos(dp,nickname) > -1) {
dp = Functions.str_ireplace(nickname,dimension,dp);
}
}
return dp;
} |
602836e7-a580-4170-ab1c-27f05e1f6fe1 | 4 | public static int xDelta(int givenDirection)
{
switch(givenDirection)
{
case 0: return 0;
case 1: return 1;
case 2: return 0;
case 3: return -1;
default: throw new DirectionOutOfBoundsException();
}
} |
1c631ce6-3edb-408b-a144-e2a4d758c4d5 | 8 | private void append(String text) {
if (text.startsWith("\n"))
width = 0; // reset counter if starts with a newline. only from formats above, not in natural text
if (text.equals(" ") &&
(accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), " ", "\n")))
return; // don't accumulate long runs of empty spaces
if (text.length() + width > maxWidth) { // won't fit, needs to wrap
String words[] = text.split("\\s+");
for (int i = 0; i < words.length; i++) {
String word = words[i];
boolean last = i == words.length - 1;
if (!last) // insert a space if not the last word
word = word + " ";
if (word.length() + width > maxWidth) { // wrap and reset counter
accum.append("\n").append(word);
width = word.length();
} else {
accum.append(word);
width += word.length();
}
}
} else { // fits as is, without need to wrap text
accum.append(text);
width += text.length();
}
} |
72a17236-ab2f-48d9-b69d-1e25b68e588e | 7 | private synchronized void move(){
//Nothing to operate
if(onOperating.isEmpty()){
//No floors is waiting
if(onWaiting.isEmpty()){
status = 0;
idle();
try{
wait();
}catch(InterruptedException ex){
ex.printStackTrace();
}
}
//Floors are waiting
else{
rearrange();
}
}
//On operating
else{
if(status ==0){
status = 1;
notify();
return;
}
currentFloor += direction;
if(direction>0){
System.out.println("Up " + (currentFloor +1)+"F");
}
else if(direction<0){
System.out.println("Down " + (currentFloor +1)+"F");
}
if(currentFloor == onOperating.peek().floor){
floors[currentFloor].openDoor();
floors[currentFloor].notifyGoingOut();
notifyFloor(onOperating.remove().direction);
waitForPerson();
}
}
} |
b6212597-a252-42bf-9403-a311c637aef3 | 6 | public void entitiesModified(Iterable<SimpleEntity> entities) {
for (SimpleEntity entity : entities) {
if (entitiesInIndex.contains(entity)) {
if (!entity.exists) {
entitiesInIndex.remove(entity);
} else if (!hasAllComponents(entity)) {
entitiesInIndex.remove(entity);
}
} else {
if (entity.exists && hasAllComponents(entity)) {
entitiesInIndex.add(entity);
}
}
}
} |
7d587d2a-6178-45c3-8189-4376a189429f | 8 | public void renderProjectile(int xp, int yp, Projectile p) {
xp -= xOffset;
yp -= yOffset;
for (int y = 0; y < p.getSpriteSize(); y++) {
int ya = y + yp;
for (int x = 0; x < p.getSpriteSize(); x++) {
int xa = x + xp;
if (xa < -p.getSpriteSize() || xa >= width || ya < 0 || ya >= height) break;
if (xa < 0) xa = 0;
int col = p.getSprite().pixels[x + y * p.getSpriteSize()];
if (col !=0xFFFF00FF)
pixels[xa + ya * width] = col;
}
}
} |
b621d056-b630-4e52-9109-bf0baa157e6b | 5 | private void updatePath(float x, float y) {
closedPath = null;
if (path == null) {
path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
path.moveTo(x, y);
bounds = new Rectangle2D.Float(x, y, 0, 0);
} else {
path.lineTo(x, y);
float _xmax = (float)bounds.getMaxX();
float _ymax = (float)bounds.getMaxY();
float _xmin = (float)bounds.getMinX();
float _ymin = (float)bounds.getMinY();
if (x < _xmin) _xmin = x;
else if (x > _xmax) _xmax = x;
if (y < _ymin) _ymin = y;
else if (y > _ymax) _ymax = y;
bounds = new Rectangle2D.Float(_xmin, _ymin, _xmax - _xmin, _ymax - _ymin);
}
} |
72de487c-6bab-4384-b5f2-4ff1937e2111 | 7 | public Complex weightedVariance_as_Complex() {
boolean hold = Stat.nFactorOptionS;
if (nFactorReset) {
if (nFactorOptionI) {
Stat.nFactorOptionS = true;
} else {
Stat.nFactorOptionS = false;
}
}
boolean hold2 = Stat.nEffOptionS;
if (nEffReset) {
if (nEffOptionI) {
Stat.nEffOptionS = true;
} else {
Stat.nEffOptionS = false;
}
}
boolean holdW = Stat.weightingOptionS;
if (weightingReset) {
if (weightingOptionI) {
Stat.weightingOptionS = true;
} else {
Stat.weightingOptionS = false;
}
}
Complex varr = Complex.zero();
if (!weightsSupplied) {
System.out.println("weightedVariance_as_Complex: no weights supplied - unweighted value returned");
varr = this.variance_as_Complex();
} else {
Complex weightedVariance = Complex.zero();
Complex[] cc = this.getArray_as_Complex();
Complex[] wc = amWeights.getArray_as_Complex();
weightedVariance = Stat.variance(cc, wc);
varr = weightedVariance;
}
Stat.nFactorOptionS = hold;
Stat.nEffOptionS = hold2;
Stat.weightingOptionS = holdW;
return varr;
} |
cbef129c-0668-4389-873b-ff399d7830fc | 6 | private void makeDropTarget(final java.io.PrintStream out, final java.awt.Component c, boolean recursive) {
// Make drop target
final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();
try {
dt.addDropTargetListener(dropListener);
} // end try
catch (java.util.TooManyListenersException e) {
e.printStackTrace();
log(out, "FileDrop: Drop will not work due to previous error. Do you have another listener attached?");
} // end catch
// Listen for hierarchy changes and remove the drop target when the parent gets cleared out.
c.addHierarchyListener(new java.awt.event.HierarchyListener() {
public void hierarchyChanged(java.awt.event.HierarchyEvent evt) {
log(out, "FileDrop: Hierarchy changed.");
java.awt.Component parent = c.getParent();
if (parent == null) {
c.setDropTarget(null);
log(out, "FileDrop: Drop target cleared from component.");
} // end if: null parent
else {
new java.awt.dnd.DropTarget(c, dropListener);
log(out, "FileDrop: Drop target added to component.");
} // end else: parent not null
} // end hierarchyChanged
}); // end hierarchy listener
if (c.getParent() != null)
new java.awt.dnd.DropTarget(c, dropListener);
if (recursive && (c instanceof java.awt.Container)) {
// Get the container
java.awt.Container cont = (java.awt.Container) c;
// Get it's components
java.awt.Component[] comps = cont.getComponents();
// Set it's components as listeners also
for (int i = 0; i < comps.length; i++)
makeDropTarget(out, comps[i], recursive);
} // end if: recursively set components as listener
} // end dropListener |
94b6ba30-6737-48b3-82c8-f22efdba130f | 7 | public boolean addItemStackToInventory(ItemStack par1ItemStack)
{
int var2;
if (par1ItemStack.isItemDamaged())
{
var2 = this.getFirstEmptyStack();
if (var2 >= 0)
{
this.mainInventory[var2] = ItemStack.copyItemStack(par1ItemStack);
this.mainInventory[var2].animationsToGo = 5;
par1ItemStack.stackSize = 0;
return true;
}
else if (this.player.capabilities.isCreativeMode)
{
par1ItemStack.stackSize = 0;
return true;
}
else
{
return false;
}
}
else
{
do
{
var2 = par1ItemStack.stackSize;
par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack);
}
while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < var2);
if (par1ItemStack.stackSize == var2 && this.player.capabilities.isCreativeMode)
{
par1ItemStack.stackSize = 0;
return true;
}
else
{
return par1ItemStack.stackSize < var2;
}
}
} |
954a5f68-6149-43f7-be2b-d01ba617f3b2 | 7 | public static boolean partialArgumentsUnifyWithArgumentsP(Proposition subproposition, Proposition referenceproposition) {
{ PatternRecord patternrecord = ((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord;
int ubstackoffset = patternrecord.topUnbindingStackOffset;
boolean successP = false;
{ boolean testValue000 = false;
{ boolean alwaysP000 = true;
{ Stella_Object superarg = null;
Vector vector000 = referenceproposition.arguments;
int index000 = 0;
int length000 = vector000.length();
Stella_Object subarg = null;
Vector vector001 = subproposition.arguments;
int index001 = 0;
int length001 = vector001.length();
loop000 : for (;(index000 < length000) &&
(index001 < length001); index000 = index000 + 1, index001 = index001 + 1) {
superarg = (vector000.theArray)[index000];
subarg = (vector001.theArray)[index001];
if (!(Logic.nullInstanceP(subarg) ||
(Logic.nullInstanceP(superarg) ||
Logic.bindArgumentToValueP(superarg, Logic.valueOf(subarg), false)))) {
alwaysP000 = false;
break loop000;
}
}
}
testValue000 = alwaysP000;
}
if (testValue000) {
testValue000 = referenceproposition.arguments.length() == subproposition.arguments.length();
}
successP = testValue000;
}
if (!successP) {
PatternRecord.unbindVariablesBeginningAt(patternrecord, ubstackoffset + 1);
}
return (successP);
}
} |
f70fb24b-1171-44f8-aa3e-f8488ccfe0fb | 0 | public String goToAdminUpdateProduct() {
this.product = this.userFacade.getProductById(this.id);
this.setPropertyFromProduct();
return "adminUpdateProduct";
} |
b761db9a-0f5d-43f2-8567-4547def8258b | 0 | public void setMessage(String message){ this.Message = message; } |
713b2994-3a00-4b6e-91ae-52e4293e4f33 | 1 | public void visitEnd() {
super.visitEnd();
if (mv != null) {
mv.visitEnd();
}
} |
42bf39fc-1c89-47b9-ac88-98066399e9d6 | 3 | @Override
public double[] derivn(double time, double[] currentMarking) {
updateExpressionValuesTable(currentMarking);
double[] derivativePlaceOverDerivativeTime = new double[input.getSpecies().size()];
List<Specie> species = input.getSpecies();
for (int i = 0; i < species.size(); i++) {
Specie specie = species.get(i);
List<Integer> expressionsForSpecie = specieExpressionsTable.get(specie);
/**
* Convention:
*
* expressionIndex > 0, if the value must be added
* expressionIndex < 0, if the value must be subtracted
*/
for (Integer expressionIndex : expressionsForSpecie) {
ExpressionValue expressionValue = expressionValuesTable.get(Math.abs(expressionIndex));
if (expressionIndex > 0) {
derivativePlaceOverDerivativeTime[i] += expressionValue.getValue();
} else {
derivativePlaceOverDerivativeTime[i] -= expressionValue.getValue();
}
}
}
return derivativePlaceOverDerivativeTime;
} |
79f3f2b2-b6f8-4cd8-8a0d-46d6e55a1ca3 | 6 | public static void main(String[] args) throws IOException, FileNotFoundException {
ArrayList<Edge> edges = new ArrayList<Edge>();
final int K = 4;
int n;
BufferedReader br = new BufferedReader(new FileReader("clustering1.txt"));
n = Integer.parseInt(br.readLine());
parents = new int[n][2];
for(int i = 0; i < n ; i++){
parents[i][0] = -1; // initialized parent for each node at begining, -1 indicates self-parent
parents[i][1] = 0; // initialized parent for each node at begining, -1 indicates self-parent
}
String line;
while((line = br.readLine())!=null){
String[] split = line.trim().split("(\\s)+");
int i = Integer.parseInt(split[0]);
int j = Integer.parseInt(split[1]);
int dist = Integer.parseInt(split[2]);
edges.add(new Edge(i-1, j-1, dist));
}
br.close(); // done with reading
Collections.sort(edges); // sorted from min to max by overrode method
for(Edge e : edges){
union(e.fr,e.to);
if ((cluster_fusion_counter + K) == n) {
System.out.println( K + " clusters were found ");
break;
}
}
// print the max space among clusters.
// scan through all edges again, find the min distance between any two clusters
int max = Integer.MAX_VALUE;
for (Edge e : edges){
if (find(e.fr)!=find(e.to)) max=Math.min(max, e.cost);
}
System.out.println("max spacing "+max);
} |
59fb0cd6-60a1-44fb-af84-3557c348194e | 2 | public void saveFile(Object obj, File file) {
if (file.exists()) {
String dirs = file.getPath();
file.delete();
this.createNewFile(file, dirs);
}
try {
this.obj = obj;
this.file = file;
this.saveFile(obj, file);
} catch (Exception e) {
e.printStackTrace();
}
} |
2eb42010-5ab3-4481-908a-4eaef1d18be3 | 1 | @Override
public void run()
{
try
{
Game.log("Game thread sucessfully started");
this.game.run();
}
catch (Exception e)
{
this.didEncounterError = true;
this.exception = e;
this.interrupt();
}
} |
efffec3f-ad5f-4d15-8d01-46787942b79e | 9 | private static final Pair<Integer, Integer> calculateCoordinate( IBoard board, int row, int column, Move joinType ) {
switch (joinType) {
case UP_LEFT:
row--;
column--;
break;
case UP_CENTER:
row--;
break;
case UP_RIGHT:
row--;
column++;
break;
case LEFT:
column--;
break;
case RIGHT:
column++;
break;
case DOWN_LEFT:
row++;
column--;
break;
case DOWN_CENTER:
row++;
break;
case DOWN_RIGHT:
row++;
column++;
break;
default:
break;
}
try {
board.getCell(row,column);
} catch (Exception IllegalArgumentException) {
return null;
}
return new Pair<Integer, Integer>(row, column);
} |
7400a496-f8e6-4e5c-89be-84f746516b87 | 3 | public static String[] split(String toSplit, String delimiter) {
if (!hasLength(toSplit) || !hasLength(delimiter)) {
return null;
}
int offset = toSplit.indexOf(delimiter);
if (offset < 0) {
return null;
}
String beforeDelimiter = toSplit.substring(0, offset);
String afterDelimiter = toSplit.substring(offset + delimiter.length());
return new String[] {beforeDelimiter, afterDelimiter};
} |
4ee823fb-7390-484d-a870-d638e247796e | 0 | public String getFooter() {
return footer;
} |
275dcc60-7465-4d4f-81b3-f2436c33ea8d | 9 | public DERObject getDERObject()
{
if (seq == null)
{
ASN1EncodableVector vec = new ASN1EncodableVector();
for (int i = 0; i != ordering.size(); i++)
{
ASN1EncodableVector v = new ASN1EncodableVector();
DERObjectIdentifier oid = (DERObjectIdentifier)ordering.elementAt(i);
v.add(oid);
String str = (String)values.elementAt(i);
if (str.charAt(0) == '#')
{
str = str.toLowerCase();
byte[] data = new byte[str.length() / 2];
for (int index = 0; index != data.length; index++)
{
char left = str.charAt((index * 2) + 1);
char right = str.charAt((index * 2) + 2);
if (left < 'a')
{
data[index] = (byte)((left - '0') << 4);
}
else
{
data[index] = (byte)((left - 'a' + 10) << 4);
}
if (right < 'a')
{
data[index] |= (byte)(right - '0');
}
else
{
data[index] |= (byte)(right - 'a' + 10);
}
}
ASN1InputStream aIn = new ASN1InputStream(
new ByteArrayInputStream(data));
try
{
v.add(aIn.readObject());
}
catch (IOException e)
{
throw new RuntimeException("bad object in '#' string");
}
}
else
{
if (oid.equals(EmailAddress))
{
v.add(new DERIA5String(str));
}
else
{
if (canBePrintable(str))
{
v.add(new DERPrintableString(str));
}
else
{
v.add(new DERUTF8String(str));
}
}
}
vec.add(new DERSet(new DERSequence(v)));
}
seq = new DERSequence(vec);
}
return seq;
} |
7f7fbe4f-b795-4118-9662-f46be4fae1fa | 9 | protected boolean sendRefCommand(boolean takeoff, boolean emergency) {
int ref = REF_BASE;
if (takeoff) {
ref = ref | MASK_TAKEOFF;
}
if (emergency) {
ref = ref | MASK_EMERGENCY;
}
try {
final String payload = String.format(REF, DUMMY_SN, ref);
if (emergency) {
commandQueue.offer(payload);
return true;
}
final WaitForState task = new WaitForState();
task.setMaxWaitMs(10000);
if (takeoff) {
task.setStateMask(Navdata.MASK_FLY);
task.setTransitionState(E_MajorControlState.CTRL_TRANS_TAKEOFF);
task.setEndState(E_MajorControlState.CTRL_HOVERING);
} else {
task.setInversionMask(Navdata.MASK_FLY);
task.setTransitionState(E_MajorControlState.CTRL_TRANS_LANDING);
task.setEndState(E_MajorControlState.CTRL_LANDED);
}
final Future<Boolean> f = exec.submit(task);
long start = System.currentTimeMillis();
int nSent = 0;
while (!f.isDone()) {
if (nSent < 3) {
commandQueue.offer(payload);
nSent++;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
}
if (Util.DEBUG_ENABLED) {
long end = System.currentTimeMillis();
long dt = end - start;
Util.printDebug("Takeoff/landing completed with result "
+ f.get() + " after " + dt + "ms");
}
return Boolean.TRUE.equals(f.get());
} catch (Exception e) {
Util.printError("Exception occurred while sending REF (" + takeoff
+ ") command : ", e, false);
return false;
}
} |
37fe2efd-e08c-48c3-831b-4dde3d35b09d | 4 | public void bind() {
if(shaderProgram != 0 && !isBound) {
ARBShaderObjects.glUseProgramObjectARB(shaderProgram);
isBound = true;
}
else if(shaderProgram != 0 && isBound) {
System.err.print("RoyalFlush: Shader.bind - Shader program " + shaderProgram + " already bound.\n");
}
else {
System.err.print("RoyalFlush: Shader.bind - No texture has been loaded.\n");
}
} |
c12c6ba7-306b-4c52-9482-4b1f0b9fdb73 | 5 | /* */ @EventHandler
/* */ public void onPlayerDeath(PlayerDeathEvent event)
/* */ {
/* 107 */ if (Main.getAPI().isBeingSpectated(event.getEntity()))
/* */ {
/* 109 */ for (Player p : Main.getAPI().getSpectators(event.getEntity()))
/* */ {
/* 111 */ if ((Main.getAPI().getSpectateMode(p) == SpectateMode.SCROLL) || (Main.getAPI().isScanning(p)))
/* */ {
/* 113 */ SpectateScrollEvent scrollEvent = new SpectateScrollEvent(p, Main.getAPI().getSpectateablePlayers(), ScrollDirection.RIGHT);
/* 114 */ Bukkit.getServer().getPluginManager().callEvent(scrollEvent);
/* */
/* 116 */ ArrayList<Player> playerList = scrollEvent.getSpectateList();
/* */
/* 118 */ playerList.remove(p);
/* 119 */ playerList.remove(event.getEntity());
/* */
/* 121 */ p.sendMessage(ChatColor.GRAY + "The person you were previously spectating has died.");
/* */
/* 123 */ if (!Main.getAPI().scrollRight(p, playerList))
/* */ {
/* 125 */ Main.getAPI().stopSpectating(p, true);
/* 126 */ p.sendMessage(ChatColor.GRAY + "You were forced to stop spectating because there is nobody left to spectate.");
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 132 */ Main.getAPI().stopSpectating(p, true);
/* 133 */ p.sendMessage(ChatColor.GRAY + "You were forced to stop spectating because the person you were spectating died.");
/* */ }
/* */
/* */ }
/* */
/* 139 */ return;
/* */ }
/* */ } |
ad1533c3-5842-40e7-9fa4-172fc6656f3c | 9 | void mouseDoubleClick(int x, int y, int modifiers, int nearestAtomIndex) {
// viewer.setStatusUserAction("mouseDoubleClick: " + modifiers);
setMouseMode();
switch (modifiers & BUTTON_MODIFIER_MASK) {
case LEFT:
if (measurementEnabled) { // XIE
if (measurementMode) {
addToMeasurement(nearestAtomIndex, true);
toggleMeasurement();
}
else if (!drawMode && measuresEnabled) {
enterMeasurementMode();
addToMeasurement(nearestAtomIndex, true);
}
}
break;
case ALT_LEFT:
case MIDDLE:
case SHIFT_LEFT:
if (nearestAtomIndex < 0)
viewer.script("reset");
break;
}
} |
221f0996-30b7-487c-a0dc-c59d7aa16194 | 6 | @Override
public Component getListCellRendererComponent(JList<? extends RosterComponent> list,
RosterComponent value, int index, boolean isSelected, boolean cellHasFocus) {
Integer cnt = MainWindow.tripDB.getRosterAssignmentCount(c.getTime(), value.getRoster());
Color col = Color.BLACK;
if (value.getRoster().getIsAspirant()) {
col = Color.BLUE;
}
if (cnt == 1) {
col = new Color (0, 150, 0);
}
else if (cnt > 1) {
col = Color.RED;
}
if (value.getRoster().getIsAspirant()) {
rosterLabel.setForeground(col);
rosterLabel.setText("HFL: " + value.getRoster().getGivenName() + " " + value.getRoster().getFamilyName());
}
else {
rosterLabel.setForeground(col);
rosterLabel.setText(value.getRoster().getGivenName() + " " + value.getRoster().getFamilyName());
}
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
return this;
} |
7d855861-0be1-4a1a-8d3e-03f4d5a8359d | 6 | private boolean isPic(String s) {
if(s.startsWith("http") && (s.contains(".jpg")||s.contains(".png")||s.contains(".bmp")||s.contains(".gif")||s.contains("jpeg"))){
return true;
}
else
return false;
} |
dbaf1974-f6f0-4a9e-9007-1b972a22276c | 0 | public boolean getEcho() {return this.echoToConsole;} |
efb025d4-08ba-4236-8915-2b58dbcbb4fa | 3 | @Override
public void setPlayers(PlayerDescription[] value) {
for (int i = 0; i < value.length; i++) {
JToggleButton toggle = new JToggleButton(value[i].getName());
toggle.addActionListener(playerSelectActionListener);
toggle.setActionCommand(value[i].getName());
toggle.putClientProperty( "JButton.buttonType", "segmented" );
if(i == value.length - 1)
toggle.putClientProperty( "JButton.segmentPosition", "last" );
else
toggle.putClientProperty( "JButton.segmentPosition", "middle" );
toggle.setForeground(CatanColor.valueOf(value[i].getColor().toUpperCase()).getJavaColor());
toggleButtonGroup.add(toggle);
this.playerSelectionPanel.add(toggle);
this.playerButtons.add(toggle);
}
this.players = value;
for (JPanel panel : this.upDownPanels) {
panel.setVisible(false);
}
} |
26a804d2-fcc0-42f0-80b1-55e5047f871f | 1 | private static void writeHeader(ObjectOutputStream oos, int[] header) throws IOException
{
for(int i = 0; i < 128; i++)
{
oos.writeInt(header[i]);
}
oos.writeInt(textLength);
} |
2288b274-dc52-4eba-9afd-a562bc612b78 | 5 | public void updateItemDisplay(
Model itemModel, float amount, float xoff, float yoff
) {
ItemStack match = null ;
for (ItemStack s : stackFX) if (s.itemModel == itemModel) match = s ;
if (amount < 1) { if (match != null) stackFX.remove(match) ; return ; }
if (match == null) stackFX.add(match = new ItemStack(itemModel)) ;
match.updateAmount((int) amount) ;
match.position.set(
position.x + xoff,
position.y + yoff,
position.z
) ;
} |
5fe3f79b-65dd-48e1-a961-023a590f173b | 9 | protected static NodeInstallInformation getNodeInstallationInformation(String version, File directory) throws MojoExecutionException {
String baseURL = "http://nodejs.org/dist/v" + version + "/";
String basePath = directory.getAbsolutePath() + File.separator;
String arch;
if (Os.isArch("x86") || Os.isArch("i386")) {
arch = "x86";
} else if (Os.isArch("x86_64") || Os.isArch("amd64")) {
arch = "x64";
} else {
throw new MojoExecutionException("Unsupported OS arch: " + Os.OS_ARCH);
}
NodeInstallInformation result = new NodeInstallInformation();
try {
if (Os.isFamily(Os.FAMILY_WINDOWS) || Os.isFamily(Os.FAMILY_WIN9X)) {
result.url = new URL(baseURL + "node.exe");
result.archive = new File(basePath + "node-" + version + ".exe");
result.executable = new File(basePath + "node-" + version + ".exe");
} else if (Os.isFamily(Os.FAMILY_MAC)) {
result.url = new URL(baseURL + "node-v" + version + "-darwin-" + arch + ".tar.gz");
result.archive = new File(basePath + "node-v" + version + "-darwin-" + arch + ".tar.gz");
result.executable = new File(basePath + "node-v" + version + "-darwin-" + arch + File.separator + "bin" + File.separator + "node");
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
result.url = new URL(baseURL + "node-v" + version + "-linux-" + arch + ".tar.gz");
result.archive = new File(basePath + "node-v" + version + "-linux-" + arch + ".tar.gz");
result.executable = new File(basePath + "node-v" + version + "-linux-" + arch + File.separator + "bin" + File.separator + "node");
} else {
throw new MojoExecutionException("Unsupported OS: " + Os.OS_FAMILY);
}
} catch (java.net.MalformedURLException ex) {
throw new MojoExecutionException("Malformed node URL", ex);
}
return result;
} |
3992c269-b39f-4d70-b0f5-807cf1b74d1c | 7 | */
public static void unassertProposition(Proposition self) {
if (self != null) {
{ boolean equivalenceP = self.kind == Logic.KWD_EQUIVALENT;
if (Proposition.trueP(self)) {
if (equivalenceP) {
Proposition.updateEquivalenceProposition(self, Logic.KWD_RETRACT_TRUE);
}
else {
Proposition.updatePropositionTruthValue(self, Logic.KWD_RETRACT_TRUE);
}
}
else if (Proposition.falseP(self)) {
if (equivalenceP) {
Proposition.updateEquivalenceProposition(self, Logic.KWD_RETRACT_FALSE);
}
else {
Proposition.updatePropositionTruthValue(self, Logic.KWD_RETRACT_FALSE);
}
}
else if (Proposition.inconsistentP(self)) {
if (equivalenceP) {
Proposition.deassignTruthValue(self, Logic.KWD_RETRACT_INCONSISTENT);
Proposition.updateEquivalenceProposition(self, Logic.KWD_RETRACT_TRUE);
Proposition.updateEquivalenceProposition(self, Logic.KWD_RETRACT_FALSE);
}
else {
Proposition.deassignTruthValue(self, Logic.KWD_RETRACT_INCONSISTENT);
Proposition.updatePropositionTruthValue(self, Logic.KWD_RETRACT_TRUE);
Proposition.updatePropositionTruthValue(self, Logic.KWD_RETRACT_FALSE);
}
}
}
}
} |
a813adef-a799-4937-8a97-3dae8ca57da3 | 2 | private boolean isAURIMatch(Request request) {
for (String uri : getRouteKeySet(request)) {
if (request.getURI().equals(uri)) {
return true;
}
}
return false;
} |
ea001047-9322-4fbe-8731-af254b2fff92 | 3 | public void setADe(TNumeroInt node)
{
if(this._aDe_ != null)
{
this._aDe_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._aDe_ = node;
} |
a36eb9a6-454a-40cd-af5f-cbbac46bb3bb | 9 | public void cellDraw(int x, int y){
if(!sedna.getSelected() ||sedna.getSelection(x,y)){
if(cellfillflag){
switch(cft){
case 0: populate(x,y,1); break;
case 1: mainBrain.getCell(x, y).setOption(toolstring[3], opval[3]); break;
case 2: mainBrain.getCell(x, y).setParameter(toolstring[3], paramval[3]); break;
default: populate(x,y,1); break;}
}
else{ switch(cdt){
case 0: populate(x,y,1);break;
case 1: mainBrain.getCell(x, y).setOption(toolstring[2], opval[2]); break;
case 2: mainBrain.getCell(x, y).setParameter(toolstring[2], paramval[2]); break;
default: populate(x,y,1); break;}
}
}} |
8856d092-64c4-454d-aa9b-0f5f0efa1020 | 8 | public static int getElementCount(Compoundable compound, Element e)
{
int count = 0;
//System.out.println(compound);
if(compound instanceof Atom && ((Atom)compound).getElement().equals(e))
{
count = 1;
}
else if(compound instanceof Compound)
{
Compoundable[] temp = compound.getElements();
for(int k = 0; k < temp.length; k++)
{
if(temp[k] instanceof Compound)
{
Set<Element> uniques = getUniqueElements(temp[k]);
if(uniques.contains(e))
{
count += (compound.getSubscripts())[k] * getElementCount(temp[k], e);
}
}
else if(temp[k] instanceof Atom && e.equals(((Atom)temp[k]).getElement()))
{
count += (compound.getSubscripts())[k];
}
}
}
return count;
} |
431a0273-f0b8-4b97-8354-999cb4776096 | 0 | public String getPrenom() {
return prenom;
} |
4af5b4a7-45f2-4175-a032-18a1e8b46017 | 4 | * @Post: no changes
* @Return: Returns whether or not a current point is under attack by the enemy
*/
private boolean isUnderAttack(Point pointToCheck) {
// TODO Auto-generated method stub
return knightsCanAttack(pointToCheck)||diagonalCanAttack(pointToCheck)||lineCanAttack(pointToCheck)||pawnCanAttack(pointToCheck)||kingCanAttack(pointToCheck);
} |
0542bcae-4cc6-492e-8a4c-d8f2340f2c63 | 7 | int [] getCliqueTree(int [] order, Set [] cliques, Set [] separators) {
int nNodes = order.length;
int [] parentCliques = new int[nNodes];
//for (int i = nNodes - 1; i >= 0; i--) {
for (int i = 0; i < nNodes; i++) {
int iNode = order[i];
parentCliques[iNode] = -1;
if (cliques[iNode] != null && separators[iNode].size() > 0) {
//for (int j = nNodes - 1; j > i; j--) {
for (int j = 0; j < nNodes; j++) {
int iNode2 = order[j];
if (iNode!= iNode2 && cliques[iNode2] != null && cliques[iNode2].containsAll(separators[iNode])) {
parentCliques[iNode] = iNode2;
j = i;
j = 0;
j = nNodes;
}
}
}
}
return parentCliques;
} // getCliqueTree |
c4803f26-8d26-4afe-9956-db58f2133ce9 | 2 | public void fillSuccessors() {
if (jump != null)
flowBlock.addSuccessor(jump);
StructuredBlock[] subs = getSubBlocks();
for (int i = 0; i < subs.length; i++) {
subs[i].fillSuccessors();
}
} |
8c5be155-c6ee-468b-b033-01c543f9d232 | 6 | public byte getCHRMappedMemory(int address, boolean isDirect) {
// read BEFORE we potentially bank switch
byte b = chrData[((address < 0x1000) ? lowBank : highBank) * 0x1000 + (address & 0xFFF)];
if(! isDirect) {
//PPU reads $0FD0 through $0FDF: latch 0 is set to $FD for subsequent reads
//PPU reads $0FE0 through $0FEF: latch 0 is set to $FE for subsequent reads
//PPU reads $1FD0 through $1FDF: latch 1 is set to $FD for subsequent reads
//PPU reads $1FE0 through $1FEF: latch 1 is set to $FE for subsequent reads
if( (address & 0x1FD0) == 0x0FD0) {
lowBank = fdLowCHR;
lowTrigger = 0xFD;
}
else if( (address & 0x1FE0) == 0x0FE0) {
lowBank = feLowCHR;
lowTrigger = 0xFE;
}
else if( (address & 0x1FD0) == 0x1FD0) {
highBank = fdHighCHR;
highTrigger = 0xFD;
}
else if( (address & 0x1FE0) == 0x1FE0) {
highBank = feHighCHR;
highTrigger = 0xFE;
}
}
return b;
} |
66f7b80b-4f5c-4952-9406-29836171876b | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(CadastrarFeeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(CadastrarFeeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(CadastrarFeeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(CadastrarFeeds.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CadastrarFeeds().setVisible(true);
}
});
} |
c1f956ed-4e7a-472c-9817-6c51f2a2429d | 8 | public Object setAccelerator(String section,String tool,KeyStroke key) {
int i;
for(i=0;i<_tb.size() && !_tb.get(i).name().equals(section);i++);
if (i==_tb.size()) {
return null;
} else {
toolbarSection sec=_tb.get(i);
for(i=0;i<sec.size() && (sec.get(i)==null ? true : (!sec.get(i).getName().equals(tool))) ;i++);
if (i==sec.size()) {
return null;
} else {
if (section.substring(0,1).equals("@")) {
sec.getMenuItem(i).setAccelerator(key);
return sec.getMenuItem(i);
} else {
return null;
}
}
}
} |
92438148-09ad-467d-b2a5-6320e8b50bcb | 0 | public void setSaleTime(Timestamp saleTime) {
this.saleTime = saleTime;
} |
d4cd60ad-1e36-4fef-9d1b-9a251143294d | 4 | public static boolean polygonIntersectPolygon(Polygon p1, Polygon p2) {
Point p;
for (int i = 0; i < p2.npoints; i++) {
p = new Point(p2.xpoints[i], p2.ypoints[i]);
if (p1.contains(p))
return true;
}
for (int i = 0; i < p1.npoints; i++) {
p = new Point(p1.xpoints[i], p1.ypoints[i]);
if (p2.contains(p))
return true;
}
return false;
} |
575b2648-c2a5-43a1-bdce-b94521ea3052 | 2 | @Test(groups = {"Regression", "Smoke"})
public void testNavigatingToRepeatingTab() throws Exception {
// Initialize the servers
initializeDriver();
// Define variables
String userName = GenericFunctions.props.getProperty(CommonConstants.DEFAULT_LOGIN_USER_NAME);
String email = GenericFunctions.props.getProperty(CommonConstants.DEFAULT_LOGIN_USER_EMAIL);
String password = GenericFunctions.props.getProperty(CommonConstants.DEFAULT_LOGIN_USER_PASSWORD);
String logInUrl = GenericFunctions.props.getProperty(CommonConstants.DEFAULT_LOGIN_URL);
// Log-in to the system
Assert.assertTrue(Login(email, password, logInUrl), "Log-in to the system failed. No point of continuing test");
// Navigate to Sales Screen
print("Navigating to 'Sales' window.");
driver.findElement(By.id("Accounts")).click();
waitTillElementLoad(By.partialLinkText("Sales"));
driver.findElement(By.partialLinkText("Sales")).click();
// Page load verification
try {
waitTillElementLoad(By.id("page_title"));
Assert.assertTrue(driver.findElement(By.id("page_title")).getText().contains("Sales"), "Sales Screen has not loaded properly");
sleep(GenericFunctions.defaultSleepMilliseconds);
print("'Sales' window successfully loaded.");
} catch (Exception e) {
Assert.fail("Sales Screen has not loaded properly");
}
// Navigate to Repeating Tab
print("Navigating to 'Repeating' tab.");
waitTillElementLoad(By.partialLinkText("Repeating"));
driver.findElement(By.partialLinkText("Repeating")).click();
sleep(GenericFunctions.defaultSleepMilliseconds);
// Page load verification
try {
waitTillElementLoad(By.id("title"));
Assert.assertTrue(driver.findElement(By.id("title")).getText().contains("Invoices"), "'Repeating' tab has not loaded properly");
print("'Repeating' tab successfully loaded.");
} catch (Exception e) {
Assert.fail("'Repeating' tab has not loaded properly");
}
// Log-out from the system
LogOut(userName);
} |
cbf93b1c-bf85-467e-8444-ab5b815a2a03 | 2 | public String toString() {
if (!reversed) {
reverse();
}
Element tmp = firstElement;
String result = "";
while (tmp != null) {
result += tmp.getValue() + " ";
tmp = tmp.getNextElement();
}
return result;
} |
66258c64-123d-47c8-a1b1-0457fb2fca21 | 2 | public void saveToFile(File f) {
try {
File out = new File(f.getPath() + System.getProperty("file.separator") + getRuleName() + ".rule");
try (BufferedWriter bw = new BufferedWriter(new FileWriter(out, false))) {
bw.write(getRuleName()); bw.newLine();
bw.write(getRuleURL()); bw.newLine();
bw.write(getRuleRegExpr()); bw.newLine();
bw.write((this.isIsEnabled()) ? "1" : "0"); bw.newLine();
}
} catch (Exception e) {
e.printStackTrace();
}
} |
e421128c-6533-448e-b1c2-1b8bc13af16c | 7 | protected ConclusionType evaluateAmbiguousConclusionsByModality(Literal literal, ConclusionType conclusionType, //
Collection<Literal> conflictLiterals) throws ReasoningEngineException {
// no need to perform literal modal operators comparisons if the conclusion type is already negative
if (conclusionType.isNegativeConclusion()) return conclusionType;
// count the number of conflict modal literals that appear in the records
// and the number of literals weaker than the prescribed literal
int conflictLiteralExistCount = 0;
int strongModeCount = 0;
for (Literal conflictLiteral : conflictLiterals) {
if (isRecordExist(conflictLiteral, conclusionType)) {
conflictLiteralExistCount++;
if (hasStrongerMode(literal, conflictLiteral)) {
logMessage(Level.FINEST, 2, null, literal, " hasStrongerMode: ", conflictLiteral);
strongModeCount++;
}
}
}
// only conclusion with strongest modality is positively concluded
if (strongModeCount == conflictLiteralExistCount) {
// literal with strongest modal operator find
// positive conclusion => conclusion type unchanged
return conclusionType;
} else {
// literal does not with strongest modality
// defeated conclusion => change conclusion type to negative
switch (conclusionType) {
case DEFINITE_PROVABLE:
return ConclusionType.DEFINITE_NOT_PROVABLE;
case DEFEASIBLY_PROVABLE:
return ConclusionType.DEFEASIBLY_NOT_PROVABLE;
default:
throw new ReasoningEngineException(getClass(), "unknown conclusion type: " + conclusionType);
}
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.