method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
142b0f34-6026-4f6e-8b68-f75e3e008abd
| 9
|
public void initiate(){
//Reset the boolean chosen of the other starters sprites
Iterator<Sprite> it = starters.iterator();
while (it.hasNext()) {
Sprite element = it.next();
((StarterSprite) element).setChosen(false);
}
//Remove all components
jCheck1.setSelected(false);
jCheck2.setSelected(false);
jCheck3.setSelected(false);
//Resetting the map list
mapList.removeAllItems();
File tmpFolder = new File("img/map");
String[] files = tmpFolder.list();
for(int i=0; i<files.length;i++){
if (files[i].endsWith("_hm.png")){
for(int k=0;k<files.length;k++){
if(files[k].endsWith("_view.png")){
String nameOfHmMap = files[i].split("_")[0];
String nameOfViewMap = files[k].split("_")[0];
if(nameOfHmMap.equals(nameOfViewMap)) mapList.addItem(nameOfHmMap);
}
}
}
}
//TODO Checking if there's a least one item in the list of map
//If not : back to Home and errorDialog
if(mapList.getItemCount() != 0){
mapList.setSelectedIndex(0);
for(int i=0; i<mapList.getItemCount(); i++){
if(mapList.getItemAt(i).equals("DefaultMap")){
mapList.setSelectedIndex(i);
break;
}
}
}
nbEnemies = 0;
remove(jEnemies);
remove(jCheck1);
remove(jCheck2);
remove(jCheck3);
remove(firstEnemySprite);
remove(secondEnemySprite);
remove(thirdEnemySprite);
remove(jMap);
remove(mapList);
remove(jButtonStart);
//Repaint the panel
revalidate();
repaint();
}
|
51613e61-04c9-4d9f-b097-dc95e475ecee
| 6
|
public static void main(String args[]){
int mapSize = 5;
//Creating a colour scheme to test the renderer with
Colour[] colours = new Colour[mapSize];
for (int i=0; i<5; i++) {
switch (i) {
case 0: Colour black = new Colour("#000000");
colours[i] = black;
break;
case 1: Colour darkgrey = new Colour("#222222");
colours[i] = darkgrey;
break;
case 2: Colour grey = new Colour("#555555");
colours[i] = grey;
break;
case 3: Colour lightgrey = new Colour("#BBBBBB");
colours[i] = lightgrey;
break;
case 4: Colour white = new Colour("#EEEEEE");
colours[i] = white;
break;
}
}
ColourMap greyscale = new ColourMap(colours, "Greyscale");
//Test class
CustomBarRenderer testCustomBarRenderer=
new CustomBarRenderer(greyscale);
//Test GetMap class
System.out.println("CustomBarRenderer:: GetMap()");
testCustomBarRenderer.GetMap();
System.out.println("CustomBarRenderer:: GetMap() - Test Passed");
//Test SetMap class
System.out.println("CustomBarRenderer:: SetMap()");
testCustomBarRenderer.SetMap(greyscale);
System.out.println("CustomBarRenderer:: SetMap() - Test Passed");
}
|
e951c43e-6526-4d8e-923c-b8d9da07ee7d
| 7
|
public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0
&& string.indexOf('E') < 0) {
while (string.endsWith("0")) {
string = string.substring(0, string.length() - 1);
}
if (string.endsWith(".")) {
string = string.substring(0, string.length() - 1);
}
}
return string;
}
|
f4b7ed3e-12c2-447d-bbcc-84ac09728148
| 7
|
public void testValidEdge2() {
try {
TreeNode tree = new TreeNode("tree", 2);
TreeNode subtree = new TreeNode("spare-subtree");
tree.setBranch(new TreeNode[]{ new TreeNode("subtree"), subtree });
setTree(tree);
TreeNode realTree = ((Question1)answer);
((Question1)answer).deleteSubTree(realTree, 0);
assertTrue(null, "Your code has incorrectly deleted a leaf node from a 2-branching tree",
((String)(realTree.getData())).equals("tree")
&& realTree.getBranch().length == 2
&& realTree.getBranch()[0] == null
&& realTree.getBranch()[1] == subtree);
} catch(TreeException exn) {
fail(exn, "Your code threw a `TreeException`. Possible causes: \n* Remember that the `root` node has a `label`.\n* Maybe you are using your parameters incorrectly?\n* Maybe you are using `==` instead of the `equals` method when testing labels?");
} catch(NullPointerException exn) {
fail(exn, "Your code threw an `NullPointerException`. Possible causes: \n* Remember that the `root` node has a `label`.\n* Maybe you are using your node parameter incorrectly?\n* Maybe you have assumed that edge numbering starts at 1?\n* Has your code forgotten to `exclude` the branch array's size as an index value?");
} catch(ArrayIndexOutOfBoundsException exn) {
fail(exn, "Your code threw an `ArrayIndexOutOfBoundsException`. Possible causes: \n* Remember that the `root` node has a `label`.\n* Maybe you are using your node parameter incorrectly?\n* Maybe you have assumed that edge numbering starts at 1?\n* Has your code forgotten to `exclude` the branch array's size as an index value?");
} catch(Throwable exn) {
fail(exn, "No exception's should be generated, but your code threw: " + exn.getClass().getName());
} // end of try-catch
} // end of method testValidEdge2
|
0b358ee3-9978-4228-8617-1eb75713e01f
| 5
|
protected void assertDecodedSourcesEqual(DecodedSource a, DecodedSource b)
{
try
{
int idx = 0;
while (true)
{
boolean aHasData = true;
double aData = 0.0f;
try
{
aData = a.getSample(idx);
}
catch (NoMoreDataException e)
{
aHasData = false;
}
boolean bHasData = true;
double bData = 0.0f;
try
{
bData = b.getSample(idx);
}
catch (NoMoreDataException e)
{
bHasData = false;
}
Assert.assertEquals("The audio sources were of different lengths!",
aHasData,
bHasData);
// Both sources have run out, and the data has been the same so
// far. Equal.
if (!aHasData)
break;
// The two data differ at this index. Not equal.
Assert.assertEquals("The audio sources differed at position " + idx,
aData,
bData,
0.00001f);
idx += 1;
}
}
catch (InvalidAudioFormatException e)
{
Assert.fail("Two audio sources should be equal, but were corrupt!");
}
}
|
250efb4d-c420-4401-93e2-b53072f87016
| 0
|
@Override
public boolean supportsEditability() {return true;}
|
fc50d735-ce65-4b50-b358-f30d8538b80e
| 2
|
public GameWorld(WorldDescriptor descr)
throws WeigthNumberNotMatchException {
stepCount = 0;
conf = descr.configuration();
entities = Collections.synchronizedList(new LinkedList<Entity>());
dead = Collections.synchronizedList(new LinkedList<Entity>());
Random rng = new Random();
// adding agents
for (int i = 0; i < conf.getAgentCount(); i++) {
entities.add(new Agent(descr.getGenotypes().get(
rng.nextInt(descr.getGenotypes().size())), rng.nextInt(conf
.getWorldSize() + 1), rng.nextInt(conf.getWorldSize() + 1),
rng.nextInt(360)));
}
// adding food
for (int i = 0; i < conf.getInitialFoodAmount(); i++) {
entities.add(new FoodEntity(rng.nextInt(conf.getWorldSize() + 1),
rng.nextInt(conf.getWorldSize() + 1)));
}
}
|
bb67a02f-3882-4ebe-8a0a-a33dc220778b
| 0
|
@Test
public void getTest() throws Exception {
mockMvc.perform(get("/get.json"))
.andExpect(status().isOk())
.andExpect(view().name("jsonView")).andExpect(model().size(1));
}
|
fc3a2bbd-aab5-4de0-92db-d5c2ccbf523d
| 0
|
public int grab()
{
Random rand = new Random();
int randNumber = 0;
return randNumber = data[rand.nextInt(manyItems)];
}
|
af8ffca5-35a5-43f9-9405-87a36793e1f1
| 4
|
public boolean nextChunk() {
if (!this.hasNext()) {
return false;
}
int len = vsize.length -1;
int tmp = len;
while (tmp >= 0
&& this.start[tmp] + this.chunkStep[tmp] >= this.vsize[tmp]) {
tmp--;
}
this.start[tmp] += this.chunkStep[tmp];
for (int i = len; i > tmp; i--) {
this.start[i] = 0;
}
this.chunkNum++;
return true;
}
|
b1ec503b-dffb-47ca-aa52-a53229ce711a
| 2
|
private CreaturePluginFactory(double inMaxSpeed) {
try {
pluginLoader = new PluginLoader(pluginDir,ICreature.class);
}
catch (MalformedURLException ex) {
}
maxSpeed=inMaxSpeed;
constructorMap = new HashMap<String,Constructor<? extends ICreature>>();
load();
}
|
82de118f-3e98-4fdf-92ef-b7c76bdc1b39
| 3
|
public String leerLog(String path){
File f = new File(path);
if(f.exists())
{
try {
BufferedReader br = new BufferedReader(new FileReader(path));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append('\n');
line = br.readLine();
}
br.close();
return sb.toString();
}
catch(Exception e){
e.printStackTrace();
return "There is not a log file for this strategy.";
}
}
else{
return "There is not a log file for this strategy.";
}
}
|
beccce8e-d2e4-473f-bb09-ee46f54e7505
| 0
|
public double distToExit(Point pos){
return (Math.abs(pos.x - exitP.x) + Math.abs(pos.y - exitP.y));
}
|
f07198ec-09d8-4d7b-9d12-2faa5a03930f
| 5
|
public static int check(String aWord, String bWord) {
char[] a = aWord.toCharArray();
char[] b = bWord.toCharArray();
int curSum = 0, sum = 0, aSize = a.length, bSize = b.length, ia;
for (int i = 0; i < aSize + bSize - 1; i++) {
ia = i - (bSize - 1);
curSum = 0;
for (int j = 0; j < b.length; j++, ia++)
if (ia >= 0 && ia < aSize && b[j] == a[ia])
curSum++;
sum = Math.max(sum, curSum);
}
return sum;
}
|
0d91ef3b-6ecc-4962-9464-beb777376eb9
| 3
|
public void operate(Iqueue platformQueue, int phase){
if(!this.sellerQueue.isEmpty()){
int beforMoveCount = platformQueue.getSize();
moveCustomerToPlatformQueue(platformQueue,phase);
int afterMoveCount = platformQueue.getSize();
if( !this.sellerQueue.isEmpty() &&
afterMoveCount != beforMoveCount){
increaseCustomerWaitingTime(Define.first);
}
else{
increaseCustomerWaitingTime(Define.second);
}
}
}
|
e55fa66d-e7a7-4d75-b1e8-8ff501aea7e2
| 4
|
protected void standardTransform(int kc) {
if (kc == forwardKey) {
moveForward();
} else {
if (kc == backKey) {
moveBackward();
} else {
if (kc == leftKey) {
rotateLeft();
} else {
if (kc == rightKey) {
rotateRight();
}
}
}
}
}
|
cf8b7dc0-2ef4-4130-9d2c-caeb04da3731
| 4
|
public Behaviour getNextStep() {
final float demand = venue.stocks.demandFor(made.type) ;
if (demand > 0) made = Item.withAmount(made, demand + 5) ;
if (venue.stocks.hasItem(made)) {
return null ;
}
if (GameSettings.hardCore && ! hasNeeded()) return null ;
return new Action(
actor, venue,
this, "actionMake",
Action.REACH_DOWN, "Working"
) ;
}
|
54f87db4-10f3-40a5-91a9-138272bf7d4b
| 8
|
public void setUserSavedGame(String true_false) {
File file = new File("Users.txt");
String line = "";
FileWriter writer;
ArrayList<String> userData= new ArrayList<String>();
ListIterator<String> iterator;
try {
Scanner s = new Scanner(file);
while(s.hasNextLine()) {
userData.add(s.nextLine());
}
s.close();
iterator = userData.listIterator();
while(iterator.hasNext()) {
if(iterator.next().equals(user.getUsername())) {
if(iterator.hasNext()) {
iterator.next();
if(iterator.hasNext()) {
line = iterator.next();
iterator.set(true_false);
break;
}
}
}
}
writer = new FileWriter("Users.txt");
iterator = userData.listIterator();
while(iterator.hasNext()) {
writer.write(iterator.next());
writer.write("\n");
}
writer.close();
}
catch (FileNotFoundException e) {
JOptionPane.showMessageDialog(null, "Could not find User file. Contact system administrator.", "Error", JOptionPane.ERROR_MESSAGE);
}
catch (IOException e) {
JOptionPane.showMessageDialog(null, "Could not update Users. Contact system administrator.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
|
dbb215ec-bea8-444e-b360-2485427c384f
| 6
|
public static boolean isAnagrams1(String s,String t){
if( s== null || t == null){
return false;
}
if(s.length() != t.length()){
return false;
}
int[] map = new int[256];
char[] u = s.toCharArray();
char[] v = t.toCharArray();
int len = u.length;
for(int i=0;i<len;i++){
map[(int)u[i]]++;
map[(int)v[i]]--;
}
for(int i=0;i<256;i++){
if(map[i]!=0){
return false;
}
}
return true;
}
|
97c13622-ec7e-4ce7-91b4-81d38befe302
| 7
|
public void keyReleased(KeyEvent e)
{
//System.out.println("Key = " + e);
key = e.getKeyCode();
if (key == 32)
space = false;
else if (key == 38)
up = false;
else if (key == 37)
left = false;
else if (key == 39)
right = false;
else if (key == 40)
down = false;
else if (key == 10)
enter = false;
else if (key == 27)
esc = false;
}
|
f809426d-1e68-47fc-b3a0-4304845ab56d
| 9
|
private StringVector getNodesByID(XPathContext xctxt, int docContext,
String refval, StringVector usedrefs,
NodeSetDTM nodeSet, boolean mayBeMore)
{
if (null != refval)
{
String ref = null;
// DOMHelper dh = xctxt.getDOMHelper();
StringTokenizer tokenizer = new StringTokenizer(refval);
boolean hasMore = tokenizer.hasMoreTokens();
DTM dtm = xctxt.getDTM(docContext);
while (hasMore)
{
ref = tokenizer.nextToken();
hasMore = tokenizer.hasMoreTokens();
if ((null != usedrefs) && usedrefs.contains(ref))
{
ref = null;
continue;
}
int node = dtm.getElementById(ref);
if (DTM.NULL != node)
nodeSet.addNodeInDocOrder(node, xctxt);
if ((null != ref) && (hasMore || mayBeMore))
{
if (null == usedrefs)
usedrefs = new StringVector();
usedrefs.addElement(ref);
}
}
}
return usedrefs;
}
|
6437c010-6c5f-47c2-ab64-e6394d3f28f9
| 5
|
private static String describeSupport(Property p,
List<GeneralNameValueConfig> fieldSet) {
String supp="";
for(GeneralNameValueConfig cfg : fieldSet) {
if(cfg.fieldProperty==p) {
if(supp.length()>0)
supp+=", ";
supp+=cfg.fieldName
+(cfg.alternate?" (alt)":"");
}
}
return supp.length()>0?supp:"n/a";
}
|
9fdd442e-c545-488a-8442-1704fe68cd31
| 3
|
public int compute()
{
subSequence[0] = 0;
backPointers[0] = -1;
len = 1;
for (int i = 1; i < seq.length; i++) {
if (seq[i] > seq[subSequence[len-1]]) {
backPointers[i] = subSequence[len-1];
subSequence[len++] = i;
} else if (seq[i] < seq[subSequence[0]]) {
subSequence[0] = i;
backPointers[i] = -1;
} else {
int index = findPos(subSequence, 0, len-1, seq[i]);
subSequence[index] = i;
backPointers[i] = subSequence[index - 1];
}
}
return (len);
}
|
dba051c6-a5da-47fc-a156-3ec63bf69d66
| 9
|
@Override
public void loadFromFile(String trainFile, String testFile, String quizFile, String featureFile)
{
System.out.print("Loading dataset... ");
try
{
if(trainFile != null && trainFile.length() > 0);
loadDataFromFile(trainFile, InstanceType.Train);
if(testFile != null && testFile.length() > 0)
loadDataFromFile(testFile, InstanceType.Test);
if(quizFile != null && quizFile.length() > 0)
loadDataFromFile(quizFile, InstanceType.Quiz);
if(featureFile != null && featureFile.length() > 0)
loadFeatureFromFile(featureFile);
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println(this.toString());
}
|
a64afcc1-d573-4885-850e-c91de9dc7ad6
| 6
|
FlowBlock getSuccessor(int start, int end) {
/* search successor with smallest addr. */
Iterator keys = successors.keySet().iterator();
FlowBlock succ = null;
while (keys.hasNext()) {
FlowBlock fb = (FlowBlock) keys.next();
if (fb.addr < start || fb.addr >= end || fb == this)
continue;
if (succ == null || fb.addr < succ.addr) {
succ = fb;
}
}
return succ;
}
|
8a440b78-44b0-44af-bbc8-d3aa794ef5e6
| 0
|
public Ifrit(int room) {
super(new Earthquake(), new SonicBlow(), 180.0*room, 199.0*room, 190.00*room, 2.0*room, 120.0*room, 25.0*room, "Ifrit");
} // End DVC
|
d4499fb9-1b7e-44ac-a2cd-f38fa7a1e5b8
| 8
|
public void setTriArrows(CellElement current,
boolean showNotChoosen) {
m_arrowList.clear();
int cCol, cRow;
cCol = current.getColumn();
cRow = current.getRow();
this.setGridCircle(cCol, cRow);
if (((NussinovCellElement)current).isEndCell()) {
return;
}
CellElement leftCell = this.getCell(cCol - 1, cRow);
CellElement bottomCell = this.getCell(cCol, cRow + 1);
CellElement bottomLeftCell = this.getCell(cCol - 1, cRow + 1);
if (current.isPointer(leftCell)) {
this.addArrow(current, leftCell, Color.black);
}
else {
if (showNotChoosen) {
this.addArrow(current, leftCell, Color.lightGray);
}
}
if (current.isPointer(bottomCell)) {
this.addArrow(current, bottomCell, Color.black);
}
else {
if (showNotChoosen) {
this.addArrow(current, bottomCell, Color.lightGray);
}
}
if (current.isPointer(bottomLeftCell)) {
this.addArrow(current, bottomLeftCell, Color.black);
}
else {
if (showNotChoosen) {
this.addArrow(current, bottomLeftCell, Color.lightGray);
}
}
// bifuricated cell arrows
NCellPair cellPair;
ListIterator a = ((NussinovCellElement)current).getBifPointers().listIterator();
while (a.hasNext()) {
cellPair = (NCellPair)a.next();
this.addArrow(current,cellPair.getCellOne(),Color.black);
this.addArrow(current,cellPair.getCellTwo(),Color.black);
}
}
|
3be0ecec-37b3-4555-831a-b855bbe3ead8
| 9
|
private MoveAndCost findBestMoveInternal(int[][] board, int depth) {
int n = board.length;
int m = board[0].length;
double minCost = Double.POSITIVE_INFINITY;
int[][] bestBoard = null;
Move bestMove = null;
for (Move move : Move.ALL) {
int[][] newBoard = makeMove(board, move);
if (OriginalGamePlayer.equals(board, newBoard)) {
continue;
}
double cost = 0;
if (depth == maxDepth) {
cost = evaluator.evaluate(newBoard);
} else {
int emptyCnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (newBoard[i][j] == 0) {
emptyCnt++;
newBoard[i][j] = 2;
cost += findBestMoveInternal(newBoard, depth + 1).cost * 0.9;
newBoard[i][j] = 4;
cost += findBestMoveInternal(newBoard, depth + 1).cost * 0.1;
newBoard[i][j] = 0;
}
}
}
cost /= emptyCnt;
}
if (cost < minCost) {
minCost = cost;
bestMove = move;
bestBoard = newBoard;
}
}
if (bestBoard == null) {
return new MoveAndCost(null, evaluator.getFailCost());
}
if (depth == 0) {
copyBoard(board, bestBoard);
}
return new MoveAndCost(bestMove, minCost);
}
|
be651577-564d-4d3c-957a-94cd81c5dcdc
| 1
|
private boolean jj_3R_36() {
if (jj_3R_82()) return true;
return false;
}
|
70bacf19-75ca-44ae-a895-c7c2e704f0b1
| 4
|
private static void receive() {
LOG.debug("Receiving packet");
String parameterType = (String) cbType.getSelectedItem();
LOG.debug("Parameter types: {}", parameterType);
try {
GWCAPacket gwcaPacket = gwcaConnection.receivePacket();
byte[] w = null, l = null;
if (HEX.equals(parameterType)) {
//TODO: Hex format
wLabel.setText(Integer.toString(byteArrayToInt(gwcaPacket.getWparam())));
lLabel.setText(Integer.toString(byteArrayToInt(gwcaPacket.getLparam())));
} else if (INT.equals(parameterType)) {
wLabel.setText(Integer.toString(byteArrayToInt(gwcaPacket.getWparam())));
lLabel.setText(Integer.toString(byteArrayToInt(gwcaPacket.getLparam())));
} else if (FLOAT.equals(parameterType)) {
wLabel.setText(Float.toString(byteArrayToFloat(gwcaPacket.getWparam())));
lLabel.setText(Float.toString(byteArrayToFloat(gwcaPacket.getLparam())));
} else {
LOG.error("Impossible!");
}
} catch (IOException ex) {
LOG.warn("Failed: ", ex);
}
LOG.debug("Received");
}
|
be66f7eb-615d-4f69-a2d0-0be64a54038a
| 6
|
@Override
public void run() {
int skippedFrames;
long runTime = 0;
ticksClock.start();
framesClock.start();
while (game.isRunning()) {
long nsPerTick = Clock.NS_PER_SEC / game.ups;
long nsPerFrame = Clock.NS_PER_SEC / game.fps;
ticksClock.tick();
runTime += ticksClock.getTimePerTick();
skippedFrames = 0;
while (runTime >= nsPerTick && skippedFrames <= maxSkippedFrames) {
game.input.poll();
game.update();
runTime -= nsPerTick;
skippedFrames ++;
ticks++;
}
framesClock.tick();
if (framesClock.getRunTimeNs() >= nsPerFrame) {
game.render();
framesClock.reset();
frames++;
}
if (true) {
if (ticksClock.getRunTimeMs() >= 1000) {
System.out.println("Ticks: " + ticks + " Frames: " + frames);
ticks = 0;
frames = 0;
ticksClock.reset();
}
}
}
}
|
d80f5a4a-af8a-4cbd-8b84-3a755675b208
| 2
|
public Vector<TestRecord> getRecordList(ResultSet rs) {
Vector<TestRecord> records = new Vector<TestRecord>();
try {
while (rs.next()) {
TestRecord record = new TestRecord();
record.setTest_id(rs.getInt("test_id"));
record.setType_id(rs.getInt("type_id"));
record.setPatient_no(rs.getInt("patient_no"));
record.setEmployee_no(rs.getInt("employee_no"));
record.setMedical_lab(rs.getString("medical_lab"));
record.setResult(rs.getString("result"));
record.setPrescribe_date(rs.getDate("prescribe_date"));
record.setTest_date(rs.getDate("test_date"));
records.add(record);
}
} catch (SQLException e) {
}
return records;
}
|
d7f619c2-eed4-4001-804c-12fc8626dbcc
| 7
|
private String createResultMessage() {
StringBuffer message = new StringBuffer();
message.append(TextUserInterface.HORIZENTAL_LINE).
append(TextUserInterface.NEW_LINE).
append(TextUserInterface.HORIZENTAL_LINE).
append(TextUserInterface.NEW_LINE).
append("You ");
switch (this.getStatus()) {
case BLACKJACK:
message.append("won by a Blackjack!!");
break;
case BUSTED:
message.append("busted! Easy dude/gal!");
break;
case CAN_HIT:
message.append(" still can hit! hmm!");
break;
case LOST:
message.append(" lost! Nice try but gotta practice more! Or somehow ask universe for a better luck!");
break;
case STAND:
message.append(" just stood! Maybe it was a wise decision! Let's see!");
break;
case PUSH:
message.append(" reached a push! Neither lost nor won! Not too bad!");
break;
case WON:
message.append(" won and that's great!");
break;
default:
message.append(" have undefined status!! what brought you here?");
break;
}
return message.toString();
}
|
53994fb6-09ca-4277-b077-24bd91be643d
| 0
|
public static void add(long uid, Notification notification) {
UserNotificationBuffer buffer = getMonitorFor(uid);
buffer.addNotification(notification);
}
|
976f7758-dd8a-4d73-8e8c-4c6307e3da10
| 3
|
public static void initiate(JavaPlugin plugin, String name, String prefix) {
logPrefix = prefix;
fileName = name;
File folder = plugin.getDataFolder();
if (!folder.exists()) {
folder.mkdir();
}
File log = new File(plugin.getDataFolder(), fileName + ".log");
if (!log.exists()) {
try {
log.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
logFile = log;
enabled = true;
}
|
0ae34b72-6ad3-48e1-857e-bc1726d6472c
| 5
|
private static Component getFirstFocusableField(Object comp) {
if (comp instanceof JTextComponent || comp instanceof KeyStrokeDisplay) {
return (Component) comp;
}
if (comp instanceof Container) {
for (Component child : ((Container) comp).getComponents()) {
Component field = getFirstFocusableField(child);
if (field != null) {
return field;
}
}
}
return null;
}
|
35cd1250-11ea-4f25-8bbf-0183ceb48dff
| 6
|
@Override
public Value run(CodeBlock i) {
try {
__return = false;
if (body_ == null) {
body_ = parseForRun();
}
while (!__end && !__return && condition_.run(i).getBoolean()) {
Value v = runBlock(body_, this);
if (__return) {
return v;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return new Value();
}
|
b385796b-7f81-421a-a2e1-d3052eddb1ea
| 3
|
@Override
public void execute() {
Inventory.getItem(Constants.INVENTORY_BURNED_ROOT_ID).getWidgetChild().interact("Fletch");
final Timer timeout = new Timer(2000);
while(timeout.isRunning() && !validate(Constants.FLETCH_WIDGET)) {
Task.sleep(50);
}
if (validate(Constants.FLETCH_WIDGET)) {
Widgets.get(1370, 38).click(true);
}
sleep(1500, 2000);
}
|
3cddcd51-8142-4251-9a98-c77b7f30c519
| 2
|
public static List<Record> getRecords(String baseformat, int num) throws SQLException
{
String cd_extra = "AND riploc IS NOT NULL";
if (!baseformat.equalsIgnoreCase("cd"))
cd_extra = "";
String sql = "select recordnumber,count(score_value) as cnt,avg(score_value) AS mean from records,score_history,formats WHERE format = formatnumber "
+ cd_extra
+ " AND baseformat = ? AND owner = 1 AND boughtdate < (now() - interval '3 months') AND recordnumber = record_id AND salepricepence < 0 AND user_id =1 AND category != 48 GROUP BY records.owner, recrand,recordnumber HAVING count(score_value) = 1 AND MAX(score_date) < (now() - interval '3 months') "
+ " ORDER BY owner, mean LIMIT " + num;
PreparedStatement ps = Connect.getConnection().getPreparedStatement(sql);
ps.setString(1, baseformat);
System.out.println(ps);
ResultSet rs = Connect.getConnection().executeQuery(ps);
List<Record> records = new LinkedList<Record>();
while (rs.next())
records.add(GetRecords.create().getRecord(rs.getInt(1)));
return records;
}
|
61f2bb6b-dcbd-4ad1-934b-1bf0c4a29711
| 6
|
public static void startupArithmetic() {
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, Stella.getStellaModule("/PL-KERNEL-KB", Stella.$STARTUP_TIME_PHASE$ > 1));
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
if (Stella.currentStartupTimePhaseP(2)) {
_StartupArithmetic.helpStartupArithmetic1();
}
if (Stella.currentStartupTimePhaseP(5)) {
{ Stella_Class renamed_Class = Stella.defineClassFromStringifiedSource("INTEGER-INTERVAL", "(DEFCLASS INTEGER-INTERVAL (THING) :DOCUMENTATION \"An interval of integers\" :SLOTS ((INTERVAL-LOWER-BOUND :TYPE INTEGER) (INTERVAL-UPPER-BOUND :TYPE INTEGER)))");
renamed_Class.classConstructorCode = Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntegerInterval", "newIntegerInterval", new java.lang.Class [] {});
renamed_Class.classSlotAccessorCode = Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntegerInterval", "accessIntegerIntervalSlotValue", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntegerInterval"), Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("edu.isi.stella.Stella_Object"), java.lang.Boolean.TYPE});
}
{ Stella_Class renamed_Class = Stella.defineClassFromStringifiedSource("INTERVAL-CACHE", "(DEFCLASS INTERVAL-CACHE (THING) :PUBLIC? TRUE :PUBLIC-SLOTS ((HOME-CONTEXT :TYPE CONTEXT) (INTERVAL-MEMBER :TYPE LOGIC-OBJECT) (LOWER-BOUND :TYPE OBJECT) (UPPER-BOUND :TYPE OBJECT) (STRICT-LOWER-BOUND? :TYPE BOOLEAN) (STRICT-UPPER-BOUND? :TYPE BOOLEAN)) :PRINT-FORM (PROGN (PRINT-STREAM STREAM \"|cache-of: \" (INTERVAL-MEMBER SELF) \" \") (PRINT-INTERVAL STREAM (LOWER-BOUND SELF) (STRICT-LOWER-BOUND? SELF) (UPPER-BOUND SELF) (STRICT-UPPER-BOUND? SELF)) (PRINT-STREAM STREAM \"|\")))");
renamed_Class.classConstructorCode = Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "newIntervalCache", new java.lang.Class [] {});
renamed_Class.classSlotAccessorCode = Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "accessIntervalCacheSlotValue", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntervalCache"), Native.find_java_class("edu.isi.stella.Symbol"), Native.find_java_class("edu.isi.stella.Stella_Object"), java.lang.Boolean.TYPE});
}
}
if (Stella.currentStartupTimePhaseP(6)) {
Stella.finalizeClasses();
}
if (Stella.currentStartupTimePhaseP(7)) {
Stella.defineFunctionObject("ARITHMETIC-EQUAL-TEST", "(DEFUN (ARITHMETIC-EQUAL-TEST BOOLEAN) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "arithmeticEqualTest", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("ARITHMETIC-LESS-TEST", "(DEFUN (ARITHMETIC-LESS-TEST BOOLEAN) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "arithmeticLessTest", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("ARITHMETIC-GREATER-TEST", "(DEFUN (ARITHMETIC-GREATER-TEST BOOLEAN) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "arithmeticGreaterTest", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("PLUS-COMPUTATION", "(DEFUN (PLUS-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "plusComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("MINUS-COMPUTATION", "(DEFUN (MINUS-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "minusComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("TIMES-COMPUTATION", "(DEFUN (TIMES-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "timesComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("DIVIDE-COMPUTATION", "(DEFUN (DIVIDE-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER) (Y NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "divideComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("SQRT-COMPUTATION", "(DEFUN (SQRT-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "sqrtComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("NEGATE-COMPUTATION", "(DEFUN (NEGATE-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "negateComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("ABS-COMPUTATION", "(DEFUN (ABS-COMPUTATION NUMBER-WRAPPER) ((X NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "absComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("PLUS-CONSTRAINT", "(DEFUN (PLUS-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER) (X3 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "plusConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("MINUS-CONSTRAINT", "(DEFUN (MINUS-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER) (X3 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "minusConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("TIMES-CONSTRAINT", "(DEFUN (TIMES-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER) (X3 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "timesConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("DIVIDE-CONSTRAINT", "(DEFUN (DIVIDE-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER) (X3 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "divideConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("NEGATE-CONSTRAINT", "(DEFUN (NEGATE-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "negateConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("SQRT-CONSTRAINT", "(DEFUN (SQRT-CONSTRAINT OBJECT) ((MISSING-ARGUMENT INTEGER-WRAPPER) (X1 NUMBER-WRAPPER) (X2 NUMBER-WRAPPER)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "sqrtConstraint", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.IntegerWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper"), Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("PRINT-INTERVAL", "(DEFUN PRINT-INTERVAL ((STREAM NATIVE-OUTPUT-STREAM) (LOWER OBJECT) (STRICT-LOWER? BOOLEAN) (UPPER OBJECT) (STRICT-UPPER? BOOLEAN)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "printInterval", new java.lang.Class [] {Native.find_java_class("org.powerloom.PrintableStringWriter"), Native.find_java_class("edu.isi.stella.Stella_Object"), java.lang.Boolean.TYPE, Native.find_java_class("edu.isi.stella.Stella_Object"), java.lang.Boolean.TYPE}), null);
Stella.defineFunctionObject("CREATE-INTERVAL-CACHE", "(DEFUN (CREATE-INTERVAL-CACHE INTERVAL-CACHE) ((INTERVALMEMBER LOGIC-OBJECT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "createIntervalCache", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.LogicObject")}), null);
Stella.defineFunctionObject("GET-INTERVAL-CACHE", "(DEFUN (GET-INTERVAL-CACHE INTERVAL-CACHE) ((SELF LOGIC-OBJECT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "getIntervalCache", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.LogicObject")}), null);
Stella.defineFunctionObject("SIGNAL-INTERVAL-CLASH", "(DEFUN SIGNAL-INTERVAL-CLASH ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "signalIntervalClash", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntervalCache")}), null);
Stella.defineFunctionObject("EVALUATE-ADJACENT-INEQUALITIES", "(DEFUN EVALUATE-ADJACENT-INEQUALITIES ((SELF LOGIC-OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "evaluateAdjacentInequalities", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.LogicObject")}), null);
Stella.defineMethodObject("(DEFMETHOD (INTEGER-VALUED-MEMBER? BOOLEAN) ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "integerValuedMemberP", new java.lang.Class [] {}), ((java.lang.reflect.Method)(null)));
Stella.defineMethodObject("(DEFMETHOD (INTEGER-LOWER-BOUND INTEGER-WRAPPER) ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "integerLowerBound", new java.lang.Class [] {}), ((java.lang.reflect.Method)(null)));
Stella.defineMethodObject("(DEFMETHOD (INTEGER-UPPER-BOUND INTEGER-WRAPPER) ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "integerUpperBound", new java.lang.Class [] {}), ((java.lang.reflect.Method)(null)));
Stella.defineMethodObject("(DEFMETHOD EVALUATE-TIGHTER-INTEGER-INTERVAL ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "evaluateTighterIntegerInterval", new java.lang.Class [] {}), ((java.lang.reflect.Method)(null)));
Stella.defineMethodObject("(DEFMETHOD EVALUATE-TIGHTER-INTERVAL ((INTERVAL INTERVAL-CACHE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "evaluateTighterInterval", new java.lang.Class [] {}), ((java.lang.reflect.Method)(null)));
Stella.defineMethodObject("(DEFMETHOD PROPAGATE-INEQUALITY-TO-INTERVAL-CACHE ((SELF INTERVAL-CACHE) (VALUE OBJECT) (OPERATOR SURROGATE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "propagateInequalityToIntervalCache", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Surrogate")}), ((java.lang.reflect.Method)(null)));
Stella.defineFunctionObject("INVERSE-INEQUALITY-OPERATOR", "(DEFUN (INVERSE-INEQUALITY-OPERATOR SURROGATE) ((OPERATOR SURROGATE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "inverseInequalityOperator", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Surrogate")}), null);
Stella.defineFunctionObject("UNIFY-INTERVAL-CACHES", "(DEFUN UNIFY-INTERVAL-CACHES ((CACHE1 INTERVAL-CACHE) (CACHE2 INTERVAL-CACHE) (OPERATOR SURROGATE)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "unifyIntervalCaches", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntervalCache"), Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntervalCache"), Native.find_java_class("edu.isi.stella.Surrogate")}), null);
Stella.defineFunctionObject("ACCESS-INTERVAL-BOUNDS", "(DEFUN (ACCESS-INTERVAL-BOUNDS OBJECT BOOLEAN) ((X OBJECT) (LOWERORUPPER KEYWORD)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "accessIntervalBounds", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("[Ljava.lang.Object;")}), null);
Stella.defineFunctionObject("ACCESS-INTERVAL-CACHE-BOUNDS", "(DEFUN (ACCESS-INTERVAL-CACHE-BOUNDS OBJECT BOOLEAN) ((INTERVALCACHE INTERVAL-CACHE) (LOWERORUPPER KEYWORD)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.IntervalCache", "accessIntervalCacheBounds", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.pl_kernel_kb.IntervalCache"), Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("[Ljava.lang.Object;")}), null);
Stella.defineFunctionObject("COMPARE-INTERVAL-BOUNDS?", "(DEFUN (COMPARE-INTERVAL-BOUNDS? BOOLEAN) ((RELATION SURROGATE) (X OBJECT) (Y OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "compareIntervalBoundsP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Surrogate"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("NULL-NUMBER?", "(DEFUN (NULL-NUMBER? BOOLEAN) ((SELF NUMBER-WRAPPER)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "nullNumberP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.NumberWrapper")}), null);
Stella.defineFunctionObject("NULL-LITERAL-WRAPPER?", "(DEFUN (NULL-LITERAL-WRAPPER? BOOLEAN) ((SELF OBJECT)) :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "nullLiteralWrapperP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("SATISFIES-INTERVAL-BOUNDS?", "(DEFUN (SATISFIES-INTERVAL-BOUNDS? BOOLEAN) ((OBJECT OBJECT) (VALUE OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "satisfiesIntervalBoundsP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("LESS-SPECIALIST-HELPER", "(DEFUN (LESS-SPECIALIST-HELPER KEYWORD) ((FRAME CONTROL-FRAME) (RELATION SURROGATE) (XARG OBJECT) (YARG OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "lessSpecialistHelper", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.ControlFrame"), Native.find_java_class("edu.isi.stella.Surrogate"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("INEQUALITY-SPECIALIST", "(DEFUN (INEQUALITY-SPECIALIST KEYWORD) ((FRAME CONTROL-FRAME) (LASTMOVE KEYWORD)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "inequalitySpecialist", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.ControlFrame"), Native.find_java_class("edu.isi.stella.Keyword")}), null);
Stella.defineFunctionObject("INEQUALITY-EVALUATOR", "(DEFUN INEQUALITY-EVALUATOR ((SELF PROPOSITION)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "inequalityEvaluator", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Proposition")}), null);
Stella.defineFunctionObject("STRING-CONCATENATE-COMPUTATION", "(DEFUN (STRING-CONCATENATE-COMPUTATION STRING-WRAPPER) ((X OBJECT) (YARGS CONS)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "stringConcatenateComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Cons")}), null);
Stella.defineFunctionObject("SUBSEQUENCE-SPECIALIST", "(DEFUN (SUBSEQUENCE-SPECIALIST KEYWORD) ((FRAME CONTROL-FRAME) (LASTMOVE KEYWORD)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "subsequenceSpecialist", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.ControlFrame"), Native.find_java_class("edu.isi.stella.Keyword")}), null);
Stella.defineFunctionObject("STRING-MATCH-COMPUTATION-HELPER", "(DEFUN (STRING-MATCH-COMPUTATION-HELPER INTEGER-WRAPPER) ((PATTERN OBJECT) (X OBJECT) (START OBJECT) (END OBJECT) (IGNORE-CASE? BOOLEAN)) :PUBLIC? FALSE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "stringMatchComputationHelper", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), java.lang.Boolean.TYPE}), null);
Stella.defineFunctionObject("STRING-MATCH-COMPUTATION", "(DEFUN (STRING-MATCH-COMPUTATION INTEGER-WRAPPER) ((PATTERN OBJECT) (X OBJECT) (START OBJECT) (END OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "stringMatchComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("STRING-MATCH-IGNORE-CASE-COMPUTATION", "(DEFUN (STRING-MATCH-IGNORE-CASE-COMPUTATION INTEGER-WRAPPER) ((PATTERN OBJECT) (X OBJECT) (START OBJECT) (END OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "stringMatchIgnoreCaseComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("LENGTH-COMPUTATION", "(DEFUN (LENGTH-COMPUTATION INTEGER-WRAPPER) ((X OBJECT)))", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb.PlKernelKb", "lengthComputation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("STARTUP-ARITHMETIC", "(DEFUN STARTUP-ARITHMETIC () :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.pl_kernel_kb._StartupArithmetic", "startupArithmetic", new java.lang.Class [] {}), null);
{ MethodSlot function = Symbol.lookupFunction(PlKernelKb.SYM_PL_KERNEL_KB_STARTUP_ARITHMETIC);
KeyValueList.setDynamicSlotValue(function.dynamicSlots, Logic.SYM_STELLA_METHOD_STARTUP_CLASSNAME, StringWrapper.wrapString("_StartupArithmetic"), Stella.NULL_STRING_WRAPPER);
}
}
if (Stella.currentStartupTimePhaseP(8)) {
Stella.finalizeSlots();
Stella.cleanupUnfinalizedClasses();
}
if (Stella.currentStartupTimePhaseP(9)) {
Stella_Object.inModule(((StringWrapper)(Stella_Object.copyConsTree(StringWrapper.wrapString("PL-KERNEL")))));
}
} finally {
Stella.$CONTEXT$.set(old$Context$000);
Stella.$MODULE$.set(old$Module$000);
}
}
}
|
6dbeb9b1-62ad-4649-b3c9-c1e207ac0e0f
| 6
|
private String generateMIPSCode(String irCode)
{
String[] lines = irCode.split("\n");
ArrayList<String> newLines = new ArrayList<String>();
newLines.add(model.getDataHeader());
newLines.add(".text\n");
newLines.add(".globl main\n");
for(int i = 0; i < lines.length; i++)
{
if(lines[i].contains(":") && !lines[i].substring(lines[i].length() - 1, lines[i].length()).equals(":"))
{
List<String> tempLines = generateNewCode(lines[i].split(":")[1]);
newLines.add(lines[i].split(":")[0] + ":");
for(int j = 0; j < tempLines.size(); j++)
newLines.add(tempLines.get(j));
}
else
{
List<String> tempLines = generateNewCode(lines[i]);
for(int j = 0; j < tempLines.size(); j++)
newLines.add(tempLines.get(j));
}
}
newLines.add("jr $ra");
String output = "";
for(int i = 0; i < newLines.size(); i++)
{
output += newLines.get(i);
}
return output;
}
|
79961d3d-979c-448f-af7f-8380b5bcd350
| 1
|
public String getOutput() {
int nextBlank = buffer.indexOf("" + BLANK, getTapeHead());
if (nextBlank == -1)
nextBlank = buffer.length();
return buffer.substring(getTapeHead(), nextBlank);
}
|
145ebe2b-c269-457b-8ff2-c6a1ad12cd97
| 9
|
public ConfigTextParser(String filePath){
textFilePath = filePath;
//lecture du fichier texte
try{
InputStream ips=new FileInputStream(textFilePath);
InputStreamReader ipsr=new InputStreamReader(ips);
BufferedReader br=new BufferedReader(ipsr);
String ligne;
while ((ligne=br.readLine())!=null){
System.out.println(ligne);
if(host == null)
host = ligne;
else if(port == 0)
port = Integer.parseInt(ligne);
else if(teamName == null){
teamName = ligne;
if(teamName.length() == 0){
teamName = "XXX";
}else if(teamName.length() == 1){
teamName = teamName + "XX";
}else if(teamName.length() == 2){
teamName = teamName + "X";
}else if(teamName.length() > 3){
teamName = ""+teamName.charAt(0) + teamName.charAt(1) + teamName.charAt(2);
}
break;
}
}
br.close();
}
catch (Exception e){
System.out.println(e.toString());
}
}
|
98fc8300-6cb9-4e0b-ab7b-87780da15fc4
| 3
|
public void and(BitSet set)
{
if (this == set)
return;
while (wordsInUse > set.wordsInUse)
words[--wordsInUse] = 0;
// Perform logical AND on words in common
for (int i = 0; i < wordsInUse; i++)
words[i] &= set.words[i];
recalculateWordsInUse();
checkInvariants();
}
|
5b2eb364-d910-4c0c-94ba-3509040cbc40
| 5
|
private void loadConfig() {
saveDefaultConfig();
FileConfiguration cfg = getConfig();
// Add defaults
if (cfg.getConfigurationSection("global-settings") == null) {
cfg.createSection("global-settings");
cfg.set("global-settings.enabled", true);
cfg.set("global-settings.check-for-updates", true);
cfg.set("global-settings.auto-update", false);
cfg.set("global-settings.hunger", true);
}
List<String> worlds = cfg.getStringList("worlds");
if (worlds.isEmpty() || worlds == null) {
worlds.add("world");
worlds.add("world_nether");
cfg.set("worlds", worlds);
}
if (cfg.getConfigurationSection("effects") == null) {
cfg.set("effects.poison.duration", 7);
cfg.set("effects.poison.amplifier", 2);
cfg.set("effects.poison.hunger-at-activation", 16);
cfg.set("effects.poison.message",
"&eYou are sick from your starvation... You should really consider eating.");
}
if (cfg.getConfigurationSection("depletion-rate") == null) {
cfg.set("depletion-rate.sprinting", 1.7);
cfg.set("depletion-rate.sneaking", 0.77);
cfg.set("depletion-rate.swimming", 1.6);
cfg.set("depletion-rate.flying", 1.0);
cfg.set("depletion-rate.sleeping", 0.3);
}
cfg.options().header(getHeader());
saveConfig();
}
|
6b00567e-5061-4aa2-9c61-738a2f7099bd
| 4
|
public void doPrintSchnitt() {
for (int i = 0; i < this.inspectedVertices.size(); i++) {
boolean isSchnitt = false;
String schnittTarget = "";
String node = this.inspectedVertices.get(i);
List<String> edges = this.graph.getIncident(node);
for (String edge : edges) {
String target = this.graph.getTarget(edge);
if (!this.inspectedVertices.contains(target)) {
isSchnitt = true;
schnittTarget = target;
}
}
if (isSchnitt) {
System.out.println("Schnitt: von " + node + " nach " + schnittTarget + " Fluss nicht mehr steigerbar");
}
}
}
|
370101dd-2271-4d5c-a611-54e0001f384e
| 4
|
private void jButtonCalcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCalcActionPerformed
/**This method calculates Monthly Mortgage Payment**/
/**Get Input**/
//Get the vlaue of the text fiels
sPrinciple = jTextFieldPrincipal.getText();
//add error checking
sAnualInterest = jTextFieldInterest.getText();
//add error checking
sTermYr = jTextFieldTerm.getText();
//error checking
if(sPrinciple.isEmpty()||sAnualInterest.isEmpty()||sTermYr.isEmpty()){
ErrorLabel.setText("Incorrect or missing value");
return;}
//convert strings to numbers
dPrinciple = Double.parseDouble(sPrinciple); //Amount Barrowed
dInterest = Double.parseDouble(sAnualInterest); //Anual interest Rate
iYearTerm = Integer.parseInt(sTermYr); // Loan Payback Period in Years
//TODO add error checking
//**get monthly payment info**//
//Calculate the number of months in the term
int iMonthterm = iYearTerm * 12;
//Calculate monthly interest
double dMonthInterest = dInterest / 1200;
//Calculate Monthly Payment
dMonthlyPayment = (dPrinciple * (Math.pow((1 + dMonthInterest) , iMonthterm))* dMonthInterest)/
((Math.pow((1 + dMonthInterest) , iMonthterm))-1);
//Formats Monthly Payment
currency = NumberFormat.getCurrencyInstance(); //creates currency
sMonthlyPayment=currency.format(dMonthlyPayment);
//write output
jTextFieldMoPay.setText(sMonthlyPayment);
//writes to Table
while (iMonthterm > 0){
iMonthterm = iMonthterm-1;//holds which months payment is on
dCurrentInterest = dPrinciple * dMonthInterest; //Shows current interest payed
dPrinciplePaid = dMonthlyPayment - dCurrentInterest; //shows principle paid
dPrinciple = dPrinciple - dPrinciplePaid; //shows remaining principle
++iPayment;
sPayment = Integer.toString(iPayment);//required for output reasons
String[] rowData ={sPayment,(currency.format(dMonthlyPayment)),(currency.format(dCurrentInterest)),
(currency.format(dPrinciplePaid)),(currency.format(dPrinciple))};
amortModel.addRow(rowData);
}//end while
}//GEN-LAST:event_jButtonCalcActionPerformed
|
5ad9ae97-4225-4d55-8758-b791a2212782
| 8
|
private boolean initConnections(StringBuffer msg) {
JnnLayer currentLayer;
JnnLayer testLayer;
JnnUnit currentUnit;
JnnUnit testUnit;
JnnConnection currentConnection;
int layerIndex;
int unitIndex;
for (JnnLayer layer : layers) {
currentLayer = layer;
for (int j = 0; j < currentLayer.getNumUnits(); j++) {
currentUnit = currentLayer.getUnitAt(j);
for (int k = 0; k < currentUnit.getNumConnections(); k++) {
currentConnection = currentUnit.getConnectionAt(k);
layerIndex = currentConnection.getSourceLayerIndex();
if (layerIndex < 0 || layerIndex >= numLayers) {
msg.append(MessageFormat.format("invalid 0-based connection source layer index: ''{0}''", layerIndex));
return false;
}
testLayer = layers[layerIndex];
unitIndex = currentConnection.getSourceUnitIndex();
if (unitIndex < 0 || unitIndex >= testLayer.getNumUnits()) {
msg.append(MessageFormat.format("invalid 0-based connection source unit index: ''{0}''", unitIndex));
return false;
}
testUnit = testLayer.getUnitAt(unitIndex);
if (testUnit == null) {
msg.append(MessageFormat.format("invalid 0-based connection source unit index: ''{0}''", unitIndex));
return false;
}
currentConnection.setInputUnit(testUnit);
}
}
}
return true;
}
|
42c96852-67d5-4176-bd4d-ca580f98c962
| 2
|
private void siirryTunnuksenLoppuun() {
while (true) {
if (!merkkiOsaTunnusta()) {
break;
}
paikka++;
}
}
|
6360ef36-0ffc-451c-be96-d4fd25f3f0ea
| 8
|
public boolean isSameTree(TreeNode p, TreeNode q) {
if((p == null && q != null) || (p != null && q == null)) return false;
if(p == null && q == null) return true;
if(p.val != q.val) return false;
return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
}
|
eb7bfb39-29d7-4d9c-b33e-17dd21959323
| 4
|
public Query retryResult(String query) {
boolean passed = false;
Connection connection = open();
Statement statement = null;
ResultSet result = null;
while (!passed) {
try {
statement = connection.createStatement();
result = statement.executeQuery(query);
passed = true;
return new Query(connection, statement, result);
} catch (SQLException ex) {
if (ex.getMessage().toLowerCase().contains("locking") || ex.getMessage().toLowerCase().contains("locked")) {
passed = false;
} else {
this.writeError("Error at SQL Query: " + ex.getMessage(), false);
}
}
}
return null;
}
|
3b9246ed-e18e-40ab-82d2-505c65021ce6
| 1
|
public void UpdateAll(float delta)
{
Update(delta);
for(GameObject child : m_children)
child.UpdateAll(delta);
}
|
204c0375-a1f0-41ac-acaa-b66b48ebb2be
| 6
|
public void init(String n,int id){
if(n.equals("Creneau"))
etat = Etat.Creneau;
else if (n.equals("Creneau1")){
etat = Etat.Creneau1;
try {
this.creneau = new Seance(id);
} catch (SQLException ex) {
Logger.getLogger(New_Etudiant.class.getName()).log(Level.SEVERE, null, ex);
}
this.nom.setText(creneau.getNom());
}
for(String nomUE : UE.list_nom_UE(this.id_promo)){
this.ue.addItem(nomUE);
}
for(String nomIntervenant : Intervenant.list_nom_Intervenant()){
this.intervenant.addItem(nomIntervenant);
}
for(String nomSalle : Salle.list_nom_Salle()){
this.salle.addItem(nomSalle);
}
}
|
0ac32138-85ec-48e0-8082-b2fd28b209ec
| 5
|
private static void printGroup(ContactGroupEntry groupEntry) {
System.err.println("Id: " + groupEntry.getId());
System.err.println("Group Name: " + groupEntry.getTitle().getPlainText());
System.err.println("Last Updated: " + groupEntry.getUpdated());
System.err.println("Extended Properties:");
for (ExtendedProperty property : groupEntry.getExtendedProperties()) {
if (property.getValue() != null) {
System.err.println(" " + property.getName() + "(value) = " +
property.getValue());
} else if (property.getXmlBlob() != null) {
System.err.println(" " + property.getName() + "(xmlBlob) = " +
property.getXmlBlob().getBlob());
}
}
System.err.print("Which System Group: ");
if (groupEntry.hasSystemGroup()) {
SystemGroup systemGroup
= SystemGroup.fromSystemGroupId(groupEntry.getSystemGroup().getId());
System.err.println(systemGroup);
} else {
System.err.println("(Not a system group)");
}
System.err.println("Self Link: " + groupEntry.getSelfLink().getHref());
if (!groupEntry.hasSystemGroup()) {
// System groups are not modifiable, and thus don't have an edit link.
System.err.println("Edit Link: " + groupEntry.getEditLink().getHref());
}
System.err.println("-------------------------------------------\n");
}
|
8187f1ac-306d-4f93-8b2b-0a4566229274
| 7
|
public final void loadMonsterRate(final boolean first) {
final int spawnSize = monsterSpawn.size();
/* if (spawnSize >= 25 || monsterRate > 1.5) {
maxRegularSpawn = Math.round(spawnSize / monsterRate);
} else {
maxRegularSpawn = Math.round(spawnSize * monsterRate);
}*/
maxRegularSpawn = Math.round(spawnSize * monsterRate);
if (maxRegularSpawn < 2) {
maxRegularSpawn = 2;
} else if (maxRegularSpawn > spawnSize) {
maxRegularSpawn = spawnSize - (spawnSize / 15);
}
Collection<Spawns> newSpawn = new LinkedList<Spawns>();
Collection<Spawns> newBossSpawn = new LinkedList<Spawns>();
for (final Spawns s : monsterSpawn) {
if (s.getCarnivalTeam() >= 2) {
continue; // Remove carnival spawned mobs
}
if (s.getMonster().getStats().isBoss()) {
newBossSpawn.add(s);
} else {
newSpawn.add(s);
}
}
monsterSpawn.clear();
monsterSpawn.addAll(newBossSpawn);
monsterSpawn.addAll(newSpawn);
if (first && spawnSize > 0) {
MapTimer.getInstance().register(new Runnable() {
@Override
public void run() {
respawn(false);
}
}, createMobInterval);
}
}
|
d8f53bc7-ba3f-4d17-a3e9-77d02a01cdff
| 5
|
public static void sort(double[] a)
{
int N = a.length;
// Sentinel
for (int i = N - 1; i > 0; i--)
{
if (a[i] < a[i - 1])
{
double t = a[i];
a[i] = a[i - 1];
a[i - 1] = t;
}
}
// Sort a[] into increasing order.
for (int i = 2; i < N; i++)
{ // Insert a[i] among a[i-1], a[i-2],
// a[i-3]... ..
int j = i;
double t = a[j];
try
{
while (t < a[j - 1])
{
a[j] = a[j - 1];
j--;
}
}
catch (Exception e)
{
System.out.println(j + " " + i);
System.exit(1);
}
a[j] = t;
}
}
|
c56c0809-af6f-4c9b-b108-b4fbf9371829
| 6
|
private double[][] enlarge(double[][] small, int factor){
int smallXSize = small.length;
int smallYSize = small[0].length;
int largeXSize = smallXSize*factor;
int largeYSize = smallYSize*factor;
double[][] large = new double[largeXSize][largeYSize];
for(int y=0; y<largeYSize; y+=factor) {
for (int x = 0; x < largeXSize; x++) {
if (x % factor == 0) { //we are on a point provided by the small grid
large[x][y] = small[x/factor][y/factor];
} else{
//System.out.printf("x %d, y %d\n", x, y);
//System.out.printf("Interpolating from %d,%d to %d,%d\n\n",x/factor,y/factor,(x/factor+1)%(smallXSize),y/factor);
large[x][y] = interpolate(
small[x/factor][y/factor],
small[(x/factor+1)%(smallXSize)][y/factor],
(double)(x%factor)/factor);
}
}
}
for(int x=0; x<largeXSize; x++){
for(int y=0; y<largeYSize; y++){
if(y%factor == 0){
continue;
}
//System.out.printf("x %d, y %d\n", x, y);
large[x][y] = interpolate(
large[x][y-y%factor],
large[x][(y-y%factor+factor)%largeYSize],
(double)(y%factor)/factor);
}
}
return large;
}
|
1004e114-9094-4d00-bf3b-f56a636527d7
| 7
|
public Snapshot validate() {
if(f_0 != null || s_0 != null || v2_0 != null || (v3_0 != null && v3_0.len() > 0) || c_0 != null || d_0 != null) return this;
return null;
}
|
24634eb8-4e75-496c-9830-453d367440f2
| 4
|
public void start() {
// crawl through all pages and grab every link you can get
System.out.print("CRAWLING #" + pagesCrawled);
crawlPage(ROOT_URL);
if (GUI != null) GUI.notifyCrawlingFinished();
// Print results
System.out.println("\n\nINTERNAL LINKS:");
int i = 1;
for (Map.Entry<String, Integer> entry : internalLinks.entrySet()) {
System.out.println("[" + i + "] [" + entry.getValue() + "] " + entry.getKey());
i++;
}
System.out.println("\nEXTERNAL LINKS:");
i = 1;
for (Map.Entry<String, Integer> entry : externalLinks.entrySet()) {
System.out.println("[" + i + "] [" + entry.getValue() + "] " + entry.getKey());
i++;
}
System.out.println("\nINTERNAL / EXTERNAL IMAGES:");
i = 1;
for (Map.Entry<String, Integer> entry : imageLinks.entrySet()) {
System.out.println("[" + i + "] [" + entry.getValue() + "] " + entry.getKey());
i++;
}
// Create XML-file
XMLOutput.createXmlOutput(internalLinks, externalLinks, imageLinks, new File("output.xml"));
}
|
64b74cfd-f2d1-466f-9d7e-37b319419a76
| 9
|
public void writeReducedOtuSpreadsheetsWithTaxaAsColumns(
File newFilePath, int numTaxaToInclude) throws Exception
{
HashSet<String> toInclude = new LinkedHashSet<String>();
HashMap<String, Double> taxaSorted =
getTaxaListSortedByNumberOfCounts();
numTaxaToInclude = Math.min(numTaxaToInclude, taxaSorted.size());
for( String s : taxaSorted.keySet() )
{
if( numTaxaToInclude > 0 )
{
toInclude.add(s);
numTaxaToInclude--;
}
}
//System.out.println("Including " + toInclude);
if(toInclude.contains("other"))
throw new Exception("Other already defined");
HashMap<String, Double> otherCounts =new HashMap<String,Double>();
for( int x=0; x < this.getSampleNames().size(); x++)
{
double counts =0;
for(int y=0; y < this.getOtuNames().size(); y++)
if( ! toInclude.contains(this.getOtuNames().get(y)))
counts += this.dataPointsUnnormalized.get(x).get(y);
otherCounts.put(this.getSampleNames().get(x), counts);
}
BufferedWriter writer = new BufferedWriter(new FileWriter(newFilePath));
writer.write("sample");
for(String s : toInclude)
writer.write("\t" + s);
writer.write("\tother\n");
for(int x=0;x < this.sampleNames.size(); x++)
{
writer.write(this.sampleNames.get(x));
for(String s : toInclude)
{
writer.write( "\t" + this.dataPointsUnnormalized.get(x).get(getIndexForOtuName(s)) );
}
writer.write("\t" + otherCounts.get(this.sampleNames.get(x)) + "\n" );
}
writer.flush(); writer.close();
}
|
501d3d98-008c-487b-b2ea-03d8c41d86da
| 5
|
private void realput(URL loc, byte[] data) {
FileContents file;
try {
try {
file = back.get(loc);
} catch(FileNotFoundException e) {
back.create(loc, data.length);
file = back.get(loc);
}
if(file.getMaxLength() < data.length) {
if(file.setMaxLength(data.length) < data.length) {
back.delete(loc);
return;
}
}
OutputStream s = file.getOutputStream(true);
try {
s.write(data);
} finally {
s.close();
}
} catch(IOException e) {
return;
} catch(Exception e) {
/* There seems to be a strange bug in NetX. */
return;
}
}
|
51c6c9c4-01bd-4102-962d-9fe26fff563b
| 7
|
private void performSecurityOperation(APDU apdu) {
byte[] buffer = apdu.getBuffer();
short p1p2 = Util.makeShort(buffer[ISO7816.OFFSET_P1], buffer[ISO7816.OFFSET_P2]);
short len;
switch (p1p2) {
case (short)0x9e9a:
byte[] counter = signCount.getData();
if (!chv1.isValidated()) {
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
}
if (!chv) { chv1.reset(); }
len = receiveData(apdu, tmpData);
sig.init(keySign.getPrivate(), Cipher.MODE_ENCRYPT);
len = sig.doFinal(tmpData, (short)0, len, tmpData, (short)0);
if (counter[2] < 255) {
counter[2]++;
} else {
counter[2] = 0;
if (counter[1] < 255) {
counter[1]++;
} else {
counter[1] = 0;
counter[0]++;
}
}
sendData(apdu, tmpData, len);
return;
case (short)0x8086:
if (!chv2.isValidated()) {
ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
}
len = receiveData(apdu, tmpData);
cipher.init(keyDecrypt.getPrivate(), Cipher.MODE_DECRYPT);
len = cipher.doFinal(tmpData, (short)1, (short)(len - 1), tmpData, (short)0);
sendData(apdu, tmpData, len);
return;
default:
ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
}
}
|
50682019-c4da-45dd-9cae-0e1429a9a9ba
| 8
|
public boolean isMatchHelp(String s, String p) {
if (p.length() == 0) {
if (s.length() == 0)
return true;
return false;
}
if (s.length() == 0) {
if (p.equals("*"))
return true;
return false;
}
if (p.charAt(0) == '?')
return isMatchHelp(s.substring(1), p.substring(1));
if (p.charAt(0) == '*')
return isMatchHelp(s, p.substring(1)) || isMatchHelp(s.substring(1), p);
if (s.charAt(0) == p.charAt(0))
return isMatchHelp(s.substring(1), p.substring(1));
return false;
}
|
deb6c8d3-cf99-46ea-becc-f330d6759541
| 4
|
public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection();
String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
writeBody(connection, body);
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
for (Object profile : array) {
JSONObject jsonProfile = (JSONObject) profile;
String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name");
UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}
if (rateLimiting && i != requests - 1) {
Thread.sleep(100L);
}
}
return uuidMap;
}
|
2e7c6bcd-22b5-4ea8-ab5e-1b38b73045fe
| 1
|
public static double showSign (double value) {
if (value == 0.0) {
return 0.0;
}
else {
return (value / Math.abs(value));
}
}
|
92974723-57cd-4b5f-9ffc-df4d26d5a7ed
| 1
|
public Float getFloatItem(String... names) throws ReaderException {
try {
return Float.parseFloat(getItem(names).toString());
} catch (NumberFormatException e) {
throw new ReaderException("No key exists with this type, keys: " + _parseMessage(names) + ". In file: " + ConfigurationManager.config_file_path);
}
}
|
1f92dd8e-c878-4331-8fad-fee029f11ed5
| 4
|
public Environment<K,V> locateChild( Path<String> path ) {
if( path == null )
throw new NullPointerException( "Cannot locate children by null-paths." );
if( path.getLength() == 0 )
return this;
Environment<K,V> child = this.getChild( path.getFirstElement() );
if( child == null || path.getLength() == 1 ) {
// No such child found or end-of-path reached
return child;
}
// Child found and path has more elements.
return child.locateChild( path.getTrailingPath() );
}
|
92a0a1fa-79fe-4943-8e34-486c21e1d1c1
| 7
|
public LibraryBean[] showByTags(String[] tags){
//Get all idlibrary that have tags
LinkedList<Integer> list = new LinkedList<>();
TagListDAO tagListDAO = new TagListDAO(connection);
for(int i = 0; i < tags.length; i++){
list.addAll(tagListDAO.getAllLibraryIdByTag(tags[i]));
}
Collections.sort(list);
//Get all idlibrary if they was founded more that threshold times
int threshold = (tags.length < 3 || list.size() < 4) ? 0 : (int)Math.ceil(tags.length * 0.5);
Integer[] array = new Integer[list.size()];
list.toArray(array);
LinkedList<Integer> libraryIdList = new LinkedList<>();
int prev = -1;
int count = 0;
for(int i = 0; i < array.length; i++){
if(array[i] != prev){
if(count >= threshold) {
libraryIdList.add(array[i]);
}
prev = array[i];
count = 1; //it's first time at this step
} else {
count++;
}
}
//Get LibraryBean array objects from idlibrary array
Integer[] libraryIdArray = new Integer[libraryIdList.size()];
libraryIdList.toArray(libraryIdArray);
LinkedList<LibraryBean> resultList = new LinkedList<>();
LibraryDAO libraryDAO = new LibraryDAO(connection);
for(int i = 0; i < libraryIdArray.length; i++){
LibraryBean bean = libraryDAO.getLibrary(libraryIdArray[i]);
resultList.add(bean);
}
LibraryBean[] result = new LibraryBean[resultList.size()];
return resultList.toArray(result);
}
|
661fc10b-65de-4109-9368-987ca57e1683
| 7
|
public void updateCheck()
{
//check to make sure we have a base folder system to work out of
//Normally will generate files it need if not something is wrong
addToConsole("Checking File System");
Boolean fileExist = FileManager.rootFileCheck();
if(fileExist)
{
if(FileManager.errors.size() > 0)
{
addToConsole("Main file check Debug:");
for(int i = 0; i < FileManager.errors.size(); i++)
{
addToConsole(" "+FileManager.errors.get(i));
}
}
//Check for the update list that is used to manage mods
Boolean uc = FileManager.updateList();
if(!uc)
{
addToConsole("Critical: Failed To Get List");
if(new File(FileManager.updaterDir+"/ModList.list").exists())
{
addToConsole("Defaulting to old list");
}
else
{
addToConsole("Critical: No Update List Found.");
}
}
}
else
{
addToConsole("Critical: Main file check failed");
if(FileManager.errors.size() > 0)
{
addToConsole("Main File Check Debug:");
for(int i = 0; i < FileManager.errors.size(); i++)
{
addToConsole(" "+FileManager.errors.get(i));
}
}
}
}
|
bdea73f2-96d6-4c6b-9d0b-d6ac934f41e4
| 7
|
public void mousePressed(MouseEvent e) {
if (scrollableTabLayoutEnabled()) {
MouseListener[] ml = tabPane.getMouseListeners();
for (int i = 0; i < ml.length; i++) {
ml[i].mousePressed(e);
}
}
if (!tabPane.isEnabled()) {
return;
}
int tabIndex = getTabAtLocation(e.getX(), e.getY());
if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) {
if (tabIndex == tabPane.getSelectedIndex()) {
if (tabPane.isRequestFocusEnabled()) {
tabPane.requestFocus();
tabPane.repaint(getTabBounds(tabPane, tabIndex));
}
} else {
tabPane.setSelectedIndex(tabIndex);
}
}
}
|
0285fae5-f48c-49e8-ab17-3d1070c38d8f
| 3
|
public Position getRandomPassablePos(double radius) {
Position middlePos = new Position(this.getWidth() / 2,
this.getHeight() / 2);
Position pos = new Position(this.random.nextDouble() * this.getWidth(),
this.random.nextDouble() * this.getHeight());
for (int attempt = 0; attempt < 5; attempt++) {
if(!this.isImpassable(pos, radius) && this.liesWithinBoundaries(pos, radius))
return pos;
else
pos = new Position((middlePos.getX() - pos.getX()) / 2+ pos.getX(),
(middlePos.getY() - pos.getY()) / 2 + pos.getY());
}
return null;
}
|
705cb93e-8af7-4c0e-93a0-bfb8836c4c2a
| 2
|
private boolean testaaPiste(Piste piste) {
if(this.osuikoJohonkin == EsteenTyyppi.QUIT) {
return false;
}
EsteenTyyppi este = taso.onkoPisteessaEste(piste);
if (este != null) {
this.osuikoJohonkin = este;
return true;
}
return false;
}
|
97080377-4014-4e18-b0f9-61f89eb76ff8
| 0
|
@Override
public void resetProperty(String key) {
this.current_values.put(key, this.default_values.get(key));
}
|
386f8149-9a4e-4c95-ae70-47a750d63f64
| 6
|
protected void populateResults(int year, boolean wantPrev) {
colName.setCellValueFactory(new PropertyValueFactory<SgaPOJO,String>("Name"));
colCat.setCellValueFactory(new PropertyValueFactory<SgaPOJO,String>("Category"));
colPyReq.setCellValueFactory(new PropertyValueFactory<SgaPOJO,Double>("PrevYearReq"));
colPyApp.setCellValueFactory(new PropertyValueFactory<SgaPOJO,Double>("PrevYearApp"));
colCyReq.setCellValueFactory(new PropertyValueFactory<SgaPOJO,Double>("CurrYearReq"));
colCyApp.setCellValueFactory(new PropertyValueFactory<SgaPOJO,Double>("CurrYearApp"));
Connection connect = null;
try {
Class.forName("org.sqlite.JDBC");
connect = DriverManager.getConnection(DatabaseInfo.DB_URL);
Statement stmt = connect.createStatement();
stmt.executeUpdate("DROP VIEW IF EXISTS CurrentYear");
stmt.executeUpdate("DROP VIEW IF EXISTS PreviousYear");
stmt.executeUpdate("DROP VIEW IF EXISTS RetroactiveYears");
stmt.executeUpdate("DROP VIEW IF EXISTS ProactiveYears");
stmt.executeUpdate("DROP VIEW IF EXISTS SgaAllocationResults");
stmt.executeUpdate("CREATE VIEW CurrentYear AS SELECT * FROM SgaAllocation WHERE Year="+year+";");
ResultSet rset = stmt.executeQuery("SELECT * FROM CurrentYear;");
boolean barrier = wantPrev;
if(barrier) {
ResultSet check = stmt.executeQuery("SELECT * FROM SgaAllocation WHERE Year="+(year-1)+";");
barrier = barrier && check.next();
}
if(barrier) {
stmt.executeUpdate("CREATE VIEW PreviousYear AS SELECT * FROM SgaAllocation WHERE Year="+(year-1)+";");
stmt.executeUpdate("CREATE VIEW ProactiveYears AS"
+ " SELECT CY.Name, CY.Category,"
+ " PY.Requested AS PrevYearReq, PY.Approved AS PrevYearApp,"
+ " CY.Requested AS CurrYearReq, CY.Approved AS CurrYearApp"
+ " FROM CurrentYear AS CY LEFT OUTER JOIN PreviousYear AS PY"
+ " ON CY.Name=PY.Name AND CY.Category=PY.Category;");
stmt.executeUpdate("CREATE VIEW RetroactiveYears AS"
+ " SELECT PY.Name, PY.Category,"
+ " PY.Requested AS PrevYearReq, PY.Approved AS PrevYearApp,"
+ " CY.Requested AS CurrYearReq, CY.Approved AS CurrYearApp"
+ " FROM PreviousYear AS PY LEFT OUTER JOIN CurrentYear AS CY"
+ " ON CY.Name=PY.Name AND CY.Category=PY.Category;");
rset = stmt.executeQuery("SELECT * FROM ProactiveYears UNION SELECT * FROM RetroactiveYears;");
} else {
rset = stmt.executeQuery("SELECT * FROM CurrentYear;");
}
ObservableList<SgaPOJO> csvData = FXCollections.observableArrayList();
while(rset.next()) {
String name = rset.getString("Name");
String category = rset.getString("Category");
double prevYearReq = 0;
double prevYearApp = 0;
double currYearReq = 0;
double currYearApp = 0;
if(barrier) {
prevYearReq = rset.getInt("PrevYearReq");
prevYearApp = rset.getInt("PrevYearApp");
currYearReq = rset.getInt("CurrYearReq");
currYearApp = rset.getInt("CurrYearApp");
} else {
currYearReq = rset.getInt("Requested");
currYearApp = rset.getInt("Approved");
}
csvData.add(new SgaPOJO(name, category, prevYearReq, prevYearApp, currYearReq, currYearApp));
}
sgaTable.setItems(csvData);
connect.close();
} catch (Exception e) {
System.out.println(e);
message.setText(e.getMessage() + " Please contact the database admin for help.");
}
}
|
a9b4d34a-a140-406d-a035-4e1bd2b0c0a5
| 2
|
public String join(String separator) throws JSONException {
int len = length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i += 1) {
if (i > 0) {
sb.append(separator);
}
sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
}
return sb.toString();
}
|
f2b2e87a-04aa-4284-b071-2cde14702116
| 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(FrameZbiory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FrameZbiory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FrameZbiory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FrameZbiory.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 FrameZbiory().setVisible(true);
}
});
}
|
234d9fbe-4dc8-4214-84db-936452a4e036
| 2
|
public void changeWidth(int width)
{
for(int i=0;i<markers;i++)
{
if(marker[i].isSelectedWidth())
{
marker[i].changeWidth(width);
// break;
}
}
}
|
8ff7ebc1-ebe0-4672-ad47-dc06b8742e0e
| 7
|
public boolean blocksColor(Point p, int x, int y, int i, int a,
ArrayList<Integer> list) {
Point[] arr = { new Point(x + 1, y), new Point(x, y + 1),
new Point(x - 1, y), new Point(x, y - 1) };
return board.getCell(p.x, p.y).isFull()
// Cell is full
&& i != (player.getColor())
// the color being checked is not the ai self
&& (playerCount != 2 || (i != ((player.getColor() + 1) % 2 + player
.getColor())))
// The color being checked is not the ai's second color (in 2p
// game)
&& list.get(i) == 0
// the given player has no pieces in this cell
&& board.getCell(p.x, p.y).getOwnerList().get(i) == 0
// the given player has no pieces in the neighbouring cell
&& board.isCell(arr[(a + 2) % 4].x, arr[(a + 2) % 4].y)
// the cell across the neighbouring cell exists
&& board.getCell(arr[(a + 2) % 4].x, arr[(a + 2) % 4].y)
.getOwnerList().get(i) == 0;
// The cell across the neighbouring cell also doesnt have a piece from
// the given player.
}
|
4ad414f6-5b10-43ce-a10a-ea45cda4ce5b
| 6
|
private void createTablePage() {
Composite parent = getContainer();
// XXX move all the creation into its own component
Canvas canvas = new Canvas(parent, SWT.None);
GridLayout layout = new GridLayout(6, false);
canvas.setLayout(layout);
// create the header part with the search function and Add/Delete rows
Label searchLabel = new Label(canvas, SWT.NONE);
searchLabel.setText("Filter: ");
final Text searchText = new Text(canvas, SWT.BORDER | SWT.SEARCH);
searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.HORIZONTAL_ALIGN_FILL));
// Create and configure the buttons
Button duplicate = new Button(canvas, SWT.PUSH | SWT.CENTER);
duplicate.setText("Duplicate");
duplicate.setToolTipText("Duplicate the current row");
GridData buttonDuplicateGridData = new GridData(
GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonDuplicateGridData.widthHint = 80;
duplicate.setLayoutData(buttonDuplicateGridData);
duplicate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
if (row != null) {
model.duplicateRow(row);
tableModified();
}
}
});
Button insert = new Button(canvas, SWT.PUSH | SWT.CENTER);
insert.setText("Insert Row");
insert.setToolTipText("Insert a new row before the current one");
GridData buttonInsertGridData = new GridData(
GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonInsertGridData.widthHint = 80;
insert.setLayoutData(buttonInsertGridData);
insert.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
if (row != null) {
model.addRowAfterElement(row);
tableModified();
}
}
});
/*
* insert.addKeyListener(new KeyAdapter() { public void
* keyPressed(KeyEvent e) { //if(((e.stateMask & SWT.CTRL) != 0) &
* (e.keyCode == 'd')) { //if (e.stateMask == SWT.CTRL && e.keyCode ==
* 'd') { if (e.character == SWT.DEL) { CSVRow row = (CSVRow)
* ((IStructuredSelection)
* tableViewer.getSelection()).getFirstElement(); if (row != null) {
* model.addLineAfterElement(row); tableViewer.refresh();
* tableModified(); } } } });
*/
Button add = new Button(canvas, SWT.PUSH | SWT.CENTER);
add.setText("Add Row");
add.setToolTipText("Add a new row at the end of the file");
GridData buttonAddGridData = new GridData(
GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonAddGridData.widthHint = 80;
add.setLayoutData(buttonAddGridData);
add.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
model.addRow();
tableModified();
}
});
Button delete = new Button(canvas, SWT.PUSH | SWT.CENTER);
delete.setText("Delete Row");
delete.setToolTipText("Delete the current row");
GridData buttonDelGridData = new GridData(
GridData.HORIZONTAL_ALIGN_BEGINNING);
buttonDelGridData.widthHint = 80;
delete.setLayoutData(buttonDelGridData);
delete.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
while(row != null){
row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
if (row != null) {
model.removeRow(row);
tableModified();
}
}
}
});
/*
* insert.addKeyListener(new KeyAdapter() { public void
* keyPressed(KeyEvent e) { if (e.stateMask == SWT.CTRL && e.keyCode ==
* 'd') { CSVRow row = (CSVRow) ((IStructuredSelection)
* tableViewer.getSelection()).getFirstElement(); if (row != null) {
* model.removeLine(row); tableViewer.refresh(); tableModified(); } } }
* });
*/
/*
*
* // manage 1st line - should only be visible if global option is set
* if (pref.getUseFirstLineAsHeader()) { Label encodingLineLabel = new
* Label(canvas, SWT.NONE);
* encodingLineLabel.setText("Display 1st line"); final Button
* encodingLineBtn = new Button(canvas, SWT.CHECK);
* encodingLineBtn.setLayoutData(new
* GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
* encodingLineBtn.setSelection(true);
* encodingLineBtn.addSelectionListener(new SelectionAdapter() { public
* void widgetSelected(SelectionEvent e) {
* model.displayFirstLine(encodingLineBtn.getSelection());
* updateTableFromTextEditor(); } }); }
* sensitiveBtn.addSelectionListener(new SelectionAdapter() { public
* void widgetSelected(SelectionEvent e) {
* tableFilter.setSearchText(searchText.getText(),
* sensitiveBtn.getSelection());
* labelProvider.setSearchText(searchText.getText());
* tableViewer.refresh(); } });
*/
tableViewer = new TableViewer(canvas, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
tableViewer.setUseHashlookup(true);
final Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// set the sorter for the table
tableSorter = new CSVTableSorter();
tableViewer.setSorter(tableSorter);
// set a table filter
final CSVTableFilter tableFilter = new CSVTableFilter();
tableViewer.addFilter(tableFilter);
// add the filtering and coloring when searching specific elements.
searchText.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent ke) {
tableFilter.setSearchText(searchText.getText(),
model.getSensitiveSearch());
String filterText = searchText.getText();
for (int i = 0; i < tableViewer.getColumnProperties().length; i++) {
CellLabelProvider labelProvider = tableViewer
.getLabelProvider(i);
if(labelProvider != null){
((CSVLabelProvider) labelProvider)
.setSearchText(filterText);
}
}
tableViewer.refresh();
}
});
/*
* // create a TableCursor to navigate around the table final
* TableCursor cursor = new TableCursor(table, SWT.NONE); // create an
* editor to edit the cell when the user hits "ENTER" // while over a
* cell in the table final ControlEditor editor = new
* ControlEditor(cursor); editor.grabHorizontal = true;
* editor.grabVertical = true;
*
* cursor.addSelectionListener(new SelectionAdapter() { // This is
* called as the user navigates around the table public void
* widgetSelected(SelectionEvent e) { // Select the row in the table
* where the TableCursor is table.setSelection(new TableItem[]
* {cursor.getRow()}); }
*
* // when the user hits "ENTER" in the TableCursor, // pop up a text
* editor so that user can change the text of the cell public void
* widgetDefaultSelected(SelectionEvent e) { // Begin an editing session
* final Text text = new Text(cursor, SWT.NONE);
*
* // Copy the text from the cell to the Text int column =
* cursor.getColumn(); text.setText(cursor.getRow().getText(column));
*
* // Add a handler to detect key presses text.addKeyListener(new
* KeyAdapter() { public void keyPressed(KeyEvent e) { // tab will save
* & move to the next column if (e.character == SWT.TAB) { TableItem row
* = cursor.getRow(); int column = cursor.getColumn();
* row.setText(column, text.getText()); text.dispose();
* cursor.setSelection(row, column+1); tableModified(); } // close the
* text editor and copy the data over // when the user hits "ENTER" if
* (e.character == SWT.CR) { TableItem row = cursor.getRow();
* row.setText(cursor.getColumn(), text.getText()); tableModified();
* text.dispose(); } // close the text editor when the user hits "ESC"
* if (e.character == SWT.ESC) { text.dispose(); } } }); // close the
* text editor when the user tabs away text.addFocusListener(new
* FocusAdapter() { public void focusLost(FocusEvent e) {
* text.dispose(); } }); editor.setEditor(text); text.setFocus(); } });
*
* /* // Hide the TableCursor when the user hits the "CTRL" or "SHIFT"
* key. // This allows the user to select multiple items in the table.
* cursor.addKeyListener(new KeyAdapter() { public void
* keyPressed(KeyEvent e) {
*
* // delete line if (e.character == SWT.DEL) { TableItem row =
* cursor.getRow(); tableModified(); row.dispose();
* //table.showItem(row); //cursor.setSelection(row, 0); }
*
* // insert line if (e.character == (char) SWT.F8) { TableItem row =
* cursor.getRow(); row.dispose(); }
*
* // add line
*
* cursor.setVisible(true); cursor.setFocus();
*
* if (e.keyCode == SWT.CTRL || e.keyCode == SWT.SHIFT || (e.stateMask &
* SWT.CONTROL) != 0 || (e.stateMask & SWT.SHIFT) != 0) {
* cursor.setVisible(false); return; } } });
*
* // When the user double clicks in the TableCursor, pop up a text
* editor so that // they can change the text of the cell.
* cursor.addMouseListener(new MouseAdapter() { public void
* mouseDown(MouseEvent e) { final Text text = new Text(cursor,
* SWT.NONE); TableItem row = cursor.getRow(); int column =
* cursor.getColumn(); text.setText(row.getText(column));
* text.addKeyListener(new KeyAdapter() { public void
* keyPressed(KeyEvent e) { // close the text editor and copy the data
* over // when the user hits "ENTER" if (e.character == SWT.CR) {
* TableItem row = cursor.getRow(); int column = cursor.getColumn();
* row.setText(column, text.getText()); tableModified(); text.dispose();
* } // close the text editor when the user hits "ESC" if (e.character
* == SWT.ESC) { text.dispose(); } } }); // close the text editor when
* the user clicks away text.addFocusListener(new FocusAdapter() {
* public void focusLost(FocusEvent e) { text.dispose(); } });
* editor.setEditor(text); text.setFocus(); } });
*
* // Show the TableCursor when the user releases the "SHIFT" or "CTRL"
* key. // This signals the end of the multiple selection task.
* table.addKeyListener(new KeyAdapter() { public void
* keyReleased(KeyEvent e) {
*
* if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0)
* return; if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) !=
* 0) return; if (e.keyCode != SWT.CONTROL && (e.stateMask &
* SWT.CONTROL) != 0) return; if (e.keyCode != SWT.SHIFT && (e.stateMask
* & SWT.SHIFT) != 0) return;
*
* TableItem[] selection = table.getSelection(); TableItem row =
* (selection.length == 0) ? table.getItem(table.getTopIndex()) :
* selection[0]; table.showItem(row); cursor.setSelection(row, 0);
* cursor.setVisible(true); cursor.setFocus(); } });
*/
/* tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
CSVRow row = (CSVRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
DetailedView input = new DetailedView(Display.getDefault(), model.getHeader(), row);
input.open();
}
});*/
// Layout the viewer
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 6;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
tableViewer.getControl().setLayoutData(gridData);
addPage(canvas);
setPageText(indexTBL, "CSV Table");
}
|
32bf494f-6ca1-4075-946a-38fbbac3d6d2
| 6
|
private void btnCalcCoinageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalcCoinageActionPerformed
// TODO add your handling code here:
//validation for number entry; resets form if entry is not a numerical value
boolean floatTest = (MyUtils.isFloat(txtDollarAmount.getText()));
if (floatTest == false) {
txtDollarAmount.setText("");
txtDollarAmount.requestFocusInWindow();
} else{
float fmoneyValue = 0;
int imoneyValue = 0;
final int[] coinageValues = {25, 10, 5, 1};
int[] countOfCoins = new int[coinageValues.length];
int i = 0;
//get Dollar amount from form and make conversions needed for integer calculation and proper display
float moneyValueDisplayed = Float.parseFloat(txtDollarAmount.getText());
fmoneyValue = Float.parseFloat(txtDollarAmount.getText()) * 100;
imoneyValue = (int)fmoneyValue;
//display the dollar amount as entered, before * 100 multiplication, and add a dollar sign before it
//format the Dollar value displayed
txtDollarAmount.setText(MyUtils.moneyFormatting(moneyValueDisplayed));
//loop through the countOfCoins array
for (i = 0; i < coinageValues.length; i++) {
countOfCoins[i] = imoneyValue/coinageValues[i];
imoneyValue = imoneyValue - (countOfCoins[i] * coinageValues[i]);
}
if (countOfCoins[0] == 1){
txtQuarters.setText(countOfCoins[0] + " Quarter");
} else {
txtQuarters.setText(countOfCoins[0] + " Quarters");
}
if(countOfCoins[1] == 1){
txtDimes.setText(countOfCoins[1] + " Dime");
} else {
txtDimes.setText(countOfCoins[1] + " Dimes");
}
if(countOfCoins[2] == 1){
txtNickels.setText(countOfCoins[2] + " Nickel");
} else {
txtNickels.setText(countOfCoins[2] + " Nickels");
}
if(countOfCoins[3] == 1){
txtPennies.setText(countOfCoins[3] + " Penny");
} else {
txtPennies.setText(countOfCoins[3] + " Pennies");
}
}
}//GEN-LAST:event_btnCalcCoinageActionPerformed
|
d6f312bb-2702-4cd8-9dc9-c65c12a1ad8e
| 1
|
public Dimension getViewSize() {
return (viewIsUnbounded() ? getView().getPreferredSize() : super.getViewSize());
}
|
4b8a7e50-2486-4aef-94ad-b4c76fb3a333
| 5
|
public void weaponSwing(Arc2D.Double arc, Point p) {
boolean projectileHit = false;
Projectile projectile = null;
try {
for (String key : projectiles.keySet()) {
projectile = (Projectile) projectiles.get(key);
if (projectile != null) {
if (arc.intersects(projectile.getRect())) {
projectile.setIsDirty(true);
projectileHit = true;
}
}
}
} catch (ConcurrentModificationException concEx) {
//another thread was trying to modify projectiles while iterating
//we'll continue and the new item can be grabbed on the next update
}
if (projectileHit) {
SoundClip cl = new SoundClip(registry, "Player/HitProjectile", p);
}
}
|
520a273c-a17f-433d-8527-676c084cc62b
| 0
|
@Override
public String execute() throws Exception {
memberDAO.save(member);
return SUCCESS;
}
|
67efb8e0-df3a-46c9-ac8a-6a4dbbdcd369
| 0
|
public List<String> getMcEcho_ActiveChannels(){ return McEcho_ActiveChannels; }
|
b2227844-3e9b-489d-a5b6-fd08114206f7
| 2
|
public int reduceHealth(int damage)
{
health = health - damage;
if(health <= 0)
{
health = 0;
}
if(health > 200)
{
health = 200;
}
return health;
}
|
0f71a968-4d7a-4116-83ab-0e3eba4d046e
| 5
|
final AbstractFontRasterizer createFontRasterizer(BitmapFont class143, ImageSprite[] class207s,
boolean bool) {
int[] is = new int[class207s.length];
int[] is_60_ = new int[class207s.length];
boolean bool_61_ = false;
for (int i = 0; i < class207s.length; i++) {
is[i] = ((ImageSprite) class207s[i]).indexWidth;
is_60_[i] = ((ImageSprite) class207s[i]).indexHeight;
if (((ImageSprite) class207s[i]).alphaIndex != null)
bool_61_ = true;
}
if (bool) {
if (bool_61_)
throw new IllegalArgumentException
("Cannot specify alpha with non-mono font unless someone writes it");
return new h(this, aYa5121, class143, class207s, null);
}
if (bool_61_)
throw new IllegalArgumentException
("Cannot specify alpha with non-mono font unless someone writes it");
return new n(this, aYa5121, class143, class207s, null);
}
|
f78ea5fa-750a-4348-832c-bb25baf2b2bf
| 3
|
public boolean esta(Recorrido x){
if(recorridos.isEmpty())
return false;
for(Recorrido r:recorridos)
if(r.equals(x))
return true;
return false;
}
|
f249c885-bc9c-4000-abc5-3913d25f4b92
| 3
|
public static void resetTextures() {
if (Rasterizer.textureStore == null) {
Rasterizer.textureStoreCount = 20;
if (Rasterizer.lowMem) {
Rasterizer.textureStore = new int[Rasterizer.textureStoreCount][16384];
} else {
Rasterizer.textureStore = new int[Rasterizer.textureStoreCount][0x10000];
}
for (int i = 0; i < 50; i++) {
Rasterizer.textureCache[i] = null;
}
}
}
|
33de8771-e1d0-422d-b222-77bba3e0836f
| 6
|
public void esborraRest(int tipus,int numRest){
switch (tipus){
case 1:
cgen.getCjtResGA().remove(numRest);
break;
case 2:
cgen.getCjtRestGS().remove(numRest);
break;
case 3:
cgen.getCjtRestAss().remove(numRest);
break;
case 4:
cgen.getCjtRestAss().remove(numRest);
break;
case 5:
cgen.getCjtRestS().remove(numRest);
break;
case 6:
cgen.getCjtRestAul().remove(numRest);
break;
}
}
|
bc0d3912-54e2-4cec-a038-1fb5802e64e4
| 8
|
void splitExp(Entity thnStore, int CUR_EXP)
{
if (thnStore.BLN_POPUP)
{
thnStore.send(""+(char)33+"You have lost "+CUR_EXP+" CUR_EXP\n");
} else
{
thnStore.chatMessage("You have lost "+CUR_EXP+" CUR_EXP\n");
}
thnStore.CUR_EXP -= CUR_EXP;
Vector vctStore;
double tp,
sidepoints=0;
Entity thnFront;
if (thnStore.bytSide == 1)
{
vctStore = vctSide2;
thnFront = thnFront1;
}else
{
vctStore = vctSide1;
thnFront = thnFront2;
}
int i,
i2=0;
Entity thnStore2;
tp=thnFront.getTotalPoints();
thnFront.lngDamDone = 0;
for (i=0;i<vctStore.size();i++)
{
thnStore2 = (Entity)vctStore.elementAt(i);
if (thnStore2.isPlayer())
{
sidepoints += thnStore.getTotalPoints();
}
}
try
{
for (i=0;i<vctStore.size();i++)
{
i2 = 0;
thnStore2 = (Entity)vctStore.elementAt(i);
if (!thnStore2.isMob())
{
if (thnStore2.lngDamDone > thnFront.stats.getMAXHP())
{
thnStore2.lngDamDone = thnFront.stats.getMAXHP();
}
i2 = (int)(engGame.EXP_GAIN_MOD * (((tp/sidepoints)
+ (2*(thnStore2.lngDamDone/(double)thnFront.stats.getMAXHP())
* (tp/(double)thnStore2.getTotalPoints())))/3));
thnStore2.chatMessage("You get "+i2+" experience.\n");
thnStore2.CUR_EXP += i2;
}
thnStore2.lngDamDone = 0;
}
}catch(Exception e)
{
engGame.LOG.printError("splitExp()", e);
}
}
|
09a8eff4-25b6-46dc-b6d6-eebf2d1e2510
| 7
|
public Color getColor(int index, int c) {
if (blastCounter > 0) {
c = 255 - c;
return new Color(c, c, c);
}
if (index == 0)
return new Color(c, c / 2, c / 2);
if (index == 1)
return new Color(c / 2, c, c / 2);
if (index == 2)
return new Color(c / 2, c / 2, c);
if (index == 3)
return new Color(0, c, c);
if (index == 4)
return new Color(c, 0, c);
if (index == 5)
return new Color(c, c, 0);
return Color.black;
}
|
21257602-ddde-4453-b8b7-c3c0859ebc90
| 1
|
public static PlayerMovementServer getInstance() {
if(instance == null)
instance = new PlayerMovementServer();
return instance;
}
|
f5a5d8a9-2dc9-402a-bd63-350c2b4bf5ae
| 2
|
public ArrayList<Action> readData(String path2File) throws IOException {
logger.debug("Reading actions.");
ArrayList<Action> actions = new ArrayList<Action>();
BufferedReader br = new BufferedReader( new FileReader( path2File ) );
String line;
while ((line = br.readLine()) != null ) {
Action action = this.getAction(line);
if (action != null) {
actions.add(action);
}
}
br.close();
return actions;
}
|
1ee28013-3b51-4ba4-8d3a-32d178c38ea4
| 5
|
static void criaAreaNotificacao() {
//Verifica se n�o � poss�vel trabalhar com "TrayIcon"
if (!SystemTray.isSupported()) {
System.out.println("Não da pra fazer, nem tenta!");
return;
}
//Instancia��o de um objeto java.awt.PopupMenu
final PopupMenu pop = new PopupMenu();
//Instancia��o do objeto java.awt.SystemTray;
final SystemTray tray = SystemTray.getSystemTray();
//Cria��o do objeto TrayIcon, informando uma imagem e um t�tulo
trayIcon = new TrayIcon(createImage("../Img/icone.png", ""));
//set a frase que aparece quando você passa o mouse.
trayIcon.setToolTip("Support Manager");
//Cria��o dos itens do Menu Popup
MenuItem menuAbrir = new MenuItem("Abrir");
MenuItem menuFechar = new MenuItem("Fechar");
//Adicionando os itens ao Menu Popup
pop.add(menuAbrir);
pop.addSeparator();
pop.add(menuFechar);
//Setando o menu padrao no TrayIcon, que por acaso a este logo acima.
trayIcon.setPopupMenu(pop);
trayIcon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
pai.setVisible(true);
pai.setExtendedState(JFrame.MAXIMIZED_BOTH);
//Esta linha deixa a janela sobre as outras, caso ela apare�a minimizada.
try {
//Agora basta remover (ou esconder) o icone da area de Notificao
tray.remove(trayIcon);
trayIcon = null;
//Limpando a referencia ao Systemtray da classe Janelinha
pai.an.finalize();
} catch (Throwable e1) {
e1.printStackTrace();
}
}
});
//Adicionando o Icone na Area de Notificacao, como o menu ja esta dentro do icone,
//ira junto tambem.
try {
tray.add(trayIcon);
} catch (AWTException e) {
System.out.println("Não consegui pra fazer isso...");
}
//opção do menu "abrir"
menuAbrir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//Simplesmente deixa-se a janela vis�vel novamente.
pai.setVisible(true);
//Esta linha deixa a janela sobre as outras, caso ela apare�a minimizada.
pai.setExtendedState(JFrame.MAXIMIZED_BOTH);
try {
//Agora basta remover (ou esconder) o �cone da �rea de Notifica��o
tray.remove(trayIcon);
trayIcon=null;
//Limpando a refer�ncia ao Systemtray da classe Janelinha
pai.an.finalize();
} catch (Throwable e1) {
e1.printStackTrace();
}
}
});
//opção do menu fechar
menuFechar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
trayIcon.displayMessage(null, "Fechando...", TrayIcon.MessageType.NONE);
Thread.sleep(1000);
pai.dispose();
System.exit(0);
} catch (InterruptedException ex) {
JOptionPane.showMessageDialog(null, "Erro ao fechar");
}
}
});
}
|
33e06ef2-9856-4cb2-a3ae-50d9f223f555
| 9
|
protected void updatePaving(boolean inWorld) {
if (! inWorld) {
base().paving.updatePerimeter(this, null, false) ;
return ;
}
final Batch <Tile> toPave = new Batch <Tile> () ;
for (Tile t : Spacing.perimeter(area(), world)) {
if (t.blocked()) continue ;
boolean between = false ;
for (int n : N_INDEX) {
final int o = (n + 4) % 8 ;
final Tile
a = world.tileAt(t.x + N_X[n], t.y + N_Y[n]),
b = world.tileAt(t.x + N_X[o], t.y + N_Y[o]) ;
between =
(a != null && a.owner() instanceof NativeHut) &&
(b != null && b.owner() instanceof NativeHut) ;
if (between) break ;
}
if (between) toPave.add(t) ;
}
base().paving.updatePerimeter(this, toPave, true) ;
}
|
1148a769-032a-4403-93a3-fd870b42a6c4
| 5
|
public int readIdfTable(String file_name) throws SQLException, IOException{
//creating a hashmap which will have all tokens
int total_records =0;
String line_read;
Runtime runtime = Runtime.getRuntime();
BufferedReader buffReader_obj = new BufferedReader(new FileReader(file_name));
long time = System.currentTimeMillis();
StringBuffer valuesBuffer = new StringBuffer();
int valueList=0;
while((line_read = buffReader_obj.readLine())!= null){
HashMap<Long, Long> tokens_hashmap;
total_records = total_records +1;
StringTokenizer str_tok = new StringTokenizer(line_read,"\t");
str_tok.nextToken();
String tokens = str_tok.nextToken();
tokens_hashmap = getUniqueList(tokens);
for(Map.Entry<Long, Long> entry:tokens_hashmap.entrySet()){
valuesBuffer.append("("+entry.getKey().intValue()+","+1+","+0+"),");
valueList++;
}
if(total_records % 4000 == 0 || valueList >= 80000){
System.out.println("Total values getting inserted:"+valueList);
valueList=0;
String values = valuesBuffer.toString();
valuesBuffer = new StringBuffer();
String insertSql = "INSERT into idf (id,freq,idfScore) VALUES "+values.substring(0,values.length()-1)+" ON DUPLICATE KEY " +
"UPDATE freq = freq +VALUES(freq)";
PreparedStatement prestInsert = conn.prepareStatement(insertSql);
prestInsert.execute();
prestInsert.close();
System.out.println("Time elpased:"+(System.currentTimeMillis()-time)/1000);
System.out.println("Record Count: "+total_records);
long mb = 1024*1024;
System.out.println("Used Memory:"+(runtime.totalMemory() - runtime.freeMemory())/mb);
//Print free memory
System.out.println("Free Memory:"+runtime.freeMemory()/mb);
}
}
if(valuesBuffer.length()!=0){
String values = valuesBuffer.toString();
String insertSql = "INSERT into idf (id,freq,idfScore) VALUES "+values.substring(0,values.length()-1)+" ON DUPLICATE KEY " +
"UPDATE freq = freq +VALUES(freq)";
PreparedStatement prestInsert = conn.prepareStatement(insertSql);
prestInsert.execute();
prestInsert.close();
System.out.println("Done with the remaining");
}
buffReader_obj.close();
return total_records;
}
|
75e93dd2-0ce3-4e71-9341-dbfd07908254
| 5
|
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof StatusPessoa)) {
return false;
}
StatusPessoa other = (StatusPessoa) object;
if ((this.codstatuspessoa == null && other.codstatuspessoa != null) || (this.codstatuspessoa != null && !this.codstatuspessoa.equals(other.codstatuspessoa))) {
return false;
}
return true;
}
|
6ec15b8a-64c0-458e-99c0-56ffbe660851
| 0
|
protected Automaton getAutomaton() {
return automaton;
}
|
854bea69-4b1e-406a-8eea-6fd56a7ce291
| 1
|
private void saveList() {
int serverCount = servers.size();
for (int i = 0; i < serverCount; ++i)
storeDetails(i);
storage.store(servers);
MainWindow.getInstance().getMainMenu().loadFavoriteServersList(servers);
}
|
aefe20c5-7bc2-4bdc-b09d-805f61f95c93
| 2
|
public static void hangup() {
try {
if (rxSock != null) {
rxSock.close();
}
} catch (IOException ex) {
Alerter.getHandler().warning("Message Listener", "Unable to correctly hang up - some sockets may not have been closed.");
}
listener.interrupt();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.