method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
ef9cb443-406e-4ddd-a03b-bfc97ad2abbb
| 3
|
public void loadAll() throws IOException
{
//xstream
XStream xstream = new XStream();
xstream.alias("configuration", Configuration.class);
xstream.alias("domain", Domain.class);
xstream.alias("mimeType", MimeType.class);
try
{
this.element = this.loadFromFile(xstream);
}
catch (IOException ioException)
{
this.element = this.generateDefault();
}
if (!this.file.exists())
{
//create directory
this.root.mkdir();
this.directory.mkdir();
try (FileOutputStream fileOutputStream = new FileOutputStream(this.file))
{
xstream.toXML(this.element, fileOutputStream);
}
catch (IOException ioException)
{
throw ioException;
}
}
}
|
6b369aa4-9fae-40c5-b8c3-deb8355e81ab
| 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(MedicineSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MedicineSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MedicineSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MedicineSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
MedicineSearch dialog = new MedicineSearch(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
|
617d4390-368d-4b2d-a5fb-48377b753c4f
| 4
|
public boolean Reset(String ticket, String lastName) throws Exception {
try {
//Load the MySQL driver
Class.forName("com.mysql.jdbc.Driver");
//Setup the connection with the database
conn = DriverManager.getConnection("jdbc:mysql://" +dbHost+ ":" +dbPort+ "/" +dbName, dbUser, dbPass);
//Create statement to execute query
stmt = conn.createStatement();
//Execute query
int result = stmt.executeUpdate("update users set internet = '0' where ticket='" +ticket+ "' and lastname='" +lastName+ "'");
//Result is already an int so, if good => true else => false (executeUpdate returns the number of rows updated, so it should be 1)
if(result == 1) {
return true;
}
else {
return false;
}
//If there is an error, throw it
} catch (Exception e) {
throw e;
//Finally close the connections
} finally {
if (stmt != null) stmt.close();
if (conn != null) conn.close();
}
}
|
c6d05742-e65a-4026-9e8a-765001f44411
| 9
|
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BasketItem other = (BasketItem) obj;
if (getRecordId() == null) {
if (other.getRecordId() != null)
return false;
} else if (!getRecordId().equals(other.getRecordId()))
return false;
if (session == null) {
if (other.session != null)
return false;
} else if (!session.equals(other.session))
return false;
return true;
}
|
b7103219-8a98-4f0c-a9a9-4dba248ce8ee
| 1
|
public void actionPerformed(ActionEvent e) {
Grammar g = environment.getGrammar(UnrestrictedGrammar.class);
if (g == null)
return;
ChomskyPane cp = new ChomskyPane(environment, g);
environment.add(cp, "Test", new CriticalTag() {
});
environment.setActive(cp);
}
|
3c1aa39b-d8c0-4773-8a1a-4fde124ca2e4
| 6
|
public List<NamedEntity> getNamedEntities(String text)
throws NamedEntityExtractorException{
ArrayList<NamedEntity> entities = new ArrayList<NamedEntity>();
/*
* please refer to the stanford-ner package documentation to find out
* what this is all about
*/
List<List<CoreLabel>> labeledSentences = classifier.testSentences(text);
for (List<CoreLabel> sentence : labeledSentences) {
String value = "";
String label = "";
String previousLabel = "";
for (CoreLabel word : sentence) {
label = word.getString(AnswerAnnotation.class);
if (!(label.equals(previousLabel) || previousLabel.equals(""))) {
if (!previousLabel.equals(UNKNOWN)) {
entities.add(createEntity(previousLabel, value.trim()));
}
value = word.getString(CurrentAnnotation.class) + " ";
} else {
value += word.getString(CurrentAnnotation.class) + " ";
}
previousLabel = label;
}
// process the last word
if (!label.equals(UNKNOWN)) {
entities.add(createEntity(label, value.trim()));
}
}
return entities;
}
|
7da3b5a5-fe8f-4366-9061-149842ce5ce4
| 2
|
private static File getOutputDir() {
File file = new File(properties.getProperty("usecase.outputdir") + "/pandemie");
if (!file.mkdirs() && !file.exists()) {
throw new RuntimeException("Fail to create output directory at " + file);
}
return file;
}
|
f6c94e9e-3928-4a52-88fa-d32a109e280e
| 7
|
void endParagraph() {
finishWord();
if (!_endnote) {
if (!_firstPar && _fill) {
writeBlankLines();
}
_firstPar = false;
if (_fill) {
processPhil();
} else {
emitLine(_wordLine, _firstLine
? _indent + _parindent : _indent);
if (!_firstPar) {
writeBlankLines();
}
}
_wordLine.clear();
_firstLine = true;
if (_holding) {
_parSkip = _nextSkip;
}
}
}
|
82823b67-d2ed-4146-aeb9-0e893dbcc56d
| 2
|
void schedule(long delay, TimeUnit delayUnits) {
if (mKey != null) {
synchronized (PENDING) {
if (!PENDING.add(mKey)) {
mWasCancelled = true;
return;
}
}
}
EXECUTOR.schedule(this, delay, delayUnits);
}
|
74d0fc18-8b38-4d08-8ed9-72de533a4617
| 0
|
public CmdAddExecutor(SimpleQueues plugin) {
this.plugin = plugin;
}
|
c8067434-9a73-4bea-b9a2-b6bbc3dffcb3
| 5
|
public static void inputCommand(){
System.out.println("\n0:Add 1:All 2:Search 3:Delete 9:EXIT ");
Scanner scCommand = new Scanner(System.in);
System.out.print("=>");
String inputCommand = scCommand.next();
if(inputCommand.equals("0")){
System.out.println("Action: new contact");
System.out.print("First Name=>");
String first = scCommand.next();
System.out.print("Last Name=>");
String last = scCommand.next();
System.out.print("Phone Number=>");
String num = scCommand.next();
System.out.print("Email=>");
String email = scCommand.next();
contactsDatabase.addContact(first, last, num, email);
}
else if(inputCommand.equals("1")){
System.out.println("Action: Show All");
contactsDatabase.showAll();
}
else if(inputCommand.equals("2")){
System.out.println("Action: Search Contacts");
System.out.print("Name=>");
String name = scCommand.next();
contactsDatabase.searchContacts(name);
}
else if(inputCommand.equals("3")){
System.out.println("Action: delete contact");
System.out.print("First Name=>");
String first = scCommand.next();
System.out.print("Last Name=>");
String last = scCommand.next();
contactsDatabase.deletContact(first, last);
System.out.println("Deleted!");
}
else if(inputCommand.equals("9")){
System.out.println("Exit...");
System.exit(0);
}
else{
System.out.println("Error: Invalid Command");
}
}
|
b7a3233f-dd2d-4290-b889-5f02d47e7e77
| 4
|
public World(int width) {
// Create the squares
squares = new Square[width][width];
for (int x = 0; x < width; x++) {
for (int y = 0; y < width; y++) {
squares[x][y] = new Square();
}
}
setUp(width);
// Place the agent
// If the entire world is full of obstacles, this loop runs forever
while (true) {
agentX = uniform(width);
agentY = uniform(width);
if (!getSquare(agentX, agentY).isObstacle()) {
return;
}
}
}
|
48481d32-5833-4d1e-8f4b-31d3fe8577da
| 4
|
public static void setLogForName(final String str) {
if (str.equalsIgnoreCase("Normal logs -> Normal planks")) {
plankSet = 1;
} else if (str.equalsIgnoreCase("Oak logs -> Oak planks")) {
plankSet = 2;
} else if (str.equalsIgnoreCase("Teak logs -> Teak planks")) {
plankSet = 3;
} else if (str.equalsIgnoreCase("Mahogany logs -> Mahogany planks")) {
plankSet = 4;
}
}
|
f626c408-3da5-4c37-bdfe-0363c78ab0b8
| 1
|
public void updateType() {
if (!isVoid())
updateParentType(subExpressions[0].getType());
}
|
524d5917-4169-4874-bf0d-3cec98cff49e
| 2
|
public boolean pollin (int index) {
if (index < 0 || index >= this.next)
return false;
return items [index].isReadable();
}
|
3189d913-2f0e-415e-b5f3-89878a184c31
| 2
|
public synchronized void stop() //Use synchronized when stopping thread
{
if(running)
{
running = false;
try {
gameThread.join();
}
catch (InterruptedException ex) {
System.out.println(ex.getMessage());
}
}
}
|
db10bae4-795c-45a4-a3f6-f96d60f3b26d
| 2
|
public void updateConfigureButtonState() {
if (comboBox.getModel().getSelectedItem().equals("Contestant")) {
if (lblIpVerification.getText().equals("Valid IP Address"))
btnConfigure.setEnabled(true);
else
btnConfigure.setEnabled(false);
} else
btnConfigure.setEnabled(true);
}
|
2ba887ec-e931-4af0-8044-b9fafd392eb6
| 6
|
public void bulkLoad(IndexPair[] pairs, int offset, int length) {
if (length > capacity) {
throw new RuntimeException("Cannot write " + length
+ " elements to a block of size " + capacity);
}
if (length == 0) {
return;
}
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
for (int i = offset; i < offset + length; i++) {
IndexPair pair = pairs[i];
writePair(out, pair);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (out != null)
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
startKey = pairs[offset].getBitSignature();
size = length;
IndexPair[] cachedPairs = new IndexPair[length];
System.arraycopy(pairs, offset, cachedPairs, 0, length);
cache = new SoftReference<IndexPair[]>(cachedPairs);
}
|
eaffb737-b059-4992-b561-52042503e7b8
| 2
|
public static Point getResolution(int i) {
if (i == 16) {
//full screen
return new Point(0, 0);
} else {
String resString = (String) resolutions.get(i);
String[] resParts = resString.split("x");
Point res = null;
if (resParts.length == 2) {
res = new Point(Integer.parseInt(resParts[0]), Integer.parseInt(resParts[1]));
} else {
res = new Point(800, 600);
}
return res;
}
}
|
3deb16d6-f099-4473-abef-6a4be29addd2
| 7
|
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (!(obj instanceof BtcPeer))
return false;
BtcPeer other = (BtcPeer) obj;
if (networkAddress == null) {
if (other.networkAddress != null)
return false;
} else if (!networkAddress.equals(other.networkAddress))
return false;
return true;
}
|
c89f3dbe-81e5-4485-ae0e-2fa92c71d7d8
| 0
|
public String getNome()
{
return this.nome;
}
|
c007fbd7-e503-4a3a-a36f-eecc3f1f8d36
| 1
|
@Override
public boolean hasNext() {
if (index < array.length) {
return true;
} else {
return false;
}
}
|
5aac5913-2c66-4947-93ec-5ffc7c8b65a3
| 7
|
public Hashtable<String, Integer> getShortestPaths(Vertex node)
{
_distances = new Hashtable<String, Integer>();
_predecessors = new Hashtable<String, Vertex>();
_unoptimizedNodes = new ArrayList<Vertex>(_nodes);
for(Vertex vertex : _nodes)
{
_distances.put(vertex.toString(), Integer.MAX_VALUE);
}
//set distance to self to 0
_distances.put(node.toString(), 0);
while(!_unoptimizedNodes.isEmpty())
{
Vertex shortest = null;
int shortestValue = Integer.MAX_VALUE;
for(Vertex vertex : _unoptimizedNodes)
{
if(_distances.get(vertex.toString()) < shortestValue)
{
shortest = vertex;
shortestValue = _distances.get(vertex.toString());
}
}
//remove shortest from unoptimized nodes list
_unoptimizedNodes.remove(shortest);
if(_distances.get(shortest.toString()) == Integer.MAX_VALUE)
{
break;
}
int alt = 0;
for(Vertex vertex : getNeighbors(shortest))
{
System.out.println("NEIGHBOR: " + vertex);
System.out.println("SHORTEST: " + shortest);
alt = _distances.get(shortest.toString()) + getWeight(shortest, vertex);
System.out.println(getWeight(shortest, vertex));
System.out.println(_distances.get(vertex.toString()));
if(alt < _distances.get(vertex.toString()))
{
_distances.put(vertex.toString(), alt);
_predecessors.put(vertex.toString(), shortest);
_unoptimizedNodes.add(vertex);
}
}
}
return _distances;
}
|
e25f7351-7f79-423e-bea5-4efc18b57327
| 7
|
private boolean jj_3R_50() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(9)) {
jj_scanpos = xsp;
if (jj_scan_token(19)) {
jj_scanpos = xsp;
if (jj_scan_token(26)) {
jj_scanpos = xsp;
if (jj_scan_token(24)) {
jj_scanpos = xsp;
if (jj_scan_token(28)) {
jj_scanpos = xsp;
if (jj_3R_60()) {
jj_scanpos = xsp;
if (jj_scan_token(46)) return true;
}
}
}
}
}
}
return false;
}
|
882e54d3-28c5-4f26-8523-5f3caed5cf91
| 0
|
protected DiscountStrategy(double price, int copies) {
this.price = price;
this.copies = copies;
}
|
502abe3d-8cba-45fe-9739-e9a21fc47056
| 9
|
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
ProxyKey key = mappings.get(method);
Class<?> type = method.getReturnType();
if (key != null) {
if (type == void.class) {
setValue(args, key);
return null;
}
else {
return getValue(key, type);
}
}
else if (Attributes.class.isAssignableFrom(type) && method.getParameterTypes().length == 0) {
return Attributes.this;
}
else if (ReflectionUtil.isHashCodeMethod(method)) {
return System.identityHashCode(proxy);
}
else if (ReflectionUtil.isEqualsMethod(method)) {
return (proxy == args[0]);
}
else if (ReflectionUtil.isToStringMethod(method)) {
return toString();
}
else if (method.getReturnType().isPrimitive()) {
return ObjectUtil.getPrimitiveDefault(method.getReturnType());
}
else {
return null;
}
}
|
dc71c7a6-f323-45b1-80ad-ae8a411e7259
| 0
|
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Manifest")
public JAXBElement<ManifestType> createManifest(ManifestType value) {
return new JAXBElement<ManifestType>(_Manifest_QNAME, ManifestType.class, null, value);
}
|
68be540c-c6fd-40f6-832a-434fccab9999
| 4
|
protected IQueueServiceListener[] getQueueServiceListenersByJob(IJob job){
IQueueServiceListener[] allWithoutJobID = getQueueServiceListeners();
IQueueServiceListener[] result = allWithoutJobID;
if (listenerByJobs.containsKey(job.getJobId()) && listenerByJobs.get(job.getJobId()) != null){
IQueueServiceListener[] queueListenerByJobId = listenerByJobs.get(job.getJobId()).getListeners(IQueueServiceListener.class);
result = new IQueueServiceListener[allWithoutJobID.length + queueListenerByJobId.length];
for (int i=0; i<allWithoutJobID.length; i++){
result[i] = allWithoutJobID[i];
}
for (int i=0; i<queueListenerByJobId.length; i++){
result[allWithoutJobID.length-1+i] = queueListenerByJobId[i];
}
}
return result;
}
|
d3652afb-4138-4320-933c-533a6a2d43fb
| 9
|
public TableView(int height) {
entries = new ArrayList<Item>();
listeners = new HashSet<SymbolSelectionListener>();
showFrequencies = true;
final String[] header = { "Symbol", "Codeword", "Frequency" };
tableModel = new AbstractTableModel() {
@Override
public String getColumnName(int col) {
return header[col];
}
public int getColumnCount() {
return (showFrequencies ? 3 : 2);
}
public int getRowCount() {
return entries.size();
}
public Object getValueAt(int row, int col) {
Item it = entries.get(row);
switch (col) {
case 0:
return HuffmanDemo.printableSymbol(it.symbol);
case 1:
return it.codeword;
case 2:
return (showFrequencies ? it.freq : null);
}
return null;
}
@Override
public Class getColumnClass(int c) {
return (c < 2 ? String.class : Integer.class);
}
};
table = new JTable(tableModel);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setAutoCreateRowSorter(true);
tableModel.addTableModelListener(table);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setGridColor(Color.black);
table.getTableHeader().setReorderingAllowed(false);
table.getTableHeader().setResizingAllowed(false);
table.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int k = table.getSelectedRow();
String sym = (k == -1 ? null : entries.get(table.convertRowIndexToModel(k)).symbol);
for (SymbolSelectionListener l : listeners)
l.selectionChanged(new SymbolSelectionEvent(this, sym));
}
}
});
setLayout(new BorderLayout());
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
add(scrollPane, BorderLayout.CENTER);
reFit();
}
|
2d890b43-2a8d-41ff-bcd4-6e4b814f9e6e
| 9
|
protected String getNewThreadName(String base_name, String addr, String cluster_name) {
StringBuilder sb=new StringBuilder(base_name != null? base_name : "thread");
if(use_numbering) {
short id;
synchronized(this) {
id=++counter;
}
sb.append("-").append(id);
}
if(cluster_name == null)
cluster_name=clusterName;
if(addr == null)
addr=this.address;
if(!includeClusterName && !includeLocalAddress && cluster_name != null) {
sb.append(",shared=").append(cluster_name);
return sb.toString();
}
if(includeClusterName)
sb.append(',').append(cluster_name);
if(includeLocalAddress)
sb.append(',').append(addr);
return sb.toString();
}
|
d9a62b18-f4fa-4c25-8028-3cb03d45317c
| 7
|
@EventHandler
public void WitherHarm(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getZombieConfig().getDouble("Wither.Harm.DodgeChance") / 100;
final double ChanceOfHappening = random.nextDouble();
if (ChanceOfHappening >= randomChance) {
dodged = true;
}
if (damager instanceof WitherSkull) {
WitherSkull a = (WitherSkull) event.getDamager();
LivingEntity shooter = a.getShooter();
if (plugin.getWitherConfig().getBoolean("Wither.Harm.Enabled", true) && shooter instanceof Wither && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) {
Player player = (Player) e;
player.addPotionEffect(new PotionEffect(PotionEffectType.HARM, plugin.getWitherConfig().getInt("Wither.Harm.Time"), plugin.getWitherConfig().getInt("Wither.Harm.Power")));
}
}
}
|
93cc8a82-31df-4a1f-87eb-7dee3a1a48ce
| 2
|
public int compare(Node arg0, Node arg1) {
if(arg0.f > arg1.f)
return 1;
else if(arg0.f < arg1.f)
return -1;
return 0;
}
|
b75600e8-b314-4db1-b97b-202f993c9eb1
| 9
|
}
// -----------------------------------------------------------------------
@Override
public DateTimeValueRange range(DateTimeField field) {
if (field instanceof ChronoField) {
ChronoField f = (ChronoField) field;
if (f.isDateField()) {
switch (f) {
case DAY_OF_MONTH:
return DateTimeValueRange.of(1, lengthOfMonth());
case DAY_OF_YEAR:
return DateTimeValueRange.of(1, lengthOfYear());
case ALIGNED_WEEK_OF_MONTH:
return DateTimeValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
case YEAR_OF_ERA:
return (getYear() <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
}
return field.range();
}
throw new DateTimeException("Unsupported field: " + field.getName());
}
|
04a28a14-ed46-4f45-b073-80ea0e7ba101
| 5
|
public static void nameGame(String inputName)
{
int i = 0;
while (inputName.charAt(i) != 'u' && inputName.charAt(i) != 'e'
&& inputName.charAt(i) != 'o' && inputName.charAt(i) != 'a'
&& inputName.charAt(i) != 'i')
{
i++;
}// while
String tempName = inputName.substring(i, inputName.length()); // the input
// name
// without
// consonants
// at the
// beginning
PrintWriter screenPen = new PrintWriter(System.out, true);
screenPen.println(inputName + '!');
screenPen.println(inputName + ", " + inputName + " bo " + 'B' + tempName
+ " Bonana fanna fo " + 'F' + tempName);
screenPen.println("Fee fy mo M" + tempName + ", " + inputName + '!');
}// nameGame
|
6ef21b61-d390-403e-806b-76885afd101b
| 7
|
public static Rule_dirLocal parse(ParserContext context)
{
context.push("dirLocal");
boolean parsed = true;
int s0 = context.index;
ArrayList<Rule> e0 = new ArrayList<Rule>();
Rule rule;
parsed = false;
if (!parsed)
{
{
ArrayList<Rule> e1 = new ArrayList<Rule>();
int s1 = context.index;
parsed = true;
if (parsed)
{
boolean f1 = true;
int c1 = 0;
for (int i1 = 0; i1 < 1 && f1; i1++)
{
rule = Terminal_StringValue.parse(context, ".local");
if ((f1 = rule != null))
{
e1.add(rule);
c1++;
}
}
parsed = c1 == 1;
}
if (parsed)
e0.addAll(e1);
else
context.index = s1;
}
}
rule = null;
if (parsed)
rule = new Rule_dirLocal(context.text.substring(s0, context.index), e0);
else
context.index = s0;
context.pop("dirLocal", parsed);
return (Rule_dirLocal)rule;
}
|
88a75552-f3a4-48e7-819b-f53535346c4f
| 2
|
static void difference(Class<?> superset, Class<?> subset) {
System.out.print(superset.getSimpleName() + " extends "
+ subset.getSimpleName() + ", adds: ");
Set<String> comp = Sets.difference(methodSet(superset),
methodSet(subset));
comp.removeAll(object); // Don't show 'Object' methods
System.out.println(comp);
interfaces(superset);
}
|
4918c114-7817-4137-8841-cc90f1803d68
| 5
|
private void printNode(Node n)
{
boolean goLeft = false, goRight = false;
System.out.print("Node: " + n.hashCode());
if (n.value != null)
{
System.out.println("\tValue: " + n.value);
}
if (n.leftChild != null)
{
System.out.println(" Left Child: " + n.leftChild.hashCode());
goLeft = true;
}
if (n.rightChild != null)
{
System.out.println(" Right Child: " + n.rightChild.hashCode());
goRight = true;
}
System.out.print("\n\n");
if (goLeft)
{
printNode(n.leftChild);
}
if (goRight)
{
printNode(n.rightChild);
}
}
|
79d0d31b-5475-4ae3-a35c-ac03da158aaf
| 6
|
public void change(){
bu1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Clink and Select");
JFileChooser chooser = new JFileChooser();
if(jb1.isSelected()){
FileNameExtensionFilter filter = new FileNameExtensionFilter("xml", "xml");
chooser.setFileFilter(filter);
}
else
{FileNameExtensionFilter filter = new FileNameExtensionFilter("xls", "xls");
chooser.setFileFilter(filter);}
int returnVal = chooser.showOpenDialog(new JPanel());
if(returnVal == JFileChooser.APPROVE_OPTION){
System.out.println("The file you choose"+chooser.getSelectedFile().getAbsolutePath());
filename.setText(chooser.getSelectedFile().getAbsolutePath());
}
}
});
bu2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(jb1.isSelected()){
String path = filename.getText();
try {
new CreatExcel().creat(new ReadXml().Read(path), path);
System.out.println("succeed");
jl3.setVisible(true);
JOptionPane.showMessageDialog(null, "the conversion was successful!");
} catch (RowsExceededException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (WriteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (DocumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else{
String path = filename.getText();
new CreatXml().create(path);
System.out.println("succeed");
jl3.setVisible(true);
JOptionPane.showMessageDialog(null, "the conversion was successful!");
}
}
});
}
|
10dded5a-714f-4f9b-ab8d-bf7ad8ef5bf5
| 8
|
public void onBlockPlaced(World par1World, int par2, int par3, int par4, int par5)
{
int var6 = par1World.getBlockMetadata(par2, par3, par4);
int var7 = var6 & 8;
var6 &= 7;
if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 2))
{
var6 = 4;
}
else if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 3))
{
var6 = 3;
}
else if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 4))
{
var6 = 2;
}
else if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 5))
{
var6 = 1;
}
else
{
var6 = this.getOrientation(par1World, par2, par3, par4);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 + var7);
}
|
005ef687-5486-4aca-91d4-62f70197fb2d
| 0
|
public void copyTo(TicketQueryArgs other)
{
other._action = this._action;
other._count = this._count;
other._date = this._date;
other._departureStation = this._departureStation;
other._destinationStation = this._destinationStation;
other._seatType = this._seatType;
other._sequence = this._sequence;
other._trainNumber = this._trainNumber;
other.channel = this.channel;
}
|
75ab02dc-445b-4d98-8cef-0179ce4a9e41
| 1
|
public boolean authenticate()
{
try
{
listServerIds();
return true;
}
catch (Exception e)
{
return false;
}
}
|
ecdaa878-8d08-4add-a7c9-e3839f33b56c
| 5
|
@Override
public void run() {
for (int i = from; !Thread.interrupted() && done.getCount() > 0
&& i < to; i++) {
BigInteger exp = new BigInteger(Integer.toString(i));
BigInteger gbx1 = gB.modPow(exp, p);
for (int k = 0; k < xx.length; k++) {
BigInteger val = xx[k].get(gbx1);
if (val != null) {
result = new AbstractMap.SimpleEntry<BigInteger, BigInteger>(
exp.multiply(BBig), val);
done.countDown();
}
}
}
}
|
22722953-b96f-4d82-94db-b0177dbdee86
| 9
|
@Override
protected Post instanceFromResultSet(ResultSet rs, Set<Enum> selectedFields) throws SQLException {
boolean allFields = selectedFields == null || selectedFields.isEmpty();
long id = rs.getLong("id");
return new Post(id,
allFields || selectedFields.contains(Post._Fields.title) ? rs.getString("title") : null,
allFields || selectedFields.contains(Post._Fields.posted_at_millis) ? getDateAsLong(rs, "posted_at_millis") : null,
allFields || selectedFields.contains(Post._Fields.user_id) ? getIntOrNull(rs, "user_id") : null,
allFields || selectedFields.contains(Post._Fields.updated_at) ? getDateAsLong(rs, "updated_at") : null,
databases
);
}
|
4b205bc3-605c-4913-bd8e-5b347ad0b6d2
| 6
|
private static HashMap<Integer, User> buildUsersFromJsonData(String path) {
HashMap<Integer, User> userMap = new HashMap<Integer, User>();
JSONParser parser = new JSONParser();
try {
Object obj = null;
try {
obj = parser.parse(new FileReader(path));
} catch (org.json.simple.parser.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONObject jsonObject = (JSONObject) obj;
JSONArray users = (JSONArray) jsonObject.get("profiles");
for(Object o: users){
User user = new User();
int id = ((Long)((JSONObject)o).get("id")).intValue();
JSONArray answers = (JSONArray) ((JSONObject)o).get("answers");
for(int i = 0; i < answers.size(); i++){
JSONArray acceptableAnswers = (JSONArray) ((JSONObject)answers.get(i)).get("acceptableAnswers");
//translate the json based importance into the okcupid based importance
int importance = IMPORTANCE_POINTS[((Long) ((JSONObject)answers.get(i)).get("importance")).intValue()];
int questionId = ((Long) ((JSONObject)answers.get(i)).get("questionId")).intValue();
int answer = ((Long) ((JSONObject)answers.get(i)).get("answer")).intValue();
//Build set of acceptable answers, then add it to the user object
HashSet<Integer> acceptableAnswerSet = new HashSet<Integer>();
for(int k = 0; k < acceptableAnswers.size(); k++)
{
acceptableAnswerSet.add(((Long) acceptableAnswers.get(k)).intValue());
}
user.setExpectedAnswer(questionId, acceptableAnswerSet);
user.setAnswer(questionId, answer);
user.setImportance(questionId, importance);
user.setUserId(id);
}
//Place the user that was built in the previous steps based on the json data into the user map
userMap.put(id, user);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return userMap;
}
|
b2cdbf66-5f6c-49fd-9b15-ea56e744cf47
| 6
|
public boolean addHeightOffset(Location spawnLoc, int playerHeight, int heightRange)
{
if (heightOffset == 0)
return true;
if (!RandomLocationGen.findSafeY(spawnLoc, playerHeight + heightOffset, heightRange, requirements == null || requirements.requireOpaqueBlock))
return false;
Block b = spawnLoc.getBlock();
return (!getMobType().isTall() || RandomLocationGen.isTallLocation(b)) && (!getMobType().isWide() || RandomLocationGen.isWideLocation(b));
}
|
2627a4bd-4f9b-404c-8b2c-3b251ccae5d7
| 8
|
final void method1716(boolean bool) {
anInt5864++;
if (method1735(bool)) {
if (((Class348_Sub51) ((Class239) this).aClass348_Sub51_3136)
.aClass239_Sub25_7271.method1830((byte) -97)
&& !Class151.method1210((byte) -94, ((Class348_Sub51)
(((Class239) this)
.aClass348_Sub51_3136))
.aClass239_Sub25_7271
.method1829(-32350)))
((Class239) this).anInt3138 = 1;
if ((((Class348_Sub51) ((Class239) this).aClass348_Sub51_3136)
.aClass239_Sub8_7254.method1751(-32350)
^ 0xffffffff)
== -2)
((Class239) this).anInt3138 = 1;
}
if ((((Class239) this).anInt3138 ^ 0xffffffff) == -4)
((Class239) this).anInt3138 = 2;
if (bool != false)
method1716(true);
if ((((Class239) this).anInt3138 ^ 0xffffffff) > -1
|| (((Class239) this).anInt3138 ^ 0xffffffff) < -4)
((Class239) this).anInt3138 = method1710(20014);
}
|
57b81546-1e09-42d7-9bf4-74139a71de66
| 3
|
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
//System.out.println("Debug Grid Status: " + DRAW_DEBUG_GRID);
if(DRAW_DEBUG_GRID == true)
{
int gridX = 0;
while(gridX < canvasWidth)
{
Line2D xLine = new Line2D.Double(gridX, 0, gridX, canvasHeight);
g2d.setColor(Color.RED);
g2d.setStroke(new BasicStroke(1));
g2d.draw(xLine);
gridX = gridX + 32;
}
int gridY = 0;
while(gridY < canvasWidth)
{
Line2D xLine = new Line2D.Double(0, gridY, canvasWidth, gridY);
g2d.setColor(Color.RED);
g2d.setStroke(new BasicStroke(1));
g2d.draw(xLine);
gridY = gridY + 32;
}
}
updateUI();
}
|
fa17629e-5878-43d6-ab78-5470b1c6e457
| 3
|
@Override
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state)
{
Rectangle temp = state.getRectangle();
int x = temp.x;
int y = temp.y;
int w = temp.width;
int h = temp.height;
String direction = mxUtils.getString(state.getStyle(),
mxConstants.STYLE_DIRECTION, mxConstants.DIRECTION_EAST);
Polygon triangle = new Polygon();
if (direction.equals(mxConstants.DIRECTION_NORTH))
{
triangle.addPoint(x, y + h);
triangle.addPoint(x + w / 2, y);
triangle.addPoint(x + w, y + h);
}
else if (direction.equals(mxConstants.DIRECTION_SOUTH))
{
triangle.addPoint(x, y);
triangle.addPoint(x + w / 2, y + h);
triangle.addPoint(x + w, y);
}
else if (direction.equals(mxConstants.DIRECTION_WEST))
{
triangle.addPoint(x + w, y);
triangle.addPoint(x, y + h / 2);
triangle.addPoint(x + w, y + h);
}
else
// EAST
{
triangle.addPoint(x, y);
triangle.addPoint(x + w, y + h / 2);
triangle.addPoint(x, y + h);
}
return triangle;
}
|
e7781263-5e7f-4027-ab46-e8d658836546
| 6
|
public void sortList(){
Collections.sort(dataEntries, new Comparator<String[]>() {
@Override
public int compare(String[] o1, String[] o2) {
String[] obj1 = o1[0].split(":");
String[] obj2 = o2[0].split(":");
if(Integer.parseInt(obj1[0]) > Integer.parseInt(obj2[0])){
return 1;
} else if(Integer.parseInt(obj1[0]) < Integer.parseInt(obj2[0])){
return -1;
}
if(Integer.parseInt(obj1[1]) > Integer.parseInt(obj2[1])){
return 1;
} else if(Integer.parseInt(obj1[1]) < Integer.parseInt(obj2[1])){
return -1;
}
if(Integer.parseInt(obj1[2]) > Integer.parseInt(obj2[2])){
return 1;
} else if(Integer.parseInt(obj1[2]) < Integer.parseInt(obj2[2])){
return -1;
}
return 0;
//return o1[0].compareTo(o2[0]);
}
});
}
|
e00b00ad-8ff7-49aa-8689-8ceb62374fae
| 7
|
public String findLargestPalindrome(String string) {
if (string.length() > 2) {
char[] carr = string.toCharArray();
int maxPalindromeLength = Integer.MIN_VALUE;
int globalBegin = 0;
int globalEnd = 0;
for (int i=3; i<carr.length; i++) {
int mid = i;
int begin = i-1;
int end = i+1;
while (begin >= 0 && end <= carr.length-1) {
if (carr[begin] != carr[end])
break;
begin--;
end++;
}
int palindromeLength = (end-begin)+1;
if (palindromeLength > maxPalindromeLength) {
maxPalindromeLength = palindromeLength;
globalBegin = begin+1;
globalEnd = end-1;
}
}
String result = "";
for (int i=globalBegin; i<=globalEnd; i++) {
result += Character.toString(carr[i]);
}
return result;
} else {
return string;
}
}
|
e3c436d4-a38d-43ea-a50b-799798aa1692
| 8
|
public void open()
throws DBException
{
if (null != jdbc) return;
if (!location.isDirectory())
throw new DBException("There is no valid " + this);
Throwable status = new RuntimeException("No database names have been configured");
Logger log = log();
for (int legacyIndex = 0; DB_NAMES.length > legacyIndex; )
{
String url = baseURL(false, legacyIndex) + MUSTEXIST_SUFFIX;
boolean isLast = DB_NAMES.length <= ++legacyIndex;
log.finer("Trying database at \"" + url + "\" ...");
try
{
establishConnection(url, !isLast);
status = null;
break;
}
catch (SQLException fail)
{
if (org.h2.constant.ErrorCode.DATABASE_NOT_FOUND_1 != fail.getErrorCode())
{
status = fail;
if (!isLast)
clearPassword();
break;
}
else if (!(status instanceof SQLException))
{
status = fail;
}
}
}
if (null != status)
throw new DBException("Open failed for " + this, status);
}
|
4041b4ac-d47b-4988-b737-8ed59be33b78
| 5
|
public void addPatron(Patron p) {
Connection conn =null;
PreparedStatement pSt=null;
// If p is null, do nothing
if (p == null)
return;
try {
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/librarysystem?user=admin&password=123456");
String insert = "INSERT INTO Patron(cardNumber, name, phone, address, unpaidFees) VALUES (?, ?, ?, ?, ?)";
pSt = conn.prepareStatement(insert);
pSt.setInt(1, p.getCardNumber());
pSt.setString(2, p.getName());
pSt.setInt(3, p.getPhone());
pSt.setString(4, p.getAddress());
pSt.setInt(5, p.getUnpaidFees());
pSt.executeUpdate();
} catch (SQLException e) {
e.getMessage();
} finally {
try {
if(conn != null)
conn.close();
if(pSt != null)
pSt.close();
} catch (Exception e) {
}
}
}
|
104179c1-568b-4b29-91c2-bced33cd1b50
| 5
|
public List<String[]> getMounts() {
List<String[]> list = new ArrayList<>();
String mount, mountpoint, mounttype, opts;
for (String m : getMountLines()) {
mount = m.substring(0, m.indexOf(" on "));
mountpoint = m.substring(m.indexOf(" on ") + 4, m.indexOf(" type "));
mounttype = m.substring(m.indexOf(" type ") + 6, m.indexOf(" ("));
opts = m.substring(m.indexOf(" (") + 2, m.length() - 2);
// TODO: find better fix.
// Fix trailing /
if(mount.length() > 0 && mount.charAt(mount.length() - 1) == '/') {
mount = mount.substring(0, mount.length() - 1);
}
if(mountpoint.length() > 0 && mountpoint.charAt(mountpoint.length() - 1) == '/') {
mountpoint = mountpoint.substring(0, mountpoint.length() - 1);
}
list.add(new String[] { mount, mountpoint, mounttype, opts });
}
return list;
}
|
45f6f44a-8589-4b29-9e82-73deea02642e
| 9
|
private void parseMessage(Message msg) throws IllegalArgumentException {
try {
COMMAND cmd = msg.getCommand();
switch(cmd) {
case A:
addReplaceFile(msg.getCommand(), msg.isLastMessage(), msg.getFilename(), msg.getDataLength(), msg.getData());
break;
case C:
setCircumference(msg.getDataAsInt());
break;
case F:
sendFile(msg.getFilename());
break;
case L:
listFiles();
break;
case U:
addCertificate(msg.isLastMessage(), msg.getFilename(), msg.getDataLength(), msg.getData());
break;
case V:
// Add method call
// verify(filename, certificate)
addReplaceFile(msg.getCommand(), msg.isLastMessage(), msg.getFilename(), msg.getDataLength(), msg.getData());
break;
case Q:
this.exit = true;
break;
case EXIT:
this.exit = true;
break;
default:
// Command is BLANK or null
throw new IllegalArgumentException("Command '" + cmd + "' is not an accepted message command.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
|
c962bda9-6348-4e00-9ba4-d8ecac0728d7
| 5
|
private AbstractInsnNode[] makeResult(int start, int end) {
int startIndex = 0;
int endIndex = -1;
for (int i = 0; i < offsets.length - 1; i++) {
int offset = offsets[i];
if (offset == start)
startIndex = i;
if ((offset < end) && (offsets[i + 1] >= end)) {
endIndex = i;
break;
}
}
if (endIndex == -1)
endIndex = offsets.length - 1;
int length = endIndex - startIndex + 1;
AbstractInsnNode[] result = new AbstractInsnNode[length];
System.arraycopy(instructions, startIndex, result, 0, length);
return result;
}
|
f7b52c24-6535-4e19-82fd-3885d87d6220
| 1
|
public void configureAction(Map<String, Object> config) {
if (config == null) {
this.task = null;
this.gruntFile = null;
this.page = null;
} else {
this.task = (String) config.get(Activator.KEY_TASK);
this.gruntFile = (IFile) config.get(Activator.KEY_FILE);
this.page = (IWorkbenchPage) config.get(Activator.KEY_PAGE);
}
}
|
21ef5382-07ca-4b5d-9f7c-6d3d7234a659
| 1
|
public void testWithFieldAdded_DurationFieldType_int_5() {
LocalTime test = new LocalTime(10, 20, 30, 40);
try {
test.withFieldAdded(DurationFieldType.days(), 6);
fail();
} catch (IllegalArgumentException ex) {}
}
|
9c5c1705-5806-4e2c-88e0-ee5eee500463
| 5
|
protected void authenticateUser() throws LoginException {
if (!(_currentRealm instanceof RestRealm)) {
String msg = sm.getString("restlm.badrealm");
throw new LoginException(msg);
}
final RestRealm restRealm = (RestRealm)_currentRealm;
// A JDBC user must have a name not null and non-empty.
if ( (_username == null) || (_username.length() == 0) ) {
String msg = sm.getString("restlm.nulluser");
throw new LoginException(msg);
}
AuthenticationDescriptor model = restRealm.authenticate(_username.toLowerCase(), getPasswordChar());
_username = model.getName();
String[] grpList = model.getGroups();
if (grpList == null) { // JAAS behavior
String msg = sm.getString("restlm.loginfail", _username);
throw new LoginException(msg);
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "REST login succeeded for: {0} groups:{1}",
new Object[]{_username, Arrays.toString(grpList)});
}
commitUserAuthentication(grpList);
}
|
ea167911-6530-4854-9169-c243c207bfb8
| 3
|
private static char[] collectVersionFromCompare( String mvdName,
int v1, int v2, ChunkState unique, char[] original )
throws Exception
{
String vId1 = Integer.toString(v1);
String vId2 = Integer.toString(v2);
String[] args0 = {"-c","compare","-m",mvdName,"-v",vId1,
"-w",vId2,"-u",unique.toString()};
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream( bos, true, "UTF-8" );
MvdTool.run( args0, ps );
ps.close();
int pos = 0;
int j = 0;
String chunkStr = bos.toString();
char[] chunkData = new char[chunkStr.length()];
chunkStr.getChars(0,chunkData.length,chunkData,0);
StringBuilder sb = new StringBuilder();
while ( pos < chunkData.length )
{
Chunk chunk = new Chunk( chunkData, pos, (short)0 );
char[] bytes = chunk.getData();
for ( int i=0;i<bytes.length;i++,j++ )
{
if ( original[j] != bytes[i] )
throw new MVDTestException(
"Retrieved version from compare "
+"not the same as original");
}
pos += chunk.getSrcLen();
sb.append( chunk.getData() );
}
char[] res = new char[sb.length()];
sb.getChars(0,res.length,res,0);
return res;
}
|
420ed2c3-6120-41a6-ac17-7e028b086df9
| 8
|
@Override
public boolean equals(Object obj) {
if (obj instanceof Bounds) {
Bounds other = (Bounds) obj;
return getRotation() == other.getRotation()
&& getScale() == other.getScale()
&& getHeight() == other.getHeight()
&& getWidth() == other.getWidth()
&& get(Edge.TOP_LEFT).equals(other.get(Edge.TOP_LEFT))
&& get(Edge.TOP_RIGHT).equals(other.get(Edge.TOP_RIGHT))
&& get(Edge.BOTTOM_LEFT)
.equals(other.get(Edge.BOTTOM_LEFT))
&& get(Edge.BOTTOM_RIGHT).equals(
other.get(Edge.BOTTOM_RIGHT));
} else {
return false;
}
}
|
5c9d1176-d92e-4e00-af58-99727c9b63a1
| 9
|
public SearchInvoicesResponse(Map<String, String> map, String prefix) {
if( map.containsKey(prefix + "responseEnvelope" + ".timestamp") ) {
String newPrefix = prefix + "responseEnvelope" + '.';
this.responseEnvelope = new ResponseEnvelope(map, newPrefix);
}
if( map.containsKey(prefix + "count") ) {
this.count = Integer.valueOf(map.get(prefix + "count"));
}
for(int i=0; i<10; i++) {
if( map.containsKey(prefix + "invoices" + '(' + i + ')'+ ".invoiceID") ) {
String newPrefix = prefix + "invoices" + '(' + i + ')' + '.';
this.invoices.add(new InvoiceSummaryType(map, newPrefix));
}
}
if( map.containsKey(prefix + "page") ) {
this.page = Integer.valueOf(map.get(prefix + "page"));
}
if( map.containsKey(prefix + "hasNextPage") ) {
this.hasNextPage = Boolean.valueOf(map.get(prefix + "hasNextPage"));
}
if( map.containsKey(prefix + "hasPreviousPage") ) {
this.hasPreviousPage = Boolean.valueOf(map.get(prefix + "hasPreviousPage"));
}
for(int i=0; i<10; i++) {
if( map.containsKey(prefix + "error" + '(' + i + ')'+ ".errorId") ) {
String newPrefix = prefix + "error" + '(' + i + ')' + '.';
this.error.add(new ErrorData(map, newPrefix));
}
}
}
|
66330555-fd2c-42dd-ab39-a309bf67c2f0
| 2
|
public DetalleRegistro(Ticket ticket, java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
tipos = new ComboModelTipo();
monedas = new ComboModelMoneda();
estados = new ComboModelEstado();
tipo_paxs = new ComboModelTipoPax();
posiciones = new ComboModelPosicion();
if (ticket != null) {//el ticket no es nuevo
isNuevo = false;
ticket.setGds("A");
tipos.setSelectedItem(ticket.getTipo());
estados.setSelectedItem(ticket.getEstado());
monedas.setSelectedItem(ticket.getMoneda());
tipo_paxs.setSelectedItem(ticket.getTipoPasajero());
posiciones.setSelectedItem(ticket.getPosicion());
this.txt_ticket.setText(ticket.getTicket());
this.txt_num_file.setText(ticket.getNumFile());
this.txt_reemitido.setText(ticket.getOldTicket());
this.txt_pnr.setText(ticket.getPnr());
this.txt_emd.setText(ticket.getCodEmd());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
try {
this.date_fecha_emi.setDate(sdf.parse(ticket.getFechaEmision()));
this.date_fecha_anu.setDate(sdf.parse(ticket.getFechaAnulacion()));
this.date_fecha_ree.setDate(sdf.parse(ticket.getFechaRemision()));
} catch (ParseException ex) {
ex.printStackTrace();
}
this.txt_nombre_pax.setText(ticket.getNombrePasajero());
this.txt_fpago.setText(ticket.getfPago());
//DecimalFormat df = new DecimalFormat("#,##");
this.txt_comision.setValue(ticket.getComision());
this.txt_valor_neto.setValue(ticket.getValorNeto());
this.txt_valor_tax.setValue(ticket.getValorTasas());
this.txt_valor_final.setValue(ticket.getValorFinal());
this.txt_codigo_la.setText(ticket.getcLineaAerea());
this.txt_ruta.setText(ticket.getRuta());
TableModelSegmentos segmentos_model = new TableModelSegmentos(ticket);
this.table_segmentos.setModel(segmentos_model);
this.txt_ticket.setEditable(false);
} else {//elt ticket es nuevo
isNuevo = true;
tipos = new ComboModelTipo();
this.cmb_tipo.setModel(tipos);
java.util.Date fecha = new Date();
this.date_fecha_emi.setDate(fecha);
this.txt_comision.setValue(new Double("0.00"));
this.txt_valor_final.setValue(new Double("0.00"));
this.txt_valor_neto.setValue(new Double("0.00"));
this.txt_valor_tax.setValue(new Double("0.00"));
}
this.table_segmentos.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
this.cmb_estado.setModel(estados);
this.cmb_moneda.setModel(monedas);
this.cmb_tipo.setModel(tipos);
this.cmb_tipopax.setModel(tipo_paxs);
this.cmb_posi.setModel(posiciones);
this.setTitle("Oris-TKT");
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setResizable(false);
}
|
aba4aa7c-1c34-446a-b257-e4e245df5c41
| 2
|
public boolean hasEffect(SkillEffect effect){
for (SkillEffect e: skillEffects) {
if(e == effect) return true;
}
return false;
}
|
a62186ec-1842-4cde-8fca-1e221ed4d10a
| 3
|
public static void PrintSeparator(char ch)
{
switch(ch){
case '_':
System.out.println("___________________________________________________________________________");
break;
case '-':
System.out.println("---------------------------------------------------------------------------");
break;
case '#':
System.out.println("###########################################################################");
break;
}
}
|
5332e30a-3fd8-4561-872c-7ed8d9e17d20
| 3
|
public static ArrayList<SchoolBean> view(String id){
Connection con=DBConnection.getConnection();
SchoolBean sb=new SchoolBean();
ArrayList<SchoolBean> list=new ArrayList<SchoolBean>();
if(con==null)
return null;
try {
Statement pt=con.createStatement();
ResultSet rs=pt.executeQuery("select * from school where schoolid='"+id+"'");
if(rs.next()){
sb.setSchoolid(rs.getString(1));
sb.setName(rs.getString(2));
sb.setLocation(rs.getString(3));
sb.setPhone(rs.getString(4));
sb.setBoard(rs.getString(5));
sb.setEmail(rs.getString(6));
list.add(sb);
}
//con.commit();
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
|
db2c350f-fee1-40f2-96c0-43c2c381d0a2
| 1
|
public CreditsRenderer()
{
try
{
}
catch (Exception e1)
{
}
}
|
ac950a29-6eda-45bd-85c9-48479db50e35
| 2
|
public static Color checkColour(JTextPane pane)
{
AttributeSet attributes = pane.getInputAttributes();
if (attributes.isDefined(StyleConstants.Foreground))
{
return (Color) attributes.getAttribute(StyleConstants.Foreground);
}
if (attributes.isDefined(CSS.Attribute.COLOR))
{
String s = attributes.getAttribute(CSS.Attribute.COLOR).toString();
return Color.decode(s);
}
return Color.BLACK;
}
|
3479962a-6157-4cc2-bea0-5564a7e7db29
| 5
|
public void setGoal(int x, int y) {
if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
return;
// Free old position
if (this.goalPos != null) {
this.field[goalPos.y][goalPos.x] = FieldType.FREE.ordinal();
}
this.goalPos = new Point(x, y);
this.field[y][x] = FieldType.GOAL.ordinal();
}
|
db40291f-e472-4d80-9911-eb8dc922477d
| 5
|
private int parseInt(String s,int i){
String sub=s.substring(i);
char current=sub.charAt(0);
String num=String.valueOf(current);
/* on parcourt la sous-chaine jusqu'a sortir de celle-ci ou de
l'entier, lequel des 2 se produit en premier*/
int j=1;
for(j=1;j<sub.length() && Character.isDigit(current);){
current=sub.charAt(j);
if(Character.isDigit(current)){
num=num+current;
j++;
}
}
// fin de la chaine ?
boolean end=(j>=sub.length());
// On ajoute l'entier a la pile en simplifiant les signes moins
int a=Integer.parseInt(num);
if(negative%2!=0){
valueStack.push(new LinkedRBinaryTree<Integer>(new Node<Integer>(-a)));
}
else{
valueStack.push(new LinkedRBinaryTree<Integer>(new Node<Integer>(a)));
}
negative=0;
if(end){
return -1;
}
else{
return i+j-1;
}
}
|
6225c004-eea8-4934-9ef0-7c58fb1e2e67
| 6
|
private static void loadFile() throws FileNotFoundException {
File inputFile = new File("topscore.txt");
Scanner inputScanner = new Scanner(inputFile);
String topscore = "";
while (inputScanner.hasNextLine())
topscore += inputScanner.nextLine();
// Separating high score file in names and scores
boolean name = true;
int nameIndex =0;
int scoreIndex =0;
String tempScore = "";
for (int i=0; i<topscore.length(); i++) {
if (name) {
if (topscore.charAt(i) != ',')
topNames[nameIndex] += topscore.charAt(i);
else {
name = false;
nameIndex++;
}
} else {
if (topscore.charAt(i) != ';')
tempScore += topscore.charAt(i);
else {
topScores[scoreIndex] = Integer.parseInt(tempScore);
name = true;
scoreIndex ++;
tempScore="";
}
}
}
for (int i=0; i<topscore_length; i++)
System.out.println((i+1)+". "+topNames[i]+" - "+topScores[i]);
}
|
4823805d-a7f2-47a4-9ca8-3841d79de336
| 4
|
private static HashMap<String, ArrayList<String>> BuildMedList() throws Exception {
HashMap<String,String> stopwords = LoadStopWords(stopwordPath);
HashMap<String,ArrayList<String>> medList = new HashMap<String,ArrayList<String>>();
File medFile = new File("NICTA/atc_20130403.txt");
BufferedReader reader = new BufferedReader(new FileReader(medFile));
String temp;
while ((temp = reader.readLine()) != null){
String[] content = temp.split("!");
String[] name = content[1].split(" ");
for(String s:name){
s = s.toLowerCase();
if(medList.containsKey(s) == false ){
//TODO: test med stop words
if(!stopwords.containsKey(s)){
ArrayList<String> string = new ArrayList<String>();
string.add(content[1]);
medList.put(s, string);
}
}
else{
medList.get(s).add(content[1]);
}
}
}
reader.close();
return medList;
}
|
771f30d7-8d71-4f4e-8be9-e78f2e79d36c
| 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(StringParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StringParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StringParameterEditDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StringParameterEditDialog.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 StringParameterEditDialog().setVisible(true);
}
});
}
|
5b6b00a2-acae-4759-9a1b-5b4fe549c259
| 0
|
public Sequencer getSequencer() {
return sequencer;
}
|
366ec6ce-87d9-4c4f-baf8-84acdd97307c
| 9
|
private boolean validParameters(String[] parameters) {
boolean validParameters = true;
for (int i = 0; parameters != null && i < parameters.length && validParameters; i++) {
String brackets = "";
int arraySeparationIndex = parameters[i].indexOf("[");
if (arraySeparationIndex >= 0) {
brackets = parameters[i].substring(arraySeparationIndex).trim();
parameters[i] = parameters[i].substring(0, arraySeparationIndex).trim();
}
int typeSeparationIndex = parameters[i].lastIndexOf("*");
if (typeSeparationIndex < 0) {
typeSeparationIndex = parameters[i].lastIndexOf(" ");
}
String parameterDataType = (typeSeparationIndex == -1) ? parameters[i] : parameters[i].substring(0, typeSeparationIndex + 1).trim();
String parameterIdentifier = (typeSeparationIndex == -1) ? "" : parameters[i].substring(typeSeparationIndex + 1).trim();
validParameters = validDataType(parameterDataType + brackets) && (parameterIdentifier.length() == 0 || validIdentifier(parameterIdentifier));
}
return validParameters;
}
|
7f038c66-f0d5-4520-92ba-e96d37a7b483
| 3
|
public Section(int x, int y, Minesweeper game) {
this.x = x;
this.y = y;
this.game = game;
int chance = new Random().nextInt(100);
if (chance < ratio)
bomb = true;
if (!bomb) {
chance = new Random().nextInt(100);
if (chance < 10)
hasHeart = true;
}
points = new Random().nextInt(10);
}
|
f42661a2-faa9-42a0-b0d4-f10732554e8c
| 3
|
@Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
user = (User) session.get("User");
Criteria ucri = myDao.getDbsession().createCriteria(Campaign.class);
ucri.add(Restrictions.like("campaignName", s + "%"));
ucri.setMaxResults(50);
allcamplist = (List<Campaign>) (ucri.list());
addActionMessage(allcamplist.size() + "\t\tResults Found");
return "success";
} catch (HibernateException e) {
addActionError("Server Error Please Try Again ");
e.printStackTrace();
return "error";
} catch (NullPointerException ne) {
addActionError("Server Error Please Try Agains ");
ne.printStackTrace();
return "error";
} catch (Exception e) {
addActionError("Server Error Please Try Again ");
e.printStackTrace();
return "error";
}
}
|
f4f61244-bef1-4545-81a2-232488e4cf4e
| 9
|
public static void registerEntities() {
for (CustomEntityType entity : values())
a(entity.getCustomClass(), entity.getName(), entity.getID());
// BiomeBase#biomes became private.
BiomeBase[] biomes;
try {
biomes = (BiomeBase[]) getPrivateStatic(BiomeBase.class, "biomes");
} catch (Exception exc) {
// Unable to fetch.
return;
}
for (BiomeBase biomeBase : biomes) {
if (biomeBase == null)
break;
// This changed names from J, K, L and M.
for (String field : new String[] { "as", "at", "au", "av" })
try {
Field list = BiomeBase.class.getDeclaredField(field);
list.setAccessible(true);
@SuppressWarnings("unchecked")
List<BiomeMeta> mobList = (List<BiomeMeta>) list.get(biomeBase);
// Write in our custom class.
for (BiomeMeta meta : mobList)
for (CustomEntityType entity : values())
if (entity.getNMSClass().equals(meta.b))
meta.b = entity.getCustomClass();
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
9d0f21d9-1609-417c-81cf-be8c6af6b00f
| 6
|
public void run() {
long lastTime = System.nanoTime();
double nsPerTick = 1000000000D / 60D;
long lastTimer = System.currentTimeMillis();
double delta = 0;
init();
log.info("_WIDTH = " + _WIDTH);
log.info("_HEIGHT = " + _HEIGHT);
log.info("_SCALE = " + _SCALE);
if (Fullscreen) log.info("_SIZE = width:" + _SIZE.width + " height:" + _SIZE.height);
else log.info("_SIZE = width:" + _SIZE.width * _SCALE + " height:" + _SIZE.height * _SCALE);
log.info("_TITLE = " + _TITLE);
for (int i = 0; i < _AUTHOR.length; i++) {
log.info("_AUTHOR[" + i + "] = " + _AUTHOR[i]);
}
int ticks = 0;
int frames = 0;
requestFocus();
boolean shouldRender = true;
while (running) {
long now = System.nanoTime();
delta += (now - lastTime) / nsPerTick;
lastTime = now;
while (delta >= 1) {
update();
ticks++;
tick();
delta -= 1;
shouldRender = true;
}
if (shouldRender) {
frames++;
render();
}
fpsCurrent = frames;
if (System.currentTimeMillis() - lastTimer >= 1000) {
fps = frames;
this.ticks = ticks;
lastTimer += 1000;
frames = 0;
ticks = 0;
}
}
stop();
}
|
32caddf6-7440-4d71-a1f1-747129e9db66
| 8
|
public GrapheEntreLivraisons(int nbVertices, int[][] cost) {
this.nbVertices = nbVertices;
int tempMaxCost = -1;
int tempMinCost = Integer.MAX_VALUE;
succ = new ArrayList<ArrayList<Integer>>();
for(int i=0 ; i<nbVertices ; i++) {
for(int j=0 ; j<nbVertices ; j++) {
if(cost[i][j] > tempMaxCost) {
tempMaxCost = cost[i][j];
}
if(cost[i][j] < tempMinCost && cost[i][j] > 0) {
tempMinCost = cost[i][j];
}
}
}
this.maxArcCost = tempMaxCost;
this.minArcCost = tempMinCost;
for(int i=0 ; i<nbVertices ; i++) {
ArrayList<Integer> l = new ArrayList<Integer>();
for(int j=0 ; j<nbVertices ; j++) {
if(cost[i][j] < 0) {
cost[i][j] = this.maxArcCost+1;
}
else {
l.add(j);
}
}
succ.add(i,l);
}
this.cost = cost;
}
|
41a1dbd2-2727-4fdd-ae73-bf766d6a25da
| 8
|
public boolean verify() {
if(this.getServer_ip() == null || this.getServer_ip().length()<1) return false;
if(this.getId().length()<1) return false;
if(this.getApiUser().length()<1) return false;
if(this.getApiToken().length()<1) return false;
if(this.getMysqlDump().length()<1) return false;
if(this.getTmpDirectory().length()<1) return false;
if(this.getWorkingDirectory().length()<1) return false;
return true;
}
|
d41621a2-8e25-4fbf-9379-609f4f02c275
| 8
|
public By getBy(String locator) {
By by;
if(locator.startsWith("//"))
by = By.xpath(locator);
else if(locator.startsWith("class="))
by =By.className(locator.replace("class=", ""));
else if(locator.startsWith("css="))
by = By.cssSelector(locator.replace("css=", "").trim());
else if(locator.startsWith("link="))
by = By.linkText(locator.replace("link=", ""));
else if(locator.startsWith("name="))
by = By.name(locator.replace("name=", "").trim());
else if(locator.startsWith("tag="))
by = By.tagName(locator.replace("tag=", "").trim());
else if(locator.startsWith("partialText="))
by= By.partialLinkText(locator.replace("partialText=", ""));
else if(locator.startsWith("id="))
by= By.id(locator.replace("id=",""));
else
by = By.id(locator);
return by;
}
|
93089856-6d5d-47d6-b967-84591b4c3059
| 3
|
@Override
public V getObject(K key) {
if (ramCache.containsKey(key)) {
return ramCache.getObject(key);
}
if (hardDiskCache.containsKey(key)) {
K tMinKey = ramCache.getMinFrequencyKey();
int tMinFrequency = ramCache.getFrequency(tMinKey);
int frequencyOfKey = hardDiskCache.getFrequency(key);
if (frequencyOfKey + 1 > tMinFrequency) {
V value = hardDiskCache.removeObject(key);
hardDiskCache.addObject(tMinKey, ramCache.removeObject(tMinKey), tMinFrequency);
ramCache.addObject(key, value, frequencyOfKey + 1);
return value;
} else {
return hardDiskCache.getObject(key);
}
}
return null;
}
|
eb26d8c5-2959-424a-94f7-712bf81421ba
| 1
|
public String getTurnPlayerName(){
return board.getIsBattingFirstTurn() ? playerAName : playerBName;
}
|
5b9c3537-7a1a-4a64-85ea-bfe1f7b14ca6
| 5
|
public static RiverDB readCSV (String fName) {
RiverDB riverDB = new RiverDB ();
LabeledCSVParser lcsvp = null;
try {
lcsvp = new LabeledCSVParser(
new CSVParser(
new FileReader( fName )
)
);
try {
while(lcsvp.getLine() != null){
/*
System.out.println(
"Parse Fluss: " + lcsvp.getValueByLabel("Fluss") +
" Start: " + lcsvp.getValueByLabel("Einstieg") +
" Ziel: " + lcsvp.getValueByLabel("Ausstieg")
);
*/
riverDB.add (lcsvp.getValueByLabel("Fluss"), lcsvp.getValueByLabel("Einstieg"), lcsvp.getValueByLabel("Ausstieg"),
lcsvp.getValueByLabel("WW"), Integer.parseInt(lcsvp.getValueByLabel("WW Stufe")),
Integer.parseInt(lcsvp.getValueByLabel("Km")), Integer.parseInt(lcsvp.getValueByLabel("Entfernung")),
lcsvp.getValueByLabel("Land"), lcsvp.getValueByLabel("Info"),
Integer.parseInt(lcsvp.getValueByLabel("Min")), Integer.parseInt(lcsvp.getValueByLabel("Max")), lcsvp.getValueByLabel("Einheit"),
Integer.parseInt(lcsvp.getValueByLabel("Teilnehmer")), "", Integer.parseInt(lcsvp.getValueByLabel("Favorit")) == 1);
}
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
riverDB.sort();
return riverDB;
}
|
3a97b85c-4761-4fcf-9ef2-c30c3858b7fa
| 2
|
@Override
public void componentResized(ComponentEvent event) {
if (gamePanel.getGraphics() != null) {
final BufferStrategy b = that.gamePanel.getBufferStrategy();
if (b != null) {
myPen.simplePen.pen = (Graphics2D) b.getDrawGraphics();
}
SimpleGraphics.this.onResize(myPen);
}
}
|
42391683-2ca7-4c90-bcef-ef56811bcdbf
| 0
|
public void setComposition(String composition) {
this.composition = composition;
}
|
71b38545-af62-4ed9-a37d-d89cf7270ac8
| 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(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Registration.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 Registration().setVisible(true);
}
});
}
|
78b7cb81-cf7f-431a-9834-f78f57e38c20
| 2
|
@Override
public void addUser() {
try {
credentials = new BufferedWriter(new FileWriter("credentials", true));
credentials.write(this.username);
credentials.newLine();
credentials.write(this.password);
credentials.newLine();
credentials.write(this.numeComplet);
credentials.newLine();
credentials.write(this.CNP);
credentials.newLine();
credentials.write(this.statut);
credentials.newLine();
credentials.close();
} catch (IOException ex) {
Logger.getLogger(Administrator.class.getName()).log(Level.SEVERE, null, ex);
}
String path = "elevi/"+this.clasa;
try {
try (BufferedWriter addElevInClasa = new BufferedWriter(new FileWriter(path))) {
addElevInClasa.write(numeComplet);
addElevInClasa.newLine();
}
} catch (IOException ex) {
Logger.getLogger(Administrator.class.getName()).log(Level.SEVERE, null, ex);
}
}
|
8019c44c-b5fc-42da-aa8e-fbeed2c0a2fc
| 7
|
public Tile getTile(int x, int y) {
if (x < 0 || y < 0 || x >= width || y >= height) return Tile.voidTile;
if (tiles[x + y * width] == 0xff00FF00) return Tile.grass;
if (tiles[x + y * width] == 0xffFFFF00) return Tile.flower;
if (tiles[x + y * width] == 0xff7F7F00) return Tile.rock;
return Tile.voidTile;
}
|
b93c8045-7357-47e7-8a29-a122d9a84e26
| 1
|
public static byte[] genCRC16(byte[] data) {
int crc = 0x0000;
for (byte b : data) {
crc = (crc >>> 8) ^ table[(crc ^ b) & 0xff];
}
return checksumToByteArray(crc);
}
|
6a66073b-a23d-4cd1-a406-458ed2607054
| 1
|
public void immediatelyRenewLease() {
logger.finest("immedidately renewing the lease");
interrupt();
try {
// give time for Cyc to renew the lease
sleep(250);
} catch (InterruptedException e) {
}
}
|
182ff28f-3ef1-488e-aed2-8c849ebabaf6
| 2
|
protected synchronized CtMember.Cache getMembers() {
CtMember.Cache cache = null;
if (memberCache == null
|| (cache = (CtMember.Cache)memberCache.get()) == null) {
cache = new CtMember.Cache(this);
makeFieldCache(cache);
makeBehaviorCache(cache);
memberCache = new WeakReference(cache);
}
return cache;
}
|
690ab778-bd6c-4966-9dd0-e9b512fb0be8
| 3
|
public boolean hasServerConfig() {
return ((url != null && !url.isEmpty()) && (apiKey != null && !apiKey.isEmpty()));
}
|
5a2ce17a-aec6-41f3-a562-da68ed8738e0
| 3
|
public void showCharList(char start, char end){
if(start <= end){
for(char i = start; i <= end; i++){
System.out.println(i);
}
}
else{
for(char i = end; i <= start; i++){
System.out.println(i);
}
}
}
|
b5e2c8fd-541a-4da1-a135-7bcec02621ad
| 0
|
public void setModeleJComboBoxLabo(DefaultComboBoxModel modeleJComboBoxLabo) {
this.modeleJComboBoxLabo = modeleJComboBoxLabo;
}
|
2de88eb6-32b3-4e7a-9f87-46fa7b0a9569
| 2
|
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanelProjeto = new javax.swing.JPanel();
lblNome = new javax.swing.JLabel();
lblDescriscao = new javax.swing.JLabel();
btnCadastrar = new javax.swing.JButton();
txtNome = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
txtDescricao = new javax.swing.JTextArea();
lblDataInicio = new javax.swing.JLabel();
lblDataTermino = new javax.swing.JLabel();
txtDataInicio = new javax.swing.JFormattedTextField();
txtDataFim = new javax.swing.JFormattedTextField();
jLabel1 = new javax.swing.JLabel();
cbDepartamentos = new javax.swing.JComboBox();
setClosable(true);
setIconifiable(true);
setTitle("Cadastro de Projeto");
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifnmg/alvespereira/segurancadados/icones/11295_128x128.png"))); // NOI18N
jPanelProjeto.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Dados do Projeto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.BELOW_TOP, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(0, 102, 102))); // NOI18N
lblNome.setText("Nome:");
lblDescriscao.setText("Descrição:");
btnCadastrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/ifnmg/alvespereira/segurancadados/icones/8441_32x32.png"))); // NOI18N
btnCadastrar.setText("Cadastrar");
btnCadastrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCadastrarActionPerformed(evt);
}
});
txtNome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtNomeActionPerformed(evt);
}
});
txtDescricao.setColumns(20);
txtDescricao.setRows(5);
jScrollPane1.setViewportView(txtDescricao);
lblDataInicio.setText("Data Início:");
lblDataTermino.setText("Data Término: ");
try {
txtDataInicio.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
try {
txtDataFim.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
jLabel1.setText("Departamento:");
cbDepartamentos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDepartamentos.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
cbDepartamentosFocusGained(evt);
}
});
javax.swing.GroupLayout jPanelProjetoLayout = new javax.swing.GroupLayout(jPanelProjeto);
jPanelProjeto.setLayout(jPanelProjetoLayout);
jPanelProjetoLayout.setHorizontalGroup(
jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addComponent(lblNome)
.addGap(18, 18, 18)
.addComponent(txtNome))
.addComponent(jScrollPane1)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblDescriscao)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addComponent(lblDataInicio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addComponent(lblDataTermino)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtDataFim, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))))
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addGap(119, 119, 119)
.addComponent(btnCadastrar)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbDepartamentos, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
jPanelProjetoLayout.setVerticalGroup(
jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelProjetoLayout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblNome)
.addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblDescriscao)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(21, 21, 21)
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblDataInicio)
.addComponent(lblDataTermino)
.addComponent(txtDataInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtDataFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanelProjetoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cbDepartamentos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 35, Short.MAX_VALUE)
.addComponent(btnCadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanelProjetoLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, lblDataInicio});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanelProjeto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(13, 13, 13))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanelProjeto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(14, 14, 14))
);
pack();
}// </editor-fold>//GEN-END:initComponents
|
d0f7e5f2-d96c-48a8-986b-e01eee135353
| 8
|
public void registerPom(File file, POMInfo pomInfo) throws DependencyNotFoundException {
dep2info.put(pomInfo.getThisPom(), pomInfo);
unresolvedPoms.put(file, pomInfo);
POMInfo parentPOM = superPom;
try {
if (pomInfo.getParent() != null && !pomInfo.getParent().isSuperPom()) {
POMInfo foundParent = getPOM(pomInfo.getParent());
if (foundParent == null) {
pomsWithMissingParent.put(file, pomInfo);
throw new DependencyNotFoundException(pomInfo.getParent());
} else {
parentPOM = foundParent;
pomsWithMissingParent.remove(file);
}
if (!resolvedPoms.values().contains(parentPOM)) {
throw new DependencyNotFoundException(parentPOM.getThisPom());
}
}
} finally {
// Always merge with the parent POM - which is by default the super POM,
// as we can have intermediate situations in the DependenciesSolver where
// the true parent POM is not known and will be eliminated, yet we need
// the versions from the super POM.
pomInfo.setParentPOM(parentPOM);
// check if the pom specifies plugins or dependencies without an explicit version
pomsWithMissingVersions.remove(file);
for (Dependency dependency : pomInfo.getDependencies().get(DependencyType.DEPENDENCIES)) {
if (dependency.getVersion() == null) {
pomsWithMissingVersions.put(file, pomInfo);
}
}
for (Dependency dependency : pomInfo.getDependencies().get(DependencyType.PLUGINS)) {
if (dependency.getVersion() == null) {
pomsWithMissingVersions.put(file, pomInfo);
}
}
}
// mark the pom as resolved
resolvedPoms.put(file, pomInfo);
unresolvedPoms.remove(file);
}
|
1c1764e6-e298-4e78-9389-466f1e9e3b39
| 6
|
@Override
public void actionPerformed(final ActionEvent e) {
if (e.getSource() instanceof JButton) {
final JButton button = (JButton) e.getSource();
if (button == bestMove) {
getBestMove();
} else if (button == tilesInHand) {
requestLettersInHand();
} else if (button == newGame) {
game.getBoard().clear();
} else if (button == loadGame) {
loadGame();
} else if (button == saveGame) {
saveGame();
}
}
}
|
d839bba3-326c-47a6-b0cb-2fd6e53a0f2d
| 1
|
public String getFullAlias() {
if (pack.parent == null)
return getAlias();
else
return pack.getFullAlias() + "." + getAlias();
}
|
37451c5b-98f4-4b9b-9208-fe6c9d9a07ad
| 9
|
public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics()) return;
Device device = gc.getDevice();
float scaleX = 10f;
float scaleY = 10f;
Image image = null;
switch (imageCb.getSelectionIndex()) {
case 0:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "home_nav.gif");
break;
case 1:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "help.gif");
break;
case 2:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "task.gif");
break;
case 3:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "font.gif");
break;
case 4:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "cube.png");
scaleX = 0.75f;
scaleY = 0.5f;
break;
case 5:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "swt.png");
scaleX = 0.4f;
scaleY = 0.8f;
break;
case 6:
image = GraphicsExample.loadImage(device, GraphicsExample.class, "ovals.png");
scaleX = 1.1f;
scaleY = 0.5f;
break;
}
Rectangle bounds = image.getBounds();
// draw the original image
gc.drawImage(image, (width-bounds.width)/2, 20);
Font font = new Font(device, getPlatformFont(), 20, SWT.NORMAL);
gc.setFont(font);
// write some text below the original image
String text = GraphicsExample.getResourceString("OriginalImg"); //$NON-NLS-1$
Point size = gc.stringExtent(text);
gc.drawString(text, (width-size.x)/2, 25 + bounds.height, true);
Transform transform = new Transform(device);
transform.translate((width - (bounds.width * scaleX + 10) * 4) / 2, 25 + bounds.height + size.y +
(height - (25 + bounds.height + size.y + bounds.height*scaleY)) / 2);
transform.scale(scaleX, scaleY);
// --- draw strings ---
float[] point = new float[2];
text = GraphicsExample.getResourceString("None"); //$NON-NLS-1$
size = gc.stringExtent(text);
point[0] = (scaleX*bounds.width + 5 - size.x)/(2*scaleX);
point[1] = bounds.height;
transform.transform(point);
gc.drawString(text, (int)point[0], (int)point[1], true);
text = GraphicsExample.getResourceString("Low"); //$NON-NLS-1$
size = gc.stringExtent(text);
point[0] = (scaleX*bounds.width + 5 - size.x)/(2*scaleX) + bounds.width;
point[1] = bounds.height;
transform.transform(point);
gc.drawString(text, (int)point[0], (int)point[1], true);
text = GraphicsExample.getResourceString("Default"); //$NON-NLS-1$
size = gc.stringExtent(text);
point[0] = (scaleX*bounds.width + 5 - size.x)/(2*scaleX) + 2*bounds.width;
point[1] = bounds.height;
transform.transform(point);
gc.drawString(text, (int)point[0], (int)point[1], true);
text = GraphicsExample.getResourceString("High"); //$NON-NLS-1$
size = gc.stringExtent(text);
point[0] = (scaleX*bounds.width + 5 - size.x)/(2*scaleX) + 3*bounds.width;
point[1] = bounds.height;
transform.transform(point);
gc.drawString(text, (int)point[0], (int)point[1], true);
gc.setTransform(transform);
transform.dispose();
// --- draw images ---
// no interpolation
gc.setInterpolation(SWT.NONE);
gc.drawImage(image, 0, 0);
// low interpolation
gc.setInterpolation(SWT.LOW);
gc.drawImage(image, bounds.width, 0);
// default interpolation
gc.setInterpolation(SWT.DEFAULT);
gc.drawImage(image, 2*bounds.width, 0);
// high interpolation
gc.setInterpolation(SWT.HIGH);
gc.drawImage(image, 3*bounds.width, 0);
font.dispose();
if (image != null) image.dispose();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.