method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
290f7521-24fe-4661-80dd-2a499a4f52f5 | 0 | public void setHistorialClinicoidHistorialClinico(Historialclinico historialClinicoidHistorialClinico) {
this.historialClinicoidHistorialClinico = historialClinicoidHistorialClinico;
} |
7c6d6106-ea37-4e89-b2dd-12858fae6752 | 7 | private void checkTransitionObject(Object[] action) {
if (action.length != 3 || action[0] == null || action[1] == null || action[2] == null
|| !(action[STATE_POS] instanceof State) || !(action[CHAR_POS] instanceof Character) || !(action[DIR_POS] instanceof Direction)) {
throw new InvalidTransitionException("Action must be a valid triple of State, Character, Direction");
}
checkState((State)action[STATE_POS]);
checkSymbol((Character)action[CHAR_POS]);
} |
ebc281d6-929d-4783-a0a7-5a9de8b40919 | 1 | public void evaluate_void(Object[] dl) throws Throwable {
if (Debug.enabled)
Debug.println("Wrong evaluateXXXX() method called,"+
" check value of getType().");
return;
}; |
9541e77c-f45a-40eb-9c8d-0df360c53a9a | 3 | public void postCollide()
{
if (cam.collideY)
{
speedY = 0;
}
else
{
speedY -= gravity;
}
if (cam.speedY <= 0 && cam.collideY)
{
jumpDelay = 0;
}
} |
80d9001f-7988-4fcb-83c5-a29d51009a25 | 6 | static final byte[] method878(String string, int i) {
anInt1571++;
int i_2_ = string.length();
if ((i_2_ ^ 0xffffffff) == -1)
return new byte[0];
int i_3_ = ~0x3 & 3 + i_2_;
int i_4_ = i_3_ / 4 * 3;
if (i_3_ + -2 >= i_2_
|| Class186_Sub1.method1399(7, string.charAt(i_3_ + -2)) == -1)
i_4_ -= 2;
else if (i_2_ <= i_3_ + -1
|| (Class186_Sub1.method1399(7, string.charAt(i_3_ - 1))
^ 0xffffffff) == 0)
i_4_--;
if (i > -92)
method877(-51, -45, (byte) -74);
byte[] is = new byte[i_4_];
Class318_Sub2.method2497(is, (byte) 0, string, 0);
return is;
} |
8116b2ab-75ab-4b2b-baca-67f204a060fe | 5 | public boolean validMovement(int myXCoor, int myYCoor, int targXCoor, int targYCoor, Board board){
double slope = Math.abs(super.getSlope(myXCoor,myYCoor,targXCoor,targYCoor));
if ((slope == 0.0 || slope == 1.0 || slope == 10.0) && (Math.abs(myXCoor - targXCoor) == 1 || Math.abs(myYCoor - targYCoor) == 1))
return true;
else
return false;
} |
55b69e2f-8449-44db-80a5-fa073b410c32 | 0 | public void setRemarks(String remarks) {
this.remarks = remarks;
} |
5fb2c899-f451-4122-b4ba-4bd8631a5aa9 | 3 | private void buildQueue(GeneralTreeNode<T> cur) {
if (cur != null)
queue.add(cur);
while (!queue.isEmpty()) {
GeneralTreeNode<T> tmp = queue.poll();
OutputQueue.add(tmp);
Iterator<GeneralTreeNode<T>> it = tmp.getChildren();
while (it.hasNext()) {
queue.add(it.next());
}
}
} |
d0a6d76a-3cc1-41d6-925d-262b79095b5a | 4 | public Tile getTile(int x, int y) {
if (0 > x || x >= width || 0 > y || y >= height)
return Tile.VOID;
return Tile.tiles[tiles[x + y * width]];
} |
13050f11-ba12-47ec-b59f-e5d46accb953 | 9 | public void execute(String path) {
IndexWriter writer = null;
IndexSearcher searcher = null;
try {
File indexDir = new File(System.getProperty("java.io.tmpdir"), "akka-index");
writer = openWriter(indexDir);
StopWatch stopWatch = new LoggingStopWatch();
execution.downloadAndIndex(path, writer);
stopWatch.stop(execution.getClass().getSimpleName());
searcher = openSearcher(indexDir);
TopDocs result = searcher.search(new MatchAllDocsQuery(), 100);
logger.info("Found {} results", result.totalHits);
for(ScoreDoc scoreDoc: result.scoreDocs) {
Document doc = searcher.doc(scoreDoc.doc);
logger.debug(doc.get("id"));
}
searcher.close();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
if (writer != null) {
try {
writer.rollback();
} catch (IOException ex1) {
logger.error(ex1.getMessage(), ex1);
}
}
} finally {
if (writer != null) {
try {
writer.close();
} catch (CorruptIndexException ex) {
logger.error(ex.getMessage(), ex);
} catch (IOException ex) {
logger.error(ex.getMessage(), ex);
}
}
if (searcher != null) {
try {
searcher.close();
} catch (IOException ex) {
logger.error(ex.getMessage(), ex);
}
}
}
} |
464832f4-6180-4385-8ba2-3b90b4a9a89e | 0 | public void setOption(int a){
option = a;
} |
e0db055d-d039-4f4f-b20f-ccc80495ff13 | 7 | public static int[][] houseWalls(Direction side,int xLoc, int yLoc, int size)
{
int yOffSet = 0;
int xOffSet = 0;
switch (side) {
case UP:
yOffSet = -(size * 20);
break;
case LEFT:
xOffSet = -(size * 20);
break;
}
int[][] locs = new int [400][2];
int i = 0;
int x;
for (x = 0; x <= (size * 20); x = x + 20)
{
for (int y = 0; y <= (size * 20); y = y + (size*20))
{
locs[i][0] = x + xLoc + xOffSet;
locs[i][1] = y + yLoc + yOffSet;
i++;
}
}
x = size*20;
for (int y = 20; y <= (size * 20)-20; y = y + 20)
{
locs[i][0] = x + xLoc + xOffSet;
locs[i][1] = y + yLoc + yOffSet;
i++;
}
x = 0;
for (int y = 20; y <= (size * 20) / 2 - 20; y = y + 20)
{
locs[i][0] = x + xLoc + xOffSet;
locs[i][1] = y + yLoc + yOffSet;
i++;
}
for (int y = size * 20; y >= (size * 20) / 2 + 20; y = y - 20)
{
locs[i][0] = x + xLoc + xOffSet;
locs[i][1] = y + yLoc + yOffSet;
i++;
}
return locs;
} |
8e1c7303-90ef-4c6c-a9f9-12f35a5983d7 | 5 | public void testForID_String() {
assertEquals(DateTimeZone.getDefault(), DateTimeZone.forID((String) null));
DateTimeZone zone = DateTimeZone.forID("Europe/London");
assertEquals("Europe/London", zone.getID());
zone = DateTimeZone.forID("UTC");
assertSame(DateTimeZone.UTC, zone);
zone = DateTimeZone.forID("+00:00");
assertSame(DateTimeZone.UTC, zone);
zone = DateTimeZone.forID("+00");
assertSame(DateTimeZone.UTC, zone);
zone = DateTimeZone.forID("+01:23");
assertEquals("+01:23", zone.getID());
assertEquals(DateTimeConstants.MILLIS_PER_HOUR + (23L * DateTimeConstants.MILLIS_PER_MINUTE),
zone.getOffset(TEST_TIME_SUMMER));
zone = DateTimeZone.forID("-02:00");
assertEquals("-02:00", zone.getID());
assertEquals((-2L * DateTimeConstants.MILLIS_PER_HOUR),
zone.getOffset(TEST_TIME_SUMMER));
zone = DateTimeZone.forID("-07:05:34.0");
assertEquals("-07:05:34", zone.getID());
assertEquals((-7L * DateTimeConstants.MILLIS_PER_HOUR) +
(-5L * DateTimeConstants.MILLIS_PER_MINUTE) +
(-34L * DateTimeConstants.MILLIS_PER_SECOND),
zone.getOffset(TEST_TIME_SUMMER));
try {
DateTimeZone.forID("SST");
fail();
} catch (IllegalArgumentException ex) {}
try {
DateTimeZone.forID("europe/london");
fail();
} catch (IllegalArgumentException ex) {}
try {
DateTimeZone.forID("Europe/UK");
fail();
} catch (IllegalArgumentException ex) {}
try {
DateTimeZone.forID("+");
fail();
} catch (IllegalArgumentException ex) {}
try {
DateTimeZone.forID("+0");
fail();
} catch (IllegalArgumentException ex) {}
} |
fffbfadd-7c34-481b-97d9-b3ade3f46992 | 5 | @Override
protected void doAction() {
Point3D pos = this.attackingBody.getPosition();
for (WorldObject wo : Environment.getInstance().getMap()[pos.x+this.direction.dx][pos.y+this.direction.dy][pos.z].getObjects()) {
if (wo instanceof InsectBody) {
InsectBody ib = (InsectBody) wo;
// If the sides are different
if(!ib.getSide().equals(this.attackingBody.getSide())) {
// Hit the enemy
ib.hit(this.attackingBody.generateHitAmount());
if(ib.getCurrentHealth() <= 0) {
ib.die();
for(int i = 0;i < 10;++i){
new Food(ib.getPosition());
}
}
return;
}
}
}
} |
08446a9d-154f-404e-ac80-e2a5649e4f2b | 7 | public void testTree1() {
Map refCounts = synchronizeTree(new HashMap());
TreeNode key = new TreeNode("leaf");
TreeNode[] value = new TreeNode[]{};
refCounts.put(key, value);
setTree(new TreeNode("dummy"));
try {
Map result = synchronizeTree(((Question2)answer).referenceCounts(refCounts));
assertTrue(null, "Your code fails to deal with trees that are leaves.",
result != null
&& result.size() == 1
&& result.containsKey(key)
&& result.get(key) != null
&& result.get(key) instanceof Integer
&& ((Integer)(result.get(key))).intValue() == 0);
} catch(ClassCastException exn) {
fail(exn, "Caught a `ClassCastException`: you should **only** need to cast to the types `TreeNode` and `Integer`. Check that:\n* your `Map` keys have type **TreeNode**\n* your `Map` values have type **Integer**");
} 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 testTree1 |
7d5f8f3a-b5ef-4c06-8913-0be81555b194 | 9 | private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
// Read serialized form from the stream.
ColorSpace cs = null;
// Switch on first int which is a flag indicating the class.
switch((int)in.readInt()) {
case COLORMODEL_NULL:
colorModel = null;
break;
case COLORMODEL_FLOAT_DOUBLE_COMPONENT:
if((cs = deserializeColorSpace(in)) == null) {
colorModel = null;
return;
}
colorModel =
new FloatDoubleColorModel(cs,
in.readBoolean(),
in.readBoolean(),
in.readInt(), in.readInt());
break;
case COLORMODEL_COMPONENT:
if((cs = deserializeColorSpace(in)) == null) {
colorModel = null;
return;
}
colorModel =
new ComponentColorModel(cs, (int[])in.readObject(),
in.readBoolean(), in.readBoolean(),
in.readInt(), in.readInt());
break;
case COLORMODEL_INDEX:
colorModel =
new IndexColorModel(in.readInt(), in.readInt(),
(int[])in.readObject(), 0,
in.readBoolean(), in.readInt(),
in.readInt());
break;
case COLORMODEL_DIRECT:
if((cs = deserializeColorSpace(in)) != null) {
colorModel =
new DirectColorModel(cs, in.readInt(), in.readInt(),
in.readInt(), in.readInt(),
in.readInt(), in.readBoolean(),
in.readInt());
} else if(in.readBoolean()) {
colorModel =
new DirectColorModel(in.readInt(), in.readInt(),
in.readInt(), in.readInt(),
in.readInt());
} else {
colorModel =
new DirectColorModel(in.readInt(), in.readInt(),
in.readInt(), in.readInt());
}
break;
default:
// NB: Should never get here.
throw new RuntimeException(JaiI18N.getString("ColorModelProxy1"));
}
} |
71afde5d-8e9e-422f-a64b-4d47da40c671 | 0 | @Basic
@Column(name = "PRP_FECMOD")
public Date getPrpFecmod() {
return prpFecmod;
} |
2fc349ba-65f0-4ad1-94b6-5e65d2d3b79f | 9 | private void parseSqlFindKeywords(boolean allKeywords) {
selectPos = textParser.findWordLower("select");
if (selectPos == -1) {
String msg = "Error parsing sql, can not find SELECT keyword in:";
throw new RuntimeException(msg + sql);
}
String possibleDistinct = textParser.nextWord();
if ("distinct".equals(possibleDistinct)) {
distinctPos = textParser.getPos() - 8;
}
fromPos = textParser.findWordLower("from");
if (fromPos == -1) {
String msg = "Error parsing sql, can not find FROM keyword in:";
throw new RuntimeException(msg + sql);
}
if (!allKeywords) {
return;
}
wherePos = textParser.findWordLower("where");
if (wherePos == -1) {
groupByPos = textParser.findWordLower("group", fromPos + 5);
} else {
groupByPos = textParser.findWordLower("group");
}
if (groupByPos > -1) {
havingPos = textParser.findWordLower("having");
}
int startOrderBy = havingPos;
if (startOrderBy == -1) {
startOrderBy = groupByPos;
}
if (startOrderBy == -1) {
startOrderBy = wherePos;
}
if (startOrderBy == -1) {
startOrderBy = fromPos;
}
orderByPos = textParser.findWordLower("order", startOrderBy);
} |
9293cd6b-b592-4ed4-a9ad-c91f0c50c79a | 5 | public static void initialDisplay()
{
System.out.print("Would you like to do: Add Sale (Add), Remove Sale (Remove), Finish Sale (Finish), " +
"Management Functions (Management) or Exit?: ");
String salesDisplayChoice = sc.next();
switch (salesDisplayChoice.toUpperCase())
{
case "ADD":
System.out.println("You selected Add");
InvoiceApp.addDisplay();
break;
case "REMOVE":
System.out.println("You selected Remove");
InvoiceApp.removeDisplay();
break;
case "FINISH":
System.out.println("You selected Finish");
FinishDisplay.paymentOptions();
break;
case "MANAGEMENT":
System.out.println("You selected management options");
ManagersDisplay.initialMgrsDisplay();
case "EXIT":
System.out.println("You selected Exit.");
System.out.println("Goodbye.");
System.exit(0);
break;
default:
System.out.println("Please enter a valid option.");
initialDisplay();
break;
}
//Use if you are using Java 6 since it doesn't allow switch statements for strings.
/*
if (salesDisplayChoice.equalsIgnoreCase("Add"))
{
System.out.println("You selected Add");
InvoiceApp.addDisplay();
//invoice.addProduct(product, quantity)
}
else if (salesDisplayChoice.equalsIgnoreCase("Remove"))
{
System.out.println("You selected Remove");
InvoiceApp.removeDisplay();
}
else if (salesDisplayChoice.equalsIgnoreCase("Finish"))
{
System.out.println("You selected Finish");
FinishDisplay.paymentOptions();
}
else if (salesDisplayChoice.equalsIgnoreCase("Exit"))
{
System.out.println("You selected Exit.");
System.out.println("Goodbye.");
System.exit(0);
}
else
{
System.out.println("Please enter a valid option.");
initialDisplay();
}
*/
} |
78ea06e5-5c3d-474c-96ed-703ad49f5969 | 9 | public int[][] generateMatrix(int n) {
int[][] array= new int[n][n];
int index = 1;
for (int i=0;index <=n*n ;i++ ){
//up
for (int j=0;j < n ;j++ ) {
if(array[i][j] == 0)
array[i][j] = index ++;
}
//right
for (int j=0;j < n ;j++ ) {
if(array[j][n-1-i] == 0)
array[j][n-1-i] = index ++;
}
//down
for (int j=n-1;j >=0 ;j-- ) {
if(array[n-1-i][j] == 0)
array[n-1-i][j] = index ++;
}
//left
for (int j=n-1;j >=0 ;j-- ) {
if(array[j][i] == 0)
array[j][i] = index ++;
}
}
return array;
} |
7bef256c-f2b3-4148-a16d-34938b22b4cf | 7 | public static void main(String[] args) {
// [max p, max # solutions]
int[] max = new int[2];
for(int p = 5; p < 1001; p++) {
int numSols = 0;
for(int c = 1; c < p/2; c++)
for(int a = 1; a < c; a++) {
double b = Math.sqrt(c*c - a*a);
if( Math.abs(b - (int)b) < .001 && a < (int)b && a+((int)b)+c == p )
numSols++;
}
if(numSols > max[1])
max = new int[]{p, numSols};
}
System.out.println("p = "+ max[0] +"\t#solutions = "+ max[1]);
} |
86efd30b-4889-447b-9c1c-1b5721ed8c0a | 0 | @Test
public void thirtyTwoFIsEqualToZeroC(){
ScaledQuantity fahrenheit = new ScaledQuantity(32, Temperature.Fahrenheit);
ScaledQuantity celsius = new ScaledQuantity(0, Temperature.Celsius);
assertEquals(fahrenheit, celsius);
assertEquals(celsius, fahrenheit);
assertEquals(fahrenheit, fahrenheit);
} |
53298780-0238-4371-9d04-aa87fea3b90a | 9 | @Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (instrument != this.instrument || period != this.period) {
// 対象の通貨ではない、かつ、対象の時間間隔でない場合は何もしない
return;
}
// 既に注文があるときは何もしない
if (this.aliveOrder != null && this.aliveOrder.getState() != State.CLOSED) {
this.aliveOrder.waitForUpdate(2, TimeUnit.SECONDS);
return;
}
// 現在のRSI (フラットフィルターを適用しないとRSIが0や、100になる)
// http://kakakufx.com/mk2/systrade/indicators.html
double rsi = indicators.rsi(instrument,
period,
this.offerSide,
this.appliedPrice,
this.rsiTimePeriod,
Filter.ALL_FLATS, // 全てのフラットバーを除外
1, // 1本前
askBar.getTime(), // 現在日付
0)[0];
if (rsizone) {
if (rsiLowerLine < rsi && rsi < rsiUpperLine) {
rsizone = false;
} else {
return;
}
}
if (rsi <= rsiLowerLine) {
// 今のRSIも前回のRSIも30を下回ってる場合
// [/] は使えないみたい
String label = "Buy_" + LABEL_DATEFORMAT.format(new Date(System.currentTimeMillis()));
submitOrder(label, OrderCommand.BUY, askBar, rsi);
// 注文したので仕掛けちゃだめ設定
rsizone = true;
}
if (rsiUpperLine <= rsi) {
// 今のRSIも前回のRSIも70を上回ってる場合
// [/] は使えないみたい
String label = "Sell_" + LABEL_DATEFORMAT.format(new Date(System.currentTimeMillis()));
submitOrder(label, OrderCommand.SELL, bidBar, rsi);
// 注文したので仕掛けちゃだめ設定
rsizone = true;
}
} |
33ce13e3-18fd-485e-829f-6b7f00820e10 | 0 | public void addText(String text)
{
class temp implements Runnable
{
public temp (String text)
{
this.text = text;
}
private String text;
@Override
public void run()
{
try {
//String[] array = text.split("^_^");
/*for(int i = 0 ; i < array.length ; i ++) {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(), array[i], null);
jTextPane2.insertIcon(new ImageIcon(getClass().getResource("/picture/wreck-it-ralph-vanellope.jpg")));
}*/
int pos = 0;
StringTokenizer st1= new StringTokenizer(text,"{",true);
while(st1.hasMoreTokens()){
String s1=st1.nextToken();
if(s1.equals("{")) {
jTextPane2.insertIcon(new ImageIcon(getClass().getResource("/picture/1.jpg")));
pos += 7;
if(pos>60) {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
pos = 0;
}
}
else {
StringTokenizer st2= new StringTokenizer(s1,"}",true);
while(st2.hasMoreTokens()){
String s2=st2.nextToken();
if(s2.equals("}")) {
jTextPane2.insertIcon(new ImageIcon(getClass().getResource("/picture/2.jpg")));
pos += 7;
if(pos>60) {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
pos = 0;
}
}
else {
StringTokenizer st3= new StringTokenizer(s2,"|",true);
while(st3.hasMoreTokens()){
String s3=st3.nextToken();
if(s3.equals("|")) {
jTextPane2.insertIcon(new ImageIcon(getClass().getResource("/picture/3.jpg")));
pos += 7;
if(pos>60) {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
pos = 0;
}
}
else {
pos += s3.length();
if(pos>60) {
int len = s3.length() ;
int line = 60+s3.length()-pos;
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),s3.substring(0,line), null);
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
len -= line;
while (len >60) {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),s3.substring(line,line+60), null);
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
line+=60;
len-=60;
}
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),s3.substring(line,line+len), null);
pos = len;
}
else {
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),s3, null);
}
}
}
}
}
}
}
jTextPane2.getDocument().insertString(jTextPane2.getDocument().getLength(),"\r\n", null);
pos=0;
chatRoom.setVisible(true);
}
catch (BadLocationException e) {
}
}
}
SwingUtilities.invokeLater(new temp(text));
} |
5f2a064e-9e06-47c5-b877-50441ae80f0c | 1 | private void moveDown() {
int[] rows = table.getSelectedRows();
DefaultTableModel model = (DefaultTableModel) table.getModel();
if (model.getRowCount() >= 2) {
model.moveRow(rows[0], rows[rows.length - 1], rows[0] + 1);
table.setRowSelectionInterval(rows[0] + 1,
rows[rows.length - 1] + 1);
}
} |
6a4f0028-d482-4e1a-b98f-0367d8956d22 | 2 | public static Item get(int index){
if(index >= 0 && index < 90) return inventory[index];
return null;
} |
504067d9-6be8-49a6-9c75-c4de481e202b | 7 | private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
Categoria c = new Categoria();
if (!(txCodigo.getText().equals("")) || (txCodigo.getText().equals(null))){
c.setId_tipo(Integer.parseInt(txCodigo.getText()));
}
if (txDescricao.getText().equals("") || txDescricao.getText().equals(null)){
JOptionPane.showMessageDialog(null,"Informe uma descrição antes de salvar!");
//btSalvarActionPerformed();
}
c.setDescricao(txDescricao.getText());
CategoriaController cc = new CategoriaController();
if (c.getId_tipo()== 0){
int id = cc.salvar(c);
if(id > 0){
modelo.addRow(new Object[]{id, c.getDescricao()});
JOptionPane.showMessageDialog(null,"Categoria cadastrado com sucesso!");
}
}else{
int id = cc.salvar(c);
if(id > 0){
modelo.removeRow(linhaSelecionada);
modelo.addRow(new Object[]{id, c.getDescricao()});
JOptionPane.showMessageDialog(null, "Categoria atualizado com sucesso!");
}
}
dispose();
}//GEN-LAST:event_btSalvarActionPerformed |
b00094c7-66e8-4cdb-aedb-ba42555a070b | 1 | public static void setTextures(boolean enabled)
{
if(enabled)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
} |
6c863d82-2155-4876-956a-07c5c17efae0 | 5 | @Override
public boolean equals(
Object obj )
{
if( this == obj ) return true;
if( obj == null ) return false;
if( getClass() != obj.getClass() ) return false;
Range other = (Range) obj;
if( end != other.end ) return false;
if( start != other.start ) return false;
return true;
} |
538d8a52-ca74-437c-8cee-72115497c30b | 2 | public static Type getObjectType(final String internalName) {
if (isPrimitiveType(internalName)) {
return getType(internalName);
}
char[] buf = internalName.toCharArray();
return new Type(buf[0] == '[' ? ARRAY : OBJECT, buf, 0, buf.length);
} |
e17118a3-ca89-4768-9798-a6b080b00a31 | 2 | public static void main(String[] args) {
Domino d = new Domino();
d.crearDomino();
d.barajarFicha();
d.imprimirLista(Domino.listaFicha);
d.repartirFichas();
System.out.println("Humano");
d.imprimirLista(Domino.listaFichaHumano);
System.out.println("PC");
d.imprimirLista(Domino.listaFichaPc);
System.out.println("Fichas Maso");
d.imprimirLista(Domino.listaFicha);
Scanner s = new Scanner(System.in);
do {
System.out.println("Presione 1 para robar");
int i = s.nextInt();
if (i == 1){
d.robarFicha(true);
System.out.println("Fichas maso");
d.imprimirLista(Domino.listaFicha);
System.out.println("FIHA ROBADA HUMANO");
d.imprimirLista(Domino.listaFichaHumano);
}
} while (true);
} |
6762ddc4-a218-4875-9541-4691b1aa9544 | 2 | public static void main(String[] args) {
try {
SQLHelper sQLHelper = new SQLHelper();
sQLHelper.sqlConnect();
//sQLHelper.runUpdate("insert into teacher values('10060120','haha','zheng','jjhsjl')");
ResultSet rs = sQLHelper.runQuery("select * from teacher");
while (rs.next()) {
System.out.println(rs.getString(1));
}
sQLHelper.sqlClose();
} catch (SQLException ex) {
Logger.getLogger(SQLHelper.class.getName()).log(Level.SEVERE, null, ex);
}
} |
949c55f8-f5d4-4161-9adb-b9731186d4cf | 8 | protected void makeSinCosTables()
{
// First determine max k.
int pmax = -Integer.MAX_VALUE;
int localnu1 = nu1;
int localn2 = n2;
int k = 0;
for (int l = 1; l <= nu; l++)
{
while (k < n)
{
for (int i = 1; i <= localn2; i++)
{
int p = bitrev (k >> localnu1);
if (p > pmax)
pmax = p;
k++;
}
k += localn2;
}
k = 0;
localnu1--;
localn2 = localn2/2;
}
localnu1 = nu1;
localn2 = n2;
try
{
C = new double[pmax+1];
S = new double[pmax+1];
// Now calculate actual table values.
k = 0;
for (int l = 1; l <= nu; l++)
{
while (k < n)
{
for (int i = 1; i <= localn2; i++)
{
int p = bitrev (k >> localnu1);
double arg = 2 * Math.PI * (double) p / n;
C[p] = Math.cos (arg);
S[p] = Math.sin (arg);
k++;
}
k += localn2;
}
k = 0;
localnu1--;
localn2 = localn2/2;
}
} catch (Exception e) { e.printStackTrace(); }
System.out.println("FFT sin and cos tables length "+(pmax+1));
} |
9ec95189-08a3-4d49-8f37-efba4462101a | 4 | public static Complex[] convolve(Complex[] x, Complex[] y) {
Complex ZERO = new Complex(0, 0);
Complex[] a = new Complex[2*x.length];
for (int i = 0; i < x.length; i++) a[i] = x[i];
for (int i = x.length; i < 2*x.length; i++) a[i] = ZERO;
Complex[] b = new Complex[2*y.length];
for (int i = 0; i < y.length; i++) b[i] = y[i];
for (int i = y.length; i < 2*y.length; i++) b[i] = ZERO;
return cconvolve(a, b);
} |
acac4e1c-2b5b-4b6a-8464-75f1040bf7c5 | 7 | public void run() {
try {
PrintWriter out = null;
BufferedReader in = null;
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String clientMsg = null;
while ((clientMsg = in.readLine()) != null) {
int type = -1;
try {
Request request = gson.fromJson(clientMsg, Request.class);
type = request.getType();
switch (type) {
case Request.GET_RECORDS:
out.println(gson.toJson(monitor.getRecordsOfPatient(identity, request.getData())));
break;
case Request.CREATE_RECORD:
Record createRecord = gson.fromJson(request.getData(), Record.class);
out.println(monitor.createRecord(identity, createRecord));
break;
case Request.UPDATE_RECORD:
Record updateRecord = gson.fromJson(request.getData(), Record.class);
out.println(monitor.updateRecord(identity, updateRecord));
break;
case Request.DELETE_RECORD:
Record deleteRecord = gson.fromJson(request.getData(), Record.class);
out.println(monitor.deleteRecord(identity, deleteRecord));
break;
}
} catch (JsonSyntaxException e) {
continue;
}
out.flush();
}
in.close();
out.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
} |
b455729a-e591-470e-97d7-26472ec347e8 | 5 | public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if(command.getName().equalsIgnoreCase("vanish")){
if(enabled){
if(sender instanceof Player){
Player p = (Player) sender;
if(p.hasPermission("tcl.vanish")){
for(Player pl : Bukkit.getOnlinePlayers()){
pl.hidePlayer(p);
}
p.sendMessage(Messages.vanished());
}else{
sender.sendMessage(Exceptions.noPerm());
}
}else{
sender.sendMessage(Exceptions.mustbePlayer());
}
}
}
return false;
} |
040e75f9-2dcc-420d-bf44-a258cd18c731 | 2 | public HashMap<String,Warp> loadWarps() throws SQLException {
HashMap<String,Warp> warps = new HashMap<String,Warp>();
sql.initialise();
if(!sql.doesTableExist("BungeeWarps")){
System.out.println("Table 'BungeeWarps' does not exist! Creating table...");
sql.standardQuery("CREATE TABLE BungeeWarps (W_ID int NOT NULL AUTO_INCREMENT,Name VARCHAR(50) NOT NULL UNIQUE, Server VARCHAR(50) NOT NULL, World VARCHAR(50) NOT NULL, X double NOT NULL, Y double NOT NULL, Z double NOT NULL, Yaw float NOT NULL, Pitch float NOT NULL, FOREIGN KEY(Server) REFERENCES BungeeServers(ServerName) ON DELETE CASCADE, PRIMARY KEY (W_ID))ENGINE=INNODB;");
System.out.println("Table 'BungeeWarps' created!");
}
ResultSet res = sql.sqlQuery("SELECT * FROM BungeeWarps");
while(res.next()){
String name = res.getString("Name");
warps.put(name, new Warp(name, new WarpLocation(res.getString("Server"), res.getString("World"), res.getDouble("X"), res.getDouble("Y"), res.getDouble("Z"), res.getFloat("Yaw"), res.getFloat("Pitch")),res.getBoolean("Visable")));
}
res.close();
sql.closeConnection();
return warps;
} |
e594b7a2-c83c-474e-bbb6-7a6a8e3a8a15 | 5 | public static Image trimTextImage(Image im, int width, int height)
{
/*
Due to the slight inaccuracy of the font sizes, a text image may
not need all the height allocated to it. This method will crop and
image so that all rows that are totally transparent are eliminated.
This method assumes there is at least SOME text in th image. Additionally,
I do not bother cropping columns.
*/
int transparent_pic = JIPTsettings.CLEAR_PIXEL_3; // Transparent pic
//main_frame.getJIPTsettings().getClearPixelColor();
int pix[] = JIPTUtilities.getPixelArray(im);
// Scan each row. Stop when the end of the array is reached or
// a non-transparent color is hit.
int count = 0; // A counter that keeps track of how many rows are transparent
for(int i = 1; i < pix.length; i++)
{
int alpha = (pix[i] >> 24) & 0xff;
if(alpha != 0)
break;
if(i%width == 0)
count++;
}
// System.out.println("Count = " + count);
int new_pix[] = new int[(height - count)*width];
int index = 0;
for(int i = count*width; i < pix.length; i++)
{
int alpha = (pix[i] >> 24) & 0xff;
if(alpha == 0)
new_pix[index] = transparent_pic;
else
new_pix[index] = pix[i];
index++;
}
Image new_im = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(width, height - count, new_pix, 0, width));
return new_im;
} |
6283ea5e-da47-4e9a-bb86-8a28fe634738 | 5 | private void drawShape(Graphics g,Boolean pack) {
if (currentshape == shape.LINE)
{
//packet
if(pack)
{
Packet p=new Packet(diffrentShapes.LINE, currentColor, startX, startY, currentX, currentY);
try {
oos.writeObject(p);
oos.flush();
} catch (Exception ex) {
System.err.println("Object output error: " + ex);
}
}
g.drawLine(startX, startY, currentX, currentY);
}
else if (currentshape == shape.OVAL)
{
DrawRectOval(g, pack, startX, startY, currentX, currentY);
}
else if (currentshape == shape.RECT)
{
DrawRectOval(g, pack ,startX, startY, currentX, currentY);
}
// else if (currenttool == tool.eraser)
// {
// g.setColor(fillColor);
// g.fillRect(currentX, currentY, 17, 17);
// }
// else if (currentshape == shape.FILLED_OVAL) { DrawRectOval(g, true, startX, startY, currentX, currentY); }
//else if (currentshape == shape.FILLED_RECT) { DrawRectOval(g, true, startX, startY, currentX, currentY); }
} |
c68d2691-ac18-46e5-be26-e9ca609926dc | 0 | public Item genItem(int i,int items) {
int val2=rand.nextInt(100000000);
String val3 = items + " / " + i;
Item item = new Item(i,val2,val3);
return item;
} |
f9532851-3434-4c06-a7ae-3d106a5bcb97 | 7 | public int compareTo(Object o) {
int result;
int major;
int minor;
int revision;
int [] maj = new int [1];
int [] min = new int [1];
int [] rev = new int [1];
// do we have a string?
if (o instanceof String) {
parseVersion((String)o, maj, min, rev);
major = maj[0];
minor = min[0];
revision = rev[0];
}
else {
System.out.println(this.getClass().getName() + ": no version-string for comparTo povided!");
major = -1;
minor = -1;
revision = -1;
}
if (MAJOR < major) {
result = -1;
}
else if (MAJOR == major) {
if (MINOR < minor) {
result = -1;
}
else if (MINOR == minor) {
if (REVISION < revision) {
result = -1;
}
else if (REVISION == revision) {
result = 0;
}
else {
result = 1;
}
}
else {
result = 1;
}
}
else {
result = 1;
}
return result;
} |
94c97850-fe3a-4c8d-89c3-6b3b5f9ddbaa | 3 | @Override
public boolean equals(Object o) {
if (o == this)
return true;
if (o == null)
return false;
if (!getClass().equals(o.getClass()))
return false;
final Virus v = (Virus) o;
return getName().equalsIgnoreCase(v.getName());
} |
8c13d9ae-6df2-401b-b0f7-dd8f52bc05c9 | 6 | public static Object[] toObjectArray(Object source) {
if (source instanceof Object[]) {
return (Object[]) source;
}
if (source == null) {
return new Object[0];
}
if (!source.getClass().isArray()) {
throw new IllegalArgumentException("Source is not an array: "
+ source);
}
int length = Array.getLength(source);
if (length == 0) {
return new Object[0];
}
Class<?> wrapperType = Array.get(source, 0).getClass();
Object[] newArray = (Object[]) Array.newInstance(wrapperType, length);
for (int i = 0; i < length; i++) {
newArray[i] = Array.get(source, i);
}
return newArray;
} |
ed47db47-b856-412e-ae3b-e2567d855a79 | 2 | public boolean containsCard(Card card) {
for(int i = 0; i < this.getNumCards(); i++)
if(this.getCard(i).equals(card))
return true;
return false;
} |
de43a97d-0bae-498a-a9e0-51302e4551c0 | 0 | private void setSplitPaneBounds(){
splitPane.setBounds(5, menuBar.getHeight() + menuBarWithButtons.getHeight(),
getWidth() - 15, getHeight() - menuBar.getHeight() - menuBarWithButtons.getHeight()-55 );
upperSplit.setDividerSize(5);
splitPane.setDividerSize(5);
upperSplit.setDividerLocation(200);
splitPane.setDividerLocation(0.7);
} |
159d6a9b-b47e-44ba-bb08-93efdd0becdd | 6 | public BlockOrientation getOrientation() {
IntBuffer orientationBuf = IntBuffer.allocate(1);
IntBuffer writingDirectionBuf = IntBuffer.allocate(1);
IntBuffer textlineOrderBuf = IntBuffer.allocate(1);
FloatBuffer deskewAngleBuf = FloatBuffer.allocate(1);
iterator.getOrientation(orientationBuf, writingDirectionBuf, textlineOrderBuf, deskewAngleBuf);
int value = orientationBuf.get();
Orientation orientation = Orientation.UP;
for (Orientation o: Orientation.values()) {
if (value == o.value) {
orientation = o;
break;
}
}
value = writingDirectionBuf.get();
WritingDirection direction = WritingDirection.LEFT_TO_RIGHT;
for (WritingDirection d: WritingDirection.values()) {
if (value == d.value) {
direction = d;
break;
}
}
value = textlineOrderBuf.get();
TextlineOrder order = TextlineOrder.TOP_TO_BOTTOM;
for (TextlineOrder o: TextlineOrder.values()) {
if (value == o.value) {
order = o;
break;
}
}
return new BlockOrientation(orientation, direction, order, deskewAngleBuf.get());
} |
62f01c49-0af9-4831-a249-f920adf7c037 | 2 | @Override
public boolean equals(Object obj) {
Horario h = (Horario)obj;
return dia.equals(h.getDia())&&de.equals(h.getDe())&&hasta.equals(h.getHasta());
} |
3430f7ae-f6f4-4dcb-a37c-e35c74ed8da6 | 7 | public void run() {
while(true) {
int com = readOneCommand(is);
System.out.println("Read : " + com + " from player " + p.getId());
switch (com) {
case Protocol.SEND_CARD: { // 1
int suit = readOneCommand(is);
int value = readOneCommand(is);
monitor.sendPlayedCard(new Card(suit, value, p));
break;
}
case Protocol.SET_STICKS:
monitor.setWantedSticks(readOneCommand(is), p);
break;
case Protocol.GET_DELAY: {
monitor.addCommandForAll(Protocol.SEND_MORE_TIME);
break;
}
case Protocol.PLAYER_LEFT:
monitor.addPlayerLeft();
try {
is.close();
return;
} catch (IOException e) {
e.printStackTrace();
}
return;
default: {
System.out.println(" -- unexpected input");
try {
monitor.addPlayerLeft();
is.close();
return;
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
} |
b2cab31a-8c0d-4cf2-bc8f-2553f8d59cc4 | 8 | private void createOr(String in1, String in2, String out)
{
OrGate or = new OrGate();
// Connect the first input
// Check if the in wire is an input
if (stringToInput.containsKey(in1))
{
Wire inWire = new Wire();
stringToInput.get(in1).connectOutput(inWire);
or.connectInput(inWire);
}
// Check if the in wire is an output
else if (stringToOutput.containsKey(in1))
{
Wire inWire = new Wire();
stringToOutput.get(in1).connectOutput(inWire);
or.connectInput(inWire);
}
// Check if the in wire is just a wire already known to the circuit
else if (stringToWire.containsKey(in1))
or.connectInput(stringToWire.get(in1));
else
MainFrame.showError("Error, the wire " + in1
+ " isn't in the circuit");
// Connect the Second input
// Check if the in2 wire is an input
if (stringToInput.containsKey(in2))
{
Wire inWire = new Wire();
stringToInput.get(in2).connectOutput(inWire);
or.connectInput(inWire);
}
// Check if the in wire is an output
else if (stringToOutput.containsKey(in2))
{
Wire inWire = new Wire();
stringToOutput.get(in2).connectOutput(inWire);
or.connectInput(inWire);
}
// Check if the in wire is just a wire already known to the circuit
else if (stringToWire.containsKey(in2))
or.connectInput(stringToWire.get(in2));
else
MainFrame.showError("Error, the wire " + in2
+ " isn't in the circuit");
// Connect the output
// Check if the in wire is an output
if (stringToOutput.containsKey(out))
{
Wire outWire = new Wire();
stringToOutput.get(out).connectInput(outWire);
or.connectOutput(outWire);
}
// Check if the in wire is just a wire already known to the circuit
else if (stringToWire.containsKey(out))
or.connectOutput(stringToWire.get(out));
else
MainFrame.showError("Error, the wire " + out
+ " isn't in the circuit");
gates.add(or);
} |
b23b5f2c-d8da-4f6a-afb9-f96fdd10297e | 5 | public boolean estCleValable(String k) {
String[] keys=k.split(" ");
if(keys.length==2 && keys[0]!="" && keys[1]!="") {
if(this.estClePubliqueValable(keys[0]) && this.estClePriveValable(keys[1])) {
return true;
}
else {
return false;
}
}
else {
return false;
}
} |
56fb8cb8-1d15-45c8-ab07-aaaa7305800a | 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(DiscViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DiscViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DiscViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DiscViewer.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 DiscViewer().setVisible(true);
}
});
} |
8451b92e-8b05-4fe2-a849-7d37aa785f5e | 0 | public MainPage(String title) {
super(title);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
Toolkit tk = Toolkit.getDefaultToolkit();
this.setSize(tk.getScreenSize());
this.setVisible(true);
} |
2238535a-0f07-47d4-a9c7-e34191dfddee | 4 | public boolean mouseup(Coord c, int button) {
c = new Coord((int) (c.x / getScale()), (int) (c.y / getScale()));
Coord mc = s2m(c.add(viewoffset(sz, this.mc).inv()));
if (grab != null) {
try {
grab.mmouseup(mc, button);
return (true);
} catch (GrabberException e) {
}
}
if ((cam != null) && cam.release(this, c, mc, button)) {
return (true);
} else {
return (true);
}
} |
531c0073-55cd-42b0-aaa8-d86cebda63cd | 5 | protected void creerCommunication() throws IOException {
this.communication = new Socket(this.nomServeur, this.portServeur);
this.fluxEntree = new BufferedReader(new InputStreamReader(communication.getInputStream()));
this.fluxSortie = new PrintStream(communication.getOutputStream());
// Crée un fil d'exécution parallèle au fil courant
threadComm = new SwingWorker<Object,String>(){
@Override
protected Object doInBackground() throws Exception {
firePropertyChange(ClientConnexion.PROPRIETE_DEBUT, null, (Object) ".");
while(true){
Thread.sleep(DELAI_REQUETES);
if (fluxEntree.readLine().indexOf("commande>") != -1) {
String reponseServeur;
fluxSortie.println(REQUETE_FORME);
if ((reponseServeur = fluxEntree.readLine()) != null && listener != null) {
firePropertyChange(ClientConnexion.PROPRIETE_FORME, null, reponseServeur);
}
}
}
}
};
if(listener != null) {
threadComm.addPropertyChangeListener(listener); // La méthode "propertyChange" de ApplicationFormes sera donc appelée lorsque le SwinkWorker invoquera la méthode "firePropertyChanger"
}
threadComm.execute(); // Lance le fil d'exécution parallèle.
actif = true;
} |
ac7ffd4f-f416-4101-b32d-17bac1b066ca | 2 | private void setHH(Household houseHold) {
// txtAcc1.setEnabled(false);
txtAcc1.setEditable(false);
// txtAcc2.setEnabled(false);
txtAcc2.setEditable(false);
// txtAcc3.setEnabled(false);
txtAcc3.setEditable(false);
// txtAcc4.setEnabled(false);
txtAcc4.setEditable(false);
// txtTutor1.setEnabled(false);
txtTutor1.setEditable(false);
// txtTutor2.setEnabled(false);
txtTutor2.setEditable(false);
String account = houseHold.getBanckAccount();
if (account.length() != 15)
System.out.println("bad size");
String[] parts = account.split("-");
txtAcc1.setText(parts[0]);
txtAcc2.setText(parts[1]);
txtAcc3.setText(parts[2]);
txtAcc4.setText(parts[3]);
txtTutor1.setText(houseHold.getRepresentative());
if (houseHold.getRepresentative1() != null)
txtTutor2.setText(houseHold.getRepresentative1());
} |
d6e3d1e8-c1f1-428c-9268-6d83599a865d | 0 | @Override
public Position getStart() {
return start;
} |
c2a4d880-7901-41c4-ac08-ba9f6d7bda4b | 7 | private void updateGrid(boolean cheat)
{
char[][] grid = wordSearch.getGrid();
for (Word word : wordPositions)
{
Point[] points = word.getPoints(wordSearch);
if (points == null) continue;
for (int i = 0; i < points.length; i++)
{
Point point = points[i];
grid[point.x][point.y] = word.getWord().charAt(i);
}
}
for (int x = 0; x < wordSearch.getSize(); x++)
{
for (int y = 0; y < wordSearch.getSize(); y++)
{
if (grid[x][y] == 0)
grid[x][y] = cheat ? '.' : (char) (Main.RANDOM.nextInt(26) + 'a');
}
}
} |
790e0b7e-59b0-4507-a91b-3d87ef0bb18a | 7 | public String getCommand(int x) {
String y;
if (x == 1) {
y = "attack";
}
else if (x == 2) {
y = "defend";
}
else if (x == 3) {
y = "fire";
}
else if (x == 4) {
y = "blizzard";
}
else if (x == 5) {
y = "thunder";
}
else if (x == 6) {
y = "flood";
}
else if (x == 7) {
y = "quake";
}
else {
y = "";
}
return y;
} |
62a78705-404c-4ac9-ae5c-e3161f9c2beb | 0 | public Layer getLayer() {
return layer;
} |
0625c299-d810-45f8-9d2d-850b61a5c3d9 | 4 | public Method findIsMethod(Field field) {
if(field == null)
return null;
if(getFieldDetailStore().isSetMethodPresentFor(field)) {
return getFieldDetailStore().setMethodOf(field);
}
String getterName = createMethodName("is", field.getName());
try {
Method getMethod = getInspectedClass().getDeclaredMethod(getterName);
getFieldDetailStore().addSetMethod(field,getMethod);
return getMethod;
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
return null;
} |
014b3793-a408-429d-ab18-b865fc21e3d5 | 4 | private static String maxComSubStr(int i, int j, String strA, int[][] intA) {
if (i == 0 || j == 0) {
return "";
}
if (intA[i][j] == 1) {
return maxComSubStr(i - 1, j - 1, strA, intA) + strA.charAt(i-1);
} else if (intA[i][j] == 2) {
return maxComSubStr(i - 1, j, strA, intA);
} else {
return maxComSubStr(i, j - 1, strA, intA);
}
} |
a0194cf4-2d88-4958-9767-04110364651c | 1 | @Override
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
if (iface.isInstance(this)) {
return (T) this;
}
throw new SQLException("DataSource of type [" + getClass().getName() +
"] cannot be unwrapped as [" + iface.getName() + "]");
} |
cb7d126d-4b3e-4e27-9902-1e0423d47de4 | 3 | public String subPath(int start, int end) {
if (start < 0 || end < start || end > path_.length()) {
throw new IndexOutOfBoundsException();
}
return path_.substring(start, end);
} |
fa7c3a3f-12ec-4ee4-a0a6-f8b5c1a5faa5 | 4 | @Override
public int hashCode() {
int result = stock != null ? stock.hashCode() : 0;
result = 31 * result + (int) (price ^ (price >>> 32));
result = 31 * result + (seller != null ? seller.hashCode() : 0);
result = 31 * result + (buyer != null ? buyer.hashCode() : 0);
result = 31 * result + (tradeDate != null ? tradeDate.hashCode() : 0);
return result;
} |
9df85f8d-e9a8-4540-8a02-705e2d0120e4 | 8 | protected void readAttributes(XMLStreamReader in) throws XMLStreamException {
super.readAttributes(in);
name = in.getAttributeValue(null, "username");
nationID = in.getAttributeValue(null, "nationID");
if (!isUnknownEnemy()) {
nationType = getSpecification().getNationType(in.getAttributeValue(null, "nationType"));
}
admin = getAttribute(in, "admin", false);
gold = Integer.parseInt(in.getAttributeValue(null, "gold"));
immigration = getAttribute(in, "immigration", 0);
liberty = getAttribute(in, "liberty", 0);
interventionBells = getAttribute(in, "interventionBells", 0);
oldSoL = getAttribute(in, "oldSoL", 0);
score = getAttribute(in, "score", 0);
ready = getAttribute(in, "ready", false);
ai = getAttribute(in, "ai", false);
dead = getAttribute(in, "dead", false);
bankrupt = getAttribute(in, "bankrupt", false);
tax = Integer.parseInt(in.getAttributeValue(null, "tax"));
playerType = Enum.valueOf(PlayerType.class, in.getAttributeValue(null, "playerType"));
currentFather = getSpecification().getType(in, "currentFather", FoundingFather.class, null);
immigrationRequired = getAttribute(in, "immigrationRequired", 12);
newLandName = getAttribute(in, "newLandName", null);
independentNationName = getAttribute(in, "independentNationName", null);
attackedByPrivateers = getAttribute(in, "attackedByPrivateers", false);
final String entryLocationStr = in.getAttributeValue(null, "entryLocation");
if (entryLocationStr != null) {
FreeColGameObject fcgo = getGame().getFreeColGameObject(entryLocationStr);
entryLocation = (fcgo instanceof Location) ? (Location)fcgo
: new Tile(getGame(), entryLocationStr);
}
for (RegionType regionType : RegionType.values()) {
String key = regionType.getNameIndexKey();
int index = getAttribute(in, key, -1);
if (index > 0) setNameIndex(key, index);
}
if (nationType != null) addFeatures(nationType);
switch (playerType) {
case REBEL:
case INDEPENDENT:
addAbility(new Ability("model.ability.independenceDeclared"));
break;
default:
// no special abilities for other playertypes, but silent warning about unused enum.
break;
}
tension.clear();
stance.clear();
allFathers.clear();
offeredFathers.clear();
europe = null;
monarch = null;
history.clear();
tradeRoutes.clear();
modelMessages.clear();
lastSales = null;
highSeas = null;
} |
5ecba7c8-0a55-44b5-8a29-b59bcb96c447 | 2 | public int[] plusOne(int[] digits) {
int[] array = new int[digits.length + 1];
int val = 1;
for(int i =digits.length-1 ; i>=0 ;i--){
val = digits[i]+val;
array[i+1] = val % 10;
val = val /10;
}
array[0] = val;
return (val == 0)? Arrays.copyOfRange(array,1,array.length): array;
} |
3b501f9f-57eb-46ec-a9c2-b016401d6c81 | 4 | public static int getCharacterID() {
String value = properties.getProperty(CHARACTER_ID);
if (value == null) {
return GameCharacter.LordLard.ordinal();
}
int id = GameCharacter.LordLard.ordinal();
try {
id = Integer.parseInt(value);
} catch (NumberFormatException e) {}
if (id < 0 || id >= GameCharacter.values().length-1) {
return GameCharacter.LordLard.ordinal();
}
return id;
} |
f586206e-9a33-4ce2-a68b-715bac5e9ee7 | 6 | public void keyReleased(KeyEvent e)
{
switch(e.getKeyCode())
{
case KeyEvent.VK_LEFT: Kontroller.left = false;
break;
case KeyEvent.VK_RIGHT: Kontroller.right = false;
break;
case KeyEvent.VK_UP: Kontroller.up = false;
break;
case KeyEvent.VK_DOWN: Kontroller.down = false;
break;
case KeyEvent.VK_C: Kontroller.c = false;
break;
case KeyEvent.VK_X: Kontroller.x = false;
}
} |
d80c208a-11a6-4370-83eb-e7aa112d9bef | 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 ("Windows".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.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 login().setVisible(true);
}
});
} |
7c20e6f6-1cae-4e17-873c-c5e3f301d1a8 | 6 | @Override
public boolean click(MainView parent, int x, int y, int camx, int camy) {
if (x >= this.x && x <= this.x + 200 && y >= this.y && y <= this.y + 300) {
handleClick(parent, x - this.x, y - this.y);
return true;
}
else if (coaster == null) {
int[] pos = worldData.addTile(x, y, camx, camy, 1, selectedTrack);
if (pos != null) {
coaster = new SteelCoaster(pos[0], pos[1], pos[2]);
coaster.addTrack(pos, selectedTrack);
}
return true;
}
else return false;
} |
4ab8d674-31c3-4e95-8e37-f5b5e55ab6c7 | 8 | tuple<node,Long> findInLB(int[] k, node cnode) throws valid_not_checked, pval_error, make_key_error
{
if (cnode.lfilledB==0)
return new tuple<node,Long>(null,(long)0);
long dist,min,dist1,dist2,dist3;
int in;
node minnode,tnode;
minnode=null;
min=0;
if (min<0) min+=(long)Math.pow(2,common.bkeyLength);
in=0;
for(int i=0;i<cnode.lfilledB-1;i++)
{
dist1=common.compareKeys(k,cnode.getLtableB(i).getKey());
if (dist1>0)
dist1-=(long)Math.pow(2,common.bkeyLength);
dist2=common.compareKeys(cnode.getLtableB(i+1).getKey(),cnode.getLtableB(i).getKey());
if (dist2>0)
dist2-=(long)Math.pow(2,common.bkeyLength);
if (dist1>dist2)
{
dist3=common.compareKeys(cnode.getLtableB(i+1).getKey(),k);
if (dist3>0)
dist3-=(long)Math.pow(2,common.bkeyLength);
if (dist1>dist3)
{
min=dist1;
minnode=cnode.getLtableB(i);
}
else
{
min=dist3;
minnode=cnode.getLtableB(i+1);
}
}
}
return new tuple<node,Long>(minnode,min);
} |
116d2edb-43eb-4040-ab6f-88c0946c41a6 | 2 | public ArrayList<Double> IDWT(ArrayList<Double> _dwt) {
ArrayList<Double> _temp = new ArrayList<Double>(_dwt.size());
//Initialize _temp
_temp = (ArrayList<Double>) _dwt.clone();
for (int j = 2; j <= _dwt.size(); j = j * 2) {
for (int i = 0; i < j / 2; i += 1) {
double _pre = _dwt.get(i) + _dwt.get(j / 2 + i);
double _late = _dwt.get(i) - _dwt.get(j / 2 + i);
_temp.set(i * 2, _pre);
_temp.set(i * 2 + 1, _late);
}
_dwt = (ArrayList<Double>) _temp.clone();
}
return _dwt;
} |
46999c21-f350-469e-bec2-8884fdbde25b | 1 | public void testFactory_standardSecondsIn_RPeriod() {
assertEquals(0, Seconds.standardSecondsIn((ReadablePeriod) null).getSeconds());
assertEquals(0, Seconds.standardSecondsIn(Period.ZERO).getSeconds());
assertEquals(1, Seconds.standardSecondsIn(new Period(0, 0, 0, 0, 0, 0, 1, 0)).getSeconds());
assertEquals(123, Seconds.standardSecondsIn(Period.seconds(123)).getSeconds());
assertEquals(-987, Seconds.standardSecondsIn(Period.seconds(-987)).getSeconds());
assertEquals(2 * 24 * 60 * 60, Seconds.standardSecondsIn(Period.days(2)).getSeconds());
try {
Seconds.standardSecondsIn(Period.months(1));
fail();
} catch (IllegalArgumentException ex) {
// expeceted
}
} |
bd985dcc-3c8a-4c6b-9217-fadf201a9d3d | 9 | public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
rd = new BufferedReader(new FileReader("d:\\programDATA\\Minimum Scalar Product\\A-large-practice.in"));
wr = new PrintWriter(new FileWriter("d:\\programDATA\\Minimum Scalar Product\\A-large-practice.out"));
int num;
long[] v1,v2;
String line =rd.readLine();
while (true) {
line = rd.readLine();
if (line == null) break;
else
wr.print("Case #" + count++ + ": ");
num = Integer.parseInt(line);
v1 = new long[num];
v2 = new long[num];
tokenizer = new StringTokenizer(rd.readLine(), " ");
for(int i = 0;tokenizer.hasMoreTokens();i++){
v1[i] = Long.parseLong(tokenizer.nextToken());
}
tokenizer = new StringTokenizer(rd.readLine(), " ");
for(int i = 0;tokenizer.hasMoreTokens();i++){
v2[i] = Long.parseLong(tokenizer.nextToken());
}
long temp;
for (int i = 0; i < num-1; i++) {
for(int j = i+1;j < num;j++){
if (v1[i] >= v1[j] ) {
temp = v1[i];
v1[i] = v1[j];
v1[j] = temp;
}
if (v2[i] <= v2[j] ) {
temp = v2[i];
v2[i] = v2[j];
v2[j] = temp;
}
}
}
long result = 0;
for(int i = 0;i < num;i++){
result += v1[i]*v2[i];
}
wr.println(result);
}
rd.close();
wr.close();
} |
e5e3a0ab-f0c0-4834-859f-c19fec97006d | 5 | @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
calcCellSize();
if (antSim == null) {
return;
}
for (int x = 0; x < antSim.getWidth(); x++) {
for (int y = 0; y < antSim.getHeight(); y++) {
if (map[x][y] == 1) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
g.fillRect(x * cellSize, y * cellSize, cellSize, cellSize);
}
}
for (Ant ant : antSim.getAnts()) {
g.setColor(ANT_COLOR);
g.fillRect(ant.getPos().getX() * cellSize, ant.getPos().getY() * cellSize, cellSize, cellSize);
}
} |
0de34e1d-eb47-4a7b-b2ee-67d41d51c37d | 7 | public void onEnable() {
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new JPBungee());
this.getConfig().options().copyDefaults(true);
this.saveConfig();
JumpPortsPlugin.logger = Logger.getLogger("Minecraft");
JumpPortsPlugin.plugin = this;
JumpPortsPlugin.pluginName = this.getDescription().getName();
JumpPortsPlugin.pluginVersion = this.getDescription().getVersion();
JumpPortsPlugin.lang = new Lang(this);
if (getServer().getPluginManager().getPlugin("Vault") != null) {
setupPermissions();
setupEconomy();
} else {
log(ChatColor.RED
+ "Missing dependency: Vault. Please install this for the plugin to work.");
getServer().getPluginManager().disablePlugin(plugin);
return;
}
if (getServer().getPluginManager().getPlugin("dynmap") != null) {
setupDynmap();
} else {
log(ChatColor.RED + "Dynmap support disabled.");
}
// Create ports folder
File theDir = new File(this.getDataFolder() + "/ports/"
+ File.separatorChar);
// if the directory does not exist, create it
if (!theDir.exists()) {
boolean result = theDir.mkdir();
if (result) {
log("Ports folder created.");
}
}
// Create players folder
theDir = new File(this.getDataFolder() + "/players/"
+ File.separatorChar);
// if the directory does not exist, create it
if (!theDir.exists()) {
boolean result = theDir.mkdir();
if (result) {
log("Players folder created.");
}
}
setupCommands();
PluginManager pm = getServer().getPluginManager();
Listener events = new Events(this);
pm.registerEvents(events, this);
Listener RDEvents = new RDEvents();
pm.registerEvents(RDEvents, this);
RDPlayers.loadAll();
JumpPorts.loadPorts();
try {
Metrics metrics = new Metrics(this);
Graph graph = metrics.createGraph("Number of Ports");
graph.addPlotter(new Metrics.Plotter("Ports") {
@Override
public int getValue() {
return JumpPorts.getList().size();
}
});
metrics.start();
} catch (IOException e) {
// Failed to submit the stats :-(
}
JumpPortsPlugin.updater = new UpdateCheck(this, "http://dev.bukkit.org/server-mods/jumpports/files.rss");
log(Lang.get("plugin.enabled"));
} |
4d26c16f-8fc8-47eb-996b-fa943fd47c00 | 4 | public void save()
{
DataOutputStream fos;
try {
if (!bufferedStrokes.isEmpty())
{
JOptionPane.showMessageDialog(rootPane, "Please wait for the file to buffer!");
return;
}
File lll = new File("maps");
if (!lll.exists())
{
lll.mkdir();
}
String name = JOptionPane.showInputDialog("Save as?");
File file = new File(dir+"maps"+File.separator+name+".ter");
fos = new DataOutputStream(new FileOutputStream(file));
fos.writeInt(www);
fos.writeInt(hhh);
for (int i = 0; i < writeData.length; i++)
{
fos.write(writeData[i]);
}
fos.flush();
fos.close();
} catch (HeadlessException | IOException ex) {
Logger.getLogger(MapMaker.class.getName()).log(Level.SEVERE, null, ex);
}
} |
15321c60-4058-49eb-bf8e-8a939f27f623 | 5 | private final String getChunk(String s, int slength, int marker)
{
StringBuilder chunk = new StringBuilder();
char c = s.charAt(marker);
chunk.append(c);
marker++;
if (isDigit(c))
{
while (marker < slength)
{
c = s.charAt(marker);
if (!isDigit(c))
break;
chunk.append(c);
marker++;
}
} else
{
while (marker < slength)
{
c = s.charAt(marker);
if (isDigit(c))
break;
chunk.append(c);
marker++;
}
}
return chunk.toString();
} |
855fe1df-9480-4866-a95f-9e2a091804da | 8 | public static final Instances stratify(Instances data, int folds, Random rand){
if(!data.classAttribute().isNominal())
return data;
Instances result = new Instances(data, 0);
Instances[] bagsByClasses = new Instances[data.numClasses()];
for(int i=0; i < bagsByClasses.length; i++)
bagsByClasses[i] = new Instances(data, 0);
// Sort by class
for(int j=0; j < data.numInstances(); j++){
Instance datum = data.instance(j);
bagsByClasses[(int)datum.classValue()].add(datum);
}
// Randomize each class
for(int j=0; j < bagsByClasses.length; j++)
bagsByClasses[j].randomize(rand);
for(int k=0; k < folds; k++){
int offset = k, bag = 0;
oneFold:
while (true){
while(offset >= bagsByClasses[bag].numInstances()){
offset -= bagsByClasses[bag].numInstances();
if (++bag >= bagsByClasses.length)// Next bag
break oneFold;
}
result.add(bagsByClasses[bag].instance(offset));
offset += folds;
}
}
return result;
} |
4d5244e3-db6e-42a4-bf19-3d0490ff07fa | 3 | private void processGetReplica(Sim_event ev)
{
if (ev == null) {
return;
}
Object[] data = (Object[]) ev.get_data();
if (data == null) {
return;
}
String filename = (String) data[0]; // get file name
Integer sender = (Integer) data[1]; // get sender id
// creates an object that contains the required information
Object[] dataTemp = new Object[3];
dataTemp[0] = filename;
ArrayList list = (ArrayList) catalogueHash_.get(filename);
if (list != null) {
dataTemp[1] = (Integer) list.get(0);
} else {
dataTemp[1] = new Integer(-1);
}
// sends back the result to sender
super.send(super.output, 0, DataGridTags.CTLG_REPLICA_DELIVERY,
new IO_data(dataTemp, DataGridTags.PKT_SIZE, sender.intValue()) );
} |
4edf650e-c638-4157-92d9-6ba5d18b941e | 7 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if(!jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED CHEQUE-----") && !jTextArea1.getText().trim().startsWith("-----BEGIN SIGNED VOUCHER-----")){
JOptionPane.showMessageDialog(this, "Please enter valid cheque","Error",JOptionPane.ERROR_MESSAGE);
return;
}
if(!jTextArea1.getText().contains(serverID)){
JOptionPane.showMessageDialog(this, "Cheque is not present on this server","Error",JOptionPane.ERROR_MESSAGE);
return;
}
System.out.println("Deposit Cheque accountID:"+accountID);
System.out.println("Deposit Cheque cheque value:"+jTextArea1.getText());
/* if(!jTextArea1.getText().contains(accountID)){
JOptionPane.showMessageDialog(this, "Cheque is not valid for this account","Error",JOptionPane.ERROR_MESSAGE);
return;
}*/
// TODO - Need to check if recepient NYM is not blank, it should be equl to nymID.
/*hasRecipient="true"
recipientUserID="Bg2QrSTomOEU5ICfvhfYfBYxQZPktDSnaVPpMLYxUnz"*/
if(jTextArea1.getText().trim().contains("hasRecipient=\"true\"") && !jTextArea1.getText().contains(nymID)){
JOptionPane.showMessageDialog(this, "The recipient NYM ID in cheque and your NYM ID do no match ","Error",JOptionPane.ERROR_MESSAGE);
return;
}
OpenTransactionAccount openTransaction = new OpenTransactionAccount();
try{
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
boolean success = openTransaction.depositCheque(serverID, nymID, accountID, jTextArea1.getText());
/**
* Reload the inbox and top accounts panel if success
*/
if(success){
JOptionPane.showMessageDialog(this, "Cheque deposited successfully","Success",JOptionPane.INFORMATION_MESSAGE);
Helpers.reloadOTDetails(accountID);
MainPage.reLoadAccount();
}
else
JOptionPane.showMessageDialog(this, "Error in cheque deposit","Error",JOptionPane.ERROR_MESSAGE);
}catch(Exception e){
e.printStackTrace();
} finally {
setCursor(Cursor.getDefaultCursor());
this.dispose();
}
}//GEN-LAST:event_jButton1ActionPerformed |
d7d599a1-194e-43b6-8df3-f9763625362c | 2 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final WildcardString other = (WildcardString) obj;
return (0==compareTo(other));
} |
ab61884b-d573-4fc5-b9a3-0d940fee3024 | 6 | public static boolean checkIssue(Status status, int assignee)
throws DAOException {
boolean emptyAssignee;
if (assignee == 0) {
emptyAssignee = true;
} else {
emptyAssignee = false;
}
boolean statusNew;
if (status.getId() == 1) {
statusNew = true;
} else {
statusNew = false;
}
if (statusNew && !emptyAssignee || !statusNew && emptyAssignee) {
throw new DAOException(MessageConstants.ERROR_ASSIGNEE_WRONG_STATUS);
}
return true;
} |
f3437d52-7714-46fe-a614-bf4725049a66 | 5 | @Override
public TreeRow next() {
if (hasNext()) {
if (mIterator == null) {
TreeRow row = mRows.get(mIndex++);
if (row instanceof TreeContainerRow) {
TreeContainerRow containerRow = (TreeContainerRow) row;
if (containerRow.getChildCount() > 0 && mPanel.isOpen(containerRow)) {
mIterator = new TreeRowViewIterator(mPanel, containerRow.getChildren());
}
}
return row;
}
return mIterator.next();
}
throw new NoSuchElementException();
} |
1de8ce75-8977-4fd2-be07-7c0a045e6670 | 7 | public void read(InputStream is)
throws IOException {
//Given the small size of MIDI files read all
//data into a ByteArrayStream for further processing
byte[] fileData = new byte[is.available()];
is.read(fileData);
ByteArrayInputStream bais =
new ByteArrayInputStream(fileData);
DataInputStream dis = new DataInputStream(bais);
//clear any SMF data
if (!this.trackList.isEmpty()) {
this.trackList.removeAllElements(); //remove any previous tracks
}
//check header for MIDIfile validity
if (dis.readInt() != 0x4D546864) {//Check for MIDI track validity
throw new IOException("This is NOT a MIDI file !!!");
} else {//If MIDI file passes skip length bytes
dis.readInt(); //skip over Length info
}
//get SMF Class data
try {
fileType = dis.readShort();
if (VERBOSE) System.out.println("MIDI file type = " + fileType);
this.numOfTracks = dis.readShort();
if (VERBOSE) System.out.println("Number of tracks = " + numOfTracks);
this.ppqn = dis.readShort();
if (VERBOSE) System.out.println("ppqn = " + ppqn);
} catch (IOException e) {
System.out.println(e);
e.printStackTrace();
}
// skip the tempo track fro type 1 files
/*
if(fileType == 1) {
skipATrack(dis);
numOfTracks--;
}
*/
//Read all track chunks
for (int i = 0; i < numOfTracks; i++) {
readTrackChunk(dis);
}
is.close();
dis.close();
} |
d2e96d11-0f79-46b6-8273-24ed2776fc15 | 4 | private String nodeHtmlString(TeaNode parent) {
String line = "<br/>|";
for (int i = 0; i < parent.level; i++) {
line += "-";
}
if (!parent.label.equals("")) {
line += "[" + parent.label + "]";
}
if (parent.classValue == null) {
line += parent.attribute;
} else {
line += " -> " + parent.classValue;
}
for (TeaNode node : parent.children) {
line += nodeHtmlString(node);
}
return line;
} |
468f406c-b915-4a1e-bb6c-31a64b68ea03 | 6 | private int getAmount(Location location, GoodsType goodsType) {
if (goodsType != null) {
if (location instanceof Building) {
Building building = (Building) location;
ProductionInfo info = building.getProductionInfo();
return (info == null || info.getProduction() == null
|| info.getProduction().size() == 0) ? 0
: info.getProduction().get(0).getAmount();
} else if (location instanceof ColonyTile) {
return ((ColonyTile)location).getTotalProductionOf(goodsType);
}
}
return 0;
} |
c520b2a3-f83f-4426-a2d4-79ebb80a97fc | 1 | @Override
public List<Position> getPositions() {
List<Position> positions = new ArrayList<Position>();
if (getPosition() != null)
positions.add(getPosition());
positions.addAll(otherPositions);
return positions;
} |
8e65e606-82b9-4770-9fb4-e743c6a554d2 | 6 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ReportScoreMessage that = (ReportScoreMessage) o;
if (score != that.score) return false;
if (!level.equals(that.level)) return false;
if (!token.equals(that.token)) return false;
return true;
} |
4a539581-3069-4934-ba80-7dc857e0bbca | 7 | public String[] getOptions() {
Vector<String> result;
result = new Vector<String>();
result.add("-mean-prec");
result.add("" + getMeanPrec());
result.add("-stddev-prec");
result.add("" + getStdDevPrec());
result.add("-col-name-width");
result.add("" + getColNameWidth());
result.add("-row-name-width");
result.add("" + getRowNameWidth());
result.add("-mean-width");
result.add("" + getMeanWidth());
result.add("-stddev-width");
result.add("" + getStdDevWidth());
result.add("-sig-width");
result.add("" + getSignificanceWidth());
result.add("-count-width");
result.add("" + getCountWidth());
if (getShowStdDev())
result.add("-show-stddev");
if (getShowAverage())
result.add("-show-avg");
if (getRemoveFilterName())
result.add("-remove-filter");
if (getPrintColNames())
result.add("-print-col-names");
if (getPrintRowNames())
result.add("-print-row-names");
if (getEnumerateColNames())
result.add("-enum-col-names");
if (getEnumerateRowNames())
result.add("-enum-row-names");
return result.toArray(new String[result.size()]);
} |
c0062f45-0395-4336-a1d6-cc41443ce3d8 | 2 | @Override
public synchronized void sendNow() {
packageDTO.setPacketNr(packageDTO.getPacketNr() + 1);
packageDTO.setTimestamp(TimeUtil.getSynchroTimestamp());
logger.trace("sending Paket #" + packageDTO.getPacketNr());
for (Connection c : kryoServer.getConnections()) {
if (c.isIdle())
c.sendUDP(packageDTO);
}
// kryoServer.sendToAllUDP(packageDTO);
packageDTO.getDtos().clear();
} |
5991b1e6-0e42-4b4b-9999-a24aef4c19d9 | 2 | public void draw(Graphics g) {
g.setColor(Color.BLUE);
g.drawRect(bounds.left(),bounds.top(),bounds.width()-1,bounds.height()-1);
if (nodes.get(0) != null) {
for (int i = 0; i < 4; i++) {
nodes.get(i).draw(g);
}
}
} |
e94b12f1-169a-4c78-9d7c-ccd2b9966c80 | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final Room target=mob.location();
if(target==null)
return false;
if(target.fetchEffect(ID())!=null)
{
mob.tell(L("The aura of harm is already here."));
return false;
}
final Ability oldPrayerA=target.fetchEffect("Prayer_AuraHeal");
if(oldPrayerA!=null)
{
oldPrayerA.unInvoke();
return false;
}
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=proficiencyCheck(mob,0,auto);
if(success)
{
final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?"":L("^S<S-NAME> @x1 for all to feel pain.^?",prayWord(mob)));
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
mob.location().show(mob,null,CMMsg.MSG_OK_VISUAL,L("A harmful aura descends over the area!"));
maliciousAffect(mob,target,asLevel,0,-1);
}
}
else
return maliciousFizzle(mob,target,L("<S-NAME> @x1 for an aura of harm, but <S-HIS-HER> plea is not answered.",prayWord(mob)));
// return whether it worked
return success;
} |
fd3025fc-a938-44a6-afe0-e125eddf1f66 | 4 | public File getTransactionFile(File file) throws IOException {
if (mStarted == 0) {
throw new IllegalStateException(NO_TRANSACTION_IN_PROGRESS);
} else if (file == null) {
throw new IllegalArgumentException(MAY_NOT_BE_NULL);
} else if (file.isDirectory()) {
throw new IllegalArgumentException(MAY_NOT_BE_DIRECTORY);
}
File transFile = mFiles.get(file);
if (transFile == null) {
transFile = File.createTempFile(".trn", null, file.getParentFile()); //$NON-NLS-1$
mFiles.put(file, transFile);
}
return transFile;
} |
c4ab6994-1959-4137-ad52-f5fcaaa08ab8 | 1 | @Override
public void addInheritence(String inher) {
if (!inheritence.contains(inher)) {
inheritence.add(inher);
}
} |
fe5df808-5c73-4db6-b64e-363dd1d9e18d | 1 | public void testPlus_Seconds() {
Seconds test2 = Seconds.seconds(2);
Seconds test3 = Seconds.seconds(3);
Seconds result = test2.plus(test3);
assertEquals(2, test2.getSeconds());
assertEquals(3, test3.getSeconds());
assertEquals(5, result.getSeconds());
assertEquals(1, Seconds.ONE.plus(Seconds.ZERO).getSeconds());
assertEquals(1, Seconds.ONE.plus((Seconds) null).getSeconds());
try {
Seconds.MAX_VALUE.plus(Seconds.ONE);
fail();
} catch (ArithmeticException ex) {
// expected
}
} |
209f82c2-6106-4c77-bcc8-2040220ef5f6 | 6 | public static char[][] AbrirTablaTrancicion(){
try{
File archivo = new File("src/txts/Tebla.txt");
BufferedReader txt = new BufferedReader(new FileReader(archivo));
String s = "";
String aux;
int largo = 0, alto = 0;
do {
aux = txt.readLine();
if (aux != null) {
alto ++;
largo = aux.length();
}
} while (aux != null);
char[][] tabla = new char[largo][alto];
txt = new BufferedReader(new FileReader(archivo));
int c = 0;
do {
aux = txt.readLine();
if (aux != null) {
for (int i = 0; i < largo; i++) {
tabla[i][c] = aux.charAt(i);
}
c ++;
}
} while (aux != null);
return tabla;
} catch(IOException e){return new char[0][0];}
} |
b671061a-cb81-4172-bd52-359aa4da7d70 | 1 | public static synchronized ResourceBundle getResourceBundle() {
if (bundle == null) {
bundle = ResourceBundle.getBundle("messages");
}
return bundle;
} |
80e77d82-6f1f-4d2f-b57f-4b431c4a2c43 | 2 | public static void openURL(final String link) {
try {
Desktop.getDesktop().browse(new URI(link));
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
} |
2afaedba-03ae-4d78-957d-abbfd2b615b9 | 0 | public UserOperator restart() {
stop();
run();
return this;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.