method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
175a57b1-6937-42c5-8270-b4bc1eb49fe6 | 0 | public StateExpanderTool(AutomatonPane view, AutomatonDrawer drawer,
ConversionController controller) {
super(view, drawer);
this.controller = controller;
} |
4650655c-c4a5-4d02-a596-40f0a8ef8a86 | 6 | public IOThread choose_io_thread(long affinity_) {
if (io_threads.isEmpty ())
return null;
// Find the I/O thread with minimum load.
int min_load = -1;
IOThread selected_io_thread = null;
for (int i = 0; i != io_threads.size (); i++) {
if (affinity_ == ... |
c40105ad-6fa3-4864-9ee1-f74b90c54beb | 6 | @SuppressWarnings("unchecked")
public static <T extends Number> T sub(T e1, T e2, Class<T> type) {
T result = ElementOpUtils.getNeutralMulElem(type);
switch (type.getSimpleName()) {
case "Byte":
return (T) (Byte) (byte) ((Byte) e1 - (Byte) e2);
case "Short":
return (T) (Short) (short) ((Short) e1 - (S... |
6a35f326-586e-4f5a-aa7a-93fb9a8bd891 | 2 | public Filter() {
setTitle("Filter");
setIconImage(new ImageUtil().getLogo());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JPanel panel = new JPanel();... |
57812978-4790-4c67-9e5b-7f53ef4cb9fb | 8 | public void testResetWithoutBreakage() {
try {
final CyclicBarrier start = new CyclicBarrier(3);
final CyclicBarrier barrier = new CyclicBarrier(3);
for (int i = 0; i < 3; i++) {
Thread t1 = new Thread(new Runnable() {
public void run()... |
f3f536e4-09dd-4bd2-b280-8eb022fe254e | 4 | public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
buffer.append('\n');
State[] states = getStates();
for (int s = 0; s < states.length; s++) {
if (initialState == states[s])
buffer.append("--> ");
buffer.append(states[s]);
if (isFinalState(state... |
e96cd6c9-1478-4389-95f7-1c1563dfc736 | 8 | @Override
protected void onDisconnect() {
for (final Module m : enabledModules.values()) {
if (m.onDisconnect()) {
break;
}
}
if (cleanDc) {
dispose();
} else {
boolean connected = false;
final int attempts = 0;
try {
while (!connected && (attempts < maxReconnects)) {
Thread.slee... |
5b10f858-45a8-493b-bbb3-797545e7f10b | 0 | @Test
public void testMakePurchaseNoFee() {
this.card1.makePurchase(300);
assertEquals(300, this.card1.getBalance());
} |
7382155e-1cda-4193-88ba-501fe5eea8a9 | 9 | public void tick() {
roundId = this.maxTick + Constants.USER_ACTION_DELAY;
// First tick, roundId = 50
if (this.maxTick == 0) {
RoundMessage message = new RoundMessage();
message.setRoundId(roundId);
this.getGame().sendAll(message);
}
this.ma... |
ec8b44cb-d3d7-4c0e-9c9c-08e076eee2b4 | 1 | public void criarProjeto(Projeto projeto) throws SQLException, ExcecaoprojetoExistente {
ProjetoDAO projetDAO = new ProjetoDAO();
Projeto projet = new Projeto();
projet = projetDAO.selectUmProjeto(projeto.getNome());
if (projet == null) {
projetDAO.criarProjeto(projeto);
... |
f1cffb01-8f98-4703-a733-fce834404d68 | 7 | * @param ROUND whether to round the result or ceil
* @return a "niceScaling" number to be used for the value range
*/
private double calcNiceNumber(final double RANGE, final boolean ROUND) {
final double EXPONENT = Math.floor(Math.log10(RANGE)); // exponent of range
final double FRACTION... |
e7cf3fcb-621e-4c22-b9fb-d8a0f59ed69d | 8 | public Server(int port) throws IOException {
clientList = new ArrayList<ConnectionToClient>();
messages = new LinkedBlockingQueue<Object>();
serverSocket = new ServerSocket(port);
Thread accept = new Thread() {
public void run() {
while (true) {
... |
1ee24309-e8ee-4724-8566-98512ef9ca63 | 4 | public void bounceOffWalls(boolean isEndless) {
if (isEndless) {
if (x > (FRAME_WIDTH - 2 * r)) {
vx = -vx;
x = (FRAME_WIDTH - 2 * r - 1);
}
}
if (y > (FRAME_HEIGHT - 2 * r)) {
vy = -vy;
y = (FRAME_HEIGHT - 2 * r - ... |
2b0b86cd-269e-4c14-9dd0-8793e6bec225 | 3 | public static void main(String[] args) {
//creating a barrier so we can start all threads at once
final CyclicBarrier gate = new CyclicBarrier(15);
//create the TimeKeeper and have it wait at the gate
TimeKeeper timer = new TimeKeeper(gate);
timer.start();
//create the business
Business business = n... |
ca68c205-a52b-4954-ad19-b065d7c00373 | 0 | public SenseTest() {
} |
4781f4b0-a131-48a0-8d5a-a2c7dcce2595 | 7 | public void disconnect()
{
try
{
if(sInput != null) sInput.close();
}
catch(Exception e) {} // not much else I can do
try
{
if(sOutput != null) sOutput.close();
}
catch(Exception e) {} // not much else I can do
try
{
if(_socket != null) _socket.close();
}
catch(Exception e) {} // not... |
3ad61e35-424b-403c-82b9-bc7c8db02863 | 8 | public static String dbl2Hex(double d)
{ NumberFormat nf =NumberFormat.getNumberInstance();
String S =nf.format(d); S+=(S.length()<2?".0":"");
String[] s =S.replace(".", ":").split(":",2);
long i =Long.parseLong("0"+s[0]);
String signo =(Long.signum(i)==-1... |
1571a5a5-8ab3-4edb-b8c6-26e21e7f8128 | 7 | public boolean decodeBoolean(boolean implicit) throws Asn1Exception {
boolean retValue;
//
// There must be at least 2 bytes available
//
if (residualLength < 2)
throw new Asn1Exception("Attempt to read past end of stream");
//
// Validate the tag fo... |
dceb2911-2744-479c-b425-6f72bb33c973 | 7 | public static String readSeatNumbers() {
boolean tryAgain;
do {
tryAgain = false;
str = scan.nextLine();
for(String s: str.split(" ")) {
if(s.length() < 2) {
tryAgain = true;
}
else if(s.charAt(0) < 'A' && s.charAt(0) > 'Z') {
tryAgain = true;
}
else {
try {
... |
63251f1c-15d0-457c-86c3-1360e19e4c05 | 8 | private int doPath(int[][] matrix, int row, int col, int totalRow, int totalCol) {
if (row == totalRow - 1 && col == totalCol - 1 && matrix[row][col] == 0) {
return 1;
}
int loc = row * totalCol + col;
Integer cache = pathMap.get(loc);
if (cache != null) {
... |
7da818d5-ee46-4ca6-87c4-fb803e249dc2 | 6 | public void postProcessing(){
/*
addExit();
for (int ii = 0; ii < width; ii++){
for (int jj = 0; jj < height; jj++){
if (getBlock(ii,jj) == GROUND){
setBlock(ii,jj,ROCK);
}
}
}*/
addExit();
fixCannons();
//For some reason the bottom is cut... |
7d37b615-a9aa-4097-a68a-287906e6ccb5 | 6 | @EventHandler
public void SnowmanResistance(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getsnowgolemConfig().getDouble("Snowman... |
2bc4410f-0e90-4475-bc00-385d0d641728 | 8 | public static void loadAnnouncements() {
//create defaults
setDefaults();
// load global announcements
if ( Announcements.announcer ) {
List<String> global = Announcements.announcements.getListString( "Announcements.Global.Messages", new ArrayList<String>() );
if ... |
c3475871-80a8-40ca-95cf-b1fa2740e20a | 5 | public synchronized boolean addPlayer(int slotID, int localID,
int clientID, String name, String type) {
if (!_isOpen) {
return false;
}
if ((slotID < 0) || (slotID >= _slots.size())) {
return false;
}
if (!_slots.get(slotID).isOpen()) {
... |
3734511f-aa80-4d99-a38b-e73f5c4ef6dd | 0 | public JTextField getxMinTextField() {
return xMinTextField;
} |
94bda42b-5fde-4495-b7cf-bf5e66ce4203 | 5 | public void onCollision(PowerUpControl element, String name) {
if(name!=null){
String[] data = name.split(":");
if(data != null && data.length >2 && data[0].equals(PowerUpControl.PLUS_HEALTH)){
int h= Integer.parseInt(data[1]);
if... |
2528d6c8-fb81-43ce-a987-4c08d48c1200 | 9 | private static String getHundreds(char input) // getHundreds method start
{
String output = "";
switch (input)
{
case '1': output = "one";
break;
case '2': output = "two";
break;
case '3': output = "three";
break;
case '4': output = "four";
break;
case '5': output = "five";
break;
c... |
df592db7-7709-4ff3-ac44-e0198f879a58 | 9 | public HashMap<String, ClassNode> run(){
System.out.println("{*Starting Deob*");
if (!useOutput) {
classes = new MethodRemoval(classes).refactor();
} else {
try {
List<String> lines = Files.readAllLines(Paths.get("output.txt"), Charset.defaultCharset());
... |
bbe112d3-2057-4c58-aa99-94e576c42678 | 1 | public void addToEnd(String value) {
ListElement current = new ListElement(value);
if (count == 0) {
head = current;
} else {
tail.connectNext(current);
}
tail = current;
count++;
} |
2f01907e-70f0-4e05-a52d-24c9eedbe498 | 0 | public List<Participant> getParticipants(int idEvent){
return manager.createQuery("SELECT e.participants FROM Event e WHERE e.id='"+idEvent+"'").getResultList();
} |
fc7613c1-e75a-463b-a6d2-6d0664bbbb62 | 1 | @Override
public void run() {
arr_data = FullTicket.showAll(status);
data = new Object[arr_data.size()][];
for (int i = 0; i < arr_data.size(); i++) {
data[i] = arr_data.get(i).Array();
}
this.fireTableDataChanged();
} |
37760b5a-5edb-43a5-8430-473621b5ce61 | 6 | public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
w: while (scan.hasNext()) {
int n = -1, con = 0;
boolean[] a = new boolean[101];
Arrays.fill(a, false);
ArrayList<Integer> ll = new ArrayList<Integer>();
HashSet<Integer> set = new HashSet<Integer>();
... |
0ef97fea-c33b-4644-95bc-82ad7d2469b3 | 1 | @Override
public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
Contexto oContexto = (Contexto) request.getAttribute("contexto");
oContexto.setVista("jsp/profesor/form.jsp");
ProfesorBean oProfesorBean;
ProfesorDao oProfesorDao;
... |
d2fbdf6b-da66-437e-be99-a798edc6b89a | 5 | @Override
public final void mouseWheelMoved(MouseWheelEvent e)
{
mouseWheelScrolled(e);
// TODO make this mess better!
TScrollBar scrollBar = null;
double distanceToScrollBar = Double.MAX_VALUE;
for (TComponent c : tComponents)
{
// If c is a TScrollBar
if (c.getClass() == TS... |
1ec13fd8-81a0-4711-b5ee-e5d7ad582bb0 | 4 | public void resetEnemies(){
for (Person e : easy)
e.setHealth(200);
for (Person e : medium)
e.setHealth(300);
for (Person e : hard)
e.setHealth(400);
for (Person e : tough)
e.setHealth(500);
} |
9eb51d7a-e842-4771-a43f-c944b034b3c0 | 3 | public final void doPrint() throws IOException, PrintException {
System.out.println("Printing ");
DocFlavor flavor = DocFlavor.CHAR_ARRAY.TEXT_PLAIN;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
//aset.add(MediaSizeName.NA_LETTER);
PrintService[] pservices = PrintServiceLookup.lookupPr... |
95b5ce87-ecd0-493e-83b9-889d2dd62a08 | 2 | public static double[][] transpose( double[][] mat )
{
int m = mat.length;
int n = mat[0].length;
double[][] res = new double[n][];
for ( int i = 0; i < n; ++i )
{
res[i] = new double[m];
for ( int j = 0; j < m; ++j )
res[i][j] = mat[j][i];
}
return(res);
} |
17b6faaa-2922-49e2-a95c-0153fa8199df | 4 | public String diff_prettyHtml(LinkedList<Diff> diffs)
{
StringBuilder html = new StringBuilder();
for(Diff aDiff : diffs)
{
String text = aDiff.text.replace("&", "&").replace("<", "<").replace(">", ">").replace(
"\n", "¶<br>");
switch(aDiff.operation)
{
case INSERT:
html.appen... |
5c5b8dd6-d76b-47fa-a739-aacfea41fc8f | 6 | protected Node<T> addValue(T value) {
Node<T> newNode = null;
if (this.creator == null)
newNode = new Node<T>(null, value);
else
newNode = this.creator.createNewNode(null, value);
// If root is null, assign
if (root == null) {
root = newNode;
... |
75522872-d534-47a4-9447-3e4f912d7135 | 5 | @Override
public Action getAction(GameState state) {
if(state.getActivePlayerCount()==1){
return Action.CALL;
}
if(state.getRound() == Round.PRE_FLOP){
if(random.nextFloat() >= 0.5f){
return Action.CALL;
}else{
return Action.FOLD;
}
}
else{
Hand best = Hand.getBestHand(new Card[]{holeC... |
ed9ec55f-e14f-4278-8e1c-9976cab717b8 | 8 | private Mesh loadMesh(String fileName)
{
String[] splitArray = fileName.split("\\.");
String ext = splitArray[splitArray.length - 1];
if(!ext.equals("obj"))
{
System.err.println("Error: File format not supported for mesh data: " + ext);
new Exception().printStackTrace();
System.exit(1);
}
Ar... |
e48a4b0a-a8dd-4909-8c3d-b4b9f6ced11b | 6 | public static final boolean usingGoliathGloves(Player player) {
String name = player.getEquipment().getItem(Equipment.SLOT_SHIELD) != null ? player
.getEquipment().getItem(Equipment.SLOT_SHIELD).getDefinitions()
.getName().toLowerCase()
: "";
if (player.getEquipment().getItem((Equipment.SLOT_HANDS)) != ... |
cab7a813-faa9-4efe-9f83-1fc5e961f0ff | 3 | private void printLevel() {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
System.out.print(walkways[j][i] ? ' ' : '#');
}
System.out.println();
}
} |
04c98002-6959-4e6b-a7a1-cc6a0fbe02a2 | 3 | public final static Image decode(InputStream is) throws IOException {
BufferedInputStream bis = new BufferedInputStream(is, defaultBufferSize);
checkEquality(read(bis, 12), PNGHelper.ID);
checkEquality(read(bis, 4), PNGHelper.IHDR);
int width = readInt(bis);
int height = readInt(bis);
Image result =... |
56ffd17f-3caa-4e67-9c45-72e1f5d31e5e | 4 | public synchronized void send() {
while (commands.size() == 0) {
try {
wait(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
for (Command dc : commands) {
try {
dc.send(dos);
} catch (IOException e) {
e.printStackTrace();
}
}
commands.clear();
coordCom... |
6f748c4e-71cf-4840-bf51-44e2415f2b72 | 3 | public void broadcastAbuse(Player p)
{
if (!getConfig().getString("broadcast-msg").isEmpty()) {
String prebroadcast = getConfig().getString("broadcast-msg");
String broadcast = ChatColor.translateAlternateColorCodes('&', prebroadcast);
for (Player pl : Bukkit.getOnlinePla... |
42f25022-d806-44e7-9ddd-e6f5a0c1f64d | 9 | public List<Feat> training(int T){
//initialize weights
int allPics = features.get(0).valuesFaces.size();
List<Feat> weakClassifiers = new ArrayList<Feat>();
for(Feat f : features){
for(ValueFace vf : f.valuesFaces){
vf.weight = (double)1/allPics;
}
}
//for from 1 .. T
for(int i = 0; i < T; ... |
9fc93cab-03d6-475e-ad98-91c29c3a516b | 8 | private void transform(ScriptOrFnNode tree)
{
initOptFunctions_r(tree);
int optLevel = compilerEnv.getOptimizationLevel();
Hashtable possibleDirectCalls = null;
if (optLevel > 0) {
/*
* Collect all of the contained functions into a hashtable
* so ... |
ef9f0d1e-ceb1-4341-8d48-799bc9ebb4c7 | 8 | public static int retornaQuantidadeDiasIntercessaoEntrePeriodos(
Date dataInicioA, Date dataTerminoA, Date dataInicioB, Date dataTerminoB) throws Exception {
long qtd = 0;
if (dataInicioA == null || dataTerminoA == null || dataInicioB == null || dataTerminoB == null) {
throw new Exception("retornaQuantidade... |
dc83dbbe-31c9-4488-a379-f252567baf7e | 8 | public void actionPerformed(ActionEvent evt){
Object s = evt.getSource();
if(s == menuExit){
closeProgram();
}else if(s == menuAbout){
showAbout();
}else if(s == menuAddGroup || s == btnAddGroup){
addNewGroup();
}else if(s == menuAddNote || s == btnAddNote){
openNoteEditor();
}else if(s == po... |
130da60a-daa4-43dd-b15f-80d669c1eff6 | 1 | public MiniMap(QWidget parent)
{
super(parent);
setMinimumSize(38*5, 36*5);
wmap = core.WorldMap.getLastInstance();
if (wmap != null) {
tmap = wmap.getTerrain();
}
mission = core.Mission.getLastInstance();
} |
f04c12b1-34c9-4a02-938e-bb14bfde1558 | 7 | public float[] dimensions()
{
assert (vertices != null);
float maxx, minx, maxy, miny, maxz, minz;
float dimensions[] = new float[3];
/*
* get the max/mins
*/
maxx = minx = vertices[3 + 0];
maxy = miny = vertices[3 + 1];
maxz = minz = vertic... |
6bba765f-10c6-41fa-92af-0effe59fb13c | 3 | public void loadHighScores(){
highScores = new ArrayList<Integer>();
highScoreNames = new ArrayList<String>();
DataInputStream file;
try{
file = new DataInputStream(new BufferedInputStream(new FileInputStream(new File(HIGHSCOREFILE))));
}catch (FileNotFoundException ex){
return;
}
try{
int num... |
4c238447-321f-469d-b1ef-d7891532771b | 6 | public static Cons extractVariablesFromDeclarations(Stella_Object declarations) {
{ Cons result = Stella.NIL;
if (Stella_Object.safePrimaryType(declarations) == Logic.SGT_STELLA_CONS) {
{ Cons declarations000 = ((Cons)(declarations));
{ Stella_Object item = null;
Cons iter000 =... |
5004dfca-9db4-4419-85c7-f17dae0130f8 | 2 | public static boolean isValidSurname(String surname) {
if (surname == null) return false;
return surname.matches("[a-zA-Z][a-zA-Z ,'.-]+")
&& surname.length() <= 32;
} |
b23b23dd-030e-4990-81ae-b55f9cbcc48a | 6 | @Override
public ArrayList<String> normalize(String fileName) throws IOException {
String command = treeTaggerBin + " " + fileName;
final Process proc = Runtime.getRuntime().exec(command);
final ArrayList<String> lemmas = new ArrayList<String>();
// Consommation de la sortie standard de l'application exte... |
f6628117-87c0-4d6a-94a9-1ca67d60da4e | 8 | private void checkCollision() {
if (getHeliBoy1().intersects(Robot.rectBody) || getHeliBoy1().intersects(Robot.rectLegs) || getHeliBoy1().intersects(Robot.rectLeft) || getHeliBoy1().intersects(Robot.rectRight)){
System.out.println("collision");
}
if (getHeliBoy2().intersects(Robot.rectBody) || getHeliB... |
095bba4c-a1c0-47cf-ba9b-e4221cb2d1fa | 5 | @Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value == null) {
return null;
}
try {
if (value != null && (value.equals("-") || value.equals(""))) {
value = "-1";
}
Projeto p... |
0fcc517e-f71e-4d29-91fd-e647baeef9b3 | 5 | public int setup(String arg, ImagePlus imp) {
int i;
ImageStatistics stats;
stats=imp.getStatistics();
if (IJ.versionLessThan("1.31l")){
IJ.error("Needs ImageJ 1.31l or newer.");
return DONE;
}
if (stats.histogram[0]+stats.histogram[255]!=stats.pixelCount){
IJ.error("8-bit binary image (0 a... |
9f36e81a-a465-4a61-8c4e-0f68432629d4 | 2 | public int compareTo(Object obj) {
final SubLCommandInfo that = (SubLCommandInfo) obj;
if (this.durationMillis < that.durationMillis)
return -1;
else if (this.durationMillis == that.durationMillis)
return 0;
else
return 1;
} |
59c8e859-5e33-4f63-a6e3-687c95f2e1e8 | 6 | private ArrayList<Integer> generateDestinations( byte pieceType, int position ) {
switch ( pieceType ) {
case PAWN: return ( generatePawnDestinations( position ) );
case KNIGHT: return ( generateKnightDestinations( position ) );
case BISHOP: return ( generateBishopDestinations( position ) );
... |
55da2de1-56fa-4074-9118-e09c6fd2ed9c | 0 | public void setName(String name) {
this.name = name;
} |
fe3d66ce-d0b7-4836-85dd-2e9832641b55 | 8 | private S2AreaCentroid getAreaCentroid(boolean doCentroid) {
S2Point centroid = null;
// Don't crash even if loop is not well-defined.
if (numVertices() < 3) {
return new S2AreaCentroid(0D, centroid);
}
// The triangle area calculation becomes numerically unstable as the length
// of any ... |
ca425d84-1f3a-4480-ab9b-4ea7d44e5cec | 9 | private static boolean compareArrays(byte[] array1, byte[] array2) {
if(array1 == null && array2 == null) {
return true;
} else if ((array1 == null && array2 != null) || (array1 != null && array2 == null)) {
return false;
} else if (array1.length != array2.length) {
return false;
}
for (int i = 0;... |
39a4fe6f-9b62-4701-b652-c07775e92680 | 3 | private void checkArmstrong() {
int len = this.numField.getText().trim().toCharArray().length;
if (len != 0) {
long num = Integer.parseInt(this.numField.getText().trim());
long sum = 0L;
long temp = num;
while (temp > 0) {
sum = (long) (sum + java.lang.Math.pow(temp % 10, len));
temp = temp / 10... |
568edf0a-9fa2-4623-aacc-f080d298af74 | 0 | @Override
protected StreamInbound createWebSocketInbound(String arg0,
HttpServletRequest arg1) {
return new RobotServerHandler();
} |
44b9151d-2330-415d-85f5-4c7f776ab292 | 0 | public void setOtro(String otro) {
this.otro = otro;
} |
e8506a39-c3cb-4926-be01-e44b85b211dd | 7 | @Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if (args.length != 1) {
return false;
}
if (!(sender.hasPermission(HGPermission.CREATE.toString()))) {
sender.sendMessage(plugin.getBroadcaster().styleMessage("You don't have permission!"));
retur... |
072b347b-a07a-4e74-896c-024b47b4ddf5 | 6 | @Override
public final boolean checkWin() {
int sum = 0;
for (IPlayer player : getPlayers()) {
sum += player.getPoints();
}
if (sum >= getWinThreshold()) {
return true;
}
for (IPlayer player : getPlayers()) {
ICoordinates coord =... |
1cf965d2-6512-4972-8089-ae024beccd72 | 1 | public boolean hasObject(){
if (freeObjectIndex == -1)
{
// There are no free objects so I just
// create a new object that is not in the pool.
return false;
}
return true;
} |
e7252d5f-995e-402e-8f39-0f259c3d5ed6 | 7 | public static void readFromCommandLine(Settings settings, String[] args) {
if (args == null) return;
Map<String, String> map = new HashMap<String, String>();
String key;
for (int i = 0; i < args.length; i++) {
key = args[i];
if (key != null && key.length() > 0 &&... |
3c3f9b97-a160-419a-8a3b-36c92793d4d3 | 3 | public LogAc load(LogAc logAc){
try{
File inFile = new File(filePath);
if (inFile.exists()){
FileInputStream inFileStream = new FileInputStream(inFile);
ObjectInputStream inObjectStream = new ObjectInputStream(inFileStream);
LogAc tmplogin = (LogAc) inObjectStream.readObject();
inObjectStream.c... |
5c291d5a-e363-4d73-ab51-e5f7b6ffb198 | 9 | private void installationFinished(int id) {
switch (id) {
case 1: // Pipeline installation finished
if (needsSGE || needsNITools || needsBITools) {
plTitleLabel.setText("Pipeline Server Installation Completed");
plProgressBar.setVisible(false)... |
89d8a65b-425c-4c27-b2d1-dfd3a54ca8f9 | 2 | @Test
public void test_getAverageStatistical() {
List<Long> standardList = new ArrayList<Long>();
long foo = 0;
// filling list with values
for (int i = 0; i <= 100; i++) {
standardList.add((long) 5);
}
// calculating average value
for (Long ba... |
9f1d510d-871c-428d-bcd1-6e43c26d9771 | 0 | public final K getK() { return k; } |
3b75ea70-b169-452e-923f-e383a0457944 | 0 | public int value() {
return i;
} |
e5671135-8b5a-491e-83e3-2fae89785a59 | 0 | @Override
public void documentRemoved(DocumentRepositoryEvent e) {} |
f35c271b-3607-479e-8703-eebf20aa01f9 | 9 | public void mouseUp(MouseEvent e, int x, int y) {
switch(count){
case 0:
System.out.println("Moving red archer");
game.moveUnit(new Position(2,0),new Position(3,1));
break;
case 1:
System.out.println("Ending turn");
... |
b1b71116-c332-428d-889f-3e2de3b9cbc5 | 8 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("duty")){
if (!(sender instanceof Player)) { //if not sent by player fail
sender.sendMessage("This command can Only be run by a player");
return false;
}... |
a6c2fbd7-b3c1-489c-bf30-5c12d60a8051 | 5 | @Override
public Byte[] convertFromString(Class<? extends Byte[]> cls, String str) {
if (str.length() == 0) {
return EMPTY;
}
if (str.length() % 2 == 1) {
throw new IllegalArgumentException("Invalid Byte[] string");
... |
9ba3ed1d-ac40-4dcd-aa06-aba62365e72b | 9 | public static void main (String[] args)
{
try
{
FileInputStream fis = new FileInputStream("recs.jobj");
ObjectInputStream ois = new ObjectInputStream(fis);
Object o = ois.readObject();
Hashtable<Integer, RecPair> recs = (Hashtable<Integer, RecPair>)o;
ois.close();
fis.close();
fis ... |
c591ea1e-26f6-483f-9ed6-0f4b74124cbd | 2 | public CopyOfSAXParserCPU(){
//Apenas para testes
if(ARQUIVO_HOSTS_FIXO){
//Busca pela tag <host ... /> no arquivo XML
//
//Uso uma lista porque nao sei quantos hosts podem ser retornados
java.util.ArrayList listaHosts = processar("getCPU", "basedados.xml"); //
java.util.Iterator itr = listaHosts.it... |
b6f4ae44-112e-4215-a9e5-3094dab505fb | 6 | public static void makeGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeGrid must use Sp... |
ad7848e3-e330-4196-8e1d-b66107e31a34 | 5 | private static Color getLabelColor(int selection) {
switch (selection) {
case WHITE:
case YELLOW:
return Color.BLACK;
case GREEN:
return Color.BLUE;
case RED:
case BLUE:
default:
return Color.... |
0a0f965d-095f-4d2e-8966-8be4ba3f1cab | 4 | final boolean isWhitespace(char c)
{
switch ((int) c) {
case 0x20:
case 0x09:
case 0x0d:
case 0x0a:
return true;
default:
return false;
}
} |
c0ed8277-7594-4598-bd01-9f8ffd2c9db0 | 2 | public boolean fieldConflicts(FieldIdentifier field, String newAlias) {
String typeSig = (Main.options & Main.OPTION_STRONGOVERLOAD) != 0 ? field
.getType() : "";
/*
* Fields are similar to static methods: They are not overriden but
* hidden. We must only take care, that the reference of every
* getfi... |
14c65d3f-2bd0-4606-88d6-e8ee8d356916 | 8 | public static Model loadModel(String filename)
{
String[] splitArray = filename.split("\\.");
String ext = splitArray[splitArray.length - 1];
if (!ext.equals("obj"))
{
System.err.println("Error: File format not supported fro mesh data :" + ext);
new Exceptio... |
dba1aab7-0c6f-41e5-9d56-4ed3702992e0 | 3 | public static int getInt(final String title, final int defaultValue) {
int opt = -1;
do {
try {
final String val = ConsoleMenu.getString(title + " (default:" + defaultValue + ")", null);
if (val.length() == 0) {
opt = defaultValue;
... |
8bd41efe-c36c-4fb4-afa5-926f7db9e527 | 2 | @Override
public
void startSocket() {
try {
// get Socket
socket = new Socket(address, port);
socket.setSoTimeout(300);
} catch (UnknownHostException e) {
System.err.println("Don't know about host: " + address);
} catch (IOException e) {
Sy... |
bd3654ca-1ca4-4543-a09a-fae146c4806f | 8 | private void encodeRefresh(ItemInfo itemInfo, Object[] orderEntries, boolean completed, boolean solicited)
{
OMMMsg outmsg = _mgr.getPool().acquireMsg();
outmsg.setAttribInfo(itemInfo.getOMMAttribInfo());
outmsg.setItemGroup(0);
// Set the message type to be refresh respons... |
2e8eab0f-9710-4e93-baae-d52259d6a492 | 1 | private ArrayList<Role> getAllRoles(String Declaration) {
// TODO Auto-generated method stub
ArrayList<Role> arrayrole = new ArrayList();
StringTokenizer st = new StringTokenizer(Declaration, ",");
while(st.hasMoreElements()){
String token = st.nextToken();
StringTokenizer sttemp = new StringTokenizer(tok... |
601c3753-3df3-40f8-b03c-048c01673f97 | 1 | public void testCompareTo() {
MutableDateTime test1 = new MutableDateTime(TEST_TIME1);
MutableDateTime test1a = new MutableDateTime(TEST_TIME1);
assertEquals(0, test1.compareTo(test1a));
assertEquals(0, test1a.compareTo(test1));
assertEquals(0, test1.compareTo(test1));
as... |
b596bb60-694a-4032-acc7-7cea1a4977e5 | 7 | int binarySearchRotated( int[] A, int target, int start, int end ) {
if( end < start ) return -1;
int mid = (start + end) / 2;
if( A[mid] == target ) return mid;
if( A[start] <= A[mid] ) {
if( target >= A[start] && target < A[mid] ) return binarySearch( A, target, start, mid ... |
a1b89837-74fa-4f6b-8148-e51f4e7cae4f | 4 | private static int[][] calculateDist2(double[][] points,int N) {
int[][] distanceMatrix= new int[N][N];
for(int i=0; i<N;i++){
for(int j=0;j<N;j++){
if(j==i){
distanceMatrix[i][j]=0;
} else if(i<j){
distanceMatrix[i][j]=calculateDistance(points[0][i],points[0][j],points[1][i],points[1][j]);
... |
db3e88bb-11f8-4692-a567-730ae697a132 | 3 | private void drawBlocks(Graphics2D g2) {
g2.fillRect(0, 0, size.width, size.height);
for (int y = 0; y < grid.height; y++) {
double f = (double) y / grid.height;
int green = (int) (120 + f * (240 - 120));
int red = (int) (120 + (1-f) * (240 - 120));
Color ... |
66394a88-f710-4a8f-bb25-a99082377b31 | 8 | private int compareToVersion(Version v) {
int max = Math.max(parts.length, v.parts.length);
String p1[],p2[];
if (max > parts.length){
p1 = new String[max];
System.arraycopy(parts, 0, p1, 0, parts.length);
for (int i=parts.length;i<max;i++){
p1[i] = "0";}
} else {
p1 = parts;
}
if (max > v.p... |
9ed75e85-02a3-4a0e-b7f6-3a58fb8b5881 | 6 | public void setPlayer1HandAtIndex(ImageIcon icon, int index){
if(icon!=null){
switch(index){
case 1:
jlPlayer1Hand1.setIcon(icon);
break;
case 2:
jlPlayer1Hand2.setIcon(icon);
break;
case 3:
jlPlayer1Hand3.setIcon(icon);
break;
case 4:
jlPlayer1Hand4.setIcon(icon)... |
b1146109-10ba-4b99-b4d8-c720b0426681 | 5 | @Override
public Object getValueAt(int rowIndex, int columnIndex) {
ClientMail mail = clients.get(rowIndex);
switch (columnIndex) {
case 0:
return mail.getNom();
case 1:
return mail.getPrenom();
case 2:
return mail.g... |
c4537179-9f0e-4a3d-ae91-04a723f7d84c | 3 | public static boolean createGameDirectory() {
if (OS.contains("win")) {
String env = System.getenv("APPDATA");
gameFolder = getFolder(env, DYSTOPIA);
}
else if (OS.contains("mac")) {
String support = System.getProperty("user.home") + s + "Library" + s + "Application Support";
gameFolder = getFolder(su... |
7a0dd6ad-6a9e-4d5d-8bab-0402809f0ee8 | 7 | public JDialog createDialog(Component owner, boolean modal) {
switch (selectedInteraction) {
case 1:
lj.setLJFunction(Nt.getSigma(), Nt.getEpsilon());
break;
case 2:
lj.setLJFunction(Pl.getSigma(), Pl.getEpsilon());
break;
case 3:
lj.setLJFunction(Ws.getSigma(), Ws.getEpsilon());
break;
case... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.