method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
|---|---|---|
0bfb1612-8dbf-4f2f-a4e1-1356aa668aae
| 3
|
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Estoque other = (Estoque) obj;
if (this.id != other.id) {
return false;
}
return true;
}
|
e030db10-a9d2-4ac5-9269-2ec64c848e79
| 3
|
public static void main(String[] args) {
// TODO code application logic here
//6. Дан двумерный массив целых чисел.
//б) Последний нулевой элемент каждою столбца заменить на число 100
//(предполагается, что в каждом столбце есть нулевой элемент).
System.out.println("*** Задание 6 Б ***");
int[][] array = {{1, 3, 5, 7, 0, 6}, {3, 5, 7, 0, 1, 2, 0, 2}};
show(array);
System.out.println();//Для красоты вывода.
for (int i = 0; i < array.length; i++) {
for (int j = array[i].length - 1; j > array.length; j--) {
if (array[i][j] == 0) {
array[i][j] = 100;
break;
}
}
}
show(array);
}
|
cf6048fa-5f84-406a-b963-af38671d144e
| 4
|
public int solution(int[] array) {
if (array.length == 1) {
return -2;
}
sort(array);
long minimumDistance = Long.MAX_VALUE;
for (int i = 1; i < array.length; i++) {
long distance = (long) array[i] - array[i-1];
if (distance < minimumDistance) {
minimumDistance = distance;
}
}
return minimumDistance > 100000000 ? -1 : (int) minimumDistance;
}
|
6ace27bc-98c2-4137-a0cd-90475d283ce3
| 4
|
@Override
public void setSheetName( String newname )
{
cch = (byte) newname.length();
byte[] namebytes;
if( !ByteTools.isUnicode( newname ) )
{
grbitChr = 0x0;
}
else
{
grbitChr = 0x1;
}
try
{
if( grbitChr == 0x1 )
{
namebytes = newname.getBytes( UNICODEENCODING );
}
else
{
namebytes = newname.getBytes( DEFAULTENCODING );
}
}
catch( UnsupportedEncodingException e )
{
namebytes = newname.getBytes();
log.warn( "UnsupportedEncodingException in setting sheet name: " + e + " falling back to system default." );
}
byte[] newdata = new byte[namebytes.length + 8];
if( data == null )
{
data = newdata;
}
else
{
System.arraycopy( getData(), 0, newdata, 0, 8 );
}
System.arraycopy( namebytes, 0, newdata, 8, namebytes.length );
newdata[6] = cch;
newdata[7] = grbitChr;
setData( newdata );
init();
}
|
940dbe4b-366b-412e-a374-38756841b5c8
| 0
|
protected LSystemEnvironment getEnvironment() {
return environment;
}
|
1df22052-874c-4015-8308-5b5544cde5fc
| 9
|
public static void main(String[] args) {
try {
setupLog4j();
CommandLine commandLine = parser.parse(ConsoleOptions.OPTIONS, args);
if (commandLine.hasOption("d")) {
Logger.getLogger("net.kahowell.xsd.fuzzer").setLevel(Level.DEBUG);
}
for (Option option : commandLine.getOptions()) {
if (option.getValue() != null) {
log.debug("Using " + option.getDescription() + ": " + option.getValue());
}
else {
log.debug("Using " + option.getDescription());
}
}
Injector injector = Guice.createInjector(
Modules.override(
Modules.combine(
new DefaultGeneratorsModule(),
new DefaultOptionsModule()
)
).with(new CommandLineArgumentsModule(commandLine))
);
log.debug(injector.getBindings());
XsdParser xsdParser = injector.getInstance(XsdParser.class);
XmlOptions xmlOptions = injector.getInstance(Key.get(XmlOptions.class, Names.named("xml save options")));
XmlGenerator xmlGenerator = injector.getInstance(XmlGenerator.class);
XmlGenerationOptions xmlGenerationOptions = injector.getInstance(XmlGenerationOptions.class);
doPostModuleConfig(commandLine, xmlGenerationOptions, injector);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
XmlObject generatedXml = xsdParser.generateXml(commandLine.getOptionValue("root"));
generatedXml.save(stream, xmlOptions);
if (commandLine.hasOption("v")) {
if (xsdParser.validate(stream)) {
log.info("Valid XML file produced.");
}
else {
log.info("Invalid XML file produced.");
System.exit(4);
}
}
xmlGenerator.showOrSave(stream);
}
catch (MissingOptionException e) {
if (e.getMissingOptions().size() != 0) {
System.err.println("Missing argument(s): " + Arrays.toString(e.getMissingOptions().toArray()));
}
helpFormatter.printHelp(XmlGenerator.class.getSimpleName(), ConsoleOptions.OPTIONS);
System.exit(1);
}
catch (ParseException e) {
helpFormatter.printHelp(XmlGenerator.class.getSimpleName(), ConsoleOptions.OPTIONS);
System.exit(2);
} catch (Exception e) {
e.printStackTrace();
System.exit(3);
}
}
|
d8d1ed6c-56ef-4a39-9ece-431e58962c3d
| 5
|
public String[] getEditableDimensionArray() {
TreeSet dim_set = new TreeSet();
for (Iterator i = parameters.values().iterator(); i.hasNext();) {
Parameter p = (Parameter)(i.next());
if (p.getSize() > 0) {
String foo = "";
for (int j = 0; j < p.getNumDim(); j++) {
if (j != 0) foo = foo + ",";
foo = foo + p.getDimension(j).getName();
}
dim_set.add(foo);
}
}
Object[] objs = dim_set.toArray();
String[] ret = new String[objs.length];
for (int i = 0; i < objs.length; i++) {
ret[i] = (String)objs[i];
}
return ret;
}
|
bea3ac9c-0fb1-4a05-8162-156a285f8c15
| 8
|
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || !(obj instanceof java.util.Map.Entry)) return false;
java.util.Map.Entry<?,?> me2 = (java.util.Map.Entry<?,?>)obj;
return (HashedMap.compareObjects(key, me2.getKey()) && HashedMap.compareObjects(getValue(), me2.getValue()));
}
|
7cfdfdac-8815-4f97-9e58-c91d5940c175
| 1
|
public RandomInt() {
s.add(new BigInteger("12345")); // initial seed
// calculate first 4 elements of series
for (int i = 0; i < 3; i++) {
// calculate si+1 from si
s.add(s.get(i).multiply(new BigInteger("22695477")).add(new BigInteger("1")));
}
}
|
ce9d4d55-ce59-4aad-8bec-25b48e49a49a
| 7
|
@Override
public byte[] write(DataOutputStream out, PassthroughConnection ptc, KillableThread thread, boolean serverToClient) {
if(length == null) {
return null;
}
Short lengthTemp = lengthUnit.write(out, ptc, thread, serverToClient);
if(lengthTemp == null) {
return null;
}
if((short)(lengthTemp * 4) != length) {
ptc.printLogMessage("Error writing quad byte array, breaking connection");
return null;
}
incrementCounter(serverToClient, length, ptc);
while(true) {
try {
out.write(value, 0, length);
out.flush();
} catch ( SocketTimeoutException toe ) {
if(timedOut(thread)) {
continue;
}
return null;
} catch (IOException e) {
return null;
}
super.timeout = 0;
return value;
}
}
|
3a8892bb-66fe-47cf-b923-247d8082ea14
| 5
|
@Test
public void testServerSetQueueTimeoutDisconnectIndividualInvalidEx() {
LOGGER.log(Level.INFO, "----- STARTING TEST testServerSetQueueTimeoutDisconnectIndividualInvalidEx -----");
boolean exception_other = false;
String client_hash = "";
try {
server2.setUseMessageQueues(true);
} catch (TimeoutException e) {
exception_other = true;
}
try {
server1.startThread();
} catch (IOException | ServerSocketCloseException | FeatureNotUsedException e) {
exception_other = true;
}
waitListenThreadStart(server1);
try {
client_hash = server2.addSocket("127.0.0.1", port);
} catch (IOException | TimeoutException e) {
exception_other = true;
}
waitSocketThreadAddNotEmpty(server2);
waitSocketThreadState(server2, client_hash, SocketThread.CONFIRMED);
waitMessageQueueAddNotEmpty(server2);
waitMessageQueueState(server2, client_hash, MessageQueue.RUNNING);
try {
server2.setQueueTimeoutDisconnectIndividual(client_hash, -1);
} catch (InvalidArgumentException e) {
exception = true;
} catch (FeatureNotUsedException | NullException | HashNotFoundException e) {
exception_other = true;
}
Assert.assertFalse(exception_other, "Caught an unexpected exception");
Assert.assertTrue(exception, "Successfully ran setQueueTimeoutDisconnectIndividual on server, should have received an exception");
LOGGER.log(Level.INFO, "----- TEST testServerSetQueueTimeoutDisconnectIndividualInvalidEx COMPLETED -----");
}
|
3a5ea923-542d-4a58-be15-240cc08671b5
| 4
|
@Override
public boolean execute(CommandSender sender, String identifier,
String[] args) {
if (sender instanceof Player) {
try {
ArrayList<String> list = new ArrayList<String>();
String ownedIds = "";
list = DBManager.getOwnedTitles(sender.getName());
if (list.size() >= 1) {
for (String id : list) {
ownedIds += id + ", ";
}
ownedIds = ownedIds.substring(0, ownedIds.length() - 2);
} else {
sender.sendMessage("You do not own any titles");
return false;
}
sender.sendMessage(FontFormat
.translateString("&eYour Owned Titles:\n&r" + ownedIds));
} catch (Exception ex) {
plugin.getLogger().log(Level.SEVERE,
"Error executing Title List command.", ex);
return false;
}
return false;
}
sender.sendMessage("Only players can use this command");
return false;
}
|
4ae6137c-958e-4260-8b0b-11890b03e1db
| 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(SelectAssistant.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SelectAssistant.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SelectAssistant.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SelectAssistant.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 SelectAssistant().setVisible(true);
}
});
}
|
91c5470f-a0bc-4620-9131-ddaaad91f672
| 6
|
@Override
public GrammarTree createGrammarTree(SyntaxAnalyser analyser)
throws GrammarCreateException {
GrammarTree grammarTree = new GrammarTree(new Token(TokenType.KEYWARD,
"all"));
AnalyticResult tokens = analyser.getAnalyticResult();
Token tempToken = tokens.front();
if (tempToken == null) {
GrammarCreateException exception = new GrammarCreateException(
"Error token list is empty");
analyser.addErrorMsg(exception.getMessage());
throw exception;
}
// System.out.println(WordTable.getKeyRank(tempToken.getToken()));
if (WordTable.getKeyRank(tempToken.getToken()) != 1) {
GrammarCreateException exception = new GrammarCreateException(
"Error: the sentence should start from key-word");
analyser.addErrorMsg(exception.getMessage());
throw exception;
}
GrammarTree currentNode = null;
while (tokens.hasNext()) {
Token token = tokens.next();
GrammarTree node = new GrammarTree(token);
if (token.getTokenType() == TokenType.KEYWARD) {
int rank = WordTable.getKeyRank(token.getToken());
if (rank == 1 || rank == 2) {
currentNode = node;
String value = node.getValue().getToken().toLowerCase();
node.getValue().setToken(value);
grammarTree.addSubNode(node);
} else {
currentNode.addSubNode(node);
}
} else {
currentNode.addSubNode(node);
}
}
return grammarTree;
}
|
a674cc43-9b85-4fd2-8339-3b3ce3cb2224
| 3
|
public boolean checkInitalBridge() {
if (client_bridge.isCreateGameRequest()) {
client_bridge.setGameCreated(true);
client_bridge.setCreateGameRequest(false);
setClientId(Messager.Id_Server);
start();
return true;
}
if (client_bridge.isJoinGameRequest()) {
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
client_bridge.setGameConnected(true);
setClientId(Messager.Id_Client);
start();
return true;
}
return false;
}
|
a5888e76-5b7a-4f93-a303-83ff14fb147e
| 3
|
@EventHandler
public void banCheck(LoginEvent e) throws SQLException {
if(BansManager.isPlayerBanned(e.getConnection().getName())){
Ban b =BansManager.getBanInfo(e.getConnection().getName());
if(b.getType().equals("tempban")){
if(BansManager.checkTempBan(b)){
e.setCancelled(true);
SimpleDateFormat sdf = new SimpleDateFormat();
Date then = b.getBannedUntil();
Date now = new Date();
long timeDiff = then.getTime()-now.getTime();
long hours = timeDiff / (60 * 60 *1000);
long mins = timeDiff / (60 * 1000) % 60;
sdf.applyPattern("dd MMM yyyy HH:mm:ss z");
e.setCancelReason(Messages.TEMP_BAN_MESSAGE.replace("{sender}", b.getBannedBy()).replace("{time}", sdf.format(then) + " ("+hours+":"+mins+" hours)").replace("{message}", b.getReasaon()));
LoggingManager.log(ChatColor.RED+e.getConnection().getName()+"'s connection refused due to being banned!");
return;
}
}
else{
e.setCancelled(true);
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern("dd MMM yyyy HH:mm:ss z");
e.setCancelReason(Messages.BAN_PLAYER_MESSAGE.replace("{sender}", b.getBannedBy()).replace("{message}", b.getReasaon()));
LoggingManager.log(ChatColor.RED+e.getConnection().getName()+"'s connection refused due to being banned!");
return;
}
}
}
|
107eae44-7466-44c8-bf9e-289bb1c5eef1
| 3
|
@Override
public boolean equals(Object o){
if (o == null) { return false; }
if (o == this) { return true; }
if (o.getClass() != getClass()) {
return false;
}
RomanNumeral rn = (RomanNumeral) o;
return new EqualsBuilder()
.append(this.value, rn.value)
.isEquals();
}
|
85421fef-9c2a-4d22-9dab-47f52bf226d5
| 0
|
@Override
public int getRank() {
return rank;
}
|
5a6d1ca7-b583-46b7-8ef8-9a8f307a0cf0
| 1
|
@Override
public void mousePressed(MouseEvent e) {
System.out.println("Clicked pressed at pixel (" + e.getX() + ", " + e.getY() + ")");
int x = e.getX() * _width / getWidth();
int y = e.getY() * _height / getHeight();
System.out.println("Which is cell (" + x + ", " + y + ")");
if (_draw_new_path) {
_wps.getSmoothPath().add(x, y);
_wps.getPath().add(x, y);
update();
repaint();
}
}
|
4356f94b-7ec9-46a2-be1e-297ee9008070
| 7
|
public static int kmpStrStr(String text, String pattern) {
if(text == null || pattern == null) {
return -1;
}
Set<Character> dedup = new HashSet<>();
// find all unique characters in pattern
for(char c : pattern.toCharArray()) {
dedup.add(c);
}
int[][] dfa = buildDFA(pattern, dedup);
int i = 0;
int j = 0;
for(;i< text.length() && j < pattern.length(); i++) {
if(dedup.contains(text.charAt(i))) {
j = dfa[text.charAt(i) - 'A'][j];
}
}
if(j == pattern.length()){
return i - pattern.length();
}
return -1;
}
|
925c5bc1-e695-4cba-b44b-ec14813ad92a
| 0
|
protected void onDccSendRequest(String sourceNick, String sourceLogin, String sourceHostname, String filename, long address, int port, int size) {}
|
f3c6322d-b623-4895-bdc7-9fd288a306e7
| 8
|
@Override
public void actionPerformed(ActionEvent arg0)
{
if (colorGain)
colorN += 5;
else
colorN -= 5;
if (colorN >= 200)
colorGain = false;
else if (colorN <= 30)
colorGain = true;
if (!seen)
{
tutorial = true;
if (tutorialX > 0)
{
tutorialX -= 15;
tutorialEnd = true;
}
if (tutorialMoved)
{
tutorialX -= 15;
if (tutorialX < -930)
tutorial = false;
}
}
if (!tutorial)
{
setRunning(true);
}
else
{
setRunning(false);
}
super.actionPerformed(arg0);
}
|
9a06a093-7c57-4dec-8068-831c6cbdba3c
| 9
|
private void requestUpdateRange() {
int i = 0;
for (DBUpdate u : updates) {
console.printf("[%d]: %s\n", ++i, u.getFileName());
}
first = 0;
while (first < 1) {
String sfirst = requestInputWithFallback("First Update", "1");
try {
first = Integer.parseInt(sfirst);
} catch (NumberFormatException e) {
console.printf("Not a number!\n");
first = 0;
}
if (first < 1 || first > i) {
console.printf("Invalid index!\n");
first = 0;
}
}
last = 0;
while (last < 1) {
String slast = requestInputWithFallback("Last Update",
Integer.toString(i));
try {
last = Integer.parseInt(slast);
} catch (NumberFormatException e) {
console.printf("Not a number!\n");
last = 0;
}
if (last < first || last > i) {
console.printf("Invalid index!\n");
last = 0;
}
}
}
|
12156f07-c250-44b6-88f3-10e7a343ccaf
| 7
|
public Discretize(Element discretize, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs)
throws Exception {
super(opType, fieldDefs);
/* if (m_opType == FieldMetaInfo.Optype.CONTINUOUS) {
throw new Exception("[Discretize] must have a categorical or ordinal optype");
} */
m_fieldName = discretize.getAttribute("field");
m_mapMissingTo = discretize.getAttribute("mapMissingTo");
if (m_mapMissingTo != null && m_mapMissingTo.length() > 0) {
m_mapMissingDefined = true;
}
m_defaultValue = discretize.getAttribute("defaultValue");
if (m_defaultValue != null && m_defaultValue.length() > 0) {
m_defaultValueDefined = true;
}
// get the DiscretizeBin Elements
NodeList dbL = discretize.getElementsByTagName("DiscretizeBin");
for (int i = 0; i < dbL.getLength(); i++) {
Node dbN = dbL.item(i);
if (dbN.getNodeType() == Node.ELEMENT_NODE) {
Element dbE = (Element)dbN;
DiscretizeBin db = new DiscretizeBin(dbE, m_opType);
m_bins.add(db);
}
}
if (fieldDefs != null) {
setUpField();
}
}
|
e72c4755-794b-412b-b315-1ceb36116618
| 0
|
public long getTotalTicketsSold() {
return totalTicketsSold;
}
|
9478ed0a-f091-4f49-ba26-5c73f875d747
| 8
|
private void jButtonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApplyActionPerformed
String type = typeAskPanel1.getTypeAsk();
jPanel1.setLayout(new BorderLayout());
jPanel1.removeAll();
switch (type) {
case "SelectedTest":
if(selectedPanel == null){
selectedPanel = new SelectedPanel();
}
//selectedPanel.setSize(jPanel1.getSize());
jPanel1.add(selectedPanel, BorderLayout.CENTER);
break;
case "AlternativeChoice":
if(alternativeChoicePanel == null){
alternativeChoicePanel = new AlternativePanel();
}
//alternativeChoicePanel.setSize(jPanel1.getSize());
jPanel1.add(alternativeChoicePanel, BorderLayout.NORTH);
break;
case "Matched":
if(matchedPanel == null){
matchedPanel = new MatchedPanel();
}
jPanel1.add(matchedPanel);
break;
case "Sequencing":
if(sequencingPanel == null){
sequencingPanel = new SequencingPanel();
}
jPanel1.add(sequencingPanel);
break;
default:
SMS.message("Еще не реализовано!!!");
break;
}
jPanel1.updateUI();
}//GEN-LAST:event_jButtonApplyActionPerformed
|
121a8a0a-71d8-4fc5-b5cf-38fa57396f53
| 1
|
public Icon getIcon(File file) {
return file.isFile() ? file_icon : folder_icon;
}
|
819d87d4-2daa-4202-a918-564e278252d9
| 9
|
public void generateFakeCorpus(String filePrefix){
HashMap<Integer, Double> t_wordSstat = new HashMap<Integer, Double>();
double t_allWordFrequency = 0;
for(_Doc d:m_corpus.getCollection()){
if(d instanceof _ChildDoc){
_SparseFeature[] fv = d.getSparse();
for(int i=0; i<fv.length; i++){
int wid = fv[i].getIndex();
double val = fv[i].getValue();
t_allWordFrequency += val;
if(t_wordSstat.containsKey(wid)){
double oldVal = t_wordSstat.get(wid);
t_wordSstat.put(wid, oldVal+val);
}else{
t_wordSstat.put(wid, val);
}
}
}
}
for(int wid:t_wordSstat.keySet()){
double val = t_wordSstat.get(wid);
double prob = val/t_allWordFrequency;
t_wordSstat.put(wid, prob);
}
// languageModelBaseLine lm = new languageModelBaseLine(m_corpus, 0);
// lm.generateReferenceModel();
int docIndex = 0;
File fakeCorpusFolder = new File(filePrefix+"fakeCorpus");
if(!fakeCorpusFolder.exists()){
System.out.println("creating directory\t"+fakeCorpusFolder);
fakeCorpusFolder.mkdir();
}
ArrayList<Integer> widList = new ArrayList<Integer>(t_wordSstat.keySet());
for(_Doc d:m_corpus.getCollection()){
if(d instanceof _ParentDoc4DCM){
_ParentDoc4DCM pDoc = (_ParentDoc4DCM)d;
int docLength = 0;
// docLength += pDoc.getTotalDocLength();
for(_ChildDoc cDoc:pDoc.m_childDocs)
docLength += cDoc.getTotalDocLength();
generateFakeDoc(pDoc, fakeCorpusFolder, docLength, t_wordSstat, widList, docIndex);
docIndex ++;
}
}
}
|
cfc1d879-7bcf-46e9-9d9a-9d19e2948057
| 8
|
public static boolean helpFinalizeClass(Stella_Class renamed_Class, Surrogate finalizedparent) {
if (renamed_Class.classFinalizedP) {
return (true);
}
KeyValueList.setDynamicSlotValue(renamed_Class.dynamicSlots, Stella.SYM_STELLA_BADp, Stella.TRUE_WRAPPER, null);
{ Surrogate renamed_Super = null;
Cons iter000 = renamed_Class.classDirectSupers.theConsList;
for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
renamed_Super = ((Surrogate)(iter000.value));
if (!(renamed_Super == finalizedparent)) {
{ Stella_Class superclass = Surrogate.typeToClass(renamed_Super);
if (superclass != null) {
if (!(Stella_Class.helpFinalizeClass(superclass, null))) {
return (false);
}
}
else {
return (false);
}
}
}
}
}
if (renamed_Class.classFinalizedP) {
KeyValueList.setDynamicSlotValue(renamed_Class.dynamicSlots, Stella.SYM_STELLA_BADp, null, null);
return (true);
}
Stella_Class.finalizeOneClass(renamed_Class);
{ Surrogate sub = null;
Cons iter001 = renamed_Class.classDirectSubs.theConsList;
for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
sub = ((Surrogate)(iter001.value));
{ Stella_Class subclass = Surrogate.typeToClass(sub);
if (subclass != null) {
Stella_Class.helpFinalizeClass(subclass, renamed_Class.classType);
}
}
}
}
KeyValueList.setDynamicSlotValue(renamed_Class.dynamicSlots, Stella.SYM_STELLA_BADp, null, null);
return (true);
}
|
f233a4fd-fdfe-4d9a-b08d-c12668a187f3
| 1
|
public void sendRequest(Player player) {
if (sent) return;
player.sendPluginMessage(The5zigMod.getInstance(), "5ZIG", ("/ts/seconds=" + seconds + ";up=" + up + ";id=" + id + ";name=" + name).getBytes());
sent = true;
}
|
b55b638f-badc-458d-901b-ede1eae585b9
| 5
|
public void listenForControls(int dt) {
float movementSpeed = 0.015f * dt;
if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
main.player.strafeLeft(movementSpeed);
}
if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
main.player.strafeRight(movementSpeed);
}
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
main.player.flyUp(movementSpeed);
}
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
main.player.flyDown(movementSpeed);
}
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
Display.destroy();
System.exit(0);
}
}
|
3dfe4579-4cb3-4822-a6d9-3bf92996a16b
| 1
|
public void setShowRowDivider(boolean visible) {
if (visible != mShowRowDivider) {
mShowRowDivider = visible;
notify(TreeNotificationKeys.ROW_DIVIDER, Boolean.valueOf(mShowRowDivider));
}
}
|
60f367c9-1889-440b-8b40-e57ce2b0f9a0
| 6
|
public static ExtensionRegistry getInstance()
{
if(registrySingleton == null) {
try {
// locate file in bundle
URL url = ExtensionRegistry.class.getClassLoader().getResource(CONFIG_PROPERTIES_FILENAME);
if(url != null) {
// open file and parse it
Properties config = new Properties();
config.load(url.openStream());
String registryClassName = config.getProperty(CONFIG_PROPERTIES_KEY);
if(registryClassName != null) {
try {
registrySingleton = (ExtensionRegistry) ExtensionRegistry.createObjectViaDefaultConstructor(registryClassName);
}
catch(Exception exc) {
throw new RuntimeException("Can not create extension registry.", exc);
}
}
// else: file does not define the key -> use default
}
// else: file not found
}
catch(IOException exc) {
// errors in config file -> use default
exc.printStackTrace(System.err);
}
// if none defined, use default one
if(registrySingleton == null) {
registrySingleton = new XMLExtensionRegistry(FOLDER_FOR_PLUGINS, REG_EXP_FILTER_PLUGINS);
}
}
return registrySingleton;
}
|
33d658c3-bf7e-4e70-90c5-7d6e0d1a988e
| 7
|
public Menu(Descent descent) {
this.descent = descent;
addMouseListener(new MouseInputAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
Font font = Menu.this.descent.getTitleFont().deriveFont(16.0F);
if (SwingUtilities.isLeftMouseButton(event)) {
int x = (getWidth() - MENU_ITEM_WIDTH) / 2;
int y = 128;
for (MenuItem menuItem : getMenuItems()) {
Point mouse = MouseInfo.getPointerInfo().getLocation();
if (mouse.getX() - getLocationOnScreen().getX() >= x && mouse.getY() - getLocationOnScreen().getY() >= y && mouse.getX() - getLocationOnScreen().getX() <= getWidth() - x && mouse.getY() - getLocationOnScreen().getY() <= y + 32 + getFontMetrics(font).getMaxAscent()) {
MenuSelectEvent menuSelectEvent = new MenuSelectEvent(Menu.this, menuItem);
Menu.this.descent.getEventManager().dispatchEvent(menuSelectEvent);
if (!menuSelectEvent.isCancelled()) {
menuSelectEvent.getMenuItem().doSelect();
}
return;
}
y += 1.5 * (32 + getFontMetrics(font).getMaxAscent());
}
}
}
});
}
|
aa7b8b3a-1291-4dc9-87ea-d62bdd3b6742
| 0
|
public GuiFrame() {
total.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CardLayout cardLayout = (CardLayout) panelcontainer.getLayout();
cardLayout.show(panelcontainer,"totalpanel");
//To change body of implemented methods use File | Settings | File Templates.
}
});
disclass.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//To change body of implemented methods use File | Settings | File Templates.
CardLayout cardLayout = (CardLayout) panelcontainer.getLayout();
cardLayout.show(panelcontainer, "disclasspanel");
}
});
graph.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//To change body of implemented methods use File | Settings | File Templates.
CardLayout cardLayout = (CardLayout) panelcontainer.getLayout();
cardLayout.show(panelcontainer,"graphpanel");
}
});
NetExt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//To change body of implemented methods use File | Settings | File Templates.
CardLayout cardLayout = (CardLayout) panelcontainer.getLayout();
cardLayout.show(panelcontainer, "extpanel");
}
});
}
|
0f8ccfed-5ab9-45c6-96ad-25a5bc42bf85
| 3
|
@Override
public void tick(int arg0, int arg1, int arg2) {
ArrayList<ComponentPlayer> comps = player.getComponentsOfType(ComponentPlayer.class);
ColliderBox coll;
if(comps.size() > 0)
coll = player.pos.add(comps.get(0).colliderPos).getColliderWithDim(comps.get(0).colliderDim);
else
coll = player.pos.getColliderWithDim(player.dim);
if(coll.getCollision(entity.pos.getColliderWithDim(entity.dim), new Vector2(0,0)).collides && comps.size() > 0)
{
comps.get(0).addMoney(amount);
map.getEntityList().removeEntityFromList(entity);
}
}
|
93d49fce-a974-47e3-a827-0eeeae08e762
| 8
|
private void getPossibleEventsForDate(Date selectedDate){
Hall selectedHall = (Hall) hallCombo.getSelectedItem();
String selectedHallName = selectedHall.getName();
ArrayList<Event> allAssignedEvents = new ArrayList<Event>();
allAssignedEvents = getAllAssignedEvents();
eventCombo.removeAllItems();
for (int i = 0; i < events.length; i++) {
if (events[i].getStartDate().equals(selectedDate)) {
if (!schedulesMap.isEmpty()) {
for (Map.Entry<String, ArrayList<Event>> entry : schedulesMap.entrySet()) {
String hallName = entry.getKey();
ArrayList<Event> assignedEventsPerHall = entry.getValue();
// if event is assigned to a hall, don't add it to the
// possible events
if (!allAssignedEvents.contains(events[i])) {
eventCombo.addItem(events[i]);
break;
} else if (assignedEventsPerHall.contains(events[i])
&& hallName.equalsIgnoreCase(selectedHallName)) {
eventCombo.addItem(events[i]);
}
}
} else {
eventCombo.addItem(events[i]);
}
}
}
if (eventCombo.getItemCount() > 0) {
eventCombo.insertItemAt("Please choose..", 0);
eventCombo.setSelectedIndex(0);
eventCombo.setEnabled(true);
buttonSave.setText("Save");
buttonSave.setEnabled(true);
} else {
eventCombo.insertItemAt("No events..", 0);
eventCombo.setSelectedIndex(0);
eventCombo.setEnabled(false);
buttonSave.setEnabled(false);
}
}
|
9d0cfd36-7f04-4078-a0fa-b5da3e2f168b
| 8
|
public static String htmlEscape(String input) {
if (input == null) {
throw new IllegalArgumentException("Null 'input' argument.");
}
StringBuilder result = new StringBuilder();
int length = input.length();
for (int i = 0; i < length; i++) {
char c = input.charAt(i);
if (c == '&') {
result.append("&");
}
else if (c == '\"') {
result.append(""");
}
else if (c == '<') {
result.append("<");
}
else if (c == '>') {
result.append(">");
}
else if (c == '\'') {
result.append("'");
}
else if (c == '\\') {
result.append("\");
}
else {
result.append(c);
}
}
return result.toString();
}
|
b3f91735-d7d9-4c2b-b186-0e0657826d4c
| 2
|
public static void aNewWalk() {
try {
String firstDirectoryName = "/home/xander/test/test1";
String secondDirectoryName = "/home/xander/test/test1/test2";
String fileOne = "/home/xander/test/test1/firstFile.txt";
String nameOfTheLinkToFileOne = "/home/xander/test/test1/test2/linkToFirst.txt";
Files.createDirectory(Paths.get(firstDirectoryName));
Files.createDirectory(Paths.get(secondDirectoryName));
Files.createFile(Paths.get(fileOne));
Path linkToFile = Files.createSymbolicLink(Paths.get(nameOfTheLinkToFileOne), Paths.get(fileOne));
Files.createSymbolicLink(Paths.get("/home/xander/test/test1/test2/linkToDirectory"),
Paths.get(firstDirectoryName)); // circular link
if (Files.isSameFile(Paths.get(fileOne), linkToFile)) {
Files.write(Paths.get(fileOne), Arrays.asList("Hello"), Charset.defaultCharset());
List<String> lines = Files.readAllLines(linkToFile, Charset.defaultCharset());
assert lines.get(0).equals("Hello");
}
Files.walkFileTree(Paths.get(firstDirectoryName), EnumSet.of(FileVisitOption.FOLLOW_LINKS),
Integer.MAX_VALUE,
new SimpleFileVisitor<Path>(){
public FileVisitResult visitFileFailed(Path path, IOException e) {
System.out.println((FileSystemLoopException) e);
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
|
eb65b485-a27b-42fd-9f76-2a70fb2585c4
| 5
|
public void readCharacterDefinition(String filename, UnknownDictionary dictionary) throws IOException {
FileInputStream inputStream = new FileInputStream(filename);
InputStreamReader streamReader = new InputStreamReader(inputStream, encoding);
LineNumberReader lineReader = new LineNumberReader(streamReader);
String line = null;
while ((line = lineReader.readLine()) != null) {
line = line.replaceAll("^\\s", "");
line = line.replaceAll("\\s*#.*", "");
line = line.replaceAll("\\s+", " ");
// Skip empty line or comment line
if(line.length() == 0) {
continue;
}
if(line.startsWith("0x")) { // Category mapping
String[] values = line.split(" ", 2); // Split only first space
if(!values[0].contains("..")) {
int cp = Integer.decode(values[0]).intValue();
dictionary.putCharacterCategory(cp, values[1]);
} else {
String[] codePoints = values[0].split("\\.\\.");
int cpFrom = Integer.decode(codePoints[0]).intValue();
int cpTo = Integer.decode(codePoints[1]).intValue();
for(int i = cpFrom; i <= cpTo; i++){
dictionary.putCharacterCategory(i, values[1]);
}
}
} else { // Invoke definition
String[] values = line.split(" "); // Consecutive space is merged above
String characterClassName = values[0];
int invoke = Integer.parseInt(values[1]);
int group = Integer.parseInt(values[2]);
int length = Integer.parseInt(values[3]);
dictionary.putInvokeDefinition(characterClassName, invoke, group, length);
}
}
}
|
8a10a7fa-d489-443f-878a-1ac062242c78
| 4
|
long fixedFromGJ(int year, int monthOfYear, int dayOfMonth) {
if (year == 0) {
throw new IllegalArgumentException("Illegal year: " + year);
}
int y = (year < 0) ? year + 1 : year;
long y_m1 = y - 1;
long f = JULIAN_EPOCH - 1 + 365 * y_m1 + div(y_m1, 4)
+ div(367 * monthOfYear - 362, 12) + dayOfMonth;
if (monthOfYear > 2) {
f += isLeapYear(year) ? -1 : -2;
}
return f;
}
|
163f1c93-b597-4249-b73d-6b6366940aa4
| 1
|
public void addTray(Tray tray) {
if (!this.trays.contains(tray)) {
this.setSlotNumber(tray);
this.trays.add(tray);
tray.setStorageUnit(this);
}
}
|
669b4a62-549c-48de-9971-0b680e67a98d
| 3
|
public double[] getColumnCopy(int ii){
if(ii>=this.numberOfColumns)throw new IllegalArgumentException("Column index, " + ii + ", must be less than the number of columns, " + this.numberOfColumns);
if(ii<0)throw new IllegalArgumentException("column index, " + ii + ", must be zero or positive");
double[] col = new double[this.numberOfRows];
for(int i=0; i<numberOfRows; i++){
col[i]=this.matrix[i][ii];
}
return col;
}
|
01dc4411-1195-4f13-b5eb-37824d449735
| 7
|
public void fillPreRequisites(Ability A, DVector rawPreReqs)
{
for(int v=0;v<rawPreReqs.size();v++)
{
final String abilityID=(String)rawPreReqs.elementAt(v,1);
if(abilityID.startsWith("*")||abilityID.endsWith("*")||(abilityID.indexOf(',')>0))
{
final List<String> orset=getOrSet(A.ID(),abilityID);
if(orset.size()!=0)
rawPreReqs.setElementAt(v,1,orset);
}
else
{
Ability otherAbility=CMClass.getAbility(abilityID);
if(otherAbility==null)
{
otherAbility=CMClass.findAbility(abilityID);
if(otherAbility!=null)
rawPreReqs.setElementAt(v,1,otherAbility.ID());
else
{
Log.errOut("CMAble","Skill "+A.ID()+" requires nonexistant skill "+abilityID+".");
break;
}
}
}
}
}
|
25bc661e-e5f6-4318-a044-0e37e59a022c
| 6
|
public Object getFromCache(String key) throws Exception {
Object result = null;
// We get the SoftReference represented by that key
SoftReference softRef = (SoftReference) map.get(key);
if (softRef != null) {
// From the SoftReference we get the value, which can be
// null if it was not in the map, or it was removed in
// the processQueue() method defined below
result = softRef.get();
if (result == null) {
// If the value has been garbage collected, remove the
// entry from the HashMap.
map.remove(key);
mapTtl.remove(key);
} else {
// We now add this object to the beginning of the hard
// reference queue. One reference can occur more than
// once, because lookups of the FIFO queue are slow, so
// we don't want to search through it each time to remove
// duplicates.
hardCache.add(0, result);//addFirst
try {
synchronized(lock) {
int size = hardCache.size();
if (size > getHardSize()) {
// Remove the last entry if list longer than HARD_SIZE
hardCache.remove(size-1);//removeLast();
}
}
} catch(IndexOutOfBoundsException e) {
logger.log(Level.SEVERE, "IndexOutOfBoundsException: "+e);
}
}
}
if(result==null && QuickCached.DEBUG) {
logger.log(Level.FINE, "no value in db for key: {0}", key);
}
return result;
}
|
8e3e3b2b-6e9a-4b52-9613-001d99dd95c1
| 6
|
public void bodyDetected(double x, double y, double width, double height, double dist) {
// calculate body-center pos (image) x,y 0..1
double cX = x + width / 2;
double cY = y + height / 2;
Point2D absPos = this.camPosToAbsPos(new Point2D(cX, cY));
Point3D cartPos = this.absPosToCartesian(absPos, dist);
this.controller.getGui().printConsole(
"Körper gefunden: x:" +
df.format(cartPos.x) + "m y:" +
df.format(cartPos.y) + "m z:" +
df.format(cartPos.z) + "m",
5
);
if (cartPos.z > this.minHeight) {
Body closest = null;
this.controller.getRoomState().lock(true);
for (Body candidate : this.controller.getRoomState().getBodyList()) {
double velocity = candidate.calcVelocity(cartPos);
if (velocity <= this.maxVelocity) {
if (
closest == null
|| closest.calcVelocity(cartPos) < velocity
) {
closest = candidate;
}
}
}
this.controller.getRoomState().lock(false);
if (closest == null) {
this.controller.getRoomState().addBody(new Body(cartPos, this.controller));
} else {
closest.setPos(cartPos);
}
this.focus();
}
}
|
c4e4c262-defc-45d9-9212-5f0cfef54395
| 9
|
Message parse(final DataInputStream input)
throws IOException {
if (input == null) {
throw new IllegalArgumentException("Input stream for ISO8583 message cannot be null");
}
final MessageReader reader = getMessageReader();
// if the header field is required, check that it is present
final int headerLen = header != null ? header.length() : 0;
if (headerLen > 0) {
final String msgHeader = reader.readHeader(headerLen, input);
if (!msgHeader.equals(header)) {
throw new MessageException("Message should start with header: [" + header + "]");
}
}
// read the message type (MTI)
final MTI type = reader.readMTI(input);
final MessageTemplate template = messages.get(type);
if (template == null) {
throw new MessageException("Message type [" + type + "] not defined in this message set");
}
// create resulting message
final Message result = new Message(template.getMessageTypeIndicator());
result.setHeader(headerLen > 0 ? header : "");
final Bitmap bitmap = reader.readBitmap(bitmapType, input);
// iterate across all possible fields, parsing if present:
final Map<Integer, Object> fields = new HashMap<>();
for (int i = 2; i <= 192; i++) {
if (!bitmap.isFieldPresent(i)) {
continue;
}
final FieldTemplate field = template.getFields().get(i);
final byte[] fieldData = reader.readField(field, input);
try {
final Object value = field.parse(fieldData);
fields.put(field.getNumber(), value);
} catch (final ParseException e) {
final MessageException rethrow = new MessageException("Failed to parse field: " + field.toString());
rethrow.initCause(e);
throw rethrow;
}
}
result.setFields(fields);
return result;
}
|
a0ac26bb-fc88-403c-9adf-df2d0442d116
| 8
|
public static void main( String[] args )
{
System.out.println( "NanoHTTPD 1.0 (c) 2001 Jarno Elonen\n" +
"(Command line options: [port] [--licence])\n" );
// Show licence if requested
int lopt = -1;
for ( int i=0; i<args.length; ++i )
if ( args[i].toLowerCase().endsWith( "licence" ))
{
lopt = i;
System.out.println( LICENCE + "\n" );
}
// Change port if requested
int port = 80;
if ( args.length > 0 && lopt != 0 )
port = Integer.parseInt( args[0] );
if ( args.length > 1 &&
args[1].toLowerCase().endsWith( "licence" ))
System.out.println( LICENCE + "\n" );
NanoHTTPD nh = null;
try
{
nh = new NanoHTTPD( port );
}
catch( IOException ioe )
{
System.err.println( "Couldn't start server:\n" + ioe );
System.exit( -1 );
}
nh.myFileDir = new File("");
System.out.println( "Now serving files in port " + port + " from \"" +
new File("").getAbsolutePath() + "\"" );
System.out.println( "Hit Enter to stop.\n" );
try { System.in.read(); } catch( Throwable t ) {};
}
|
8fb74799-6da1-42b1-8a3f-cba24a80bbd0
| 9
|
public void handleConf(CSTAEvent event) {
if ((event == null)
|| (!(event.getEvent() instanceof CSTAPickupCallConfEvent))) {
return;
}
this.device.replyTermPriv = event.getPrivData();
Vector<TSEvent> eventList = new Vector<TSEvent>();
if (this.terminalAddress == this.pickConnection.getTSDevice()) {
this.pickConnection.setConnectionState(88, eventList);
if (eventList.size() > 0) {
TSCall pickCall = this.pickConnection.getTSCall();
Vector<?> observers = pickCall.getObservers();
for (int j = 0; j < observers.size(); j++) {
TsapiCallMonitor callback = (TsapiCallMonitor) observers
.elementAt(j);
callback.deliverEvents(eventList, 100, false);
}
}
} else {
this.pickConnection.setConnectionState(89, eventList);
if (eventList.size() > 0) {
TSCall pickCall = this.pickConnection.getTSCall();
Vector<?> observers = pickCall.getObservers();
for (int j = 0; j < observers.size(); j++) {
TsapiCallMonitor callback = (TsapiCallMonitor) observers
.elementAt(j);
callback.deliverEvents(eventList, 100, false);
}
}
}
}
|
b53560bf-b356-4abf-980a-3b02da1c1d6f
| 5
|
public void run() {
while(connected){
try {
int i = inputStream.readInt();
IPacket packet = PacketList.instance.getPacketFromID(i);
if (packet != null){
if (!packet.isClientPacket() || packet.isServerPacket()){
eventHandler.onInvalidSidedPacketReceive(this, packet);
GameApplication.engineLogger.severe("Not reading packet " + packet + " : tried to receive from invalid side");
return;
}
packet.readPacket(inputStream);
packet.handlePacket(theGame);
}
} catch (IOException e) {
GameApplication.engineLogger.info("Client has disconnected !");
eventHandler.onClientDisconnect(this);
autoClean();
return;
}
}
}
|
5e162d79-11a2-4844-8c4f-1c700c6413e7
| 1
|
public void update(int delta) {
while(performAction(delta) != -1);
}
|
c2f89628-0278-48ed-8c5d-d43ebf701cc7
| 9
|
public boolean testForward() throws PersistitException {
setPhase("a");
_ex.clear().append(Key.BEFORE);
int index1 = 0;
int index2;
while (_ex.next() && !isStopped()) {
index2 = (int) (_ex.getKey().decodeLong());
for (int i = index1; i < index2; i++) {
if (_checksum[i] != -1) {
return false;
}
}
index1 = index2 + 1;
final int cksum = checksum(_ex.getValue());
if ((index2 < 0) || (index2 >= _total)) {
return false;
}
if (cksum != _checksum[index2]) {
return false;
}
}
for (int i = index1; i < _total; i++) {
if (_checksum[i] != -1) {
return false;
}
}
return true;
}
|
11a44f41-0cc8-48b7-bac7-7cef06b58e3d
| 0
|
public Person1 (int id,String Name,Double height)
{
this.id = id;
this.Name = Name;
this.height = height;
}
|
01d42753-a9ac-4f17-b05f-f15a2bb6964f
| 0
|
public PrintAutonomousMove(double speed,double waitTime){
_speed = speed;
_waitTime = waitTime;
}
|
6a849e7c-6185-4fb1-9fe3-3c9bf425210b
| 0
|
public int getArmor() {return armor;}
|
cd9cf07b-4c05-40ee-8ab4-73f268875f6a
| 6
|
public static void main(String args[]) throws IOException {
/* 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(GUIReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GUIReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GUIReader.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GUIReader.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 GUIReader().setVisible(true);
}
});
}
|
9cf633a3-994a-40e9-a128-cda5178c3c06
| 4
|
@Override
public void processPacket(Client c, int packetType, int packetSize) {
int tradeId = c.getInStream().readSignedWordBigEndian();
c.getPA().resetFollow();
if(c.arenas()) {
c.sendMessage("You can't trade inside the arena!");
return;
}
if(c.playerRights == 2 && !Config.ADMIN_CAN_TRADE) {
c.sendMessage("Trading as an admin has been disabled.");
return;
}
if (tradeId != c.playerId)
c.getTradeAndDuel().requestTrade(tradeId);
}
|
2977ea59-1429-4b28-94f4-a34f75fa4fd8
| 0
|
public static GsonBuilder registerAdapters(GsonBuilder builder)
{
builder.registerTypeAdapter(GeoJsonObject.class, new GeoJsonObjectAdapter());
builder.registerTypeAdapter(LngLatAlt.class, new LngLatAltAdapter());
return builder;
}
|
376e40ce-e228-489a-bd37-3afd3908bfbd
| 9
|
public static void main(String[] args) throws Throwable{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
ArrayList<Figura> figuras = new ArrayList<Figura>();
for (String ln; !(ln = in.readLine().trim()).equals("*"); ) {
String[] arr = ln.split(" +");
if(arr[0].equals("r")){
Cuadrado c = new Cuadrado('r', new Punto(parseDouble(arr[1]), parseDouble(arr[2])), new Punto(parseDouble(arr[3]), parseDouble(arr[4])));
figuras.add(c);
}
if(arr[0].equals("c")){
Circulo c = new Circulo('c', new Punto(parseDouble(arr[1]), parseDouble(arr[2])), parseDouble(arr[3]));
figuras.add(c);
}
}
int cont = 0;
while(true){
cont++;
String[] arr = in.readLine().trim().split(" +");
Punto p = new Punto(parseDouble(arr[0]), parseDouble(arr[1]));
if(p.x == 9999.9 && p.y == 9999.9)break;
boolean ws = false;
for (int i = 0; i < figuras.size(); i++)
if(p.puntoDentroDeFigura(figuras.get(i))){
sb.append("Point " + cont + " is contained in figure " + (i+1) + "\n");
ws = true;
}
if(!ws)sb.append("Point " + cont + " is not contained in any figure\n");
}
System.out.print(new String(sb));
}
|
3b651c1d-6616-411e-bd86-5b55d8148864
| 3
|
public ChatRoom getChatRoomAt(int index) {
if(list == null) {
return null;
}
if(index < 0 || index >= list.size()) {
return null;
}
return list.get(index);
}
|
bd0f564a-36ee-48bd-a501-9c51a1f5b07f
| 3
|
public static boolean compare(int a, int b) {
long resa = a;
long resb = b;
int ta = a;
int tb = b;
do {resa = resa * 10; tb = tb / 10;} while (tb != 0);
resa = resa + b;
do {resb = resb * 10; ta = ta / 10;} while (ta != 0);
resb = resb + a;
if (resa >= resb) return true;
return false;
}
|
e425b312-6880-4a72-a58b-a0c573a33957
| 4
|
public void move() {
x += dx;
y += dy;
Dimension d = panel.getSize();
if (x < 0) {
x = 0;
dx = -dx;
} else if (x + BALL_DIAM >= d.width) {
x = d.width - BALL_DIAM;
dx = -dx;
}
if (y < 0) {
y = 0;
dy = -dy;
} else if (y + BALL_DIAM >= d.height) {
y = d.height - BALL_DIAM;
dy = -dy;
}
}
|
f148a273-fe79-468a-9b38-97c35eb36674
| 1
|
public boolean getUpdate(){
if (prop.getProperty("autoUpdate").equals("true"))
return true;
else
return false;
}
|
767c6142-92b3-4622-b8d0-469bdc0ff123
| 1
|
private static void printGerber(ArrayList<Gaussian> primes) throws Exception {
System.out.println(GerberPlottables.GERBER_HEADER);
System.out.println("G75*");
int scale = 1000;
// double radius = scale/2*2/Math.sqrt(3);
double radius = scale/2;
for(Gaussian e: primes)
System.out.println(GerberPlottables.circle(e.mul(scale).toCoordinate(), radius));
System.out.println(GerberPlottables.GERBER_FOOTER);
}
|
44662edf-2260-4c7e-b317-3da50bb1fd9a
| 1
|
@Test
public void findStudentBookingsByMonthAndYearTest() {
try {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
DiningHall d1 = new DiningHall(24, BigDecimal.valueOf(4.00),
DiningHall.Type.MADRUGADORES);
DiningHall d2 = new DiningHall(20, BigDecimal.valueOf(5.00),
DiningHall.Type.COMEDOR);
Calendar cal1 = Calendar.getInstance();
cal1.setTime(sdf.parse("27/10/2014"));
Booking b1 = new Booking(cal1, familyService.findStudent(3), d1);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(sdf.parse("22/10/2014"));
Booking b2 = new Booking(cal2, familyService.findStudent(3), d1);
Calendar cal3 = Calendar.getInstance();
cal3.setTime(sdf.parse("01/08/2014"));
Booking b3 = new Booking(cal3, familyService.findStudent(3), d1);
Calendar cal4 = Calendar.getInstance();
cal4.setTime(sdf.parse("03/10/2014"));
Booking b4 = new Booking(cal4, familyService.findStudent(3), d2);
Calendar cal5 = Calendar.getInstance();
cal5.setTime(sdf.parse("03/02/2015"));
Booking b5 = new Booking(cal5, familyService.findStudent(3), d2);
bookingService.create(b1);
bookingService.create(b2);
bookingService.create(b3);
bookingService.create(b4);
bookingService.create(b5);
assertEquals(
3,
bookingService.findStudentBookingsByMonthAndYear(
familyService.findStudent(3), cal1).size());
assertEquals(
1,
bookingService.findStudentBookingsByMonthAndYear(
familyService.findStudent(3), cal3).size());
assertEquals(
1,
bookingService.findStudentBookingsByMonthAndYear(
familyService.findStudent(3), cal5).size());
bookingService.remove(b1);
bookingService.remove(b2);
bookingService.remove(b3);
bookingService.remove(b4);
bookingService.remove(b5);
} catch (InstanceNotFoundException | ParseException
| DuplicateInstanceException | MaxCapacityException
| NotValidDateException e) {
e.printStackTrace();
}
}
|
f086631e-7c74-481f-bca8-68b1972da928
| 3
|
public void setCondicao(PExpLogica node)
{
if(this._condicao_ != null)
{
this._condicao_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._condicao_ = node;
}
|
4405cc39-9402-4165-bf94-156b5bdd85c1
| 1
|
private void shiftLeft(int position) {
// int countOfLeftShift = 0;
// countOfLeftShift = (items.length - 1) - position;
for (int count=position; count > 0; count--) {
items[count]=items[count+1];
}
}
|
c7f8350d-ec3e-403f-b36f-0e23fbf07b38
| 1
|
public void setPause(int seconds) {
try {
Thread.sleep(seconds * 1000);
} catch (InterruptedException e) {
System.out.printf("\n%s", "Some thing went wrong!!!");
}
}
|
950be255-a690-4542-9569-55b523e7231a
| 5
|
private static void traverseFields(Class<?> c, List<Field> out)
{
List<Field> fieldList = new ArrayList<Field>();
for (Field f : c.getFields())
{
if ((f.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0)
{
f.setAccessible( true );
fieldList.add( f );
}
}
Collections.sort( fieldList, new Comparator<Field>()
{
public int compare( Field a, Field b )
{
return a.getName().compareTo( b.getName() );
}
} );
out.addAll( fieldList );
if (c.getSuperclass() != null && c.getSuperclass() != Object.class)
{
traverseFields( c.getSuperclass(), out );
}
}
|
8a7cc22c-ffe0-4105-ac23-718dcc058119
| 6
|
private boolean camposCompletos (){
if((!field_codigo.getText().equals(""))&&
(!field_nombre.getText().equals(""))&&
(!field_apellido.getText().equals(""))&&
(!field_localidad.getText().equals(""))&&
(!field_direccion.getText().equals(""))&&
(!field_sit_frente_iva.getText().equals(""))){
return true;
}
else{
return false;
}
}
|
a9363503-61cb-47f0-90a4-4b363e0b5377
| 0
|
public static Praticien selectNum(EntityManager em, String nom, String prenom) throws PersistenceException {
Praticien praticien = null;
Query query = em.createQuery("select pra.numero from Praticien pra where pra.nom = :nom and pra.prenom = :prenom");
query.setParameter("nom", nom);
query.setParameter("prenom", prenom);
praticien = (Praticien) query.getSingleResult();
return praticien;
}
|
171c26b8-60fd-454f-8c5e-8e01f6756634
| 3
|
@SuppressWarnings("deprecation")
@Override
public boolean girisYap(String kullaniciAdi, String sifre) throws Throwable {
if (!kullaniciAdi.isEmpty() && !sifre.isEmpty()) {
kullanici = new Calisan();
if (kullanici.girisYap(kullaniciAdi, sifre)) {
kullanici.bilgileriGetir(kullaniciAdi);
ana = new AnaEkran();
ana.show();
mutlakkafe.MutlakKafe.mainCont.girisBasarili();
return true;
}
JOptionPane.showMessageDialog(null, "Yanlıs kullanıcı adı sifre",
"Hata", JOptionPane.ERROR_MESSAGE);
}
else
JOptionPane.showMessageDialog(null, "Lütfen alanları doldurunuz.",
"Hata", JOptionPane.ERROR_MESSAGE);
return false;
}
|
38679f21-dbc6-4d90-9da1-b5177c3ea2a7
| 7
|
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ComparableObjectSeries)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
ComparableObjectSeries that = (ComparableObjectSeries) obj;
if (this.maximumItemCount != that.maximumItemCount) {
return false;
}
if (this.autoSort != that.autoSort) {
return false;
}
if (this.allowDuplicateXValues != that.allowDuplicateXValues) {
return false;
}
if (!ObjectUtilities.equal(this.data, that.data)) {
return false;
}
return true;
}
|
c6d42c78-ae91-45ff-8e2f-0d208845c2bf
| 0
|
@Override
public boolean existsLockRead(Long connectionId, String objectType) {
return readLocks.contains(objectType + lockSeparate + connectionId);
}
|
60e4bf57-e0c2-4c3a-aaee-b61eea97a241
| 3
|
public static BEProvince fromCode(String code){
if (!StringUtils.isBlank(code)){
String codeUpper = code.toUpperCase().trim();
for (BEProvince p : BEProvince.values()){
if (codeUpper.equals(p.provinceCode)){
return p;
}
}
}
return null;
}
|
0f597568-680b-4146-93ef-937bf686672a
| 5
|
private final String getChunk(String s, int slength, int marker)
{
StringBuilder chunk = new StringBuilder();
char c = s.charAt(marker);
chunk.append(c);
marker++;
if (isDigit(c))
{
while (marker < slength)
{
c = s.charAt(marker);
if (!isDigit(c))
break;
chunk.append(c);
marker++;
}
} else
{
while (marker < slength)
{
c = s.charAt(marker);
if (isDigit(c))
break;
chunk.append(c);
marker++;
}
}
return chunk.toString();
}
|
b8e8a3b5-8794-4bed-b713-122f8ba35c45
| 5
|
private Set<Local> getAllDeadKeys(List<Local> live_var){
Set<Local> dead_keys = new HashSet<Local>();
for(Map.Entry<Local, Set<Local>> e: map.entrySet()){
if(!live_var.contains(e.getKey())){
Set<Local> myset = e.getValue();
boolean flag = true;
for(Local l: myset){
if(live_var.contains(l)){
flag = false;
break;
}
}
if(flag){
dead_keys.add(e.getKey());
}
}
}
return dead_keys;
}
|
b251a1e3-3ac3-4f7d-bba0-75b8ad11f747
| 2
|
public void mostrarDatos(beansVentas registros){
if(registros.getAccion().equals("Descuento")){
System.out.println("Descripcion "+registros.getDescripcion());
System.out.println("Descuento "+registros.getDescuento()+"%");
System.out.println("TotalSinDescuento "+registros.getTotalSinDescuento());
System.out.println("------------------------------------------");
}else if(registros.getAccion().equals("Oferta")){
System.out.println("Oferta "+registros.getDescripcion());
System.out.println("ProductoTotal "+registros.getProductoAdicional());
System.out.println("------------------------------------------");
}
System.out.println("Total Q."+registros.getTotal()+".00");
System.out.println("------------------------------------------");
}
|
658150a2-1873-4e37-8c7f-7649e58494c3
| 5
|
public static void get_bill_configure()
{
try{
FileInputStream in = new FileInputStream(billConfigFile);
try (BufferedReader bufffile = new BufferedReader(new InputStreamReader(in, "UTF8")))
{
String strLine;
strLine = bufffile.readLine();
while (strLine != null) {
if(strLine.substring(0, 3).equals("=01"))
{
phone_number = strLine.substring(3);
}
else if(strLine.substring(0, 3).endsWith("=00"))
{
owner_name = strLine.substring(3);
}
else if(strLine.substring(0, 3).endsWith("=09"))
{
MAX_NAME_CHAR = Integer.parseInt(strLine.substring(3));
}
strLine = bufffile.readLine();
}
}
in.close();
}catch (Exception e){//Catch exception if any
phone_number = "(083)592.33.79";
owner_name = "Tạp Hóa SÁU VÂN";
MAX_NAME_CHAR = 20;
}
}
|
6f05e5a8-2337-404d-82c4-eb2a8346c1b9
| 2
|
public static Double toDouble(Object obj) {
if(obj==null)
return null;
String string=StringUtils.trimNonNumeric(obj.toString());
Double o=null;
try {
o=new Double(Double.parseDouble(string));
} catch (NumberFormatException ex) {
}
return o;
}
|
1075615d-ee5f-41b4-a915-448b343ec244
| 1
|
@Override
public void collideWith(Element e) {
if (e instanceof Moveable)
getGrid().teleportElement(e, destination);
}
|
17c7f3b4-0beb-4a6b-95af-f21f803ca86e
| 4
|
public static String toString(JSONObject jo) throws JSONException {
StringBuffer sb = new StringBuffer();
sb.append(escape(jo.getString("name")));
sb.append("=");
sb.append(escape(jo.getString("value")));
if (jo.has("expires")) {
sb.append(";expires=");
sb.append(jo.getString("expires"));
}
if (jo.has("domain")) {
sb.append(";domain=");
sb.append(escape(jo.getString("domain")));
}
if (jo.has("path")) {
sb.append(";path=");
sb.append(escape(jo.getString("path")));
}
if (jo.optBoolean("secure")) {
sb.append(";secure");
}
return sb.toString();
}
|
a1f1f3b0-9b34-46c4-a9ed-202b9b1a6908
| 9
|
public void mousePressed(MouseEvent event) {
int x = event.getX();
int y = event.getY();
int mouseButton = event.getButton();
Marking initialMarking = PNEditor.getRoot().getCurrentMarking();
if (PNEditor.getRoot().getClickedElement() != null
&& PNEditor.getRoot().isSelectedTool_Token()) {
Element targetElement = PNEditor.getRoot().getDocument().petriNet.getCurrentSubnet().getElementByXY(x, y);
if (targetElement instanceof PlaceNode) {
PlaceNode placeNode = (PlaceNode) targetElement;
if (mouseButton == MouseEvent.BUTTON1) {
PNEditor.getRoot().getUndoManager().executeCommand(new AddTokenCommand(placeNode, initialMarking));
} else if (mouseButton == MouseEvent.BUTTON3) {
if (initialMarking.getTokens(placeNode) > 0) {
PNEditor.getRoot().getUndoManager().executeCommand(new RemoveTokenCommand(placeNode, initialMarking));
}
}
} else if (targetElement instanceof Transition) {
Transition transition = (Transition) targetElement;
if (mouseButton == MouseEvent.BUTTON1) {
if (initialMarking.isEnabled(transition)) {
PNEditor.getRoot().getUndoManager().executeCommand(new FireTransitionCommand(transition, initialMarking));
}
}
}
}
}
|
97d850d6-5b91-4ba9-b40b-8fbb70bc3e86
| 4
|
public void init( ArrayList<Monster> mon ) {
int enmyCt = 1 + (int)(Math.random()*4); //How many enemies in play?
while ( enmyCt > 0 ) { //Add rand enmys to battle depending on MONSTERS
try {
Class mans = MONSTERS.get((int)(Math.random()
*MONSTERS.size())).getClass();
_eInPlay.add( (Monster)(mans.newInstance()) );
}
catch(InstantiationException e) {
}
catch(IllegalAccessException e) {
}
enmyCt--;
}
for ( Monster m : _eInPlay ) {
gainE += m.getExp();
gainM += m.getMun();
}
}
|
c5a99815-b848-4dd0-884f-58e4714247a3
| 0
|
public String getRealName() {
return realName;
}
|
697f5405-030d-49ae-b415-5387aebd1dbc
| 5
|
private void put(JsonElement value) {
if (pendingName != null) {
if (!value.isJsonNull() || getSerializeNulls()) {
JsonObject object = (JsonObject) peek();
object.add(pendingName, value);
}
pendingName = null;
} else if (stack.isEmpty()) {
product = value;
} else {
JsonElement element = peek();
if (element instanceof JsonArray) {
((JsonArray) element).add(value);
} else {
throw new IllegalStateException();
}
}
}
|
5a98d908-e8e2-4320-a74f-01a0f00fac46
| 8
|
public void keyPressed( KeyEvent e ) {
int iday = getSelectedDay();
switch ( e.getKeyCode() ) {
case KeyEvent.VK_LEFT:
if ( iday > 1 )
setSelected( iday-1 );
break;
case KeyEvent.VK_RIGHT:
if ( iday < lastDay )
setSelected( iday+1 );
break;
case KeyEvent.VK_UP:
if ( iday > 7 )
setSelected( iday-7 );
break;
case KeyEvent.VK_DOWN:
if ( iday <= lastDay-7 )
setSelected( iday+7 );
break;
}
}
|
37a58686-48be-477d-8e6a-f5f3d69a53d0
| 9
|
private static boolean bestPermutationMutated (Tour tour, int a, int b, int c, int d, int e, int f) {
City A = tour.getCity(a);
City B = tour.getCity(b);
City C = tour.getCity(c);
City D = tour.getCity(d);
City E = tour.getCity(e);
City F = tour.getCity(f);
double[] dist = new double[8];
dist[0] = A.distanceTo(B) + C.distanceTo(E) + D.distanceTo(F) + r.nextInt(10);
dist[1] = A.distanceTo(C) + B.distanceTo(D) + E.distanceTo(F) + r.nextInt(10);
dist[2] = A.distanceTo(C) + B.distanceTo(E) + D.distanceTo(F) + r.nextInt(10);
dist[3] = A.distanceTo(D) + E.distanceTo(B) + C.distanceTo(F) + r.nextInt(10);
dist[4] = A.distanceTo(D) + E.distanceTo(C) + B.distanceTo(F) + r.nextInt(10);
dist[5] = A.distanceTo(E) + D.distanceTo(B) + C.distanceTo(F) + r.nextInt(10);
dist[6] = A.distanceTo(E) + D.distanceTo(C) + B.distanceTo(F) + r.nextInt(10);
dist[7] = A.distanceTo(B) + C.distanceTo(D) + E.distanceTo(F) + r.nextInt(10);
int index = 0;
double min = Double.MAX_VALUE;
for (int i = 0; i < dist.length; i++)
if (dist[i] < min) {
index = i;
min = dist[i];
}
if (index == 0) {
tour.setCity(d, E);
tour.setCity(e, D);
exchange(tour, c+2, e-1);
return false;
} else if (index == 1) {
tour.setCity(b, C);
tour.setCity(c, B);
exchange(tour, a+2, c-1);
return false;
} else if (index == 2) {
tour.setCity(b, C);
tour.setCity(c, B);
tour.setCity(d, E);
tour.setCity(e, D);
exchange(tour, a+2,c-1);
exchange(tour, c+2,e-1);
return false;
} else if (index == 3) {
tour.setCity(b, D);
tour.setCity(c, E);
tour.setCity(d, B);
tour.setCity(e, C);
exchange(tour, a+2,e-1);
exchange(tour, a+2,c-1);
exchange(tour, c+2,e-1);
return false;
} else if (index == 4) {
tour.setCity(b, D);
tour.setCity(c, E);
tour.setCity(d, C);
tour.setCity(e, B);
exchange(tour, c+2,e-1);
exchange(tour, a+2,e-1);
return false;
} else if (index == 5) {
tour.setCity(b, E);
tour.setCity(c, D);
tour.setCity(d, B);
tour.setCity(e, C);
exchange(tour, a+2,c-1);
exchange(tour, a+2,e-1);
return false;
} else if (index == 6) {
tour.setCity(b, E);
tour.setCity(e, B);
exchange(tour, a+2,e-1);
return false;
} else {
return true;
}
}
|
79abc85e-e7ab-4dc6-9090-0c6d5757a52f
| 3
|
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jColorChooser1 = new javax.swing.JColorChooser();
jColorChooser2 = new javax.swing.JColorChooser();
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
projectNameLabel = new javax.swing.JLabel();
categoryLabel = new javax.swing.JLabel();
categoryComboBox = new javax.swing.JComboBox();
statusLabel = new javax.swing.JLabel();
statusComboBox = new javax.swing.JComboBox();
scopeLabel = new javax.swing.JLabel();
scopeComboBox = new javax.swing.JComboBox();
peopleLabel = new javax.swing.JLabel();
peopleComboBox = new javax.swing.JComboBox();
outcomeLabel = new javax.swing.JLabel();
projectNameTextField = new javax.swing.JTextField();
outcomeTextField = new javax.swing.JTextField();
fromDateLabel = new javax.swing.JLabel();
toDateLabel = new javax.swing.JLabel();
fromDateTextField = new javax.swing.JTextField();
toDateTextField = new javax.swing.JTextField();
searchButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
jPanel2.setBackground(new java.awt.Color(225, 242, 229));
jPanel3.setBackground(new java.awt.Color(225, 242, 229));
jLabel1.setFont(new java.awt.Font("Candara", 1, 48)); // NOI18N
jLabel1.setText("FrugaInnovation");
jLabel2.setFont(new java.awt.Font("Candara", 1, 48)); // NOI18N
jLabel2.setForeground(java.awt.Color.red);
jLabel2.setText("Lab");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(267, 267, 267)
.addComponent(jLabel1)
.addGap(0, 0, 0)
.addComponent(jLabel2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap(33, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel2)))
);
jPanel4.setBackground(new java.awt.Color(225, 242, 229));
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 987, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jPanel5.setBackground(new java.awt.Color(225, 242, 229));
jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Candara", 0, 14))); // NOI18N
jPanel1.setBackground(new java.awt.Color(225, 242, 229));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Project Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Candara", 0, 14))); // NOI18N
projectNameLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
projectNameLabel.setText("Project Name");
categoryLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
categoryLabel.setText("Category");
categoryComboBox.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
categoryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
categoryComboBox.removeAllItems();
String[] strArray = projectTableController.getCategoryComboBoxesData();
for(String str : strArray) {
categoryComboBox.addItem(str);
}
categoryComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
categoryComboBoxActionPerformed(evt);
}
});
statusLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
statusLabel.setText("Status");
statusComboBox.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
statusComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
statusComboBox.setPreferredSize(new java.awt.Dimension(56, 24));
statusComboBox.removeAllItems();
String[] status_strArray = projectTableController.getStatusComboBoxesData();
for(String str : status_strArray) {
statusComboBox.addItem(str);
}
scopeLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
scopeLabel.setText("Scope");
scopeComboBox.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
scopeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
scopeComboBox.removeAllItems();
String[] scope_strArray = projectTableController.getScopeComboBoxesData();
for(String str : scope_strArray) {
scopeComboBox.addItem(str);
}
peopleLabel.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
peopleLabel.setText("People");
peopleComboBox.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
peopleComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
outcomeLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
outcomeLabel.setText("Outcome");
projectNameTextField.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
projectNameTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
projectNameTextFieldActionPerformed(evt);
}
});
outcomeTextField.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
fromDateLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
fromDateLabel.setText("Start Date");
toDateLabel.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
toDateLabel.setText("End Date");
fromDateTextField.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
fromDateTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fromDateTextFieldActionPerformed(evt);
}
});
toDateTextField.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(125, 125, 125)
.addComponent(fromDateLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(projectNameTextField)
.addComponent(fromDateTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE))
.addGap(145, 145, 145)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(outcomeLabel)
.addComponent(peopleLabel)
.addComponent(scopeLabel)
.addComponent(toDateLabel))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(scopeComboBox, 0, 106, Short.MAX_VALUE)
.addComponent(outcomeTextField)
.addComponent(peopleComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(toDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(146, 146, 146))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(128, 128, 128)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(projectNameLabel)
.addComponent(categoryLabel)
.addComponent(statusLabel))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(categoryComboBox, 0, 106, Short.MAX_VALUE)
.addComponent(statusComboBox, 0, 106, Short.MAX_VALUE))
.addContainerGap(471, Short.MAX_VALUE)))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(scopeLabel)
.addComponent(scopeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(projectNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(peopleLabel)
.addComponent(peopleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(outcomeLabel)
.addComponent(outcomeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fromDateLabel)
.addComponent(toDateLabel)
.addComponent(fromDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(toDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(35, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(projectNameLabel)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(categoryLabel)
.addComponent(categoryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statusLabel)
.addComponent(statusComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(81, Short.MAX_VALUE)))
);
searchButton.setFont(new java.awt.Font("Candara", 0, 14)); // NOI18N
searchButton.setText("Search");
searchButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchButtonActionPerformed(evt);
}
});
cancelButton.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
cancelButton.setText("Cancel");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(44, 44, 44)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(searchButton)
.addGap(18, 18, 18)
.addComponent(cancelButton))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(44, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(searchButton)
.addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(15, Short.MAX_VALUE))
);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/scu_footer.PNG"))); // NOI18N
jLabel3.setText("jLabel3");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
.addComponent(jLabel3))
);
getContentPane().add(jPanel2);
pack();
}// </editor-fold>
|
8d586758-e8a1-428c-8865-11e9b4371849
| 2
|
@Override
public String getLabel()
{
if (Java8Util.PARAMETER_NAME == null)
{
throw new IllegalStateException("Missing Label");
}
try
{
return Java8Util.PARAMETER_NAME.invoke(javaParameter).toString();
}
catch (IllegalAccessException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
|
355b61f8-4408-4897-ab62-c4d3818bd44f
| 8
|
private static String addScriptDirectives(Element scriptElement) throws IOException, DocumentTemplateException {
String scriptReplacement = "";
List scriptParts = parseScriptParts(scriptElement.getValue());
for (int index = 0; index < scriptParts.size(); index++) {
ScriptPart scriptPart = (ScriptPart) scriptParts.get(index);
if (scriptPart.getLocation() == null) {
scriptReplacement = scriptPart.getText();
} else {
Element enclosingElement = findEnclosingElement(scriptElement, scriptPart.getLocation());
if (scriptPart.isTagAttribute()) {
String[] nameValue = scriptPart.getText().split("=", 2);
if (nameValue.length != 2) {
throw new DocumentTemplateException("script error: # attribute name=value not found");
}
String attributeNamespace = enclosingElement.getNamespaceURI();
if (nameValue[0].contains(":")) {
String prefix = nameValue[0].split(":")[0];
if (!prefix.equals(enclosingElement.getNamespacePrefix())) {
attributeNamespace = XPATH_CONTEXT.lookup(prefix);
if (attributeNamespace==null) {
throw new DocumentTemplateException("unsupported attribute namespace: " + prefix);
}
}
}
enclosingElement.addAttribute(new Attribute(nameValue[0], attributeNamespace, nameValue[1]));
} else {
ParentNode parent = enclosingElement.getParent();
int parentIndex = parent.indexOf(enclosingElement);
if (scriptPart.afterEndTag()) {
parentIndex++;
}
parent.insertChild(newNode(scriptPart.getText()), parentIndex);
}
}
}
return scriptReplacement;
}
|
77b319a8-73f3-4d7a-9c17-84f0b35d0f05
| 6
|
public void initFromXML( Element node, String projectDir )
{
NodeList nList = node.getElementsByTagName("settings") ;
Element elem = null ;
// a settings entry was found
if (nList != null)
{
if (nList.getLength() > 0)
{
elem = (Element) nList.item(0) ;
setProjectName( elem.getAttribute("name"));
// other settings
settings.initFromXML(elem);
}
}
nList = node.getElementsByTagName("files") ;
// project files
if (nList != null)
{
if (nList.getLength() > 0)
{
elem = (Element) nList.item(0) ;
String wd = elem.getAttribute("workdirectory") ;
setWorkingDirectory( wd );
// import all file settings
getProjectData().getAvailableLangs().initFromXML(elem, wd, projectDir);
}
}
// scanner
nList = node.getElementsByTagName("scanner") ;
// read only the first element
if (nList != null)
{
if (nList.getLength() > 0)
{
elem = (Element) nList.item(0) ;
// import the settings
scannerData.initFromXML(elem);
}
}
}
|
47911940-e280-457d-a102-10d257c0f289
| 8
|
public static void displayJob(String selected) {
Position position = Position.fromString(selected);
Map<Evaluation, Set<Dwarf>> eval = new EnumMap<Evaluation, Set<Dwarf>>(Evaluation.class);
for (Dwarf dwarf : dwarvesList) {
Evaluation evaluation = position.evaluate(dwarf);
if (form.showOnlyPositive.isSelected() && evaluation.isPositive()) {
continue;
}
if (!eval.containsKey(evaluation)) {
eval.put(evaluation, new TreeSet<Dwarf>());
}
eval.get(evaluation).add(dwarf);
}
HTMLDocument document = (HTMLDocument) form.jobInfo.getDocument();
try {
javax.swing.text.Element body = newBodyElement(document);
StringBuilder sb = new StringBuilder();
sb.append("<h1>").append(position).append("</h1>");
for (Map.Entry<Evaluation, Set<Dwarf>> e : eval.entrySet()) {
sb.append("<h2>").append(e.getKey()).append("</h2><ul>");
for (Dwarf dwarf : e.getValue()) {
sb.append("<li>").append(dwarf).append("</li>");
}
sb.append("</ul>");
}
document.insertBeforeEnd(body, sb.toString());
} catch (BadLocationException e) {
reportError(e);
} catch (IOException e) {
reportError(e);
}
}
|
2cc51531-f616-43c5-88bf-318985ddbdc7
| 3
|
public boolean validateAndStartScriptExecutable(ScriptExecutable pScriptExecutable, int pStatementSequence) {
try {
if(pScriptExecutable instanceof ScriptSQL){
ScriptSQL lScriptSQL = (ScriptSQL) pScriptExecutable;
//Check if we can run this exectuable
boolean lRunAllowed = validateScriptExecutable(lScriptSQL);
if(lRunAllowed) {
//Do the insert
insertPatchRunStatement(lScriptSQL, pStatementSequence);
}
return lRunAllowed;
}
else {
//Allow all other types of script executable
return true;
}
}
catch (SQLException e) {
throw new ExFatalError("Failed to validate script executable", e);
}
}
|
9ab65648-1949-40a4-83eb-15cf81677aea
| 0
|
public State getState() {
return this.state;
}
|
6ec79bdc-9cfa-4cb1-b1ed-14bc1676c408
| 7
|
public void setOptions(String[] options) throws Exception {
String classifierString = Utils.getOption('W', options);
if (classifierString.length() == 0)
classifierString = weka.classifiers.rules.ZeroR.class.getName();
String[] classifierSpec = Utils.splitOptions(classifierString);
if (classifierSpec.length == 0) {
throw new Exception("Invalid classifier specification string");
}
String classifierName = classifierSpec[0];
classifierSpec[0] = "";
setClassifier(AbstractClassifier.forName(classifierName, classifierSpec));
String cString = Utils.getOption('C', options);
if (cString.length() != 0) {
setClassIndex((new Double(cString)).intValue());
} else {
setClassIndex(-1);
}
String fString = Utils.getOption('F', options);
if (fString.length() != 0) {
setNumFolds((new Double(fString)).intValue());
} else {
setNumFolds(0);
}
String tString = Utils.getOption('T', options);
if (tString.length() != 0) {
setThreshold((new Double(tString)).doubleValue());
} else {
setThreshold(0.1);
}
String iString = Utils.getOption('I', options);
if (iString.length() != 0) {
setMaxIterations((new Double(iString)).intValue());
} else {
setMaxIterations(0);
}
if (Utils.getFlag('V', options)) {
setInvert(true);
} else {
setInvert(false);
}
Utils.checkForRemainingOptions(options);
}
|
b7d45efb-fc2c-4c20-bfe9-40a9f2640a99
| 2
|
public void copy(int[] src, int[] dst) {
for (int i = 0; i < dst.length; i++) {
if (src.length > i) {
dst[i] = src[i];
} else {
dst[i] = 0;
}
}
}
|
b7170762-b4f7-42ec-a696-f517d0b67afd
| 5
|
public static boolean checkInBounds(Object array, int... coords) {
for (int i = 0; i < coords.length; ++i) {
if (i > 0)
array = Array.get(array, coords[i - 1]);
if (!array.getClass().isArray())
return false;
if (coords[i] < 0 || coords[i] >= Array.getLength(array))
return false;
}
return true;
}
|
3614bd2f-cd05-492d-9e92-93a87420a897
| 3
|
private Tree argumentListPro(){
Tree argumentList = null;
ArgumentListExpression argumentLists = null;
if((argumentList = expressionPro()) != null){
if(accept(Symbol.Id.PUNCTUATORS,",")!=null){
if((argumentLists = (ArgumentListExpression) argumentListPro()) != null){
return new ArgumentListExpression(argumentList, argumentLists);
}
return null;
}
return new ArgumentListExpression(argumentList);
}
return null;
}
|
7bb12b3a-8310-4319-be0a-aac7a0368daa
| 9
|
@SuppressWarnings("unchecked")
private void gatherAndLoad(ExecutionPlan plan, Collection<Class<?>> entities) {
List<Class<?>> sortedEntities = new ArrayList<Class<?>>(entities);
Collections.sort(List.class.cast(sortedEntities), Schema.CLASS_COMPARATOR);
for (Class<?> c : sortedEntities) {
plan.addOperation(new GatherForeignKeysTo(c));
}
if (sortedEntities.size()>1) {
ParallelOperation parallelOperation = new ParallelOperation();
for (Class<?> c : sortedEntities) {
parallelOperation.getOperations().add(new LoadEntities(c));
}
plan.addOperation(parallelOperation);
} else if (sortedEntities.size()==1) {
plan.addOperation(new LoadEntities(sortedEntities.get(0)));
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.