method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
9b6531ab-6adb-4293-8e65-cba3f9658178 | 3 | @RequestMapping(value="/image/upload", method=RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void handleFileUpload(@RequestParam("hashTagText") String hashTagText,
@RequestParam("file") MultipartFile file,
@RequestParam("timeStamp") String timeOfCapture,
@RequestParam("fbToken") String fbToken,
@RequestParam("location") String formattedLocation){
String fileName = StringUtils.EMPTY;
if (!file.isEmpty()) {
try {
fileName = imageStore.writeFile(file.getBytes());
} catch (ImageToOldException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
imageStore.storeImage(fileName,hashTagText,timeOfCapture,fbToken,formattedLocation);
}
} |
2f9be6c9-612a-4012-baab-c8829101dda1 | 7 | public static void setSoundMode(SoundMode mode)
{
if(AudioHandler.soundSystem == null || AudioHandler.isShutDown())
return;
AudioSwitcher.soundMode = mode;
if(currentSound != null)
{
AudioHandler.stop(currentSound);
currentSound = null;
}
switch(soundMode)
{
case TITLE:
currentSound = AudioHandler.playSound(title, true, true);
break;
case WIN:
currentSound = AudioHandler.playSound(end, true, true);
break;
case INGAME:
setRandomBGMusic();
break;
default:
break;
}
if(currentSound != null) AudioHandler.setVolume(currentSound, musicVol);
} |
9f8bce50-6d9a-4987-b53b-f1be542c1422 | 9 | private final void method648(boolean bool, int i) {
if ((6 * anInt5616 ^ 0xffffffff) >= (aGLToolkit5692.aFloatBuffer6661.buffer.length ^ 0xffffffff)) {
aGLToolkit5692.aFloatBuffer6661.offset = 0;
} else {
aGLToolkit5692.aFloatBuffer6661 = new FloatBuffer((anInt5616 - -100) * 6);
}
anInt5632++;
FloatBuffer floatbuffer = aGLToolkit5692.aFloatBuffer6661;
if (!aGLToolkit5692.aBoolean6736) {
for (int i_169_ = 0; i_169_ < anInt5616; i_169_++) {
floatbuffer.method2191(-41, aShortArray5622[i_169_]);
floatbuffer.method2191(-68, aShortArray5683[i_169_]);
floatbuffer.method2191(i + -5181, aShortArray5706[i_169_]);
}
} else {
for (int i_170_ = 0; (anInt5616 ^ 0xffffffff) < (i_170_ ^ 0xffffffff); i_170_++) {
floatbuffer.writeShort(aShortArray5622[i_170_]);
floatbuffer.writeShort(aShortArray5683[i_170_]);
floatbuffer.writeShort(aShortArray5706[i_170_]);
}
}
if (i != 5123) {
anInterface9_5696 = null;
}
if ((floatbuffer.offset ^ 0xffffffff) != -1) {
if (!bool) {
aClass107_5675.anInterface1_1365 = aGLToolkit5692.method1453(26099, false, floatbuffer.offset, 5123, floatbuffer.buffer);
} else {
if (anInterface1_5643 != null) {
anInterface1_5643.method4(5123, floatbuffer.offset, floatbuffer.buffer, 2712);
} else {
anInterface1_5643 = aGLToolkit5692.method1453(26099, true, floatbuffer.offset, 5123, floatbuffer.buffer);
}
aClass107_5675.anInterface1_1365 = anInterface1_5643;
}
if (!bool) {
aBoolean5611 = true;
}
}
} |
a181e681-de05-4f98-aad8-485bfa905803 | 1 | public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
try {
sunJSSEX509TrustManager.checkClientTrusted(chain, authType);
} catch (CertificateException excep) {
// do any special handling here, or rethrow exception.
excep.printStackTrace();
}
} |
bb306ed1-44ce-45db-8130-a4ce8afa034a | 0 | public static String css(){
return "<style>\n"+
"#hor-minimalist-b\n" +
" {\n" +
" font-family: \"Lucida Sans Unicode\", \"Lucida Grande\", Sans-Serif;\n" +
" font-size: 12px;\n" +
" background: #fff;\n" +
" margin: 45px;\n" +
" width: 480px;\n" +
" border-collapse: collapse;\n" +
" text-align: left;\n" +
" }\n" +
" #hor-minimalist-b th\n" +
" {\n" +
" font-size: 14px;\n" +
" font-weight: normal;\n" +
" color: #039;\n" +
" padding: 6px 22px;\n" +
" border-bottom: 2px solid #6678b1;\n" +
" }\n" +
" #hor-minimalist-b td\n" +
" {\n" +
" border-bottom: 1px solid #ccc;\n" +
" color: #669;\n" +
" padding: 6px 22px;\n" +
" min-width: 70px;\n" +
" white-space: nowrap;\n" +
" }\n" +
" #hor-minimalist-b tbody tr:hover td\n" +
" {\n" +
" color: #009;\n" +
" }\n" +
" #hor-minimalist-b textarea\n" +
" {\n" +
" min-width: 100%;\n" +
" min-height: 200px;\n" +
" resize:none;\n" +
" border:none;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+1) .tablesorter-filter {\n" +
" width: 80px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+2) .tablesorter-filter {\n" +
" width: 200px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+3) .tablesorter-filter {\n" +
" width: 80px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+4) .tablesorter-filter {\n" +
" width: 80px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+5) .tablesorter-filter {\n" +
" width: 40px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+6) .tablesorter-filter {\n" +
" width: 120px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+7) .tablesorter-filter {\n" +
" width: 180px;\n" +
" }\n" +
" .tablesorter .tablesorter-filter-row td:nth-child(8n+8) .tablesorter-filter {\n" +
" width: 50px;\n" +
" }\n"+
"</style>\n";
} |
fe14e457-125c-4666-9572-753dc1f4b6e5 | 3 | private void createActivity(JobMetaData meta, Allocation alloc) {
ArrayList<IJob> list = new ArrayList<IJob>();
HashMap<Integer, HashMap<Integer, String>> allocs = alloc.getAllocations();
for (Integer vmId : allocs.keySet()) {
SlaveVM vm = this.pool.getVMById(vmId);
SocketSender sender = new SocketSender(true, vm.getIp());
ArrayList<Integer> filelist = new ArrayList<Integer>();
HashMap<Integer, String> files = allocs.get(vm.getId());
filelist.addAll(files.keySet());
DownloadJob d = new DownloadJob(filelist, meta.getSender());
CombineJob c = new CombineJob(filelist);
CompressJob comp = new CompressJob();
ForwardJob f = new ForwardJob(true);
c.setIP(meta.getSender());
comp.setIP(meta.getSender());
f.setIP(meta.getSender());
f.setRemoteFileName(vm.getIp().getHostAddress());
list.add(d);
list.add(c);
list.add(comp);
list.add(f);
Activity activity = new Activity(list);
activity.setClient(meta.getSender());
activity.setVM(vm);
try {
System.out.println("Sending Activity to "
+ vm.getId() + "@" + vm.getIp().getHostAddress());
sender.send(activity, true);
} catch (IOException e) {
e.printStackTrace();
} catch (JSchException e) {
e.printStackTrace();
}
}
monitor.moveJobToRunning(meta.getId());
} |
076dc97a-e658-4f1b-8412-42540868bfaa | 7 | private void criaEventoTextField() {
textFieldConta.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (textFieldConta.getText() != null) {
Integer agenciaSelecionada = new Integer(textFieldConta
.getText());
agenciaSelecionada--;
// Se o ususario digitar 0(zero)
if (agenciaSelecionada < 0) {
agenciaSelecionada = 0;
}
if (tabelaContas.getValueAt(agenciaSelecionada, 0) != null) {
for (int i = 0; i < NUM_DE_DADOS; i++) {
switch (i) {
case 0:
labelCodigoValue.setText(tabelaContas
.getValueAt(agenciaSelecionada, i)
.toString());
break;
case 1:
labelTipoValue.setText(tabelaContas
.getValueAt(agenciaSelecionada, i)
.toString());
break;
case 2:
labelNomeClienteValue.setText(tabelaContas
.getValueAt(agenciaSelecionada, i)
.toString());
break;
}
}
}
}
}
});
} |
017d5da6-6a25-4ced-a4fa-da3d41a24df4 | 1 | @Override
public V get(Object key) {
if (key instanceof String) {
return super.get(((String) key).toLowerCase());
}
else {
return null;
}
} |
46f8bef0-b7e6-4bee-9273-9d9b34c406ee | 7 | private List<Method> findMethodsByMappedColumnName(Object targetObject, String mappedColumnName) {
List<Method> methods = new ArrayList<>();
for (Method method : targetObject.getClass().getDeclaredMethods()) {
if (method.isAnnotationPresent(XlsxColumnName.class)) {
XlsxColumnName annotation = method.getAnnotation(XlsxColumnName.class);
String value = annotation.value();
if (mappedColumnName.equals(value)) {
methods.add(method);
}
}
}
//look for annotation on its superclass if it exists
if (targetObject.getClass().getSuperclass() != null) {
for (Method method : targetObject.getClass().getSuperclass().getDeclaredMethods()) {
if (method.isAnnotationPresent(XlsxColumnName.class)) {
XlsxColumnName annotation = method.getAnnotation(XlsxColumnName.class);
String value = annotation.value();
if (mappedColumnName.equals(value)) {
methods.add(method);
}
}
}
}
return methods;
} |
cab14c3a-f462-4c47-bb3d-901dbc89f8f4 | 9 | private static long getSmallestMultiple(int number)
{
if (number < 0)
{
return 0;
}
if (number <= 2)
{
return number;
}
boolean[] isPrimes = new boolean[number];
for (int i = 0; i < number; ++i)
{
isPrimes[i] = true;
}
for (int i = 2; i < number; ++i)
{
if (isPrimes[i])
{
for (int j = i * i; j < number; j += i)
{
isPrimes[j] = false;
}
}
}
long result = 1;
for (int i = 2; i < number; ++i)
{
if (isPrimes[i])
{
int max = (int) (Math.log(number) / Math.log(i));
for (int j = 0; j < max; ++j)
{
result *= i;
}
}
}
return result;
} |
45d7227a-e255-4f6e-a15e-020885850106 | 2 | public ArrayList<BusinessObject> getSelectedObjects() {
int[] rows = getSelectedRows();
ArrayList<BusinessObject> businessObjectArrayList = new ArrayList<>();
for(int row : rows) {
BusinessObject businessObject = (BusinessObject) model.getValueAt(row, 0);
businessObjectArrayList.add(businessObject);
}
// check on which element is clicked
BusinessObject selectedObject = getSelectedObject();
if(businessObjectArrayList.contains(selectedObject))
// return all selected elements if mouse was clicked on one of them
return businessObjectArrayList;
else {
// otherwise return only the clicked element
ArrayList<BusinessObject> list = new ArrayList<>();
list.add(selectedObject);
return list;
}
} |
d79b0482-eba4-4044-a66a-f7cc5e1639eb | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TDatdprPK other = (TDatdprPK) obj;
if (!Objects.equals(this.transNo, other.transNo)) {
return false;
}
if (!Objects.equals(this.itemCode, other.itemCode)) {
return false;
}
return true;
} |
a60d6341-6c0d-45c6-81a7-f8978f31bbce | 5 | public boolean containsNearbyDuplicate(int[] nums, int k) {
if(k<1){
return false;
}
if(nums==null ){
return false;
}
boolean res =false;
HashMap s = new HashMap<>();
for(int i=0;i<nums.length;i++){
Object idx = s.get(nums[i]);
if(idx==null){
s.put(nums[i],i);
}else{
int iidx = (int)idx;
if(Math.abs(iidx-i)<=k){
res = true;
break;
}else{
s.put(nums[i],i);
}
}
}
return res;
} |
bbb6ecd1-1536-4096-9d23-3efe6f26176c | 6 | public static void make() {
if (!Bank.isOpen()) {
if (Inventory.getCount(Variables.gemToCut) > 0) {
if (gemInterface()) {
Crafting.clickStart();
final Timer gemTimer = new Timer(20000);
while (gemTimer.isRunning()
&& Inventory.getCount(Variables.gemToCut) != 0) {
Task.sleep(50);
}
} else {
WidgetChild gem = Inventory.getItem(Variables.gemToCut)
.getWidgetChild();
if (gem != null) {
gem.interact("Craft");
Task.sleep(600, 700);
}
}
}
} else {
Bank.close();
}
} |
f5e8d2c3-3af4-4133-8e3a-b7d8eb016298 | 8 | private void actualizarJuga(int j1,int j2){
if (j1==Jugador.HUMANO)
jLabelJug1.setText("Humano");
else{
if (j1 == OthelloHexagonal.FACIL)
jLabelJug1.setText("Maquina-Principiante");
if (j1 == OthelloHexagonal.MEDIO)
jLabelJug1.setText("Maquina-Normal)");
if (j1 == OthelloHexagonal.EXPERTO)
jLabelJug1.setText("Maquina-Experto)");
}
if (j2==Jugador.HUMANO)
jLabelJug2.setText("Humano");
else{
if (j2 == OthelloHexagonal.FACIL)
jLabelJug2.setText("Maquina-Principiante");
if (j2 == OthelloHexagonal.MEDIO)
jLabelJug2.setText("Maquina-Normal");
if (j2 == OthelloHexagonal.EXPERTO)
jLabelJug2.setText("Maquina-Experto");
}
} |
959a24c2-c214-44da-a556-21182cc7ffcb | 6 | @Override
public void add(E elem) {
if (root == null) {
root = new Node(elem, null, null, null);
} else {
for (Node start = root; start != null; ) {
if (start.item.compareTo(elem) > 0) {
if (start.left != null) {
start = start.left;
} else {
start.left = new Node(elem, start, null, null);
break;
}
} else if (start.item.compareTo(elem) < 0) {
if (start.right != null) {
start = start.right;
} else {
start.right = new Node(elem, start, null, null);
}
} else {
break;
}
}
}
} |
d155c43b-85b7-4fa3-b4c3-dd6b1d89e273 | 0 | public Dimension getMinimumSize(JComponent c) {
return getPreferredSize(c);
} |
93b94c3f-0b64-499a-85a9-58d8aa3e31aa | 7 | public BrowserLauncher getBrowserLauncher(String browser, String sessionId, RemoteControlConfiguration configuration, BrowserConfigurationOptions browserOptions) {
if (browser == null) {
throw new IllegalArgumentException("browser may not be null");
}
String executablePath = null;
if (browserOptions.hasOptions()) {
executablePath = browserOptions.getExecutablePath();
} else {
configuration.copySettingsIntoBrowserOptions(browserOptions);
}
for (String key : supportedBrowsers.keySet()) {
final BrowserStringParser.Result result;
result = new BrowserStringParser().parseBrowserStartCommand(key, browser);
if (result.match()) {
if (executablePath == null) {
executablePath = result.customLauncher();
browserOptions.setExecutablePath(executablePath);
}
LOGGER.debug("Requested browser string '" + browser + "' matches *" + key + " ");
return createBrowserLauncher(supportedBrowsers.get(key), executablePath, sessionId, configuration, browserOptions);
}
}
LOGGER.debug("Requested browser string '" + browser + "' does not match any known browser, treating it as a custom browser...");
Matcher CustomMatcher = CUSTOM_PATTERN.matcher(browser);
if (CustomMatcher.find()) {
String browserStartCommand = CustomMatcher.group(1);
if (browserStartCommand == null) {
throw new RuntimeException("You must specify the path to an executable when using *custom!\n\n");
}
browserStartCommand = browserStartCommand.substring(1);
return new CustomBrowserLauncher(browserStartCommand, sessionId, configuration, browserOptions);
}
throw browserNotSupported(browser);
} |
ef689615-d614-41a3-9c8b-d5b3a6e023ab | 4 | @Override
public boolean activate() {
return (!validate(Constants.WAITFOR_WIDGET)
&& !Inventory.contains(Settings.bar.getFirstId())
&& Inventory.contains(Settings.bar.getBarId())
&& !Bank.isOpen()
&& !Widgets.get(13, 0).isOnScreen());
} |
63f5ae5f-6714-451e-8085-c1e932f30fd9 | 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(Pedido.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Pedido.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Pedido.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Pedido.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 Pedido().setVisible(true);
}
});
} |
e9f72d73-3284-4045-a0a8-3930f896c449 | 8 | void createOffscreenImage(boolean discard_image) {
d=getSize();
if(discard_image) {
img=null;
imgsize=null;
}
if(img == null || imgsize == null || imgsize.width != d.width || imgsize.height != d.height) {
img=createImage(d.width, d.height);
if(img != null) {
gr=img.getGraphics();
if(gr != null && state != null) {
drawState();
}
}
imgsize=d;
}
repaint();
} |
3ee37284-60fc-4c8a-834f-731a0c84dcaf | 8 | public static void deleteFiles(File dir, FilenameFilter filter) {
// validations
if(dir == null) {
throw new DataUtilException("The delete directory parameter can not be a null value");
} else if(!dir.exists() || !dir.isDirectory()) {
throw new DataUtilException("The delete directory does not exist: " + dir.getAbsolutePath());
}
// delete files
File [] files;
if(filter == null) {
files = dir.listFiles();
} else {
files = dir.listFiles(filter);
}
if (files != null) {
for(File file : files) {
if(file.isFile()) {
if(!file.delete()) {
throw new DataUtilException("Failed to delete file: " + file.getAbsolutePath());
}
}
}
}
} |
db2be0a5-538c-4a17-9291-822ef6937895 | 6 | public static Type max(Type p1, Type p2) {
if (!numeric(p1) || !numeric(p2)) {
return null;
} else if (p1 == Type.Fixed || p2 == Type.Fixed) {
return Type.Fixed;
} else if (p1 == Type.Integer || p2 == Type.Integer) {
return Type.Integer;
} else {
return Type.Char;
}
} |
d627a0cc-f810-40b1-9c9b-50821156a358 | 0 | @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Data")
public JAXBElement<X509DataType> createX509Data(X509DataType value) {
return new JAXBElement<X509DataType>(_X509Data_QNAME, X509DataType.class, null, value);
} |
71f94bfe-cd08-461c-8f00-0c332197247f | 7 | @Override
public String toString() {
if (seqChange == null || marker == null) return null;
String pos = pos();
if (pos == null) return null;
String protChange = "";
switch (seqChange.getChangeType()) {
case SNP:
case MNP:
return snpOrMnp();
case INS:
protChange = ins();
break;
case DEL:
protChange = del();
break;
default:
break;
}
return "p." + pos + protChange;
} |
35a3b7d7-363a-4f26-b4d2-fc1773fb2deb | 2 | private Table getTableAyantId(int tableId) {
for (Table table : tables) {
if (table.getTableId() == tableId)
return table;
}
return null;
} |
72c65c6e-7127-485d-a265-45b770756057 | 4 | public void recalcHeightMap()
{
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++)
{
int y = MAP_HEIGHT - 1;
while (Blocks.getBlockOpacity(getBlock(x, y, z)) == 0 && y > 0)
y--;
y++;
setHeight(x, z, y);
}
} |
07d49511-32dd-4b7e-8415-8e74d08a92fa | 1 | public void make(Piece[][] board) {
Piece1 = board[x1][y1];
//System.out.println("Make: " + (Piece1.x == x1 && Piece1.y == y1));
if (board[x2][y2] != null) {
Piece2 = board[x2][y2];
}
board[x2][y2] = board[x1][y1];
board[x1][y1] = null;
//System.out.println(x1 + "," + y1 + " to " + x2 + "," + y2);
} |
30bf8e55-d6f7-45f1-8f07-49b82a420544 | 6 | public double calculateDistance(DataPoint other) {
if (this.equals(other))
return 1;
HashMap<Integer, Double> minHash, maxHash;
HashMap<Integer, Double> current = getVector(), otherHashMap = other
.getVector();
if (current.size() < otherHashMap.size()) {
minHash = current;
maxHash = otherHashMap;
} else {
minHash = otherHashMap;
maxHash = current;
}
double d1_d2 = 0;
for (int key : minHash.keySet()) {
if (maxHash.containsKey(key))
d1_d2 += maxHash.get(key) * minHash.get(key);
}
if (this.value == 0)
calculateValue();
if (other.value == 0)
other.calculateValue();
double denum = this.value * other.value;
return 1 - (d1_d2 / denum);
// HashMap<Integer, Double> dim1 = getVector();
// HashMap<Integer, Double> dim2 = other.getVector();
// double ECDis = 0.0;
// int dimSize = dim1.size();
// for (int k = 0; k < dimSize; k++) {
// ECDis += (dim1.get(k) - dim2.get(k))
// * ((dim1.get(k) - dim2.get(k)));
// }
// ECDis = Math.sqrt(ECDis);
// return ECDis;
} |
ffeb8742-32d4-4d7d-8ec8-a4191f8dc92e | 6 | public String getResultString() {
// String resultString;
// String filter = this.getFileFilter().getDescription();
String path = null;
// boolean isDirMode = (this.getFileSelectionMode() == DIRECTORIES_ONLY);
boolean isMulti = this.isMultiSelectionEnabled();
if (isMulti) {
File [] files = this.getSelectedFiles();
if (files != null && files.length > 0) {
path = "";
for (File file : files) {
path = path /*+ "<br>"*/ + file.getPath();
}
}
} else {
File file = this.getSelectedFile();
if (file != null) {
path = /* "<br>" +*/ file.getPath();
}
}
if (path != null) {
/* path = path.replace(" ", " ");
filter = filter.replace(" ", " ");
resultString =
"<html>You chose " + (isMulti ? "these" : "this") + " " +
(isDirMode ? (isMulti ? "directories" : "directory")
: (isMulti ? "files" : "file")) +
": <code>" + path +
"</code><br><br>with filter: <br><code>" + filter;
*/ } else {
path = "Nothing was chosen";
}
return path;
} |
5fcc6e9d-af88-41ec-9a35-535eaa2ffb4a | 8 | protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
for (Map.Entry<?, ?> entry : input.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
if (value instanceof Map) {
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
} else {
section.set(key, value);
}
}
} |
a0a5f0fe-dc6e-4f4d-8e56-489739fd601f | 8 | private static int memoryLocation(int abv) {
switch (abv) {
case ABV_MEMSIZE:
return 0;
case ABV_DEFENSE:
return 1;
case ABV_OFFENSE:
return 2;
case ABV_SIZE:
return 3;
case ABV_ENERGY:
return 4;
case ABV_PASS:
return 5;
case ABV_TAG:
return 6;
case ABV_POSTURE:
return 7;
default:
throw new IllegalArgumentException();
}
} |
9507a03c-3cad-4416-a6f3-83df4951a55a | 8 | private boolean checkNeedE( int res1, int res1AANum, int res1RotNum, int res2, int res2AANum, int res2RotNum ){
//Returns if we need to compute the given shell or pairwise energy
if(!compCETM)//Need all energies for normal energy matrices
return true;
if (eliminatedRotAtRes == null){//no pruning, so try to compute everything
//(we'll do an extra steric check in pairwiseRotamerEnergySidechainHelper in this case)s
return true;
}
//Now check that the RC(s) and, if applicable, pair are not pruned
//If compCETM then we should have eliminatedRotAtRes and splitFlags available
if( eliminatedRotAtRes.get(res1,res1AANum,res1RotNum) )
return false;
if(res2!=-1){//Pairwise energy
if( eliminatedRotAtRes.get(res2,res2AANum,res2RotNum) )
return false;
if(compCETM && splitFlags!=null) {
//if we've done pairs pruning and are considering CET computation
if( splitFlags[res1][res1AANum][res1RotNum][res2][res2AANum][res2RotNum] )
return false;
}
}
return true;
} |
af154d3e-04da-42b5-af93-40199fbe705e | 1 | @Test
public void testNoAgregarEntidad() {
Sistema sistema = Sistema.getInstance();
String nombre = "Alicates";
int tamAnterior = sistema.getEntidades().size();
try {
CONTROL.agregarEntidad(new Long(3000), nombre, new Double(nombre));
} catch (NumberFormatException numberFormatException) {
System.out.println("Ha ocurrido un numberFormatException");
} finally {
int tamSiguiente = sistema.getEntidades().size();
assertEquals(tamAnterior, tamSiguiente);
}
} |
f006ad98-8596-4440-b4a3-e3f5ba3087c5 | 0 | public String getTeams() {
return "For todays game we hate the " + this.team1 + " versus the " + this.team2;
} |
e6e7ce26-ed5d-44cf-aa85-aa7a4d6159f7 | 1 | public static String addLeadingZero(String s) {
// If it's length is one, then add a zero
if (s.length() == 1)
return "0" + s;
// Otherwise just return it as it is
return s;
} |
1fec87fc-ebce-4727-a815-88158be2b36f | 5 | @Override
public V compute(final A arg) throws InterruptedException {
while (true) { // 重试机制:无限次!
Future<V> f = cache.get(arg);
if (f == null) { // 首先检查某个计算是否已经开始
Callable<V> eval = new Callable<V>() {
@Override
public V call() throws Exception {
return c.compute(arg);
}
};
FutureTask<V> ft = new FutureTask<>(eval);
f = cache.putIfAbsent(arg, ft); // 先检查计算是否已经开始,避免漏洞!
if (f == null) {
f = ft;
ft.run(); // 在这里将调用 c.compute
}
}
try {
return f.get(); // 等待计算结果
} catch (CancellationException ce) {
cache.remove(arg, f);
// 任务被取消执行后,会重试
} catch (ExecutionException e) {
cache.remove(arg, f);
e.printStackTrace();
throw new InterruptedException(e.getMessage());
}
}
} |
1db9432a-d51e-4ae8-898b-53aa1e50dec3 | 9 | private String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
FileInputStream in = new FileInputStream(filename);
Exception exception = null;
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
Exception innerExc = null;
try {
String line;
while ((line = reader.readLine()) != null)
source.append(line).append('\n');
} catch (Exception exc) {
exception = exc;
} finally {
try {
reader.close();
} catch (Exception exc) {
if (innerExc == null)
innerExc = exc;
else
exc.printStackTrace();
}
}
if (innerExc != null)
throw innerExc;
} catch (Exception exc) {
exception = exc;
} finally {
try {
in.close();
} catch (Exception exc) {
if (exception == null)
exception = exc;
else
exc.printStackTrace();
}
if (exception != null)
throw exception;
}
return source.toString();
} |
e40c3295-8a3c-4f39-a69a-cc122aeabbb0 | 9 | static void printSpiralMatrix(int[][] matrix, int rows, int columns){
int columnIndex1 = 0;
int columnIndex2 = columns-1;
int rowIndex1 = 0;
int rowIndex2 = rows-1;
int indexVisited = 1;
int i;
while(indexVisited <= columns*rows){
for(i = columnIndex1; i <= columnIndex2; i++){
if(indexVisited == 1){
System.out.print(matrix[rowIndex1][i]);
}else{
System.out.print("," + matrix[rowIndex1][i]);
}
indexVisited++;
}
if(!(indexVisited <= columns*rows)) break;
for(i = rowIndex1 + 1; i <= rowIndex2;i++){
System.out.print("," + matrix[i][columnIndex2]);
indexVisited++;
}
if(!(indexVisited <= columns*rows)) break;
for(i = columnIndex2 - 1; i >= columnIndex1; i--){
System.out.print("," + matrix[rowIndex2][i]);
indexVisited++;
}
if(!(indexVisited <= columns*rows)) break;
for(i = rowIndex2 - 1; i >= rowIndex1 + 1; i--){
System.out.print("," + matrix[i][columnIndex1]);
indexVisited++;
}
columnIndex1++;
columnIndex2--;
rowIndex1++;
rowIndex2--;
}
} |
b345ddef-5a58-448f-ae33-96e4ca5961a0 | 5 | public void handleRequest() {
Thread pollQueue = new Thread(new Runnable() {
public void run() {
while (true) {
FolderWatcherQueue s = changes.poll();
// System.out.println("The size of the " + changes.size());
if (s != null) {
String eventType = s.getEventType();
if (eventType.equals("ENTRY_CREATE")) {
handleCreateFile(s);
} else if (eventType.equals("ENTRY_DELETE")) {
handleDeleteFile(s);
} else if (eventType.equals("ENTRY_MODIFY")) {
handleModifyFile(s);
} else {
continue;
}
}
}
}
});
pollQueue.start();
} |
abfb198a-aac8-48d0-8c4b-ce0398e2e72d | 7 | * @param improvementType a <code>TileImprovementType</code> value
*/
public void changeWorkImprovementType(Unit unit,
TileImprovementType improvementType) {
if (!requireOurTurn()) return;
if (!unit.checkSetState(UnitState.IMPROVING)
|| improvementType.isNatural()) {
return; // Don't bother (and don't log, this is not exceptional)
}
Player player = freeColClient.getMyPlayer();
Tile tile = unit.getTile();
if (!player.owns(tile)) {
if (!claimTile(player, tile, unit, player.getLandPrice(tile), 0)
|| !player.owns(tile)) return;
}
if (askServer().changeWorkImprovementType(unit, improvementType)) {
;// Redisplay should work
}
nextActiveUnit();
} |
b0b7a7c1-27e2-4684-8dbc-fb0aa65264e1 | 8 | public int Open(String Filename, int NewMode)
{
int retcode = DDC_SUCCESS;
if ( fmode != RFM_UNKNOWN )
{
retcode = Close();
}
if ( retcode == DDC_SUCCESS )
{
switch ( NewMode )
{
case RFM_WRITE:
try
{
file = new RandomAccessFile(Filename,"rw");
try
{
// Write the RIFF header...
// We will have to come back later and patch it!
byte[] br = new byte[8];
br[0] = (byte) ((riff_header.ckID >>> 24) & 0x000000FF);
br[1] = (byte) ((riff_header.ckID >>> 16) & 0x000000FF);
br[2] = (byte) ((riff_header.ckID >>> 8) & 0x000000FF);
br[3] = (byte) (riff_header.ckID & 0x000000FF);
byte br4 = (byte) ((riff_header.ckSize >>> 24)& 0x000000FF);
byte br5 = (byte) ((riff_header.ckSize >>> 16)& 0x000000FF);
byte br6 = (byte) ((riff_header.ckSize >>> 8)& 0x000000FF);
byte br7 = (byte) (riff_header.ckSize & 0x000000FF);
br[4] = br7;
br[5] = br6;
br[6] = br5;
br[7] = br4;
file.write(br,0,8);
fmode = RFM_WRITE;
} catch (IOException ioe)
{
file.close();
fmode = RFM_UNKNOWN;
}
} catch (IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
case RFM_READ:
try
{
file = new RandomAccessFile(Filename,"r");
try
{
// Try to read the RIFF header...
byte[] br = new byte[8];
file.read(br,0,8);
fmode = RFM_READ;
riff_header.ckID = ((br[0]<<24)& 0xFF000000) | ((br[1]<<16)&0x00FF0000) | ((br[2]<<8)&0x0000FF00) | (br[3]&0x000000FF);
riff_header.ckSize = ((br[4]<<24)& 0xFF000000) | ((br[5]<<16)&0x00FF0000) | ((br[6]<<8)&0x0000FF00) | (br[7]&0x000000FF);
} catch (IOException ioe)
{
file.close();
fmode = RFM_UNKNOWN;
}
} catch (IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
default:
retcode = DDC_INVALID_CALL;
}
}
return retcode;
} |
5a9fc135-2d46-4772-a844-63571d439e83 | 7 | public Colgroup(HtmlMidNode parent, HtmlAttributeToken[] attrs){
super(parent, attrs);
for(HtmlAttributeToken attr:attrs){
String v = attr.getAttrValue();
switch(attr.getAttrName()){
case "align":
align = Align.parse(this, v);
break;
case "char":
charr = Char.parse(this, v);
break;
case "charoff":
charoff = Charoff.parse(this, v);
break;
case "span":
span = Span.parse(this, v);
break;
case "valign":
valign = Valign.parse(this, v);
break;
case "width":
width = Width.parse(this, v);
break;
}
}
} |
782f194f-1edd-4b03-bc4d-c71606bc4347 | 0 | protected Transition initTransition(State from, State to)
{
return new MealyTransition(from, to, "", "");
} |
bbed6bb9-7327-4895-b63c-56458a033c3b | 2 | public void skipRemaining() throws IOException {
while (length > 0) {
int skipped = (int) skip(length);
if (skipped == 0)
throw new EOFException();
length -= skipped;
}
} |
e3943675-d574-4e6e-8843-475fea60b518 | 0 | public Analizer() {
} |
9951f089-6c0a-43c9-933b-5ec4207edf29 | 3 | @Override
public String toString() {
String result = "\n\t\t<s id=\"" + id + "\">";
result += "\n\t\t\t<graph root=\"" + rootIDref + "\">";
result += "\n\t\t\t\t<terminals>";
terminals = Helper.sortByKey(terminals);
for (Node terminal : terminals.values()) {
result += terminal;
}
result += "\n\t\t\t\t</terminals>";
result += "\n\t\t\t\t<nonterminals>";
nonterminals = Helper.sortByKey(nonterminals);
for (Node nonTerminal : nonterminals.values()) {
result += nonTerminal;
}
result += "\n\t\t\t\t</nonterminals>";
result += "\n\t\t\t</graph>";
result += "\n\t\t\t<matches>\n\t\t\t</matches>";
result += "\n\t\t\t<sem>";
result += "\n\t\t\t\t<globals>\n\t\t\t\t</globals>";
result += "\n\t\t\t\t<frames>";
for (Frame frame : frames) {
result += frame;
}
result += "\n\t\t\t\t</frames>";
result += "\n\t\t\t\t<usp>";
result += "\n\t\t\t\t\t<uspframes/>";
result += "\n\t\t\t\t\t<uspfes/>";
result += "\n\t\t\t\t</usp>";
result += "\n\t\t\t\t<wordtags>";
result += "\n\t\t\t\t</wordtags>";
result += "\n\t\t\t</sem>";
result += "\n\t\t</s>";
return result;
//return "Sentence [id=" + id + ",\n\t terminals=" + terminals
// + ",\n\t nonterminals=" + nonterminals + ",\n\t frames=" + frames + "]";
} |
1a1f4cf7-5ae2-4d1b-8683-85d95734b71f | 9 | private void createScrollPane(Attributes attrs) {
scrollPane = new ScrollPane(scrollpaneDef);
// loop through all attributes, setting appropriate values
for (int i = 0; i < attrs.getLength(); i++) {
if (attrs.getQName(i).equals("x"))
scrollPane.getStartPoint().setX(
Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("y"))
scrollPane.getStartPoint().setY(
Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("width"))
scrollPane.setWidth(Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("height"))
scrollPane.setHeight(Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("startTime"))
scrollPane.setStartTime(Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("endTime"))
scrollPane.setEndTime(Integer.valueOf(attrs.getValue(i)));
else if (attrs.getQName(i).equals("backgroundcolor"))
scrollPane.setBkCol(new Color(Integer.valueOf(attrs.getValue(i)
.substring(1), 16)));
else if (attrs.getQName(i).equals("backgroundalpha"))
scrollPane.setBkAlpha(Float.valueOf(attrs.getValue(i)));
}
} |
e9015e64-3ce6-4f02-a2e7-2b93c7985748 | 5 | public void ChangeDoor(int ArrayID) {
int objectID = server.objectHandler.ObjectOriID[ArrayID];
int objectX = server.objectHandler.ObjectX[ArrayID];
int objectY = server.objectHandler.ObjectY[ArrayID];
int Face = server.objectHandler.ObjectFace[ArrayID];
int Type = server.objectHandler.ObjectType[ArrayID];
ReplaceObject2(objectX, objectY, -1, -1, 0);
switch (Type) {
case 1:
ReplaceObject2(objectX, (objectY + 1), objectID, Face, 0);
server.objectHandler.ObjectType[ArrayID] = 2;
break;
case 2:
ReplaceObject2(objectX, (objectY - 1), objectID, Face, 0);
server.objectHandler.ObjectType[ArrayID] = 1;
break;
case 3:
ReplaceObject2((objectX + 1), objectY, objectID, Face, -2);
server.objectHandler.ObjectType[ArrayID] = 4;
break;
case 4:
ReplaceObject2((objectX - 1), objectY, objectID, Face, -2);
server.objectHandler.ObjectType[ArrayID] = 3;
break;
case 11707:
ReplaceObject2((objectX - 1), objectY, objectID, Face, -2);
server.objectHandler.ObjectType[ArrayID] = 3;
break;
}
} |
127c75e5-56c6-4cc9-8035-2ae004560cbc | 9 | public boolean canMoveExact( int playerColor) {
if (! legitPlayerColor(playerColor)) {
throw new IllegalArgumentException("Bad color '" + playerColor + "'");
}
if ((myDice.isDoubles( )) && (myDice.getDoubletMovesCountdown( ) < 1)) {
return false;
}
// ?? need total movesCountdown so we can use up PartialMoves !!
int move1, move2;
// Cycle through all the points
for (int point = 1; point <= howManyPoints; point++) {
// Only check points which contain the player's blots
if (getColorOnPoint(point) == playerColor ) {
move1 = endPointMovingFrom(point, myDice.getDie(1 ), playerColor/*, this*/);
// might return BLACK_PAST_BEAR_OFF_LOC
move2 = endPointMovingFrom(point, myDice.getDie(2 ), playerColor/*, this*/);
if ( ((canLandOnExact(move1, playerColor)) && (!myDice.getUsedDie( 1)))
|| ((canLandOnExact(move2, playerColor)) && (!myDice.getUsedDie(2 ))) ) {
return true;
}
// canLandOnExact() only allows bearing off with exact rolls.
// If the player has no other option, moving with a roll greater than needed
// to bear off is legal
}
}
return false;
} // canMoveExact( ) |
9901803d-647e-4824-9ca9-9905c989e686 | 5 | public static ArrayList<Adress> getAll() {
try {
if(conn == null || conn.isClosed()){
conn = DatabaseConnection.getConnection();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ArrayList<Adress> adressList = new ArrayList<Adress>();
try {
Statement stmnt = conn.createStatement();
String sql = "SELECT * FROM Addresses";
ResultSet res = stmnt.executeQuery(sql);
while(res.next()) {
Adress a = new Adress(res.getString("bus"),
res.getString("street"), res.getString("city"), res.getString("number"),
res.getInt("postal_code"),res.getInt("address_id"));
adressList.add(a);
}
}
catch(SQLException e) {
System.out.println(e);
}
return adressList;
} |
89f7ae42-6ead-48d1-bdf4-8dd5f368c705 | 5 | public boolean lautaValmis() {
int nro = 1;
for (int i = 0; i < getKorkeus(); i++) {
for (int j = 0; j < getLeveys(); j++) {
if (i == getKorkeus() - 1 && j == getLeveys() - 1) {
return true;
}
if (getNappula(i, j).getTunniste() != nro) {
return false;
}
nro++;
}
}
return true;
} |
4a6ecd79-b003-47e4-aa51-35ff08f63582 | 9 | @Override
public void setMovement(Board b) {
int x = getLocation().getX();
int y = getLocation().getY();
movement.setSize(0);
movement.trimToSize();
if (y > 6 || b.getCell(new Location(x, y+1)) != null) {
} else {
movement.add(new Location(x, y+1));
}
if (x < 7 && y < 7 && b.getCell(new Location(x+1, y+1)) != null) {
movement.add(new Location(x+1, y+1));
}
if (x > 0 && y < 7 && b.getCell(new Location(x-1, y+1)) != null && b.getCell(new Location(x-1, y+1)).isWhite() != isWhite()) {
movement.add(new Location(x-1, y+1));
} else {
}
/**
if (moves == 0 && y < 6 && b.getCell(new Location(x, y+2)) == null || ((b.getCell(new Location(x, y+2)) != null && b.getCell(new Location(x, y+2)).isWhite() != isWhite()))) {
movement.add(new Location(x, y+2));
} else {
}
*/
moves++;
} |
88c88a1d-576d-4c50-9d13-b1a0f8889cab | 1 | public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
history.addFirst(editor.getPage());
Cursor c = editor.getCursor();
Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
editor.setCursor(waitCursor);
SwingUtilities.invokeLater(new PageLoader(e.getURL(), c));
}
} |
20af3036-b7a9-42c7-af8d-3802019f51dd | 9 | public BmgPanelCustom(BmgFrame fen) {
super();
this.fen = fen;
this.setLayout(new BorderLayout());
JPanel panHaut = new JPanel();
panHaut.setLayout(new GridLayout(3, 2));
// Labels
JLabel label1 = new JLabel("| Nom de l'exercice : ");
JLabel label2 = new JLabel("| Difficulté : ");
JLabel label3 = new JLabel("| Énoncé : ");
label1.setPreferredSize(new Dimension(100, 50));
label2.setPreferredSize(new Dimension(100, 50));
label3.setPreferredSize(new Dimension(100, 50));
final JTextField saisieNom = new JTextField(20);
final JTextField saisieEnonce = new JTextField(20);
// Slide
final JSlider slide = new JSlider();
final JLabel labelInfo = new JLabel("Valeur actuelle : " + 2);
slide.setMaximum(5);
slide.setMinimum(1);
slide.setValue(2);
slide.setPaintTicks(true);
slide.setPaintLabels(true);
slide.setMinorTickSpacing(1);
slide.setMajorTickSpacing(1);
slide.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent event) {
labelInfo.setText("Valeur actuelle : "
+ ((JSlider) event.getSource()).getValue());
}
});
// Ajout des composants
panHaut.add(label1);
panHaut.add(saisieNom);
panHaut.add(label2);
panHaut.add(slide);
panHaut.add(label3);
panHaut.add(saisieEnonce);
this.add(panHaut, BorderLayout.NORTH);
JPanel panCenter = new JPanel();
panCenter.setLayout(new GridLayout(7, 3));
final JTextField[] tabQuestions = new JTextField[8];
final JTextField[] tabSolutions = new JTextField[8];
final JComboBox[] tabTypes = new JComboBox[8];
final String[] types = {"entier", "réel", "caractère", "phrase"};
panCenter.add(new BmgLabel("Question", "#E43B01"));
panCenter.add(new BmgLabel("Type de la réponse", "#E43B01"));
panCenter.add(new BmgLabel("Réponse", "#E43B01"));
for (int i = 1; i < 7; i++) {
tabQuestions[i] = new JTextField(12);
panCenter.add(tabQuestions[i]);
tabTypes[i] = new JComboBox(types);
panCenter.add(tabTypes[i]);
tabSolutions[i] = new JTextField(12);
panCenter.add(tabSolutions[i]);
}
this.add(panCenter, BorderLayout.CENTER);
JPanel panSouth = new JPanel();
panSouth.setLayout(new BoxLayout(panSouth, BoxLayout.PAGE_AXIS));
JButton createEx = new JButton("Créer l'exercice");
//createEx.setPreferredSize(new Dimension(100, 100));
createEx.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
String name = saisieNom.getText();
String wording = saisieEnonce.getText();
int diff = slide.getValue();
Exercise e = new Exercise(name, "custom");
e.setWording(new Wording(wording));
e.setDifficulty(diff);
boolean ready = true;
for (int i = 1; i < 7; i++) {
String q = tabQuestions[i].getText();
if (q.equals("")) ready = false;
String t = types[tabTypes[i].getSelectedIndex()];
String s = tabSolutions[i].getText();
if (s.equals("")) ready = false;
//System.out.println("s1"+s1);
if (ready) {
switch (t) {
case "entier":
Integer[] in = {new Integer(s)};
QuestionCustom<Integer> qcu1 = new QuestionCustom<Integer>(q, in);
e.addQuestion(qcu1);
break;
case "réel":
Double[] d = {new Double(s)};
QuestionCustom<Double> qcu2 = new QuestionCustom<Double>(q, d);
e.addQuestion(qcu2);
break;
case "caractère":
Character[] c = {s.charAt(0)};
QuestionCustom<Character> qcu3 = new QuestionCustom<Character>(q, c);
e.addQuestion(qcu3);
break;
case "phrase":
String[] st = {s};
QuestionCustom<String> qcu4 = new QuestionCustom<String>(q, st);
e.addQuestion(qcu4);
break;
default:
break;
}
}
}
System.out.println("e:" + e);
e.save();
}
}
);
JLabel labelSouth = new JLabel("");
//labelSouth.setPreferredSize(new Dimension(300, 100));
createEx.setAlignmentX(CENTER_ALIGNMENT);
panSouth.add(labelSouth);
panSouth.add(createEx);
this.add(panSouth, BorderLayout.SOUTH);
} |
ef41c020-9128-4eb3-b293-54c08b1ce145 | 5 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if (!sender.hasPermission("VanishCommand.list")) {
sender.sendMessage(ChatColor.RED + "No permission!");
return true;
}
if (args.length != 0)
return false;
if (this.plugin.getHiders().isEmpty()) {
sender.sendMessage(ChatColor.RED + "No vanish players!");
return true;
}
StringBuilder builder = new StringBuilder();
for (Player p : this.plugin.getHiders()) {
if (!builder.toString().isEmpty()) builder.append(", ");
builder.append(p.getName());
}
sender.sendMessage(ChatColor.GREEN + "Vanish Players: " + ChatColor.WHITE + builder.toString());
return true;
} |
306adc9c-1a78-4d95-ac0e-cf0b950131e0 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Account other = (Account) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
return true;
} |
19c4243f-0f5f-41d9-a442-29b5101afe38 | 6 | private boolean parse(String line){
boolean retVal = true;
StringTokenizer st = new StringTokenizer(line , ",");
String command = st.nextToken();
System.out.println("SERVER : The command is : " + command);
if(command.equals("REQ")){
int numDep = Integer.parseInt(st.nextToken());
int numArr = Integer.parseInt(st.nextToken());
int dateDeb = Integer.parseInt(st.nextToken());
int dateFin = Integer.parseInt(st.nextToken());
svg.dessinerREQ(numDep, numArr, dateDeb, dateFin);
}else if(command.equals("SC")){
int num = Integer.parseInt(st.nextToken());
int dateDeb = Integer.parseInt(st.nextToken());
int dateFin = Integer.parseInt(st.nextToken());
svg.dessinerSC(num, dateDeb, dateFin);
}
else if(command.equals("EXIT")){
retVal = false;
try {
svg.close();
} catch (IOException ex) {
Logger.getLogger(ServerReader.class.getName()).log(Level.SEVERE, null, ex);
}
}
else if (command.equals("REP")){
int numDep = Integer.parseInt(st.nextToken());
int numArr = Integer.parseInt(st.nextToken());
int dateDeb = Integer.parseInt(st.nextToken());
int dateFin = Integer.parseInt(st.nextToken());
svg.dessinerREP(numDep, numArr, dateDeb, dateFin);
}
else if (command.equals("REAL")){
int numDep = Integer.parseInt(st.nextToken());
int numArr = Integer.parseInt(st.nextToken());
int dateDeb = Integer.parseInt(st.nextToken());
int dateFin = Integer.parseInt(st.nextToken());
svg.dessinerREAL(numDep, numArr, dateDeb, dateFin);
}
return retVal;
} |
7097a1b2-a563-4134-b75a-af1bc82840a4 | 8 | static String readCommand(String cmd) throws Exception {
boolean error = false;
cmd = cmd.replace(" ", "");
// Check if only allowed chars
if(Pattern.matches(PATTERN, cmd)) {
// This chunk here checks balancing brackets
LinkedList<Character> stack = new LinkedList<>();
for(int i = 0; i < cmd.length(); i++) {
if(cmd.charAt(i) == '[') {
stack.addLast(cmd.charAt(i));
}
if(cmd.charAt(i) == ']') {
if(stack.isEmpty()) {
error = true;
} else {
if(stack.removeLast() != '[') {
error = true;
}
}
}
}
if(!stack.isEmpty()) {
error = true;
}
if(error) {
throw new Exception("Error - Illegal balancing character ie not a corresponding closing-bracket ']'");
} else {
return cmd;
}
} else {
throw new Exception("Error - Illegal characters. Type 'help' for a list of commands");
}
} |
a0bae3e1-f94d-4b78-9c43-ada52e4a9d85 | 1 | @Override
public void endTransaction() {
if(commit()){
this.transaction = false;
}
} |
2fde465e-23e3-455f-8f6f-da5fa817a22e | 8 | public static AngleData getInterpolatedAngleData(List<AngleData> dataBase,int n,int index,double target)
{
int gpsWeek = dataBase.get(0).getTime().getWN();
int offset = 0;
double []towArray = new double[n];
double []leftAngleArray = new double[n];
double []rightAngleArray = new double[n];
if( n%2 == 0)
{
offset = n/2;
}
else
{
offset = (n-1)/2;//actually it doesn't make any sense
}
int beginIndex = index -offset;
int endIndex = index + n - offset;
int size = dataBase.size();
if (beginIndex>=0 && endIndex <=size) {
for(int i = 0;i<n;i++)
{
towArray[i] = dataBase.get(beginIndex+i).getTime().getTOW();
leftAngleArray[i]= dataBase.get(beginIndex+i).getLeftAngle();
rightAngleArray[i]= dataBase.get(beginIndex+i).getRightAngle(); }
} else {
if (beginIndex < 0) {
for (int i = 0; i < n; i++) { //处理target历元前面没有数据的情况
towArray[i] = dataBase.get(i).getTime().getTOW();
leftAngleArray[i]= dataBase.get(i).getLeftAngle();
rightAngleArray[i]= dataBase.get(i).getRightAngle(); }
}
if (beginIndex > size) {
for (int i = 0; i < n; i++) { //处理target历元后面没有数据的情况
towArray[i] = dataBase.get(size - n + i).getTime().getTOW();
leftAngleArray[i]= dataBase.get(size - n + i).getLeftAngle();
rightAngleArray[i]= dataBase.get(size - n + i).getRightAngle();
}
}
}
double tmpLeftAngle = Interpolation.LagrangeInterpolation(towArray,leftAngleArray, target);
double tmpRightAngle = Interpolation.LagrangeInterpolation(towArray,rightAngleArray,target);
return new AngleData(new Time.GPST(gpsWeek,target),tmpLeftAngle,tmpRightAngle);
} |
62b1a985-d1ff-4a04-ae9f-daebc0d555c9 | 4 | @Override
public Object getValueAt(int row, int column) {
int index = 0;
for (Entry<Integer, Boolean> e : pu.entrySet()) {
if (row == index) {
if (column == 0)
return e.getKey();
else
return e.getValue() ? "Active" : "Inactive";
}
index++;
}
return "";
} |
7becacd6-de05-490d-bb71-939f125280f5 | 5 | private ArrayList<String> fetchMatchingSpelproject() {
String searchFor = tfSpelprojectSearch.getText();
ArrayList<HashMap<String, String>> temp = null;
try {
temp = DB.fetchRows("select * from spelprojekt");
} catch (InfException e) {
e.getMessage();
}
ArrayList<String> res = new ArrayList<String>();
for (HashMap<String, String> hmt : temp) {
for (String st : hmt.values()) {
if (st != null && st.toLowerCase().contains(searchFor.toLowerCase())) {
res.add(hmt.get("SID"));
}
}
}
HashSet hs = new HashSet(res);
res.clear();
res.addAll(hs);
return res;
} |
7d9474da-33ed-4038-9b91-2d79b3592e5f | 9 | public static String getPreferredJavaType(int sqlType, int size, int decimalDigits) {
if ((sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) && decimalDigits == 0) {
if (size == 1) {
return "Boolean";
} else if (size < 3) {
return "Byte";
} else if (size < 5) {
return "Short";
} else if (size < 12) {
return "Integer";
} else if (size < 19) {
return "Long";
} else {
return "java.math.BigDecimal";
}
}
String result = _preferredJavaTypeForSqlType.getString(sqlType);
if (result == null) {
result = "Object";
}
return result;
} |
315108d6-0b05-4757-995a-3b0777241c21 | 1 | private void checkvault() {
Plugin p = getServer().getPluginManager().getPlugin("Vault");
if (p == null) {
sendtoserver(":δҵVault");
sendtoserver("Trd.");
setEnabled(false);
} else {
return;
}
} |
03dc4799-e6e8-4894-96e1-222897546d1a | 1 | public MyMap(){
int i;
registers=new HashMap<String,Integer>();
opcodes=new HashMap<String,Integer>();
opcodes_tail=new HashMap<String,Integer>();
Labels=new HashMap<String,Integer>();
for(i=0;i<8;i++){
registers.put("r"+i,i);
registers.put("R"+i,i);
}
// Arithmetic Instructions
opcodes.put("ADD",311100); opcodes_tail.put("ADD",0);
opcodes.put("add",311100); opcodes_tail.put("add",0);
opcodes.put("ADC",311100); opcodes_tail.put("ADC",1);
opcodes.put("adc",311100); opcodes_tail.put("adc",1);
opcodes.put("SUB",311101); opcodes_tail.put("SUB",0);
opcodes.put("sub",311101); opcodes_tail.put("sub",0);
opcodes.put("SBB",311101); opcodes_tail.put("SBB",1);
opcodes.put("sbb",311101); opcodes_tail.put("sbb",1);
//Logical Instructions
opcodes.put("AND",311102); opcodes_tail.put("AND",0);
opcodes.put("and",311102); opcodes_tail.put("and",0);
opcodes.put("OR",311102); opcodes_tail.put("OR",1);
opcodes.put("or",311102); opcodes_tail.put("or",1);
opcodes.put("NOT",210102); opcodes_tail.put("NOT",2);
opcodes.put("not",210102); opcodes_tail.put("not",2);
opcodes.put("XOR",311102); opcodes_tail.put("XOR",3);
opcodes.put("xor",311102); opcodes_tail.put("xor",3);
// Shift instructions
opcodes.put("SHIFTL",210103); opcodes_tail.put("SHIFTL",0);
opcodes.put("SHIFTR",210103); opcodes_tail.put("SHIFTR",1);
//MOVE Instruction
opcodes.put("MOV",201104);
opcodes.put("ADDI",311205);
opcodes.put("SUBI",311206);
opcodes.put("MOVSP",110007);
opcodes.put("MVIL",201308);
opcodes.put("MVIH",201309);
opcodes.put("LDIDR",311210);
opcodes.put("STIDR",311211);
opcodes.put("STC",12);
opcodes.put("CLC",13);
opcodes.put("PUSH",101016);
opcodes.put("JAL",100417);
opcodes.put("CALL",101018);
opcodes.put("POP",101019); //opcodes_tail.put("POP",1);
opcodes.put("RET",20); //opcodes_tail.put("RET",1);
opcodes.put("IE",21);
opcodes.put("ID",22);
opcodes.put("JMP",100423);
opcodes.put("JMPI",210224);
opcodes.put("JGEO",311227);
opcodes.put("JLEO",311226);
opcodes.put("JCO",100228);
opcodes.put("JEO",311225);
opcodes.put("HLT",29); //opcodes_tail.put("HLT",0);
opcodes.put("NOP",30);
//opcodes.put("LDIDX",311113);
//opcodes.put("STIDX",311114);
opcodes.put("RST",31); // opcodes_tail.put("RST",1);
} |
433025eb-85cb-415d-9a73-223a1bfa45d0 | 1 | private void cleanupEdge(final Block src, final Block dst) {
dst.visit(new TreeVisitor() {
public void visitPhiJoinStmt(final PhiJoinStmt stmt) {
final Expr operand = stmt.operandAt(src);
if (operand != null) {
operand.cleanup();
// Remove the operand associated with src
// from a PhiJoinStmt
stmt.setOperandAt(src, null);
}
}
public void visitStmt(final Stmt stmt) {
}
});
} |
601d1188-0c47-4d7e-a6e1-2685b788f226 | 9 | public static Command toCommand(String str, String prefix, String botnick) {
// Use this function to get the enum value for a string
String command;
String [] commandList;
commandList = str.split(" ");
command = commandList[0].toUpperCase();
if(prefix == null) { // Prefix is null, which means the command was sent in a PM.
command = command.replaceAll("[^A-Z]", ""); // Remove any prefix the user may have used.
// Add WG in the beginning of the command if it was left out
if(!"WG".equals(command.substring(0,2))) {
command = "WG" + command;
}
try {
return new Command(valueOf(command), commandList);
}
catch (Exception ex) {
return new Command(UNKNOWN, null);
}
}
else {
// Not a PM
if(command.substring(0,1).equals(prefix)) {
// User used a prefix
try {
return new Command(valueOf(command.substring(1)), commandList);
}
catch (Exception ex) {
return new Command(UNKNOWN, null);
}
}
else if(str.length() > botnick.length()) { // preventing a StringIndexOutOfBoundsException here
// TODO This looks a little hacky to me, maybe this could be done cleaner?
if(str.substring(0, botnick.length()).equals(botnick)) {
// Bot was highlighted
command = str.substring(botnick.length()+1).trim(); // Get rid of the highlight
command = command.replaceAll(prefix, ""); // Get rid of the prefix if it's given.
commandList = command.split(" ");
command = commandList[0].toUpperCase();
if(!"WG".equals(command.substring(0, 2))) { // Add WG if it wasn't in the command yet.
command = "WG" + command;
}
try {
return new Command(valueOf(command), commandList);
}
catch (Exception ex) {
return new Command(UNKNOWN, null);
}
}
else {
return new Command(NOCOMMAND, null);
}
}
else {
return new Command(NOCOMMAND, null);
}
}
} |
8e385afb-d33c-4efc-9265-33f627fb98fa | 3 | public void AddToMenu() {
if (Glob.instance != null && Glob.instance.paginae != null)
if (!Glob.instance.paginae.contains(res)) Glob.instance.paginae.add(res);
} |
9328a865-9af9-407b-9d59-f98cd9db756a | 4 | public static void main(String[] args) {
Parameters.load();
try {
// Set System L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException e) {
// handle exception
} catch (ClassNotFoundException e) {
// handle exception
} catch (InstantiationException e) {
// handle exception
} catch (IllegalAccessException e) {
// handle exception
}
new ChatMenu();
} |
e1e7da4d-da50-4215-980a-4d05d0fc86e7 | 5 | public String cryptanalyseCle(IMessage clair, IMessage crypte) {
long d=new Date().getTime();
int j=0;
boolean trouve=false;
while(j<clair.taille() && !trouve) {
if((char)(33+(clair.getChar(j)+47-33)%93)!=crypte.getChar(j) && clair.getChar(j)!=crypte.getChar(j)) {
trouve=true;
}
j++;
}
if(!trouve) {
this.succesCle=true;
}
this.time=new Date().getTime()-d;
return "47";
} |
2d132fd8-3a78-4c1f-8ccd-7b52a1f53882 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Ex25Java other = (Ex25Java) obj;
if (age != other.age)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
} |
cd96e824-16a7-4a9e-99b6-964a767ebc7d | 3 | public boolean solved(){
for(Cell[] rows : puzzle)
for(Cell cell : rows)
if(cell.getColor() == '.') return false;
return true;
} |
ccd9e398-8fd5-4f19-94ad-3a7ac86ae684 | 8 | public void resize(int x, int y) {
if (x < 1 || y < 1)
return;
Tile newMap[][] = new Tile[x][y];
initTab(newMap);
if (x <= tab.length && y <= tab[0].length) {
copy(newMap, tab, x, y);
}
else if (x > tab.length && y <= tab[0].length) {
copy(newMap, tab, tab.length, y);
}
else if (x <= tab.length && y > tab[0].length) {
copy(newMap, tab, x, tab[0].length);
}
else {
copy(newMap, tab, tab.length, tab[0].length);
}
tab = newMap;
map = new Map(tab);
boxMap = new Box(POS_MAP_X, POS_MAP_Y, Math.min(tab.length, MAP_DISPLAY_NB_TILE_X) * Tile.SIZE, Math.min(tab[0].length, MAP_DISPLAY_NB_TILE_Y) * Tile.SIZE);
} |
0de50995-2c1a-49bb-bae1-340bbe5c6504 | 8 | private void read(BufferedReader reader) throws IOException
{
String line;
// Header
line = reader.readLine();
if(!"Item".equals(line)) {
throw new IOException("Wrong header: " + line);
}
// Version
line = reader.readLine();
if(!"v.1".equals(line)) {
throw new IOException("Wrong version: " + line);
}
line = reader.readLine();
key = line;
int n;
line = reader.readLine();
n = Integer.parseInt(line);
for(int i=0; i<n; i++) {
line = reader.readLine();
if(i < strings.length) {
strings[i] = line;
}
}
line = reader.readLine();
n = Integer.parseInt(line);
for(int i=0; i<n; i++) {
line = reader.readLine();
if(i < ints.length) {
ints[i] = Integer.parseInt(line);
}
}
line = reader.readLine();
n = Integer.parseInt(line);
for(int i=0; i<n; i++) {
if(i < triplets.length) {
triplets[i].read(reader);
} else {
reader.readLine();
}
}
} |
56bba659-a07a-474c-819f-723ac0c0a6cf | 3 | public boolean checkColision(int x1, int y1, int x2, int y2){
if(alive){
if(colidate(x1, y1, x2, y2) ){
if(!getProtect().isActive()){
lives--;
imgLives.setText("x"+lives);
alive = false;
explosionTime = 0;
exp = true;
SoundManager.playExplosion();
}
return true;
}
}
return false;
} |
af93ce03-52ae-4b26-a793-33531204ab6b | 4 | @SuppressWarnings("unchecked")
@Override
public HashMap<String, JOSObject<?, ?>> getObjects() {
return (HashMap<String, JOSObject<?, ?>>) DATA.clone();
} |
a51afccb-c96e-4f5e-b525-f9885ad0b2fc | 0 | protected Automaton createEmptyAutomaton(Document document)
{
return new MealyMachine();
} |
dad9fb7c-6b31-4bd0-873b-d977c8566af3 | 1 | public static void main(String[] args) {
int[] candidates ={7,12,5,10,9,4,6,8};
int target = 32;
List<List<Integer>> list = new Combination_Sum().combinationSum(candidates, target);
for(int i =0 ;i< list.size();i++){
System.out.println(Arrays.toString(list.get(i).toArray()));
}
} |
cebbb599-edd6-4235-a3a5-1ab7a61d13f3 | 5 | /* */ public static boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
/* 167 */ boolean equal = true;
/* */
/* 169 */ if (l1.length != l2.length)
/* 170 */ return false;
/* 171 */ for (int i = 0; i < l1.length; i++) {
/* 172 */ if (l1[i] != l2[i]) {
/* 173 */ equal = false;
/* 174 */ break;
/* */ }
/* */ }
/* */
/* 178 */ return equal;
/* */ } |
54a0e357-449c-43f7-9044-b59e1e3bcce2 | 3 | public String getFullAlias() {
if (parent != null) {
String parentAlias = parent.getFullAlias();
String alias = getAlias();
if (alias.length() == 0)
return parentAlias;
else if (parentAlias.length() == 0)
return alias;
else
return parentAlias + "." + alias;
}
return "";
} |
6d277ab1-aa2a-4e0a-a674-e2f743bedda9 | 3 | public static boolean getYesOrNoAnswer(){
Scanner scanner = new Scanner(System.in);
String answer;
while (true){
answer = scanner.nextLine();
if (answer.equals("yes")){
return true;
}
if (answer.equals("no")){
return false;
} else {
System.out.println("Wrong answer, please enter yes or no");
}
}
} |
c1824cfd-0663-4446-8763-6bb8abc1e813 | 5 | public static RepSmartList UPDATE_SMART_LIST(OVSmartList ovSmartList) throws SQLException {
RepSmartList rep = new RepSmartList();
Connection connexion = GET_CONNECTION();
try {
for (OVListeProduit ovListeProduit : ovSmartList.getProduitsSmartList()) {
int coche = 0;
int supprime = 0;
if (ovListeProduit.getCoche()) {
coche = 1;
}
if (ovListeProduit.getSupprime()) {
supprime = 1;
}
Statement statement = connexion.createStatement();
int resultat = statement.executeUpdate("UPDATE listeproduit SET coche = " + coche + ", supprime = " + supprime + " WHERE id = " + ovListeProduit.getId() + ";");
if (resultat == 0) {
rep.erreur = true;
rep.messageErreur = "Aucune ligne mise à jour!";
}
}
} catch (SQLException ex) {
rep.erreur = true;
rep.messageErreur = ex.getMessage();
}
return rep;
} |
e476e1d1-7b15-41d0-8679-5cb10c78e19f | 2 | private static byte[] combineCD(byte[] C, byte[] D) {
byte[] CD = new byte[7];
// get 28 first bits from C
for(int bit = 0; bit < 28; bit++) {
ByteHelper.setBit(CD, bit, ByteHelper.getBitInt(C, bit));
}
// get 28 next bits from D
for(int bit = 28; bit < 56; bit++) {
ByteHelper.setBit(CD, bit, ByteHelper.getBitInt(D, bit - 28));
}
return CD;
} |
e3d9dc28-93ca-41e9-97f9-1f55c42d5f95 | 0 | public void setNodePlacer(NodePlacer placer) {
this.nodePlacer = placer;
invalidate();
} |
1958924f-a321-4711-afd9-eae9142779a7 | 0 | public UndoableDocumentAttributeChange(JoeTree tree, String oldKey, Object oldValue, boolean oldReadOnly, String newKey, Object newValue, boolean newReadOnly) {
this.tree = tree;
this.oldKey = oldKey;
this.oldValue = oldValue;
this.oldReadOnly = oldReadOnly;
this.newKey = newKey;
this.newValue = newValue;
this.newReadOnly = newReadOnly;
} |
e3fda94c-3bf6-40d3-b287-392b1a540746 | 5 | public int findKthSortedArrays(int A[], int sA, int B[], int sB, int k){
int eA = A.length - 1;
int eB = B.length - 1;
if(eA - sA > eB - sB){
return findKthSortedArrays(B, sB, A, sA, k);
}
if(sA > eA) return B[sB+k-1];
if(k==1) return Math.min(A[sA],B[sB]); // if k == 1, i is alwasy 0
int i = Math.min(k/2, eA-sA+1); // # of elements A can contribute
int j = k - i; // # of elements A can contribute
int a = A[sA+i-1];
int b = B[sB+j-1];
if(a < b) return findKthSortedArrays(A, sA+i, B, sB, k-i); // still need k-i
else if(a > b) return findKthSortedArrays(A, sA, B, sB+j, k-j); // still need k-j
else return a;
} |
d34901de-bf50-4246-bd30-ae80bf6081f0 | 1 | public Player(int x, int y, Cell landlord) {
super(x, y, landlord);
try {
img = ImageIO.read(new File("res/img/RaphiLangu.png"));
} catch (IOException e) {
}
} |
2cd5b98a-eb95-4f5c-80b8-fafff31d7a70 | 0 | @Test
public void testGetTipoInteres() {
System.out.println("getTipoInteres");
Cuenta instance = new Cuenta();
float expResult = 0.0F;
float result = instance.getTipoInteres();
assertEquals(expResult, result, 0.0);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
} |
24e60608-8d7b-4536-b065-e5b0793e68fc | 7 | public void addCell(cell ecoli, int x, int y){
int myx; int myy;
if(x >= xmin && x < xmax){myx = x-xmin;}else{myx = -1;}
if(y >= ymin && y < ymax){myy = y-ymin;}else{myy = -1;}
if(myy == -1 || myx == -1){ }
else{culture[myx][myy] = null;
culture[myx][myy] = ecoli;
if(ecoli.getOption("Mirror")){}else{ culture[myx][myy].setLocation(x,y);}}
} |
c1c132a0-36de-4552-a803-466e7b2430f2 | 4 | public void updateScreens() {
// GameScreen g = screens.get(screens.size()-1);
List<GameScreen> screensToInput = new ArrayList<GameScreen>();
for (int i = screens.size() - 1; i >= 0; i--) {
if (screens.get(i).state != ScreenState.HIDDEN) {
screensToInput.add(screens.get(i));
}
}
GameScreen s1 = screens.get(screens.size()-1);
while (!inputQueue.isEmpty()) {
InputEvent e = inputQueue.poll();
// for (GameScreen s : screensToInput) {
s1.manageInput(e);
// }
// g.manageInput(e);
}
for (GameScreen s : screens) {
s.updateScreen();
}
} |
343dd589-59bb-496c-9b0e-40a5d34f77ee | 1 | public static void main(String[] args) {
// TODO Auto-generated method stub
String[] fruits = {"Pine Apple", "Mango", "Banana", "Apple"};
Arrays.sort(fruits);
for(String temp: fruits){
System.out.println(temp);
}
} |
80898c4f-9c72-419a-8a54-1dbc89594473 | 5 | private void readXML(String fileName)
{
Document document;
DocumentBuilder documentBuilder;
DocumentBuilderFactory documentBuilderFactory;
NodeList nodeList;
File folder;
File[] xmlInputFiles;
ArrayList<ShotData> shots;
String currentDoc = "";
try
{
folder = new File(fileName);
xmlInputFiles = folder.listFiles();
for(File xmlInputFile : xmlInputFiles)
{
currentDoc = xmlInputFile.getAbsolutePath();
documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(xmlInputFile);
nodeList = document.getElementsByTagName("*");
ShotData s;
shots = new ArrayList<ShotData>();
document.getDocumentElement().normalize();
for (int index = 0; index < nodeList.getLength(); index++)
{
Node node = nodeList.item(index);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
Element element = (Element) node;
s = getTagValue(element);
if (s != null)
{
shots.add(s);
}
//System.out.println("\tcolour : " + getTagValue(element));
//System.out.println("\ttest : " + getTagValue(element));
//System.out.println("-----");
}
}
gameShots.add(shots);
}
}
catch (Exception exception)
{
System.out.println("Error reading shot data on file " +
currentDoc);
exception.printStackTrace();
System.exit(-1);
}
} |
ab29de49-3248-4957-a2ad-5619415d3e17 | 6 | private Class<? extends Event> getRegistrationClass(Class<? extends Event> clazz) throws IllegalAccessException {
try {
clazz.getDeclaredMethod("getEventList");
return clazz;
} catch (NoSuchMethodException e) {
if (clazz.getSuperclass() != null
&& !clazz.getSuperclass().equals(Event.class)
&& Event.class.isAssignableFrom(clazz.getSuperclass())) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
} else {
throw new IllegalAccessException("Unable to find event list for event " + clazz.getName());
}
}
} |
d04cf966-6d32-4f0f-8ec4-37cb7e026ea9 | 9 | private ArrayList<Integer> print(int[][] matrix, int top, int left, int bottom, int right) {
ArrayList<Integer> result = new ArrayList<Integer>();
// top
if (top <= bottom) {
for (int i = left; i <= right; i++) {
result.add(matrix[top][i]);
}
}
// right
if (right >= left) {
for (int i = top + 1; i <= bottom; i++) {
result.add(matrix[i][right]);
}
}
// bottom
if (bottom > top) {
for (int i = right - 1; i >= left; i--) {
result.add(matrix[bottom][i]);
}
}
// left
if (left < right) {
for (int i = bottom - 1; i > top; i--) {
result.add(matrix[i][left]);
}
}
// recursion to print inner
if (result.size() != 0) {
result.addAll(print(matrix, top + 1, left + 1, bottom - 1, right - 1));
}
return result;
} |
9b41931d-c67c-4988-b6e1-27ae5191ecad | 1 | public void visit_ifnull(final Instruction inst) {
if (longBranch) {
final Label tmp = method.newLabel();
addOpcode(Opcode.opc_ifnonnull);
addBranch(tmp);
addOpcode(Opcode.opc_goto_w);
addLongBranch((Label) inst.operand());
addLabel(tmp);
} else {
addOpcode(Opcode.opc_ifnull);
addBranch((Label) inst.operand());
}
stackHeight--;
} |
3ec65e1e-c4ae-4bf3-a066-d1f79bfc30d9 | 9 | public static Type preserveType(Type currentType, Type newType) {
Type result = newType;
if (newType != null && currentType != null &&
currentType.getObjectClass() == newType.getObjectClass()) {
if (newType.getGenericType().getGenericType() instanceof Class &&
!(currentType.getGenericType().getGenericType() instanceof Class)) {
if (newType.isNonNull() && !currentType.isNonNull()) {
result = currentType.toNonNull();
}
else if (!newType.isNonNull() && currentType.isNonNull()) {
result = currentType.toNullable();
}
}
}
return result;
} |
5d533e83-24d0-4d1c-bf98-f6d5d7cf7c3a | 5 | public void removeDocument(Document doc) {
openDocuments.remove(doc);
// Fire Event
fireDocumentRemovedEvent(doc);
// Unregister the Document
doc.setDocumentRepository(null);
// Select the last non-iconified document in the window menu and
// change to it. Otherwise change to an iconified doc. Otherwise, change to null.
if (mostRecentDocumentTouched == doc) {
setMostRecentDocumentTouched(null);
if (openDocumentCount() > 0) {
for (int i = openDocumentCount() - 1; i >= 0; i--) {
Document newDoc = getDocument(i);
if (!newDoc.isIcon() || i == 0) {
Outliner.menuBar.windowMenu.changeToWindow((OutlinerDocument) newDoc);
return;
}
}
}
// We've closed the last document. We need to set focus
// somewhere, otherwise the ctrl-q, ctrl-n keys, etc. won't work correctly.
Outliner.desktop.requestFocus();
}
} |
15c355a0-4300-496b-aa11-3a13dd40dba8 | 0 | private Combination<Colors> generateAttemptCombination3() {
List<Token<Colors>> attemptTokens = new ArrayList<Token<Colors>>();
attemptTokens.add(new Token<Colors>(Colors.P));
attemptTokens.add(new Token<Colors>(Colors.W));
attemptTokens.add(new Token<Colors>(Colors.R));
attemptTokens.add(new Token<Colors>(Colors.K));
attemptTokens.add(new Token<Colors>(Colors.B));
return new Combination<Colors>(attemptTokens);
} |
271f29b4-e5da-4340-8637-afb04474ba7b | 5 | private void lblUpdateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblUpdateMouseClicked
// check so eveything is ok
if (!Validate.tfEmpty(tfBenamning) && !Validate.tfEmpty(tfProducent)) {
if (Validate.notOverSize(tfBenamning) && Validate.notOverSize(tfProducent) && Validate.notOverSize(taBeskrivning)) {
// updates the plattform and returns to the previous panel
updatePlattform();
PanelHelper.cleanPanel(PanelHelper.getMainFrame().getMfRight());
PanelHelper.addContainerToMFRight(new PlattformPanel(), 1);
} else {
lblError.setText("Inget fält får vara över 255 bokstäver i längd.");
lblError.setVisible(true);
}
} else {
lblError.setText("Du måste skriva in något i benämning och producent för att kunna uppdatera.");
lblError.setVisible(true);
}
}//GEN-LAST:event_lblUpdateMouseClicked |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.