method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
b73cc871-13fd-4a00-84a5-0809c2321798 | 1 | public BigDecimal getValue(int row, int clums, int sheetat) {
BigDecimal value = new BigDecimal(0);
String s = null;
try {
hSheet = hWorkbook.getSheetAt(sheetat - 1);
hRow = hSheet.getRow(row - 1);
hCell = hRow.getCell(clums - 1);
hCell.setCellType(Cell.CELL_TYPE_STRING);
s = hCell.getStringCellValue();
value = new BigDecimal(s).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
value = new BigDecimal(0);
}
return value;
} |
c2958e55-a392-4ad4-824f-19ba91da27bd | 9 | private void fixup() {
// The trie has changed since we last
// found our toKey / fromKey
if(modCount != keyModCount) {
Iterator<Map.Entry<K, V>> iter = entrySet().iterator();
size = 0;
Map.Entry<K, V> entry = null;
if(iter.hasNext()) {
entry = iter.next();
size = 1;
}
fromKey = entry == null ? null : entry.getKey();
if(fromKey != null) {
TrieEntry<K, V> prior = previousEntry((TrieEntry<K, V>)entry);
fromKey = prior == null ? null : prior.getKey();
}
toKey = fromKey;
while(iter.hasNext()) {
size++;
entry = iter.next();
}
toKey = entry == null ? null : entry.getKey();
if(toKey != null) {
entry = nextEntry((TrieEntry<K, V>)entry);
toKey = entry == null ? null : entry.getKey();
}
keyModCount = modCount;
}
} |
9382307b-2018-4e9c-b067-b51af2b1bd56 | 7 | public static String convert(String coreNLPTag) {
if (coreNLPTag.startsWith("NN")) {
return "noun";
} else if (coreNLPTag.startsWith("VB")) {
return "verb";
} else if (coreNLPTag.startsWith("JJ")) {
return "adjective";
} else if (coreNLPTag.startsWith("RB")) {
return "adverb";
} else if (coreNLPTag.startsWith("DT")) {
return "determiner";
} else if (coreNLPTag.startsWith("IN")) {
return "preposition";
} else if (coreNLPTag.startsWith("TO")) {
return "to";
}
return null;
} |
27ff0726-4cb7-4bbc-b87a-5e43e5ba330a | 3 | 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 | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JanelaCadastroUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new JanelaCadastroUsuario().setVisible(true);
}
});
} |
498f20d7-4ca4-4059-8e93-b6cedf437e8a | 7 | private static boolean isDeclarationTarget(AnnotationDesc targetAnno) {
// The error recovery steps here are analogous to TypeAnnotations
ElementValuePair[] elems = targetAnno.elementValues();
if (elems == null
|| elems.length != 1
|| !"value".equals(elems[0].element().name())
|| !(elems[0].value().value() instanceof AnnotationValue[]))
return true; // error recovery
AnnotationValue[] values = (AnnotationValue[])elems[0].value().value();
for (int i = 0; i < values.length; i++) {
Object value = values[i].value();
if (!(value instanceof FieldDoc))
return true; // error recovery
FieldDoc eValue = (FieldDoc)value;
if (Util.isJava5DeclarationElementType(eValue)) {
return true;
}
}
return false;
} |
c09a22fc-bbfd-43bc-a4db-f3086525f46b | 6 | public boolean getBoolean(String key) throws JSONException {
Object o = get(key);
if (o.equals(Boolean.FALSE) ||
(o instanceof String &&
((String)o).equalsIgnoreCase("false"))) {
return false;
} else if (o.equals(Boolean.TRUE) ||
(o instanceof String &&
((String)o).equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONObject[" + quote(key) +
"] is not a Boolean.");
} |
5486e6c0-e844-489b-a943-8ea328f1d2c9 | 0 | @AfterClass
public static void tearDownClass() {
} |
89afb922-f393-4fec-8827-439fa088184c | 3 | @Override
public void die(){
if (sound.Manager.enabled) {
sound.Event effect = new sound.Event(getPosition(), getVelocity(),sound.Library.findByName(SOUND_EFFECT));
// make bigger asteroids explode bigger
effect.gain = EFFECT_VOLUME * scale.magnitude2();
effect.pitch = 0.6f;
sound.Manager.addEvent(effect);
}
velocity.timesEquals(0);
if(ParticleSystem.isEnabled())
ParticleSystem.addEvent((new Explosion<Fire>(Fire.class,this)).setIntensity((int)scale.magnitude2()));
if(scale.magnitude2() > SHATTER_THRESHOLD){
// Make a copy of this, but be sure it reset its HP
Asteroid a = new Asteroid(this);
a.scale = this.scale.times(0.5f);
a.hitPoints = a.calculateHitpoints();
a.id = null; // ID must be null or the actor set wont add it
// Move it a random direction half the radius for each piece
Vector3f displacement = Vector3f.newRandom(1).normalize().times(getRadius() * 0.52f);
Asteroid b = new Asteroid(a);
a.position.plusEquals(displacement);
a.velocity.plusEquals(displacement.times(FRAGMENT_SPEED));
a.setRotation(Quaternion.newRandom(100));
a.setAngularVelocity(Quaternion.newRandom(MAX_ROTATION_SPEED));
b.position.plusEquals(displacement.negate());
b.velocity.plusEquals(displacement.negate().times(FRAGMENT_SPEED));
b.setRotation(Quaternion.newRandom(100));
b.setAngularVelocity(Quaternion.newRandom(MAX_ROTATION_SPEED));
actors.add(a);
actors.add(b);
}
delete();
} |
fb578f28-074e-444a-94b1-34525b3c2840 | 6 | public void findRepetingElementsMethodOne(int[] a) {
/* Keep the aggregate XOR operation */
int xor = 0;
for (int i = 0; i < a.length; i++) {
xor ^= a[i];
}
for (int i = 0; i < a.length - 1; i++) {
xor ^= i;
}
/* Isolate the right-most bit set in xor */
int rightMostBitSet = xor & ~(xor - 1);
/* Revert process to get actual numbers */
int x = 0, y = 0;
for (int i = 0; i < a.length; i++) {
if ((a[i] & rightMostBitSet) > 0) {
x ^= a[i];
}else {
y ^= a[i];
}
}
for (int i = 0; i < a.length - 1; i++) {
if ((i & rightMostBitSet) > 0) {
x ^= i;
}else {
y ^= i;
}
}
System.out.printf("Repeated elements: x: %d y: %d\n", x, y);
} |
15c8d58a-f306-424d-8481-bb99f31010c4 | 7 | public ChatClient () {
client = new Client();
client.start();
// For consistency, the classes to be sent over the network are
// registered by the same method for both the client and server.
Network.register(client);
client.addListener(new Listener() {
public void connected (Connection connection) {
RegisterName registerName = new RegisterName();
registerName.name = name;
client.sendTCP(registerName);
}
public void received (Connection connection, Object object) {
if (object instanceof UpdateNames) {
UpdateNames updateNames = (UpdateNames)object;
chatFrame.setNames(updateNames.names);
return;
}
if (object instanceof ChatMessage) {
ChatMessage chatMessage = (ChatMessage)object;
chatFrame.addMessage(chatMessage.text);
return;
}
}
public void disconnected (Connection connection) {
EventQueue.invokeLater(new Runnable() {
public void run () {
// Closing the frame calls the close listener which will stop the client's update thread.
chatFrame.dispose();
}
});
}
});
// Request the host from the user.
String input = (String)JOptionPane.showInputDialog(null, "Host:", "Connect to chat server", JOptionPane.QUESTION_MESSAGE,
null, null, "localhost");
if (input == null || input.trim().length() == 0) System.exit(1);
final String host = input.trim();
// Request the user's name.
input = (String)JOptionPane.showInputDialog(null, "Name:", "Connect to chat server", JOptionPane.QUESTION_MESSAGE, null,
null, "Test");
if (input == null || input.trim().length() == 0) System.exit(1);
name = input.trim();
// All the ugly Swing stuff is hidden in ChatFrame so it doesn't clutter the KryoNet example code.
chatFrame = new ChatFrame(host);
// This listener is called when the send button is clicked.
chatFrame.setSendListener(new Runnable() {
public void run () {
ChatMessage chatMessage = new ChatMessage();
chatMessage.text = chatFrame.getSendText();
client.sendTCP(chatMessage);
}
});
// This listener is called when the chat window is closed.
chatFrame.setCloseListener(new Runnable() {
public void run () {
client.stop();
}
});
chatFrame.setVisible(true);
// We'll do the connect on a new thread so the ChatFrame can show a progress bar.
// Connecting to localhost is usually so fast you won't see the progress bar.
new Thread("Connect") {
public void run () {
try {
client.connect(5000, host, Network.port);
// Server communication after connection can go here, or in Listener#connected().
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
}
}.start();
} |
adfee78e-8869-42d2-8123-9a81fa2fde1e | 7 | public static void main(String[] args) {
Random r = new Random();
ArrayList<Integer> lista = new ArrayList<>();
BufferedReader buffer;
try {
File file = new File("numeroRandom");
buffer = new BufferedReader(new FileReader(file));
String line;
while ((line = buffer.readLine()) != null) {
lista.add(Integer.parseInt(line));
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
int contImpar = 0;
int contPar = 0;
int contadorOcorrencia = 0;
for (int i = 0; i < lista.size(); i++) {
contadorOcorrencia = 0;
for (int j = 0; j < lista.size(); j++) {
if(i==lista.get(j)){
contadorOcorrencia++;
}
}
if(contadorOcorrencia>0)
System.out.println("O número "+i+" apareceu "+contadorOcorrencia+ " vezes");
if (lista.get(i) % 2 == 0) {
contPar++;
} else {
contImpar++;
}
}
System.out.println("Tem " + contImpar + " números impar(es)");
System.out.println("Tem " + contPar + " números par(es)");
} |
95df641f-3ac1-4811-bd1d-244884f22b87 | 3 | @Override
public void deserialize(Buffer buf) {
mountUid = buf.readDouble();
if (mountUid < 0)
throw new RuntimeException("Forbidden value on mountUid = " + mountUid + ", it doesn't respect the following condition : mountUid < 0");
mountLocation = buf.readByte();
mountFoodUid = buf.readInt();
if (mountFoodUid < 0)
throw new RuntimeException("Forbidden value on mountFoodUid = " + mountFoodUid + ", it doesn't respect the following condition : mountFoodUid < 0");
quantity = buf.readInt();
if (quantity < 0)
throw new RuntimeException("Forbidden value on quantity = " + quantity + ", it doesn't respect the following condition : quantity < 0");
} |
f6784103-385c-4825-a357-4da6c2fb2322 | 7 | @SuppressWarnings("unchecked")
public void loadCache() {
if (!this.cacheEnabled)
return;
final String cacheFile = (this.cachePath == null) ? DEFAULT_CACHE_FILE : this.cachePath;
try {
// lock the lockfile
final FileInputStream fis = new FileInputStream(cacheFile);
final ObjectInputStream ois = new ObjectInputStream(fis);
final Object rval = ois.readObject(); // Loading caches can take
// very long
// (>250ms) for many entries
ois.close();
if (rval != null) {
this.cacheMap = (Map<String, JARInformation>) rval;
}
} catch (EOFException e) {
//
} catch (final FileNotFoundException e) {
// If file was not found, no problem ...
// e.printStackTrace();
} catch (final IOException e) {
e.printStackTrace();
} catch (final ClassNotFoundException e) {
this.logger
.warning("Your JSPF cache is outdated, please delete it. It will be regenerated with the next run. The next exception reflects this, so don't be afraid.");
e.printStackTrace();
}
} |
69fee4e9-4688-4877-b710-701f2d27a1e3 | 2 | public static void resolve(Tasks[] tasks, int currentTask, boolean[] used, int[] order, int orderPos) {
for (int i = 0; i < tasks[currentTask].reqs.size(); ++i) {
if (!used[tasks[currentTask].reqs.get(i)]) {
resolve(tasks, i, used, order, orderPos);
used[i] = true;
order[orderPos] = tasks[currentTask].reqs.get(i);
++orderPos;
}
}
} |
a445f933-7f09-492d-be79-22527639c9b7 | 1 | protected static Integer parseID(String string) {
try {
int num = Integer.parseInt(string);
return new Integer(num);
} catch (NumberFormatException e) {
return new Integer(-1);
}
} |
8fc67426-3086-4689-8479-0e14c42c6b11 | 1 | public static void reset() {
log.clear();
if (debug)
System.out.println("Clearing all intel");
} |
7c7dab5e-50a2-419f-9b40-affea85ab9f2 | 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(Formas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Formas.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 Formas().setVisible(true);
}
});
} |
6f66dbc3-3d00-4310-b9b2-a9b35d090951 | 0 | public boolean hasError() {
return error; // Return error status
} |
1f979eb8-473a-4083-a9a9-c62428f3f15f | 4 | @Override
public void handleInput() {
InputUpdate i = new InputUpdate();
i.input =-1;
if(Keys.isDown(Keys.W)){i.input = Keys.W;client.sendTCP(i);}
else if(Keys.isDown(Keys.S)){i.input = Keys.S;client.sendTCP(i);}
else if(Keys.isDown(Keys.A)){i.input = Keys.A;client.sendTCP(i);}
else if(Keys.isDown(Keys.D)){i.input = Keys.D;client.sendTCP(i);}
else client.sendTCP(i);
} |
dc5d3779-9d94-41ed-9dcf-0015243bf7d6 | 5 | public void parseInfoLines() {
chromLine = header.indexOf("#CHROM") >= 0;
if (vcfInfoById == null) {
vcfInfoById = new HashMap<String, VcfInfo>();
// Add standard fields
vcfInfoById.put("CHROM", new VcfInfo("CHROM", VcfInfoType.String, "1", "Chromosome name"));
vcfInfoById.put("POS", new VcfInfo("POS", VcfInfoType.Integer, "1", "Position in chromosome"));
vcfInfoById.put("ID", new VcfInfo("ID", VcfInfoType.String, "1", "Variant ID"));
vcfInfoById.put("REF", new VcfInfo("REF", VcfInfoType.String, "1", "Reference sequence"));
vcfInfoById.put("ALT", new VcfInfo("ALT", VcfInfoType.String, "A", "Alternative sequence/s"));
vcfInfoById.put("QUAL", new VcfInfo("QUAL", VcfInfoType.Float, "1", "Mapping quality"));
vcfInfoById.put("FILTER", new VcfInfo("FILTER", VcfInfoType.String, "1", "Filter status"));
vcfInfoById.put("FORMAT", new VcfInfo("FORMAT", VcfInfoType.String, "1", "Format in genotype fields"));
// Add well known fields
// Reference: http://www.1000genomes.org/wiki/Analysis/Variant%20Call%20Format/vcf-variant-call-format-version-41
vcfInfoById.put("AA", new VcfInfo("AA", VcfInfoType.String, "1", "Ancestral allele"));
vcfInfoById.put("AC", new VcfInfo("AC", VcfInfoType.Integer, "A", "Allele Frequency"));
vcfInfoById.put("AF", new VcfInfo("AF", VcfInfoType.Float, "1", "Allele Frequency"));
vcfInfoById.put("AN", new VcfInfo("AN", VcfInfoType.Integer, "1", "Total number of alleles"));
vcfInfoById.put("BQ", new VcfInfo("BQ", VcfInfoType.Float, "1", "RMS base quality"));
vcfInfoById.put("CIGAR", new VcfInfo("CIGAR", VcfInfoType.String, "1", "Cigar string describing how to align an alternate allele to the reference allele"));
vcfInfoById.put("DB", new VcfInfo("DB", VcfInfoType.Flag, "1", "dbSNP membership"));
vcfInfoById.put("DP", new VcfInfo("DP", VcfInfoType.Integer, "1", "Combined depth across samples"));
vcfInfoById.put("END", new VcfInfo("END", VcfInfoType.String, "1", "End position of the variant described in this record"));
vcfInfoById.put("H2", new VcfInfo("H2", VcfInfoType.Flag, "1", "Membership in hapmap 2"));
vcfInfoById.put("H3", new VcfInfo("H3", VcfInfoType.Flag, "1", "Membership in hapmap 3"));
vcfInfoById.put("MQ", new VcfInfo("MQ", VcfInfoType.Float, "1", "RMS mapping quality"));
vcfInfoById.put("MQ0", new VcfInfo("MQ0", VcfInfoType.Integer, "1", "Number of MAPQ == 0 reads covering this record"));
vcfInfoById.put("NS", new VcfInfo("NS", VcfInfoType.Integer, "1", "Number of samples with data"));
vcfInfoById.put("SB", new VcfInfo("SB", VcfInfoType.Float, "1", "Strand bias at this position"));
vcfInfoById.put("SOMATIC", new VcfInfo("SOMATIC", VcfInfoType.Flag, "1", "Indicates that the record is a somatic mutation, for cancer genomics"));
vcfInfoById.put("VALIDATED", new VcfInfo("VALIDATED", VcfInfoType.Flag, "1", "Validated by follow-up experiment"));
vcfInfoById.put("1000G", new VcfInfo("1000G", VcfInfoType.Flag, "1", "Membership in 1000 Genomes"));
// Structural variants
vcfInfoById.put("IMPRECISE", new VcfInfo("IMPRECISE", VcfInfoType.Flag, "0", "Imprecise structural variation"));
vcfInfoById.put("NOVEL", new VcfInfo("NOVEL", VcfInfoType.Flag, "0", "Indicates a novel structural variation"));
vcfInfoById.put("END", new VcfInfo("END", VcfInfoType.Integer, "1", "End position of the variant described in this record"));
vcfInfoById.put("SVTYPE", new VcfInfo("SVTYPE", VcfInfoType.String, "1", "Type of structural variant"));
vcfInfoById.put("SVLEN", new VcfInfo("SVLEN", VcfInfoType.Integer, ".", "Difference in length between REF and ALT alleles"));
vcfInfoById.put("CIPOS", new VcfInfo("CIPOS", VcfInfoType.Integer, "2", "Confidence interval around POS for imprecise variants"));
vcfInfoById.put("CIEND", new VcfInfo("CIEND", VcfInfoType.Integer, "2", "Confidence interval around END for imprecise variants"));
vcfInfoById.put("HOMLEN", new VcfInfo("HOMLEN", VcfInfoType.Integer, ".", "Length of base pair identical micro-homology at event breakpoints"));
vcfInfoById.put("HOMSEQ", new VcfInfo("HOMSEQ", VcfInfoType.String, ".", "Sequence of base pair identical micro-homology at event breakpoints"));
vcfInfoById.put("BKPTID", new VcfInfo("BKPTID", VcfInfoType.String, ".", "ID of the assembled alternate allele in the assembly file"));
vcfInfoById.put("MEINFO", new VcfInfo("MEINFO", VcfInfoType.String, "4", "Mobile element info of the form NAME,START,END,POLARITY"));
vcfInfoById.put("METRANS", new VcfInfo("METRANS", VcfInfoType.String, "4", "Mobile element transduction info of the form CHR,START,END,POLARITY"));
vcfInfoById.put("DGVID", new VcfInfo("DGVID", VcfInfoType.String, "1", "ID of this element in Database of Genomic Variation"));
vcfInfoById.put("DBVARID", new VcfInfo("DBVARID", VcfInfoType.String, "1", "ID of this element in DBVAR"));
vcfInfoById.put("DBRIPID", new VcfInfo("DBRIPID", VcfInfoType.String, "1", "ID of this element in DBRIP"));
vcfInfoById.put("MATEID", new VcfInfo("MATEID", VcfInfoType.String, ".", "ID of mate breakends"));
vcfInfoById.put("PARID", new VcfInfo("PARID", VcfInfoType.String, "1", "ID of partner breakend"));
vcfInfoById.put("EVENT", new VcfInfo("EVENT", VcfInfoType.String, "1", "ID of event associated to breakend"));
vcfInfoById.put("CILEN", new VcfInfo("CILEN", VcfInfoType.Integer, "2", "Confidence interval around the length of the inserted material between breakends"));
vcfInfoById.put("DP", new VcfInfo("DP", VcfInfoType.Integer, "1", "Read Depth of segment containing breakend"));
vcfInfoById.put("DPADJ", new VcfInfo("DPADJ", VcfInfoType.Integer, ".", "Read Depth of adjacency"));
vcfInfoById.put("CN", new VcfInfo("CN", VcfInfoType.Integer, "1", "Copy number of segment containing breakend"));
vcfInfoById.put("CNADJ", new VcfInfo("CNADJ", VcfInfoType.Integer, ".", "Copy number of adjacency"));
vcfInfoById.put("CICN", new VcfInfo("CICN", VcfInfoType.Integer, "2", "Confidence interval around copy number for the segment"));
vcfInfoById.put("CICNADJ", new VcfInfo("CICNADJ", VcfInfoType.Integer, ".", "Confidence interval around copy number for the adjacency"));
// Add SnpEff 'EFF' fields
vcfInfoById.put("EFF.EFFECT", new VcfInfo("EFF.EFFECT", VcfInfoType.String, ".", "SnpEff effect"));
vcfInfoById.put("EFF.IMPACT", new VcfInfo("EFF.IMPACT", VcfInfoType.String, ".", "SnpEff impact (HIGH, MODERATE, LOW, MODIFIER)"));
vcfInfoById.put("EFF.FUNCLASS", new VcfInfo("EFF.FUNCLASS", VcfInfoType.String, ".", "SnpEff functional class (NONE, SILENT, MISSENSE, NONSENSE)"));
vcfInfoById.put("EFF.CODON", new VcfInfo("EFF.CODON", VcfInfoType.String, ".", "SnpEff codon change"));
vcfInfoById.put("EFF.AA", new VcfInfo("EFF.AA", VcfInfoType.String, ".", "SnpEff amino acid change"));
vcfInfoById.put("EFF.AA_LEN", new VcfInfo("EFF.AA_LEN", VcfInfoType.Integer, ".", "Protein length in amino acids"));
vcfInfoById.put("EFF.GENE", new VcfInfo("EFF.GENE", VcfInfoType.String, ".", "SnpEff gene name"));
vcfInfoById.put("EFF.BIOTYPE", new VcfInfo("EFF.BIOTYPE", VcfInfoType.String, ".", "SnpEff gene bio-type"));
vcfInfoById.put("EFF.CODING", new VcfInfo("EFF.CODING", VcfInfoType.String, ".", "SnpEff gene coding (CODING, NON_CODING)"));
vcfInfoById.put("EFF.TRID", new VcfInfo("EFF.TRID", VcfInfoType.String, ".", "SnpEff transcript ID"));
vcfInfoById.put("EFF.RANK", new VcfInfo("EFF.RANK", VcfInfoType.String, ".", "SnpEff exon/intron rank"));
vcfInfoById.put("EFF.EXID", new VcfInfo("EFF.EXID", VcfInfoType.String, ".", "SnpEff exon ID"));
// Add SnpEff 'LOF' fields
vcfInfoById.put("LOF.GENE", new VcfInfo("LOF.GENE", VcfInfoType.String, ".", "SnpEff LOF gene name"));
vcfInfoById.put("LOF.GENEID", new VcfInfo("LOF.GENEID", VcfInfoType.String, ".", "SnpEff LOF gene ID"));
vcfInfoById.put("LOF.NUMTR", new VcfInfo("LOF.NUMTR", VcfInfoType.Integer, ".", "SnpEff LOF number of transcripts in gene"));
vcfInfoById.put("LOF.PERC", new VcfInfo("LOF.PERC", VcfInfoType.Float, ".", "SnpEff LOF percentage of transcripts in this gene that are affected"));
// Add SnpEff 'NMD' fields
vcfInfoById.put("NMD.GENE", new VcfInfo("NMD.GENE", VcfInfoType.String, ".", "SnpEff NMD gene name"));
vcfInfoById.put("NMD.GENEID", new VcfInfo("NMD.GENEID", VcfInfoType.String, ".", "SnpEff NMD gene ID"));
vcfInfoById.put("NMD.NUMTR", new VcfInfo("NMD.NUMTR", VcfInfoType.Integer, ".", "SnpEff NMD number of transcripts in gene"));
vcfInfoById.put("NMD.PERC", new VcfInfo("NMD.PERC", VcfInfoType.Float, ".", "SnpEff NMD percentage of transcripts in this gene that are affected"));
// Set all automatically added fields as "implicit"
for (VcfInfo vcfInfo : vcfInfoById.values())
vcfInfo.setImplicit(true);
//---
// Add all INFO fields from header
//---
for (String line : getLines()) {
if (line.startsWith("##INFO=") || line.startsWith("##FORMAT=")) {
VcfInfo vcfInfo = new VcfInfo(line);
vcfInfoById.put(vcfInfo.getId(), vcfInfo);
}
}
}
} |
d6083a05-5b96-402b-9833-c22d3cd1c2a1 | 1 | public boolean add(Object li) {
if (contains(li))
return false;
grow(1);
locals[count++] = (LocalInfo) li;
return true;
} |
0ce400aa-376e-4b2a-9d0c-94d0554de23b | 3 | @Override
public void processWalks(final WalkArray walks, final int[] atVertices) throws RemoteException {
try {
pendingQueue.put(new WalkSubmission(walks, atVertices));
int pending = pendingQueue.size();
if (pending > 50 && pending % 20 == 0) {
logger.info("Warning, pending queue size: " + pending);
}
} catch (Exception err) {
err.printStackTrace();
}
} |
0dd995b5-869c-438c-9924-c7954b1200e1 | 6 | public boolean movesremaining() {
for (int i = 0; i < bricks.length; i++) {
for (int j = 0; j < bricks[0].length; j++) {
if (bricks[i][j].state == true) {
boolean playing = remaining(i, j, 1);
if (bricks[i][j].color >= 6 && bricks[i][j].color <= 8)
playing = true;
if (playing)
return true;
}
}
}
return false;
} |
04d357f3-8ef9-47cf-92d3-bbe1aa98914f | 4 | public String salvar() {
try {
if (tarefa.getId() == null) {
tarefa.setStatus("1");
tarefaDao.salvar(tarefa);
mensagem = "Tarefa Salva com Sucesso!";
tarefa = new Tarefa();
} else {
// setando esses atributos, pois, eles não estão na tela. Assim não veem para o servidor, sendo necessário fazer isso, ou colocar campo hidden na view
getTarefa(tarefa.getId());
if (tarefa.getColaborador() == null) {
tarefa.setColaborador(tarefaOld.getColaborador());
}
tarefa.setProjeto(tarefaOld.getProjeto());
tarefa.setDataInicial(tarefaOld.getDataInicial());
//se tiver finalizando a tarefa...
if (tarefa.getStatus().equals("3")) {
tarefa.setDataFinal(new Date());
}
tarefaDao.atualizar(tarefa);
SalvarLog();
mensagem = "Tarefa Atualizada com Sucesso!";
}
limpar();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(mensagem));
getTarefas();
return "/listTarefa.xhtml";
} catch (Exception e) {
e.printStackTrace();
return "";
}
} |
d1c6daf2-8077-4e3e-8abb-efff4758e09e | 9 | private void setupFrame() {
_defaultFont = new FontUIResource("Dialog", Font.PLAIN, 12);
_boldFont = new FontUIResource("Dialog", Font.BOLD, 12);
_fixedFont = new FontUIResource("Monospaced", Font.PLAIN, 12);
_persistitAccentColor = new Color(119, 17, 34);
String lnfClassName = getProperty("lnf");
boolean lafLoaded = false;
if (lnfClassName != null && lnfClassName.length() > 0) {
try {
Class lnfClass = Class.forName(lnfClassName);
Method setPropertyMethod = null;
Enumeration props = _bundle.getKeys();
while (props.hasMoreElements()) {
String propName = (String) props.nextElement();
if (propName.startsWith("lnf.")) {
String propValue = _bundle.getString(propName);
if (setPropertyMethod == null) {
setPropertyMethod = lnfClass.getMethod("setProperty", new Class[] { String.class,
String.class });
}
setPropertyMethod.invoke(null, new Object[] { propName, propValue });
}
}
javax.swing.LookAndFeel lnf = (javax.swing.LookAndFeel) lnfClass.newInstance();
javax.swing.UIManager.setLookAndFeel(lnf);
lafLoaded = true;
} catch (Exception ex) {
System.err.println("Could not load LnF class " + lnfClassName);
ex.printStackTrace();
}
}
if (!lafLoaded) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// Ignore exception
}
}
setUIFont(_defaultFont);
_percentageFormat = new DecimalFormat(getProperty("PERCENTAGE_FORMAT"));
_dateFormat = new SimpleDateFormat(getProperty("DATE_FORMAT"));
_timeFormat = new DecimalFormat(getProperty("TIME_FORMAT"));
_longFormat = new DecimalFormat(getProperty("LONG_FORMAT"));
_integerFormat = new DecimalFormat(getProperty("INTEGER_FORMAT"));
_fileLocationFormat = getProperty("FILE_LOCATION_FORMAT");
_waitingMessage = getProperty("WaitingMessage");
_nullMessage = getProperty("NullMessage");
_taskStates = new String[7];
for (int state = 0; state < 7; state++) {
_taskStates[state] = getProperty("TaskState." + state);
}
_tabbedPane = new JTabbedPane();
_frame.getContentPane().add(_tabbedPane);
_frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
_frame.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent we) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// if (_frame != null)
// {
//
// Will restore normal operation to
// target Persistit instance
//
setManagement(null);
close();
// }
}
});
}
});
setupMenu();
setupTabbedPanes();
_tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
handleTabChanged();
}
});
handleTabChanged();
refreshMenuEnableState();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setFrameTitle(null);
_frame.pack();
_frame.setLocation((screenSize.width - _frame.getWidth()) / 2, (screenSize.height - _frame.getHeight()) / 2);
_frame.setVisible(true);
} |
90f72830-a658-4d8d-b541-6c0e224ae5e2 | 5 | private void btnAjouterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAjouterActionPerformed
// TODO add your handling code here:
if(!taAdresse.getText().equals("") && !tbfax.getText().equals("") && !tbtel.getText().equals(""))
{
PharmacieDAO pdao= new PharmacieDAO();
Pharmacie pp= new Pharmacie();
pp.setNom_ph(tbNomph.getText());
pp.setAdresse(taAdresse.getText());
pp.setFax(Integer.parseInt(tbfax.getText()));
pp.setTel(Integer.parseInt(tbtel.getText()));
pp.setType((String) cbtype.getSelectedItem());
pp.setGouvernorat((String) cbGvt.getSelectedItem());
// pp.setGarde(rbOui.getText());
// pp.setGarde(rbNon.getText());
String garde ="";
if(rbOui.isSelected())
garde=rbOui.getText();
if(rbNon.isSelected())
garde=rbNon.getText();
pp.setGarde(garde);
JOptionPane.showMessageDialog(null,"Pharmacie ajoutée !");
pdao.insertPharmacie(pp);
new pharmacieView().setVisible(true);
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"Tout les champs sont obligatoires !");
}
}//GEN-LAST:event_btnAjouterActionPerformed |
8d968556-82a6-45f3-8fbb-783b422726a6 | 5 | public boolean userName_IsValid(String user)
{
Connection con = null;
Statement stmt = null;
try {
DBconnection dbCon = new DBconnection();
Class.forName(dbCon.getJDBC_DRIVER());
con = DriverManager.getConnection(dbCon.getDATABASE_URL(),
dbCon.getDB_USERNAME(), dbCon.getDB_PASSWORD());
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select cst_id From customer Where cst_username='" + user+"'");
if (rs.next()) {
return false;
}
} catch (SQLException | ClassNotFoundException ex) {
System.err.println("Caught Exception: " + ex.getMessage());
} finally {
try {
if (stmt != null) {
stmt.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex) {
System.err.println("Caught Exception: " + ex.getMessage());
}
}
return true;
} |
0e0eee7b-e13a-408d-b3af-6d2b68a2f6cf | 8 | protected void txtFilterKeyPressEvent(KeyEvent arg0) {
Vector<Account> res = null;
if( txtFilter.getText().length() == 0 )
{
res=FkManager.getInstance().getList();
txtFilter.setBackground( defaultBgColor );
} else {
res = FkManager.getInstance().getList(txtFilter.getText());
if( res.size() < 1 )
{
txtFilter.setBackground( redColor );
} else if( res.size() == 1 )
{
txtFilter.setBackground( greenColor );
if( arg0.character== SWT.CR)
{
showTrigDialog(res.get(0));
}
} else {
txtFilter.setBackground( defaultBgColor );
}
}
if( res != null )
{
updateFilteredList( res );
if( res.size() > 0 )
{
if( arg0.keyCode == SWT.ARROW_UP )
{
lstAccountsControl.setFocus();
lstAccountsControl.setSelection( res.size()-1 );
}
if( arg0.keyCode == SWT.ARROW_DOWN )
{
lstAccountsControl.setFocus();
lstAccountsControl.setSelection( 0 );
}
}
}
} |
73bd0b74-c6f9-4648-9cb0-3f5cdae40c1c | 8 | final void method3049(ByteBuffer class348_sub49, int i, int i_72_) {
while_146_:
do {
try {
anInt9146++;
if (i_72_ == 31015) {
int i_73_ = i;
do {
if (i_73_ != 0) {
if ((i_73_ ^ 0xffffffff) != -2) {
if (i_73_ == 2)
break;
break while_146_;
}
} else {
aBoolean9140 = (class348_sub49.getUByte()
^ 0xffffffff) == -2;
return;
}
aBoolean9147 = class348_sub49.getUByte() == 1;
return;
} while (false);
((Class348_Sub40) this).aBoolean7045
= (class348_sub49.getUByte() ^ 0xffffffff) == -2;
break;
}
break;
} catch (RuntimeException runtimeexception) {
throw Class348_Sub17.method2929(runtimeexception,
("jia.F("
+ (class348_sub49 != null
? "{...}" : "null")
+ ',' + i + ',' + i_72_
+ ')'));
}
} while (false);
} |
d61fad1d-aaeb-466a-9952-45d5782c800c | 8 | public String getValue(String varName) throws VariableException {
String result = null;
if (gate == null)
throw new VariableException("cannot get var's value since no gate is currently loaded", varName);
if (varName.equals(VAR_TIME))
result = String.valueOf(time) + (clockUp ? "+" : " ");
else {
Node node = gate.getNode(varName);
if (node != null)
result = String.valueOf(node.get());
else {
String gateName = getVarChipName(varName);
if (gateName != null) {
int index = getVarIndex(varName);
// try to find if gateName is an internal part with GUI
BuiltInGateWithGUI guiChip = getGUIChip(gateName);
if (guiChip != null) {
try {
result = String.valueOf(guiChip.getValueAt(index));
} catch (GateException ge) {
throw new VariableException(ge.getMessage(), varName);
}
} else {
throw new VariableException("No such built-in chip used",
gateName);
}
}
if (result == null)
throw new VariableException("Unknown variable", varName);
}
}
return result;
} |
c7a95866-a462-4b45-b692-af30b6bdd9d0 | 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(Cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Cadastro.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Cadastro.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 Cadastro().setVisible(true);
}
});
} |
c3a7dbfc-317e-4ceb-9972-a3f9a06fba42 | 3 | public boolean authenticate() throws SessionException, IOException, GatewayValidationException {
if (!session_mode) {
throw new SessionException("This function can only be called when Session Mode is enabled.");
}
URL obj = new URL(URL + "auth?api_id=" + api_id + "&user=" + user + "&password=" + password);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
int responseCode = con.getResponseCode();
if (responseCode == 200) {
StringBuilder response;
try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
session_id = response.substring(4);
return true;
}
} else {
ErrorCode e = new ErrorCode(responseCode);
throw new GatewayValidationException(e.getErrorDescription());
}
} |
a2409674-8f18-4335-b646-7c626e602abf | 2 | @Override
public void update(final int delta) {
PlayerEntity player = game.getPlayer();
if (collisionBox.intersects(player.getCollisionBox()) && Math.abs(player.pos.y - pos.y - SIZE) < 3) {
collideWithPlayer(player, delta);
}
} |
9a10cc04-73dd-45b5-9773-e2c84f8dec51 | 3 | private boolean _jspx_meth_c_import_0(PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// c:import
org.apache.taglibs.standard.tag.rt.core.ImportTag _jspx_th_c_import_0 = (org.apache.taglibs.standard.tag.rt.core.ImportTag) _jspx_tagPool_c_import_url_nobody.get(org.apache.taglibs.standard.tag.rt.core.ImportTag.class);
_jspx_th_c_import_0.setPageContext(_jspx_page_context);
_jspx_th_c_import_0.setParent(null);
_jspx_th_c_import_0.setUrl("HyperLink.jsp");
int[] _jspx_push_body_count_c_import_0 = new int[] { 0 };
try {
int _jspx_eval_c_import_0 = _jspx_th_c_import_0.doStartTag();
if (_jspx_th_c_import_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
return true;
}
} catch (Throwable _jspx_exception) {
while (_jspx_push_body_count_c_import_0[0]-- > 0)
out = _jspx_page_context.popBody();
_jspx_th_c_import_0.doCatch(_jspx_exception);
} finally {
_jspx_th_c_import_0.doFinally();
_jspx_tagPool_c_import_url_nobody.reuse(_jspx_th_c_import_0);
}
return false;
} |
49313eec-ec3c-42f0-8c3e-b9b54489263b | 3 | private String getWest(char a) {
if ('0' == a) return "1, W";
if ('1' == a) return "0, halt";
if ('2' == a) return "3, W";
return "2, halt";
} |
acf76799-4641-409c-a419-f4666581e593 | 1 | private void readLines(final MyObjects myObjects, final BufferedReader reader) throws IOException {
String line;
try {
while ((line = reader.readLine()) != null) {
myObjects.addLine(line);
}
} finally {
reader.close();
}
} |
25a02e8f-1e97-4a32-8e44-311e989cba3c | 3 | public void Clear(){
num=0;
if(Composer instanceof FreeMMC)
Composer.setNotes(null);
else if(Composer instanceof AtonalMMC)
Composer =new AtonalMMC(compName,composer);
else if((Composer instanceof AlgorithmicMMC))
((AlgorithmicMMC) Composer).setNum(num);
} |
3d67efdd-e286-4f63-84df-0f9baa5ff07e | 2 | @Override public boolean equals(Object o){
if(o instanceof Peer){
return ip.equals(((Peer) o).ip)?true:false; //Love the Trinary Operations
}
return false;
} |
52eab402-4d43-4182-9400-99a2ad618bd2 | 5 | public void run() {
a = new Vector3D[bodies.size()];
for (int i = 0; i < bodies.size(); i++) { // Necessary to preload
// accelerations for
// leapfrog integration.
a[i] = getAcceleration(bodies.get(i));
}
aCraft = new Vector3D[ships.size()];
for (int p = 0; p < ships.size(); p++) {
aCraft[p] = getAccelerationForCraft(ships.get(p));
}
missionTime = 0;
for (int j = 0; j < maneuver.burns.length; j++) {
System.out.println("Waiting for burn " + j);
double stopTime = maneuver.burns[j].tOF - timeStep;
while (missionTime < stopTime) {
simulate(timeStep);
}
// So that the burn occurs exactly when it should, simulate the
// remainder of time before burning
simulate(maneuver.burns[j].tOF - stopTime);
ships.get(0).velocity.add(maneuver.burns[j].deltaV);
System.out.println("Finished burn " + j);
}
while (true) {
simulate(timeStep);
}
} |
e5b14579-f902-4e93-b54c-4ffd7845b215 | 6 | public static byte[] decodeBase64(String source) {
// Clean string
source = source.replaceAll("[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/_-]+", "");
int decodedLength = ((source.length() / 4) * 3) + (source.length() % 4 > 0 ? ((source.length() % 4) - 1) : 0);
byte[] decoded = new byte[decodedLength];
byte assembledByte = 0;
int targetIndex = 0;
for(int i = 0; i < source.length(); i++) {
int c = ((String) source).charAt(i) & 0xFF;
int b = (BASE_64_DECODING_TABLE[c - 43] & 0xFF);
int status = i % 4;
// ( 6 | 2) (4 | 4) (2 | 6)
switch (status) {
case 0:
assembledByte = (byte) (b << 2);
break;
case 1:
assembledByte = (byte) (assembledByte | (b >>> 4));
decoded[targetIndex] = assembledByte;
targetIndex++;
assembledByte = (byte) (b << 4);
break;
case 2:
assembledByte = (byte) (assembledByte | (b >>> 2));
decoded[targetIndex] = assembledByte;
targetIndex++;
assembledByte = (byte) (b << 6);
break;
case 3:
assembledByte = (byte) (assembledByte | b);
decoded[targetIndex] = assembledByte;
targetIndex++;
assembledByte = 0;
break;
}
}
return decoded;
} |
facd3673-9ba3-457a-93f5-d042fd12ec04 | 6 | public void SRC(){
pcIncrease();
int number = Integer.parseInt(getCOUNT().get(), 2);
getALU().OP1.set(SelectRegister().get());
if (getI().get().equals("0")&&getT().get().equals("0")){
getALU().arithShiftRight(number);
SelectRegister().set(getALU().RES.get());
}
else if (getI().get().equals("0")&&getT().get().equals("1"))
{
getALU().arithShiftLeft(number);
SelectRegister().set(getALU().RES.get());
}
else if (getI().get().equals("1")&&getT().get().equals("0")){
getALU().logicalShiftRight(number);
SelectRegister().set(getALU().RES.get());
}
else {
getALU().logicalShiftLeft(number);
SelectRegister().set(getALU().RES.get());
}
} |
2bcc87ea-8361-4016-9b7b-944303a6798f | 5 | public int getFacingNPC() {
TiledMap map = World.getWorld().getMap();
int layerIndex = map.getLayerIndex("npc");
Vector2 diff = getGridPosition().copy();
switch(getDirection()) {
case Direction.NORTH:
diff.addY(-1);
break;
case Direction.EAST:
diff.addX(2);
break;
case Direction.SOUTH:
diff.addY(2);
break;
case Direction.WEST:
diff.addX(-2);
diff.addY(1);
break;
}
int tileId = map.getTileId((int)diff.getX(), (int)diff.getY(), layerIndex);
if(tileId == 0)
return -1;
return Integer.parseInt(map.getTileProperty(tileId, "npcid", "-1"));
} |
a6c2495f-8360-4daa-a5df-067195ba945a | 2 | protected void setRootPane(RootPane rootPane) throws SlickException {
if (!guiInitialized) {
guiInitialized = true;
initGUI();
}
if (gui != null) {
gui.setRootPane(rootPane);
}
} |
83d93e8c-77de-4563-b858-5e59c9e6740b | 7 | private boolean fillBuffer(int minimum) throws IOException {
char[] buffer = this.buffer;
lineStart -= pos;
if (limit != pos) {
limit -= pos;
System.arraycopy(buffer, pos, buffer, 0, limit);
} else {
limit = 0;
}
pos = 0;
int total;
while ((total = in.read(buffer, limit, buffer.length - limit)) != -1) {
limit += total;
// if this is the first read, consume an optional byte order mark (BOM) if it exists
if (lineNumber == 0 && lineStart == 0 && limit > 0 && buffer[0] == '\ufeff') {
pos++;
lineStart++;
minimum++;
}
if (limit >= minimum) {
return true;
}
}
return false;
} |
e31989a6-74b0-4581-b13a-a5cc10eeba88 | 3 | public void addChilds(final HTML...childsToAdd) {
if ( childsToAdd == null )
return;
for (final HTML child : childsToAdd)
if ( !this.hasChild(child) ) {
child.setParent(this);
this.childs.add(child);
}
} |
fccb49c4-2102-4c18-992c-60c04f73b401 | 2 | private static int createOldStyleMask(StdImage image, List<byte[]> imageData, List<Integer> imageType, int type) {
int size = image.getWidth();
byte[] bytes = new byte[size * size];
int i = 0;
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
bytes[i++] = (byte) (image.getRGB(x, y) >>> 24);
}
}
imageData.add(bytes);
imageType.add(Integer.valueOf(type));
return 8 + bytes.length;
} |
bcc621d9-961d-4b98-ba58-838944103328 | 8 | public void update(Level level, int x, int y, int z, Random rand) {
boolean var7 = false;
z = z;
y = y;
x = x;
level = level;
boolean var8 = false;
boolean var6;
do {
--y;
if(level.getTile(x, y, z) != 0 || !this.canFlow(level, x, y, z)) {
break;
}
if(var6 = level.setTile(x, y, z, this.movingId)) {
var8 = true;
}
} while(var6 && this.type != LiquidType.LAVA);
++y;
if(this.type == LiquidType.WATER || !var8) {
var8 = var8 | this.flow(level, x - 1, y, z) | this.flow(level, x + 1, y, z) | this.flow(level, x, y, z - 1) | this.flow(level, x, y, z + 1);
}
if(!var8) {
level.setTileNoUpdate(x, y, z, this.stillId);
} else {
level.addToTickNextTick(x, y, z, this.movingId);
}
} |
db6df4c7-99bd-415b-a205-b5476bd12f36 | 8 | private void constructJson(JSONObject json) throws WeiboException {
try {
createdAt = parseDate(json.getString("created_at"), "EEE MMM dd HH:mm:ss z yyyy");
id = json.getString("id");
mid=json.getString("mid");
idstr = json.getLong("idstr");
text = json.getString("text");
if(!json.getString("source").isEmpty()){
source = new Source(json.getString("source"));
}
inReplyToStatusId = getLong("in_reply_to_status_id", json);
inReplyToUserId = getLong("in_reply_to_user_id", json);
inReplyToScreenName=json.getString("in_reply_toS_screenName");
favorited = getBoolean("favorited", json);
truncated = getBoolean("truncated", json);
thumbnailPic = json.getString("thumbnail_pic");
bmiddlePic = json.getString("bmiddle_pic");
originalPic = json.getString("original_pic");
repostsCount = json.getInt("reposts_count");
commentsCount = json.getInt("comments_count");
annotations = json.getString("annotations");
if(!json.isNull("user"))
user = new User(json.getJSONObject("user"));
if(!json.isNull("retweeted_status")){
retweetedStatus= new Status(json.getJSONObject("retweeted_status"));
}
mlevel = json.getInt("mlevel");
geo= json.getString("geo");
if(geo!=null &&!"".equals(geo) &&!"null".equals(geo)){
getGeoInfo(geo);
}
if(!json.isNull("visible")){
visible= new Visible(json.getJSONObject("visible"));
}
} catch (JSONException je) {
throw new WeiboException(je.getMessage() + ":" + json.toString(), je);
}
} |
17523e39-1e02-40d3-aec0-a4a9ae842c35 | 3 | @Override
public double distribute(TVC newCon) {
TVC con = null;
// We cloned connections to environment before, so we have to find our environment specific connection in our list. :(
for (TVC c: environment.getConnectionsSortedUp()) {
if (c.equals(newCon)) {
con = c;
}
}
Firewall fw1 = environment.getFirewalls()[con .getFirewallId1()];
Firewall fw2 = environment.getFirewalls()[con.getFirewallId2()];
Firewall fw = (fw2.getManagedIntencity() < fw1.getManagedIntencity()) ? fw2 : fw1;
fw.manageConnection(con);
return environment.dispersion();
} |
48abdafd-09e2-4820-ac7a-72bace30cac9 | 5 | @Override
public void actionPerformed(ActionEvent e) {
switch(e.getActionCommand()){
case "search":
LibrarianActionsControl.searchForBooks(this, new String[]{isbnField.getText(), (String) comboBox.getSelectedItem(), authorField.getText(), titleField.getText()});
break;
case "edit":
CardLayout layout = (CardLayout) this.getParent().getLayout();
String isbn = (String) table.getModel().getValueAt(table.getSelectedRow(), 0);
this.getParent().add(new LibrarianEditBookPanel(isbn), "editBook");
layout.show(this.getParent(), "editBook");
clearResults();
break;
case "remove":
CardLayout layout1 = (CardLayout) this.getParent().getLayout();
String isbn1 = (String) table.getModel().getValueAt(table.getSelectedRow(), 0);
this.getParent().add(new LibrarianRemoveBookPanel(isbn1), "editBook");
layout1.show(this.getParent(), "editBook");
clearResults();
break;
case "overdue":
break;
case "reservations":
break;
}
} |
c9f70cf0-ab71-4c29-b1b2-3a3120bbeb86 | 4 | public static void loadHats() {
ConfigManager.reload(plugin, "hats.yml");
FileConfiguration config = ConfigManager.get("hats.yml");
ConfigurationSection configurationSection = config.getConfigurationSection("hats");
loadedHats.clear();
for (String name : configurationSection.getKeys(false)) {
if (loadedHats.size() < 54) {
if(config.get("hats." + name + ".dataValue") != null) {
config.set("hats." + name + ".data-value", config.get("hats." + name + ".dataValue"));
config.set("hats." + name + ".dataValue", null);
}
double price = Main.isEconomyEnabled() ? config.getDouble("hats." + name + ".price") : 0;
Material material = Material.getMaterial(config.getString("hats." + name + ".material"));
String displayName = config.getString("hats." + name + ".display-name");
short dataValue = (short) config.getInt("hats." + name + ".data-value");
String description = config.getString("hats." + name + ".description");
Hat hat = new Hat(name, displayName, price, material, dataValue, description);
loadedHats.add(hat);
}
}
ConfigManager.save(plugin, "hats.yml");
} |
5b5c8205-7757-4c8d-88bf-d84ec7abe884 | 9 | public static char[] getResult(char[] state, Action action) {
for (int i=0; i<state.length; i++) {
if (state[i] == Puzzle.BLANK) {
char[] result = new char[state.length];
int boardSize = (int) Math.sqrt(state.length);
int iNew = i;
if (action == Action.Left) iNew += 1;
else if (action == Action.Right) iNew -= 1;
else if (action == Action.Up) iNew += boardSize;
else if (action == Action.Down) iNew -= boardSize;
for (int j=0; j<state.length; j++) {
if (j == i) result[j] = state[iNew];
else if (j == iNew) result[j] = state[i];
else result[j] = state[j];
}
return result;
}
}
return state;
} |
d890b990-52e4-4e1d-8bf9-346dcac0dbe5 | 0 | @Override
public ArrayList<Excel> getColoredExes() {
// TODO Auto-generated method stub
return coloredEx;
} |
3497ae5c-7c48-4151-9129-0b1e83c88565 | 6 | public static void generation() {
addToTable(constructers);
int start = 0;
while (true) {
if (Config.verbose >= 1) {
System.out.print("Generation : " + start + " ->");
}
ArrayList<Node> newList = new ArrayList<Node>();
ArrayList<Node> list = mainList.get(start);
int taille = list.size();
int i = 0;
Collections.sort(list, new NodeCompartor());
while (i < taille) {
Node tmp = list.get(i);
for (int j = 0; j < tmp.getFils().size(); j++) {
for (int z = 0; z < constructers.size(); z++) {
ArrayList <Node> t = tmp.AddLevel(constructers.get(z));
addList(t, newList);
}
}
i++;
}
mainList.add(newList);
System.out.println(PrintUtils.ArbresToDot(newList, "1"));
System.out.println(" Nb of Trees Generated : " + newList.size());
if(newList.size() == 0){
System.out.println("========================================");
break;
}
start++;
}
} |
923d3603-816f-4404-8cca-46cddb4bbb83 | 2 | private int getMinChildHeuristic(TrieNode node) {
int min = 0;
for (TrieNode child : node.getChildren().values()) {
if (child.getHeuristic() > min) {
min = child.getHeuristic();
}
}
return min;
} |
2fe01fcf-4c97-4633-b5ec-1746aff74b2f | 1 | public boolean dispatch(CommandSender sender, Command command, String label, String[] args) {
if (!this.commands.containsKey(label)) {
return false;
}
boolean handled = true;
CommandExecutor ce = (CommandExecutor) this.commands.get(label);
handled = ce.onCommand(sender, command, label, args);
return handled;
} |
4861fc00-bd04-4a3c-b707-c2192b10c448 | 7 | @Override
public void update() {
logger.trace("update: " + stateMachine.getState());
switch (stateMachine.getState()) {
case INGAME:
start.dispose();
game = new Game(penController, stateMachine);
break;
case MENU:
start = new StartMenu(stateMachine);
if (options != null) {
options.dispose();
}
if (result != null) {
result.dispose();
}
if (game != null) {
game.dispose();
}
break;
case OPTIONS:
options = new OptionsMenu(penController, stateMachine);
start.dispose();
break;
case RESULT:
result = new ResultDialog(penController, stateMachine);
game.dispose();
//Reinit penController for next game
this.penController = new PenController();
break;
default:
assert(false);
break;
}
} |
0d461712-e7f2-49a3-b381-d720b7d0e3af | 8 | public String toString()
{
int totalOutdegree = 0;
int totalIndegree = 0;
int totalNodes = 0;
int maxIndegree = 0;
int maxOutdegree = 0;
StringBuilder sb = new StringBuilder();
HashSet<Node> printed = new HashSet<Node>();
try
{
SimpleQueue<Node> queue = new SimpleQueue<Node>();
queue.add( start );
while ( !queue.isEmpty() )
{
Node node = queue.poll();
if ( node.indegree() > maxIndegree )
maxIndegree = node.indegree();
if ( node.outdegree() > maxOutdegree )
maxOutdegree = node.outdegree();
totalIndegree += node.indegree();
totalOutdegree += node.outdegree();
totalNodes++;
node.verify();
ListIterator<Arc> iter = node.outgoingArcs(this);
while ( iter.hasNext() )
{
Arc a = iter.next();
sb.append( a.toString() );
sb.append( "\n" );
a.to.printArc( a );
printed.add( a.to );
if ( a.to != end && a.to.allPrintedIncoming(constraint) )
{
queue.add( a.to );
}
}
}
Iterator<Node> iter2 = printed.iterator();
while ( iter2.hasNext() )
{
Node n = iter2.next();
n.reset();
}
}
catch ( Exception e )
{
System.out.println(sb.toString());
}
float averageOutdegree = (float)totalOutdegree/(float)totalNodes;
float averageIndegree = (float)totalIndegree/(float)totalNodes;
sb.append("\naverageOutdegree=" );
sb.append( averageOutdegree );
sb.append("\naverageIndegree=" );
sb.append( averageIndegree );
sb.append("\nmaxOutdegree=" );
sb.append( maxOutdegree );
sb.append("\nmaxIndegree=" );
sb.append( maxIndegree );
return sb.toString();
} |
3aa91705-5b9b-4b66-b6ff-d70110c7d0c2 | 1 | public void sortSccsBySize() {
Iterator<Integer> it = sccsOfLeader.keySet().iterator();
int i = 0;
while (it.hasNext()) {
int leaderVertex = it.next();
int sizeOfSccs = sccsOfLeader.get(leaderVertex).size();
sortedSCCsSize[i] = sizeOfSccs;
i++;
}
// sorting the array
int length = i;
System.out.println("length=" + length);
printSizeOfSccs(length, 0);
ArraySort.quickSort(sortedSCCsSize, 0, length - 1);
printSizeOfSccs(length, 1);
// for(int j=0;i<length-1;j++){
// for(int k=j+1;k<length;k++){
// if(sortedSCCsSize[j]<sortedSCCsSize[k]){
// int tmp = sortedSCCsSize[k];
// sortedSCCsSize[k] =sortedSCCsSize[j];
// sortedSCCsSize[j] =tmp;
// }
// }
// }
} |
c4a37904-e3c9-4f19-9e0c-30623db0f5e6 | 9 | public static String decrypt(String strToDecrypt, int ikey){
byte[] key = null;
if(ikey == 0){
key = thekey;
if(thekey == null){
return "ERROR: NO KEY";
}
}else if(ikey == 1){
key = the2ndkey;
if(the2ndkey == null){
return "ERROR: NO KEY2";
}
}else if(ikey == 2){
key = the3rdkey;
if(the3rdkey == null){
return "ERROR: NO KEY3";
}
}else if(ikey == 3){
key = the4thkey;
if(the4thkey == null){
return "ERROR: NO KEY4";
}
}else{
return "Invalid Key";
}
try{
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt)));
return decryptedString;
} catch (Exception e) {
Platform.runLater(new Runnable() {
@Override
public void run() {
Main.AddToConsoleField("[~] Wrong Key.");
}
});
return "Your String is not Encrypted! (" + ikey + ")";
}
} |
dbe5a1de-3138-4cef-b3f0-b2ed18777402 | 9 | private void removeSongButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSongButtonActionPerformed
List<Song> selected = ownedList.getSelectedValuesList();
for (Song s : selected) {
if(currUser.getLibrary().hasWaitingList(s))
{
Queue<User> users = currUser.getLibrary().getWaitingListUsers(s);
for(User u : users)
{
u.addNotification(s.getName() + " is no longer available.");
}
}
List<User> friends = currUser.getFriends();
for (User f : friends) {
if (f.getLibrary().borrowed().contains(s)) {
mMngr.takeBack(f, s);
f.addNotification(s.getName() + " has been removed.");
}
}
Map<String, Library> playlists = currUser.getLibrary().getPlayLists();
for (Map.Entry<String, Library> entry : playlists.entrySet())
{
if(entry.getValue().contains(s))
{
entry.getValue().removeSong(s);
}
}
currUser.getLibrary().removeSong(s);
Vector<String> tmp = new Vector<String>();
for (Map.Entry<String, Library> entry : playlists.entrySet()) {
tmp.add(entry.getKey());
List<Song> tmpSongs = entry.getValue().owned();
for (Song song : tmpSongs) {
tmp.add(" " + song.toString());
}
}
playListList.setListData(tmp.toArray());
}
loanedList.setListData(currUser.getLibrary().loaned().toArray());
ownedList.setListData(currUser.getLibrary().owned().toArray());
}//GEN-LAST:event_removeSongButtonActionPerformed |
164c77b4-62be-4cfc-9609-2ac96f79401a | 0 | public int getY(){
return y;
} |
f4d00658-4822-41f6-b217-bb01847c1156 | 5 | void setSpeed(int speed) {
switch (speed) {
case -2:
factor = 0;
break;
case -1:
factor = 0.5;
break;
case 0:
factor = 1.2;
break;
case 1:
factor = 2.5;
break;
case 2:
factor = 5.0;
break;
}
} |
e7d0c901-621e-4319-9e20-b0af35c2d9f4 | 2 | private void initCostsByCoordinates() {
for(int i = 0;i<coordinates.length;i++){
for(int j = 0;j<coordinates.length;j++){
costs[i][j] = calculateTravelCostsBetweenCities(i,j);
}
}
} |
35a066ee-5f64-47c8-8ed7-8f03febce0e8 | 6 | public void breadthFirstTraversal(){
LinkedQueueClass<Integer> queue =
new LinkedQueueClass<Integer>();
boolean[] visited;
visited = new boolean[gSize];
for (int ind = 0; ind < gSize; ind++)
visited[ind] = false; //initialize the array
//visited to false
for (int index = 0; index < gSize; index++){
if (!visited[index]){
queue.addQueue(index);
visited[index] = true;
System.out.print(" " + index + " ");
while (!queue.isEmptyQueue()){
int u = queue.front();
queue.deleteQueue();
UnorderedLinkedList<Integer>.
LinkedListIterator<Integer> graphIt
= graph[u].iterator();
while (graphIt.hasNext()){
int w1 = graphIt.next();
if (!visited[w1]){
queue.addQueue(w1);
visited[w1] = true;
System.out.print(" " + w1 + " ");
}
}
}
}
}
} |
0e9bc5e9-ad99-4309-97ee-7c064fa28073 | 7 | protected void inCloseTag(final char c)
{
switch(c)
{
case ' ': case '\t': case '\r': case '\n':
changedTagState(State.AFTERCLOSETAG);
return;
case '<': changeTagState(State.BEFORETAG); return;
case '>':
changeTagState(State.START);
closePiece(bufDex-1);
return;
case '/': changedTagState(State.BEFORECLOSETAG); return;
default: bufDex++; return;
}
} |
14d33aea-da2a-4d9f-ac4a-469a93d2300d | 0 | public PanelOptions getPanelSettings() {
return pnlSettings;
} |
7148ad9f-6140-4559-92f6-2a57e5db5a41 | 4 | public static void shiftSubArray(int[] arr, int from, int to, int offset){
int iters=0;
if(from>to){
iters=((arr.length-from)+to);
} else {
iters=(to-from)+1;
}
if(offset>0){
for(int i=0;i<iters;i++){
arr[Help.mod2(to+offset, arr.length)]=arr[to];
to = circleDecrement(to, arr.length);
}
} else {
for(int i=0;i<iters;i++){
arr[Help.mod2(from+offset, arr.length)]=arr[from];
from = circleIncrement(from, arr.length);
}
}
} |
2a6d4606-4e22-47a1-babf-4c9f572638dd | 2 | public static void main(String[] args) {
PriorityQueue<Integer> priorityQueue = new PriorityQueue<Integer>();
Random rand = new Random(47);
for (int i = 0; i < 10; i++)
priorityQueue.offer(rand.nextInt(i + 10));
QueueDemo.printQ(priorityQueue);
List<Integer> ints = Arrays.asList(25, 22, 20, 18, 14, 9, 3, 1, 1, 2,
3, 9, 14, 18, 21, 23, 25);
priorityQueue = new PriorityQueue<Integer>(ints);
QueueDemo.printQ(priorityQueue);
priorityQueue = new PriorityQueue<Integer>(ints.size(),
Collections.reverseOrder());
priorityQueue.addAll(ints);
QueueDemo.printQ(priorityQueue);
String fact = "EDUCATION SHOULD ESCHEW OBFUSCATION";
List<String> strings = Arrays.asList(fact.split(""));
PriorityQueue<String> stringPQ = new PriorityQueue<String>(strings);
QueueDemo.printQ(stringPQ);
stringPQ = new PriorityQueue<String>(strings.size(),
Collections.reverseOrder());
stringPQ.addAll(strings);
QueueDemo.printQ(stringPQ);
Set<Character> charSet = new HashSet<Character>();
for (char c : fact.toCharArray())
charSet.add(c); // Autoboxing
PriorityQueue<Character> characterPQ = new PriorityQueue<Character>(
charSet);
QueueDemo.printQ(characterPQ);
} |
0c47ebbd-3fb5-43df-a80e-57c149190811 | 8 | public static void initialiser_phase2(Vector<Vector<String>> data)
{
data.set(data.size()-1, z_initial);
z_type_courant = z_type;
System.out.println("Probleme de base : "+z_type_courant);
for(int i=1;i<data.size()-1;i++)
{
for(int j=1;j<data.lastElement().size()-1;j++)
{
if(data.get(i).get(0).equals(data.get(0).get(j)))
{
Simplexe.calculer(data, i+","+j);
}
}
}
boolean stop =false;
while(!stop)
{
for(int i=0;i<data.lastElement().size();i++)
{
if(data.get(0).get(i).matches("^a[0-9]+$"))
{
System.out.println("Colonne "+i+" a supprimer");
for(int j=0;j<data.size();j++)
{
data.get(j).remove(i);
}
break;
}
if(i==data.lastElement().size()-1)
stop=true;
}
}
} |
edc68665-6b66-4f9e-8ed8-92798ad6ce16 | 9 | public final void incremental(double value,int type){
double y=0.,yl=0.,yr=0.;
switch(type){
case 1:
nl += 1;
nr -= 1;
sl += value;
sr -= value;
s2l += value*value;
s2r -= value*value;
break;
case -1:
nl -= 1;
nr += 1;
sl -= value;
sr += value;
s2l -= value*value;
s2r += value*value;
break;
case 0:
break;
default: System.err.println("wrong type in Impurity.incremental().");
}
if(nl<=0.0){
vl=0.0;
sdl=0.0;
}
else {
vl = (nl*s2l-sl*sl)/((double)nl*((double)nl));
vl = Math.abs(vl);
sdl = Math.sqrt(vl);
}
if(nr<=0.0){
vr=0.0;
sdr=0.0;
}
else {
vr = (nr*s2r-sr*sr)/((double)nr*((double)nr));
vr = Math.abs(vr);
sdr = Math.sqrt(vr);
}
if(order <= 0)System.err.println("Impurity order less than zero in Impurity.incremental()");
else if(order == 1) {
y = va; yl = vl; yr = vr;
} else {
y = Math.pow(va,1./order);
yl = Math.pow(vl,1./order);
yr = Math.pow(vr,1./order);
}
if(nl<=0.0 || nr<=0.0)
impurity = 0.0;
else {
impurity = y - ((double)nl/(double)n)*yl - ((double)nr/(double)n)*yr;
}
} |
6cd20814-c47f-4c0d-a505-cb84e037fbca | 4 | public long skip(long n) throws IOException
{
long totalSkipped = 0;
long skipped;
// loop until bytes are really skipped.
while (totalSkipped < n)
{
skipped = in.skip(n-totalSkipped);
if (totalSkipped ==-1)
throw new IOException("skip not supported");
else if(skipped == 0)
return 0;
else
totalSkipped += totalSkipped + skipped;
}
//change the firstRead flag
if(firstRead)
firstRead = false;
return totalSkipped;
} |
6a2ab81d-eae5-4c8e-ae9d-38ea78c701b9 | 0 | public double normalAttack() {
return weaponSlot.increaseDamage((double)hero.fight());
} |
23707061-7b10-4f35-a1db-1801a8ddac93 | 6 | public void bingoClientGui() {
JFrame f = new JFrame("Bingo Law");
f.getContentPane().add(this);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
Dimension tela = Toolkit.getDefaultToolkit().getScreenSize();
setSize(tela.width, tela.height);
botoes = new ArrayList<JButton>(30);
setLayout(new GridLayout(7, 5));
String bingo = "BINGO";
for (int i = 0; i < 5; i++) {
final JButton buttoncol = new JButton(String.valueOf(bingo
.charAt(i)));
buttoncol.setBackground(Color.white);
add(buttoncol);
botoes.add(buttoncol);
buttoncol.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JButton b = (JButton) e.getSource();
try {
comp.verificaColuna(stub, b.getText());
} catch (RemoteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}
for (int i = 5; i < 29; i++) {
if (i == 17) {
add(label);
}
JButton button = new JButton("" + number.get(i - 5));
button.setBackground(Color.white);
add(button);
botoes.add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JButton b = (JButton) e.getSource();
if (b.getBackground().equals(Color.green)) {
b.setBackground(Color.white);
} else {
b.setBackground(Color.green);
}
System.out.println();
}
});
}
JButton buttonBingo = new JButton("BINGO!");
add(buttonBingo);
botoes.add(buttonBingo);
buttonBingo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
comp.verificaBingo(stub);
} catch (RemoteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
textArea.setLineWrap(true);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane( textArea );
add(scrollPane);
} |
c024e252-c67d-4cec-91c6-891dc5fecf0f | 2 | public boolean Exist(String Stu_ID, String PassCode) {
try {
StringBuffer sql = new StringBuffer();
sql.append(" select * from student where");
sql.append(" stu_ID='");
sql.append(Stu_ID);
sql.append("' && stu_Passcode='");
sql.append(PassCode);
sql.append("';");
SQLHelper sqlHelper = new SQLHelper();
sqlHelper.sqlConnect();
ResultSet rs = sqlHelper.runQuery(sql.toString());
if (rs.next()) {
return true;
}
} catch (SQLException ex) {
Logger.getLogger(Student_DAO.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
return false;
} |
47023992-da7f-4d59-887c-39ea8d6281d0 | 7 | private void ParseTable() throws IOException{
List<String> symbols = new ArrayList<String>();
List<Integer> synchronizationSymbols = new ArrayList<Integer>();
// Symbols
BufferedReader br = new BufferedReader(new FileReader("src/hr/unizg/fer/labComplete/symbols.txt"));
String line;
while ((line = br.readLine()) != null) {
symbols.add(line);
}
br.close();
// Synchronization Symbols
br = new BufferedReader(new FileReader("src/hr/unizg/fer/labComplete/synchronizationSymbols.txt"));
while ((line = br.readLine()) != null) {
synchronizationSymbols.add(Integer.parseInt(line));
}
br.close();
mSTB = new SyntaxTreeBuilder(symbols, synchronizationSymbols);
// Now populate action table.
br = new BufferedReader(new FileReader("src/hr/unizg/fer/labComplete/actionTable.txt"));
while ((line = br.readLine()) != null) {
line += " "; // this is needed for the algorithm to know when to stop.
int i = line.indexOf(" ") + 1;
int inputIndex = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int stateIndex = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int actionTypeInt = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
ActionType actionType;
switch (actionTypeInt){
case 0: actionType = ActionType.Move; break;
case 1: actionType = ActionType.Reduce; break;
case 2: actionType = ActionType.Accept; break;
default: actionType = null; break;
}
i = line.indexOf(" ") + 1;
int actionSpecificValue_a = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int actionSpecificValue_b = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int productionPriority = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
mSTB.AddActionCell(inputIndex, stateIndex, actionType, actionSpecificValue_a, actionSpecificValue_b, productionPriority);
}
br.close();
// Now populate new_state table.
br = new BufferedReader(new FileReader("src/hr/unizg/fer/labComplete/newStateTable.txt"));
while ((line = br.readLine()) != null) {
line += " "; // this is needed for the algorithm to know when to stop.
int i = line.indexOf(" ") + 1;
int inputIndex = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int stateIndex = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
i = line.indexOf(" ") + 1;
int actionSpecificValue = Integer.parseInt(line.substring(0, i - 1));
line = line.substring(i);
mSTB.AddNewStateCell(inputIndex, stateIndex, actionSpecificValue);
}
br.close();
} |
4c45b70c-9dba-4559-8c25-d57a3991aece | 8 | protected Map<String,String> getProperties(final Object obj) {
HashMap<String,String> map = new HashMap<String,String>();
map.putAll(getMapProperties(obj));
try {
BeanInfo info = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] pds = info.getPropertyDescriptors();
if(pds!=null) {
for(PropertyDescriptor pd : pds) {
String name = pd.getName();
if(!"class".equals(name)) {
name = processName(name);
String result = null;
if(pd instanceof IndexedPropertyDescriptor) {
// Ignore indexed methods.
} else {
if("data".equals(name) && isInstanceofMap(pd.getReadMethod().getReturnType())) {
map.putAll(extractDataAttributes(pd, obj));
} else {
result = getResult(pd, obj);
}
}
if(!StringUtils.isEmpty(result)) {
map.put(name,result);
}
}
}
}
} catch (IntrospectionException e) {
}
return map;
} |
af3c14fa-877c-44d3-a664-0f3f732a7220 | 4 | public ShortcutableComponent(Component comp){
comp.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if(shortcutRepeated){
return;
}
if(! (e.getKeyCode() == KeyEvent.VK_CONTROL || e.getKeyCode() == KeyEvent.VK_ALT || e.getKeyCode() == KeyEvent.VK_SHIFT) ){
shortcutRepeated = true;
}
/*
if(e.getModifiers() == InputEvent.CTRL_MASK){
if(e.getKeyCode() == KeyEvent.VK_C){
WidgetMgr.MAIN_WINDOW.copy();
}
else if(e.getKeyCode() == KeyEvent.VK_V){
WidgetMgr.MAIN_WINDOW.paste();
}
}
else{
if(e.getKeyCode() == KeyEvent.VK_INSERT){
newMap(false);
}
else if(e.getKeyCode() == KeyEvent.VK_DELETE){
WidgetMgr.MAIN_WINDOW.delete();
}
}*/
}
@Override
public void keyReleased(KeyEvent e) {
shortcutRepeated = false;
}
});
} |
bdb28612-9c7f-44b4-a860-8e2dab0d01ec | 5 | protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
System.out.println("[doEvaluate]");
//System.out.println("[scanner]"+(char)scanner.read());
//System.out.println("[Column]"+scanner.getColumn());
if (resume) {
if (endSequenceDetected(scanner))
return fToken;
} else {
int c= scanner.read();
if (c == fStartSequence[0]) {
if (sequenceDetected(scanner, fStartSequence, false)) {
if (endSequenceDetected(scanner))
return fToken;
}
}
}
scanner.unread();
return Token.UNDEFINED;
} |
ef90090b-0640-4c1d-908b-ca314614fd37 | 1 | private void start()
{
thePlayer.currentLocation = location.MainMenu; //The main menu is actually a special location
while(running == false)
{
System.out.println("--- P A R A S I T E ---\n- New Game\n- Help\n- Quit Game");
input.waitForCommand(); //wait for command referenced in CommandInput
}
} |
cef642f3-bc7f-482e-a129-6fb7a52d4af1 | 9 | public String nextToken() throws JSONException {
char c;
char q;
StringBuffer sb = new StringBuffer();
do {
c = next();
} while (Character.isWhitespace(c));
if (c == '"' || c == '\'') {
q = c;
for (;;) {
c = next();
if (c < ' ') {
throw syntaxError("Unterminated string.");
}
if (c == q) {
return sb.toString();
}
sb.append(c);
}
}
for (;;) {
if (c == 0 || Character.isWhitespace(c)) {
return sb.toString();
}
sb.append(c);
c = next();
}
} |
f1fb4065-ab8b-4a85-80fb-3efff29b524d | 1 | public static void main(String[] args) {
int larger, smaller;
/*InputStreamReader isr = null;
BufferedReader br = null;
isr = new InputStreamReader(System.in);
br = new BufferedReader(isr);
*/
String str ="1,2,3";
String[] s = str.split(",");
List<Integer> list = new ArrayList<>();
for (int i = 0; i < s.length; i++) {
list.add(Integer.parseInt(s[i]));
}
Collections.sort(list);
larger = list.get(1) * list.get(1) + list.get(2) * list.get(2);
smaller = list.get(0) * list.get(0) + list.get(1) * list.get(1);
System.out.println(larger-smaller);
String s2 = "65";
System.out.println((char)65);
/*
char[] c = str.toCharArray();
for (int i = 0; i < c.length; i++) {
System.out.print((int)c[i]);
}
*/
/* try {
str = br.readLine();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println(str);
try {
isr.close();
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
} |
6e11398c-6f6b-42e7-ae57-74bff2b6ea0b | 2 | @Override
public void onCombatTick(int x, int y, Game game) {
SinglePlayerGame spg = (SinglePlayerGame) game;
List<Entity> zombies = filterByID(spg
.getSquareNeighbors(x, y, 1), zombie.id);
for (Entity entity : zombies) {
if (((MortalEntity) entity).damage(3)) {
spg.addAnimation(Animation.hitAnimationFor(3, entity, spg));
human.damageDealt += 3;
human.kills++;
zombie.deaths++;
}
}
} |
b66e909f-4efa-49c0-9cf9-be9f1eb4952a | 5 | public DoublyLinkedListNode<T> deleteNode(int index) {
// Check for out of bounds insertion.
if (index > size) {
return null;
}
DoublyLinkedListNode<T> deleteNode = null;
DoublyLinkedListNode<T> newNextNode = null;
// Find the node before the node we want to delete.
DoublyLinkedListNode<T> current = startNode;
for (int i = 0; i < index - 1; i++) {
current = current.getNextNode();
}
// Deal with special cases.
if (size == 1) {
deleteNode = current;
startNode = null;
endNode = null;
} else if (index == 0) {
deleteNode = current;
startNode = current.getNextNode();
} else if (index == size - 1) {
deleteNode = current.getNextNode();
current.setNextNode(null);
endNode = current;
} else {
deleteNode = current.getNextNode();
newNextNode = current.getNextNode().getNextNode();
newNextNode.setPreviousNode(current);
current.setNextNode(newNextNode);
}
size--;
return deleteNode;
} |
dd85724c-4f52-46aa-8998-0ba7f4be4eaf | 4 | public boolean isInsideBoard(Position pos){
boolean inside = false;
if (pos.getX()<this.getSize().getWidth() && pos.getX()>=0 &&
pos.getY()<this.getSize().getHeight() && pos.getY()>=0)
inside=true;
return inside;
} |
23ed61a1-e3f4-453b-913d-1b3228e01c4f | 2 | public MNSASpi(Object param) {
try {
Connection c = USBConnectionFactory.getConnection();
if(c == null){
throw new IOException("No CardReader found.");
}
this.terminals = new MNSACardTerminals(c);
} catch (PortInUseException | UnsupportedCommOperationException | IOException e) {
throw new RuntimeException(e);
}
} |
a2dab896-88bc-4ac5-9b9f-a2a478d5e90e | 2 | public void dumpExpression(TabbedPrintWriter writer)
throws java.io.IOException {
if (!subExpressions[0].getType().isOfType(Type.tString)
&& !subExpressions[1].getType().isOfType(Type.tString)) {
writer.print("\"\"");
writer.breakOp();
writer.print(getOperatorString());
}
subExpressions[0].dumpExpression(writer, 610);
writer.breakOp();
writer.print(getOperatorString());
subExpressions[1].dumpExpression(writer, 611);
} |
e332ac14-d064-4d89-b8d9-472550699f37 | 9 | public static void main(String[] args) throws Throwable {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int cases = parseInt(in.readLine());
for (int casos = 0; casos < cases; casos++) {
int n = parseInt(in.readLine().split(" ")[2]);
mat = new long[n][n];
for (int i = 0; i < n; i++) {
StringTokenizer st = new StringTokenizer(in.readLine());
for (int j = 0; j < n; j++) {
mat[i][j] = parseLong(st.nextToken());
}
}
boolean symmetric = true;
for (int i = 0; i < mat.length && symmetric; i++) {
for (int j = 0; j < mat.length; j++) {
if(i!=j)
if(mat[i][j] != mat[j][i])
symmetric=false;
}
}
if(symmetric)
System.out.println("Test #"+(casos+1)+": Symmetric.");
else
System.out.println("Test #"+(casos+1)+": Non-symmetric.");
}
} |
f3c81581-97da-40e7-86df-dabda9ca5c22 | 5 | private void parseBaseLevel(Node node) throws TemplateException {
if (node.getNodeName().equals("dc:title")) {
template.setTitle(node.getTextContent());
template.getDcAttributes().add(new DCAttribute("dcterms.title", node.getTextContent()));
} else if (node.getNodeName().substring(0, 3).equals("dc:")) {
String nodeName = node.getNodeName().substring(3);
if (nodeName.equals("type")) {
template.getDcAttributes().add(new DCAttribute("dcterms.type", "IMAGE_REPORT_TEMPLATE"));
} else {
if (nodeName.equals("identifer")) {
nodeName = "identifier";
}
template.getDcAttributes().add(new DCAttribute("dcterms." + nodeName, node.getTextContent()));
}
} else if (node.getNodeName().equals("start")) {
parseStartLevel(node);
}
} |
b96ca263-d3a0-4dab-8518-ee704598e93b | 3 | public void visitForceChildren(final TreeVisitor visitor) {
if (visitor.reverse()) {
target.visit(visitor);
}
final Iterator e = operands().iterator();
while (e.hasNext()) {
final Expr operand = (Expr) e.next();
operand.visit(visitor);
}
if (!visitor.reverse()) {
target.visit(visitor);
}
} |
907b5951-e6a8-4113-9d6d-9aecda77dc5a | 5 | public int calculateState(int n) {
if (dp[n] != 0)
return dp[n];
for (int i = 2; i < n; i++) {
if (n % i == 0) {
if (calculateState(n - i) == -1) {
dp[n] = 1;
break;
}
}
}
if (dp[n] == 0)
dp[n] = -1;
return dp[n];
} |
ab4e3d90-fe63-4acf-9222-a1c3e79cd2cd | 1 | public void sendObjectToServer (String outType, Object outObj) {
try {
createSocketAndSend(outType, outObj);
}
catch (Exception e) {
System.out.println("Something went wrong trying to send the object...");
}
} |
cd0c5c07-1355-4f92-aaf8-7ec0f0c91c75 | 3 | public double coutAttaque(Peuple attaquant) {
double cout = this.nbUnite;
Iterator<Element> it = this.elements.iterator();
while (it.hasNext()) {
cout += it.next().bonusDefense(attaquant);
}
if (this.occupant != null) {
cout += this.occupant.bonusDefense(this, attaquant);
}
return cout <= 0 ? 1 : cout;
} |
ba8a4fb4-543e-46c5-93b1-fab889ce6177 | 8 | public static String[] buildRicListFromFile(String ricFileName, int maxCount)
{
RandomAccessFile dataFile = null;
try
{
int i = 0;
dataFile = new RandomAccessFile(ricFileName, "r");
String line = dataFile.readLine();
ArrayList<String> itemList = new ArrayList<String>();
while (line != null && (line = line.trim()).length() > 0)
{
line = dataFile.readLine();
if ((maxCount == -1 || i < maxCount) && line != null
&& (line = line.trim()).length() > 0)
{
itemList.add(line);
i++;
}
}
String[] ricList = new String[itemList.size()];
ricList = (String[])itemList.toArray(ricList);
dataFile.close();
dataFile = null;
itemList = null;
return ricList;
}
catch (FileNotFoundException ex)
{
return null;
}
catch (IOException ex)
{
System.out.println("IO error processing " + ex.getMessage());
System.out.println("Exiting...");
System.exit(1);
}
return null;
} |
d3620a27-33c9-414e-b41a-7c7793ceaf2c | 7 | public T remove(long seqno) {
lock.lock();
try {
if(seqno < low || seqno > high)
return null;
int index=index(seqno);
T retval=buffer[index];
if(retval != null && removes_till_compaction > 0)
num_removes++;
buffer[index]=null;
if(seqno == low)
advanceLow();
if(removes_till_compaction > 0 && num_removes >= removes_till_compaction) {
_compact();
num_removes=0;
}
return retval;
}
finally {
lock.unlock();
}
} |
cc9e1feb-1284-46a4-a256-8c2da21c8669 | 0 | public EventObject getEvent() {
return event;
} |
4269fedb-43b9-4733-a9f6-7aa4b3107518 | 7 | @Override
public int castingQuality(MOB mob, Physical target)
{
if(mob!=null)
{
final Room R=mob.location();
if((R!=null)&&(!R.getArea().getClimateObj().canSeeTheMoon(R,null)))
{
if((R.getArea().getTimeObj().getTODCode()!=TimeClock.TimeOfDay.DAWN)
&&(R.getArea().getTimeObj().getTODCode()!=TimeClock.TimeOfDay.DAY))
return Ability.QUALITY_INDIFFERENT;
if((R.domainType()&Room.INDOORS)>0)
return Ability.QUALITY_INDIFFERENT;
if(R.fetchEffect(ID())!=null)
return Ability.QUALITY_INDIFFERENT;
return super.castingQuality(mob, target,Ability.QUALITY_BENEFICIAL_SELF);
}
}
return super.castingQuality(mob,target);
} |
ddc10998-7fdb-4477-b560-ce8ec9c90a39 | 2 | public Person GetPerson()
{
//first person in line
Person tmp = null;
if(Count() != 0)
{
//pickup priority person
tmp = busStop.poll();
if(Count() == 0)
{
//reset priority
priority = 0;
}
}
//person going to the bus
return tmp;
} |
f52dcf79-b100-45c2-8273-9c3f20c1b94c | 6 | public void run()
{
if (DEBUG) log("Attempting to run TaskRemoval");
ArrayList<Task> tasks = TaskCommander.getTasks();
if (DEBUG) log("Remove the task contained in this command from the existing tasks list");
tasks.remove(task);
if (taskViewsToUpdate != null)
{
if (DEBUG) log("Remove task from taskViewToUpdate");
for (TaskView taskView : taskViewsToUpdate)
{
taskView.removeTask(task);
}
}
else
{
if (DEBUG) log("Since taskViewToUpdate was null, we did nothing.");
}
} |
fa8525ce-96b9-4a28-9eb9-bcbbdba81835 | 0 | private void anothing()
{
System.out.println("功能C");
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.