method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
5ad4af3e-d47c-4ae0-a134-2c395f502b52 | 9 | public String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
InputStream in = this.getClass().getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
Exc... |
f657bde8-457b-4e41-861c-3cd8c35bb07b | 9 | private QCell getStateFromAction(QCell currentState, Action ac) {
int endI = currentState.row;
int endJ = currentState.col;
if (ac == Action.LEFT) {
endJ--;
}
if (ac == Action.RIGHT) {
endJ++;
}
if (ac == Action.DOWN) {
endI++;
}
if (ac == Action.UP) {
endI--;
}
if (endI < 0 || endI... |
756a64dc-ff80-4c97-a55e-8ff11f67bbfc | 1 | public void setParticipantOffline(String id) {
if(participants.containsKey(id)) {
participants.get(id).setOffline();
}
setChanged();
notifyObservers(ModelNotification.LIST_OF_PARTICIPANTS_CHANGED);
} |
797c530a-8d5f-4483-93f2-ba69c052e738 | 0 | public void setFloatArray(float[] floatArray){
this.floatArray = floatArray;
} |
4b858c6a-d57b-443d-9204-73bf01b53140 | 9 | public static Color weightToColor(double weight) {
if (weight < 1e10) return Color.GREEN;
if (weight < 1e12) return Color.CYAN;
if (weight < 1e14) return Color.MAGENTA;
if (weight < 1e16) return Color.BLUE;
if (weight < 1e18) return Color.GRAY;
if (weight < 1e20) return C... |
3fe0238e-5e5e-45fb-a075-b38fee26482a | 4 | public void DDSSpecial()
{
if(IsAttackingNPC && playerEquipment[playerWeapon] == 5698)
{
setAnimation(0x426);
actionTimer = 4;
SpecDamgNPC(31);
DDS2Damg = true;
DDStimer = 1;
resetAnimation();
teleportToX = absX;
teleportToY ... |
562dba3b-8128-450c-bb46-2fa1dcd617ec | 2 | private DataInstance getInputs(){
DataInstance data = new DataInstance(net_layers[0]);
//Rack
int[] cur_rack = rack.getCards();
data.addFeature(cur_rack, game.card_count);
//Probabilities
if (USE_PROB){
double[] pHigh = new double[game.rack_size],
pLow = new double[game.rack_size];
for (int i=0; ... |
5791f378-0250-477c-a059-85cdb7636616 | 0 | protected void jump(String url, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher rd = getServletContext().getRequestDispatcher(url);
rd.forward(request, response);
// request.getRequestDispatcher(url).include(request, response); ??????
} |
ac60d51c-cea7-4372-a1f2-327953a1d3b5 | 0 | @Override
public String toString() {
String result = "\n- Cuenta: " + this.cuenta + ", Cliente: " + this.nombre + ", Saldo: " + this.saldo+"\n";
// result += "\n MOVIMIENTOS: \n" + this.movimientos.toString();
return result;
} |
142fabfb-74f8-4ed3-bdbe-cc4519bdc4e7 | 3 | public boolean Grand (String ip) {
String command = "sudo /bin/bash /portal/rules.sh grand " +ip;
try {
Process process;
process = Runtime.getRuntime().exec(command);
String line;
BufferedReader is = new BufferedReader(new InputStreamReader(process.getInputStream()));
w... |
e5b6b7ed-ff0f-4b96-b502-8b4b88d8cbe2 | 2 | @Override
public void execute(CommandExecutor player, String[] args) {
if (args.length == 0) {
help(player);
return;
}
Command cmd = player.getServer().getCommandHandler().find(args[0]);
if (cmd == null) {
player.sendMessage("The specified command wasn't found!");
return;
}
cmd.help(player... |
054b31ea-9f9c-4382-98bd-378a5f045270 | 4 | public int callCommand(PreparedStatement _sqlCommand, Connection _con)
{
int returnVal = 0;
//Benchmark time start
ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean();
long startTime;
long finishTime;
if (_enableSqlMonitor)
startTime = threa... |
e7dd7ef5-c081-405e-a88e-358ca180b858 | 0 | public void setTitle(String title) {
this.title = title;
} |
96a1b63f-088e-4439-9b41-313e5aef5cc3 | 4 | @Test
public void testWinnerRatio() throws IllegalAccessException, InstantiationException {
Class[] creatureClasses = new Class[] {
Mouse.class,
Rat.class,
BigMouse.class,
BigRat.class
};
for (Class classCreature1 : creatureCla... |
20ead7c3-6388-4424-bad2-f066bf324a68 | 5 | public void send(Envelope envelope) throws IOException {
/* Send all the necessary commands to send a message. Call
sendCommand() to do the dirty work. Do _not_ catch the
exception thrown from sendCommand(). */
String mailFrom = "MAIL FROM: " + envelope.Sender + CRLF;
sendCommand... |
bb111e51-c6be-48f8-9e73-3a030d6f1b53 | 9 | public void move(int x, int y, Entity entity) {
/*
* At some point we have to lock on the entity in order to give it an
* update as to its current location (and direction). If a collision is
* going to occur at this point, we can't have our cake and eat it too:
* it won't be possible to getLocation() of ... |
ad1d8e73-62d4-4bb6-be57-f8301d36a1bb | 8 | public String printResults(boolean all) {
StringBuffer sb = new StringBuffer(100);
double singleMultiRatio = 0.0;
sb.append("Scale factor: " + parameterPool.getScalefactor()
+ "\n");
sb.append("Number of warmup runs: " + warmups + "\n");
if (multithreading)
sb.append("Number of clients: ... |
df94e1e8-62a7-42e2-a1e1-a307f5bb7684 | 5 | public void setMissingDataOption(int option){
if(option<1 || option>5)throw new IllegalArgumentException("The missing response option entered is " + option + "; the option must be 1, 2, 3, 4 or 5");
this.replacementOption = option;
this.replacementOptionSet = true;
if(this.personDeletion... |
bcebd771-13cf-4b14-bb3e-f35f6dea523c | 9 | public Button(int i) {
super(currentfloorplan.getItem(i / N, i % N));
this.setOpaque(true);
this.setBorderPainted(true);
this.setBackground(Color.white);
this.x = i / N;
this.y = i % N;
switch(currentf... |
6d5e0bfd-c430-4a65-a3d4-4ac6fd513e24 | 7 | public static String getDescriptiveType(Object value) {
if (value == null) {
return null;
}
Class<?> clazz = value.getClass();
if (Proxy.isProxyClass(clazz)) {
StringBuilder result = new StringBuilder(clazz.getName());
result.append(" implementing ");
Class<?>[] ifcs = clazz.getInterfaces();
for ... |
a346e0e4-4d32-4615-8a76-26c95b3a5afa | 8 | @Override
public void run() {
int whatdo = Random.nextInt(0, 10);
switch (whatdo) {
case 0:
case 1:
case 2:
case 3:
int currentX = Mouse.getX();
int currentY = Mouse.getY();
Mouse.move(Random.nextInt(0, 20) + currentX, Random.nextInt(16, 39)
+ currentY);
break;
case 5:
case 4:
... |
0b223264-9416-431d-8016-d4d8615155fc | 5 | private LinkedList<Theater> loadTheatersFromDisk(File name){
FileInputStream fis;
ObjectInputStream ois;
Theater theater = null;
LinkedList<Theater> result = new LinkedList<Theater>();
try {
fis = new FileInputStream(name);
ois = new ObjectInputStream(fis);
do{
try{
theater = (Theater) oi... |
ab6aaece-7db5-43f2-acbf-906a3ab8274e | 1 | public static void asm_xorwf(Integer akt_Befehl, Prozessor cpu) {
// Decode
Integer adresse = getOpcodeFromToBit(akt_Befehl, 0, 6);
Integer d = getOpcodeFromToBit(akt_Befehl, 7, 7);
// Fetch
Integer f = cpu.getSpeicherzellenWert(adresse);
Integer w = cpu.getW();
// EXEC: XOR
Integer result = new Inte... |
a7eb2aa4-039a-473e-bbd0-47c49a045d4b | 2 | public static void main(String[] args) {
int len = 10;
Random rand = new Random();
int val;
int max = 20;
Map<Holder<Integer>, Integer> m = new HashMap<Holder<Integer>, Integer>(len);
for (int i = 0; i < len; ++i) {
val = rand.nextInt(max) + 1;
m.p... |
45b3f74a-8825-441f-9aa2-b4a14e5a13b6 | 6 | private void serverNameChanged() {
if (client.getCommunicator() != null) {
popUpWindow dialog = new popUpWindow(this, "Wollen Sie sich wirklich vom Server abmelden ?");
if (dialog.getResult()) {
client.disconnect();
}
}
if (client.getCommunicator() == null) {
isServerOk = (... |
c2106e93-a0af-46ab-aa77-51b1a86e9298 | 1 | public static void main(String... args) throws Exception {
TTransport transport = new TFramedTransport(new TSocket("localhost", 10000));
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
BookService.Client client = new BookService.Client(protocol);
long l = S... |
edf89e61-077a-4124-a3f9-dfda3ba46925 | 7 | public void writeObjectFeatureStart(String name) {
switch (AObjectEnum.valueOf(name.toUpperCase())) {
case NAME:
System.out.print("Name: ");
break;
case MASS:
System.out.print("Mass: ");
break;
case TEMPERATURE:
... |
97343dd0-4cbc-427d-b578-7dd7bb63c3dc | 5 | @Override
public int read() {
// test if the available input has reached its end
// and the EOS should be returned
if (str != null && pos == str.length()) {
str = null;
// this is supposed to return -1 on "end of stream"
// but I'm having a hard time locating the constant
return java.io.StreamTokeniz... |
70fd5e9c-f42a-4712-ba58-b8e9f4a3da07 | 1 | protected void repaint(){
if( site != null ){
site.repaint();
}
} |
e6fb1864-7674-4442-970c-505fc97be549 | 7 | public void playRound(Player player){
boolean cont = true;
Scanner in = new Scanner( System.in );
int roundNumber = 0;
while(!player.getHand(1).isBust() && cont){
roundNumber++;
//check for split....
//options hit, stand or double
if(roundNumber > 1){
System.out.println("Would you like to hi... |
b1ceb7c2-cab1-47a5-a07e-54812ab5fbc6 | 5 | protected int[] clusterIter(int iterNum) {
Smatrix = getSimilarMatrix(oriDatas);
int diffCount = 0;//中心点不变化的次数
for (int i = 0; i < iterNum; i++) {
int diffNum = 0;//在一次迭代中中心点变化的个数
// System.out.println("正在进行第" + i + "次迭代");
//注意,先更新R再更新A
//TODO 更新时是... |
f0a9ef4d-4681-4554-af39-b83470dd266e | 6 | @Override
public void train(List<Instance> instances) {
// calculate the Gram Matrix.
// java List maintains iterator order.
this.instances = instances;
int index1 = 0;
int index2 = 0;
labels = new double[instances.size()];
dualParam = new double[instances.size()];
gramMatrix = new double[instances.si... |
c8b1bf01-03ff-47b3-b938-687473ae313c | 4 | private int[][] createPattern() {
List<Integer> positionNumbers = Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); //indices of the 16 places where a dot COULD be placed
Collections.shuffle(positionNumbers); //randomize their order
List<Integer> dotPositions = positionNumbers.subList(0, 4); //get the first... |
e0ad8969-1f5c-49c9-8344-d0d65d74e16f | 4 | @Override
public void actionPerformed(ActionEvent ev) {
switch(getVector()) {
case UP:
moveUp();
break;
case DOWN:
moveDown();
break;
case LEFT:
moveLeft();
break;
... |
17a7eddb-515f-4f46-8ace-504dfae4f505 | 7 | public void move() {
Random generator = new Random();
int num1 = generator.nextInt(4);
if (num1 == 0) {
x -= 5;
y -= 5;
} else if (num1 == 1) {
x -= 5;
y += 5;
} else if (num1 == 2) {
x += 5;
y -= 5;
... |
49f5d8fc-4d39-4c61-92fd-a33467f7091d | 2 | private Response putAndGetResponse(Behavior target, String client_id)
throws IOException {
Response res;
String baseDir = baseFilePath + File.separator + client_id
+ File.separator + "Target";
// System.out.println(baseDir + File.separator + "Target.xml");
File targetXmlFile = new File(baseDir + File.se... |
0b8b354f-9536-4654-be1f-be0c222f3ffd | 5 | public Dimension getMinimumSize() {
int height = 0;
int width = 0;
//
// Use the size set by the application
//
if (isPreferredSizeSet())
return super.getPreferredSize();
//
// Leave room for the component border
//
Border bor... |
f6c5f10c-4ef4-45b5-84aa-4e4a3d06244c | 1 | public void showDebugGrid(boolean draw)
{
if(draw == true)
{
DRAW_DEBUG_GRID = true;
}
else
{
DRAW_DEBUG_GRID = false;
}
} |
5d3bcdbd-de55-499b-b46b-327389a9c6dc | 0 | public void setFlowSensitiveAliasing(boolean flowSensitiveAliasing) {
this.flowSensitiveAliasing = flowSensitiveAliasing;
} |
d3cd5a9a-dce9-40c5-81b8-c18e29e8b9d1 | 4 | public void valueChanged(ListSelectionEvent e) {
if (refreshing > 0)
return;
// If cell selection is enabled, both row and column change events are fired
if (e.getSource() == table.getSelectionModel()
&& table.getRowSelectionAllowed() && !e.getValueIsAdj... |
b9beccc2-343b-4fbc-bd31-f8858ca33a2b | 3 | public static void main(String[] args) throws ClassNotFoundException, IOException {
/*ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream("test.txt")));
out.writeObject(new Theater(1, "NAME", "THEATER", 1));
out.writeObject(new Theater(2, "NAME2", "THEATER2", 2));
o... |
6c45116b-058f-4a02-a4f8-12603ccf4392 | 0 | public void start() throws IOException{
distributedService = new DistributedService();
distributedService.registerListener(new LockEventListener(this));
distributedService.init();
String msg = "Joined_by: " + ":" + memberid;
//To notify all nodes of the network, that a new member just joined the family.
not... |
cf57d8f1-50b4-4377-9772-64029a6f3381 | 6 | @Override
public void focusLost(FocusEvent event) {
if(event.getSource() == carbohydratePercentageTextField) {
try {
carbohydratePercentageSlider.setValue(Integer.valueOf(carbohydratePercentageTextField.getText()));
} catch(NumberFormatException nfe) {
carbohydratePercentageTextField.setText(String.val... |
540621da-ec4d-4395-a806-afbc8c6f783a | 7 | public static void main(String[] args) {
DataSet data = new DataSet("Creatieve industrie");
Category cat;
String catagoryName = "Creatieve industrie";
GeoCoder geo = new GeoCoder();
SBICode sbiCode = new SBICode();
Rijksdriehoeksmeting rdCalc = new Rijksdriehoeksmeting();
int teller = 0;
Scanner ... |
dc4db549-7f4d-4ca6-978b-a1b700c64240 | 3 | public JSONArray toJSONArray(JSONArray names) throws JSONException {
if (names == null || names.length() == 0) {
return null;
}
JSONArray ja = new JSONArray();
for (int i = 0; i < names.length(); i += 1) {
ja.put(this.opt(names.getString(i)));
}
re... |
1da58142-b928-4074-ac38-955ab3e525d8 | 1 | public static File getLibraryPath(File root) {
String path = INSTANCE.versionData.getStringValue("install", "forge");
String[] split = Iterables.toArray(Splitter.on(':').omitEmptyStrings().split(path), String.class);
File dest = root;
Iterable<String> subSplit = Splitter.on('.').omitEmpt... |
0f6514f7-f27c-46a3-b5b3-fa4d67c6ac34 | 9 | public static void main(String args[]) {
CheckersSetup setup = new CheckersSetup();
UtilityKingWantsCenter test = new UtilityKingWantsCenter();
if(test.getEstimatedUtilityForDarkPlayer(setup, false) != 0) {
System.out.println("Test1 failed!");
}
int array[][] = setup.getPiecesOnBoard();
array[3][3] = ... |
b70be2c9-5a4b-4ea6-8ec4-af323b1b24bb | 9 | public void run(){
//Read input and process here
mainServer.log("Client connecting from " + address);
//DataOutputStream out = null;
try {
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(), true... |
2884f873-4bab-43e5-beeb-3450ae99ecdc | 8 | public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
boolean[] prime = new boolean[1000001];
for (int i = 2; i < 1000000; i++) {
if (!prime[i]) {
for (int j = i + i; j < 1000000; j += i) {
prime[j] = true;
... |
ee4f6b94-5e9b-40ba-b179-6ff746cd2c3e | 5 | public static LinkedListNode findKth(LinkedListNode n, int k) {
if(k<1)
return null;
LinkedListNode quick, slow;
quick = slow = n;
int i;
for(i = 1; i<=k && quick != null; i++ )
quick = quick.next;
if(i != k+1 )
return null;
while(quick!= null) {
quick = quick.next;
slow = slow.next;
... |
6a0f6804-c06c-4381-a600-3a913bc2736a | 8 | public void p_Nickname_abusive_Playforfun(
LinkedHashMap<String, LinkedHashMap<String, String>> credentials) {
autoutil.openBrowser(dataSheet(credentials,"url","url"));
autoutil.waitTime(8000);
autoutil.clickButton(dataSheet(credentials,"button","sign"),propFile("link"));
autoutil.waitTime(3000);
fo... |
83d504a9-50b1-4bd7-85eb-c36b03504808 | 0 | public SpeakerListResponse(final Boolean success, final String errorMessage, final List<Speaker> speakerList) {
super(success, errorMessage);
this.speakerList = speakerList;
} |
44a399b2-61c2-43ab-9977-032c453bae5c | 3 | @Override
public void run() {
ParticleUtil.display(WrapperPlayServerWorldParticles.ParticleEffect.CLOUD, new Vector(0.1 * count.get(), 0.15 * count.get(), 0.10 * count.get()), 0, 4 * count.get(), player.getLocation());
if(count.get() < 12) {
player.setVelocity(new Vecto... |
774d0a4b-403e-4e43-8c14-0e0a903fd239 | 2 | public static void stringToArgs(Vector<String> vec, String s,
boolean allowQuotedStrings) throws StringScanException {
StringScanner scanner = new StringScanner(s);
scanner.skipWhiteSpace();
while (!scanner.atEnd()) {
if (allowQuotedStrings) {
vec.add(scanner.scanString());
} else {
... |
2fcc82f5-55da-4134-b303-9e52b90ada46 | 9 | public static final String getCommonRoot(String fullPathOne, String fullPathTwo) {
int i;
int len1;
int len2;
int max;
if (fullPathOne == null) {
len1 = 0;
} else {
fullPathOne = fullPathOne.replace('\\', '/');
len1 = fullPathOne.length();
}
if (fullPathTwo == null) {
len2 = 0;
} else {
... |
759eb5ba-2c86-418d-b414-c769bfd317d8 | 6 | public void hardShot() throws IOException {
if (0 == stackSize) {
target = new Point(rand(), rand());
numAttempts = 0;
while (!testChoice(target, 1)) {
target = new Point(rand(), rand());
}
if (board.fire(target.x, targe... |
a2e8e495-0911-4e9c-8ef8-7cc331a9b812 | 6 | public int agregarCliente(String name, String surname1, String surname2, String mail, String DNI, String telefono, String contact_date, String transaccion) {
boolean Nocaracter = validarFormato(name);
boolean Nocaracter2 = validarFormato(surname1);
int condicion = 0;
//... |
f6fb3a7d-056a-4bf8-be4d-fffe15f6b823 | 0 | @AfterClass
public static void tearDownClass() {
} |
bba50829-5c48-4fb6-a945-fffb54eef1c0 | 7 | void enq(query q)
{
if (q.getCnode()==null)
{
common.out("Enq query is null");
Thread.dumpStack();
System.exit(0);
}
if (parentq==null) q.pqid=q.qid;
else q.pqid=parentq.qid;
query tq;
for (int i=0;i<qbuf.size();i++)
{
tq=qbuf.get(i);
if (tq.getCnode().getId()==q.getCnode().getId() && ... |
1bdfe3f1-4c72-4e9f-a5af-df0ab960753d | 9 | public void intialize(){
try{
//store local machines IP and name
InetAddress addr = InetAddress.getLocalHost();
PeerInfo.local.IP = addr.getHostAddress();
PeerInfo.local.name = addr.getHostName();
PeerInfo.local.ID = "rmi://" + PeerInfo.local.IP + ":" + PeerInfo.rmi.port + "/share";
System.out.print... |
85b9be0c-a9ac-4b87-8eb9-8314a6d4b3a1 | 0 | public int getImgIndexedColors() {
return imgIndexedColors;
} |
be52f978-406c-4f44-b9f8-58596ae6f4ae | 5 | static LinkedListNode partition(LinkedListNode n, int p) {
LinkedListNode beforeHead = null;
LinkedListNode beforeTail = null;
LinkedListNode afterHead = null;
LinkedListNode afterTail = null;
while (n != null) {
if (n.getValue() < p) {
if (beforeHead... |
2ba6d3c8-b7cc-4202-b57c-66a7669df1b6 | 3 | @Override
public void put( ByteBuffer out, boolean[] v )
{
if (v == null)
{
out.put( Compress.NULL );
}
else
{
Compress.putIntUnsignedNullable( out, v.length );
byte[] bytes = new byte[toBytes( v.length )];
for (int i = 0; ... |
8bbdb680-c53b-4ab0-b2f6-cd64e439d047 | 8 | public void update(final Observable obj, final Object arg) {
final String line = (String) arg;
final String thisLine = line.substring(line.indexOf("Text [") + "Text [".length(), line.indexOf("]", line.indexOf("Text [")));
if (thisLine.indexOf(CLUSTER_RADIO_SEND) < 0) {
return;
... |
722bd960-a939-4395-8a76-cca1691b52f5 | 3 | public boolean insertAfter(int key, int value)
{
NodeDLL current = first;
while(current.data!= key)
{
current = current.next;
if (current == null)
return false;
}
NodeDLL newNodeDLL = new NodeDLL(value);
if(current == last)
{
newNodeDLL.next = null;
last = newNodeDLL;
}
else
{
ne... |
f7b13adc-20d9-4bdf-bfcd-8deb8d97c4e4 | 8 | public String getURL(String address){
String URL = address;
if(!URL.startsWith("http://")){
URL = "http://" + address;
}
String domain = URL;
if(!URL.endsWith("/") && !URL.endsWith(".html") && !URL.endsWith(".shtml") && !URL.endsWith(".htm") && !URL.endsWith(".aspx") ... |
33d392ed-a33f-4227-92fc-ae546fedbb94 | 4 | @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == startStop){
if(recording){
Recorder stopper = (Recorder) theRecorder;
stopper.getLine().close();
recording = false;
startStop.setText("Start Recording");
backButton.setEnabled(true);
} else if(!recordi... |
fd49905a-2448-4658-8bb4-d9e3b7076c1d | 9 | @Override
public String getSVG( HashMap<String, Double> chartMetrics, HashMap<String, Object> axisMetrics, ChartSeries s )
{
double w = chartMetrics.get( "w" );
double h = chartMetrics.get( "h" );
double max = chartMetrics.get( "max" );
double min = chartMetrics.get( "min" );
Object[] categories = s.getCate... |
6976323c-e2db-423a-8400-ce959d3573b8 | 6 | private void combinationUtil(int arr[], int data[], int start,
int end, int index, int r) {
if (index == r) {
int sum = 0;
for (int j = 0; j < r - 1; j++) {
for(int k=j+1;k<r;k++){
sum+=compatibilityArr[data[j]][data[k]];
}
}
// System.out.println("sum = "+sum);
if (sum > maxTeamComp... |
a655c56f-e01f-46c0-8307-491551165548 | 4 | private void changeResolution(int res) {
if (resolution == resolutionSelections.length-1) {
increase.setEnabled(false);
decrease.setEnabled(true);
answer = true;
} else if (resolution == 0) {
decrease.setEnabled(false);
increase.setEnabled(true);
answer = false;
} else {
increase.setEnabled(t... |
c6dc71a6-b1fb-4bf7-8fae-2a9e61d6f8d4 | 5 | @Test
public void testSaleAll() throws Exception
{
TestTicketPool pool = this.createTicketPool();
int stopCount = pool.getRoute().getStops().size();
TicketPoolQueryArgs query = new TicketPoolQueryArgs();
query.setCount(1);
query.setSeatType(~0);
ArrayList<TicketPoolTicket> soldTickets = ... |
c289f0ad-31c5-4948-bb70-cadfb3b8b902 | 3 | public void bfs(UndirectedNode root) {
Queue<UndirectedNode> queue = new LinkedList<UndirectedNode>();
queue.add(root);
root.visited = true;
while (!queue.isEmpty()) {
UndirectedNode curNode = queue.poll();
System.out.println(curNode.data + " ");
for (... |
8b980a19-d2ed-4744-80f7-a89b6ac36542 | 1 | public void testGet_DateTimeFieldType() {
LocalDateTime test = new LocalDateTime(1970, 6, 9, 10, 20, 30, 40);
assertEquals(1970, test.get(DateTimeFieldType.year()));
assertEquals(6, test.get(DateTimeFieldType.monthOfYear()));
assertEquals(9, test.get(DateTimeFieldType.dayOfMonth()));
... |
3eba19c5-1279-4d95-879a-68cfcea6be5d | 9 | @Override
public void subscribeSource(ClientSenderInterface sender, ResultData initialData) throws OneSubscriptionPerSendData {
DataDescription dataDescription = initialData.getDataDescription();
if((sender == null)) throw new IllegalArgumentException("Parameter 'sender' ist null");
if((dataDescription == null)... |
b12e2fe8-80ee-4c9e-9965-08ad0c180fca | 9 | public void nextPermutation(int[] num) {
// error checking
if (num == null || num.length <= 1) {
return;
}
// find the rightmost i-1/ith pair s.t num[i-1]<num[i]
int r = num.length, l = num.length;
for (int i = num.length - 1; i >= 1; i--) {
if (num[i] > num[i - 1]) {
r = i;
l = i - 1;
bre... |
76e1669a-e824-42df-b035-cc5da00a209f | 3 | @Override
public void paintComponent(final Graphics g) {
// Check if we have a running game
super.paintComponent(g);
g.setColor(this.getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
if (this.model != null) {
// Draw all tiles by going over them x-wise and y-wise.
for (int i = 0; i < this.... |
c7c5ffc5-7821-401e-901f-81fa42dd34dd | 3 | protected Object buildXPath(final String query, final boolean moreNodes) {
try {
XPathExecutable x = xPathCompiler.compile(query);
XPathSelector selector = x.load();
selector.setContextItem(this.contextItem);
XdmValue value = selector.evaluate();
if (moreNodes) {
String[] list... |
3ae368b5-6425-4b4b-9173-23d6cfb1342d | 3 | public static String replaceWithUsrProps(String src,Properties props){
Pattern pattern = Pattern.compile("\\$\\{([^\\?}]+)(\\?([^}\\?]+))?\\}");
Matcher matcher=pattern.matcher(src);
while(matcher.find()){
String key = matcher.group(1);
String methodName = matcher.group(3... |
0e261506-e001-4235-97c3-3f0572d954e4 | 8 | private void updateImportEnablement() {
boolean isEnabled = prefLoadButton.getSelection();
prefPathTable.setEnabled(isEnabled);
prefFileAddButton.setEnabled(isEnabled);
boolean isConfig = isEnabled;
boolean isSelOne = isEnabled;
boolean canMoveUp = false;
boolean canMoveDown = false;
if (isSelOne)... |
65acf0c7-2a1f-49cd-ab95-ef2ec662d227 | 6 | public void exportAsImage() {
final JDialog dlog = new JDialog();
dlog.setTitle("Select Output Image Format");
dlog.getContentPane().setLayout(new BorderLayout());
dlog.setModal(true);
JPanel ctrlPanel = new JPanel();
ctrlPanel.add(new JLabel("Format:"));
String ... |
1b71ab7f-fc4c-4a26-8d66-684ecb01b66d | 1 | public boolean authenticate() throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
String user = in.readLine();
String pass = in.readLine();
BufferedReader br = new BufferedReader(new FileReader(
"C:\\Users\\aawor_000\\workspace\\TCPServer\\src\... |
c915c9ee-443e-45f9-9e0d-c59dc9f665f4 | 2 | public void add(Admin admin) throws DAOPoikkeus, InvalidAdminPoikkeus{
Connection connection = avaaYhteys();
//Katsotaan, että löytyykö samalla käyttäjänimellä käyttäjä, jos löytyy, niin lähetetään virhe
PreparedStatement usernameLookup;
try {
usernameLookup = connection.prepareStatement("select username ... |
e32735a7-7f4f-474b-b066-a52d3831527b | 6 | public String nextCDATA() throws JSONException {
char c;
int i;
StringBuffer sb = new StringBuffer();
for(;;) {
c = next();
if(end()) {
throw syntaxError("Unclosed CDATA");
}
sb.append(c);
i = sb.length() - 3;
if(i >= 0 && sb.charAt(i) == ']' &&
sb.charAt(i + 1) == ']' && sb.charAt(i ... |
33a2baf6-f9c5-4ca1-b654-0685a7ecc8b2 | 8 | public void registerWidgetClass(final Class<? extends FormWidget> widget) {
try {
final Constructor<? extends FormWidget> c = widget
.getConstructor(String.class);
final FormWidget fw = c.newInstance(widget.getSimpleName());
this.addWidget(fw);
} catch (final SecurityException e) {
// TODO Auto-gen... |
f0c03726-93d8-4539-8872-f4f48ed6c07c | 9 | static void rewriteResponseHeaders(URLConnection conn,
HttpServletResponse resp) {
Map<String, List<String>> map = conn.getHeaderFields();
if (map != null) {
for (Map.Entry<String, List<String>> header : map.entrySet()) {
if (header.getKey().equals("content-length")) {
continue;
}
if (header.... |
db272ac5-dba7-49e0-9d3e-84973d6cfb06 | 1 | public static boolean password(String pass){
if(pass.matches("(\\w){8,30}"))
return true;
return false;
} |
d3ce818a-126d-46ee-ad2e-fee348140f4f | 1 | private void check(final String txtToParse, final char delim, final char qualifier, final String[] expected) {
final List splitLineResults = ParserUtils.splitLine(txtToParse, delim, qualifier, 10, false, false);
assertEquals("Did Not Get Amount Of Elements Expected (d = " + delim + " q = " + qualifier ... |
1f526e37-231e-45fa-8b30-34de28a64d21 | 2 | private boolean updateBufferedOperation(int index, Operation op ) {
if(bufferedOperation.containsKey(index) ) {
Operation alreadyWaitOp = bufferedOperation.get(index);
if(transactions.get(alreadyWaitOp.getRWinfo().get(0)).isOlder(transactions.get(op.getRWinfo().get(0)))) {
// transaction waiting for the var... |
7db101d3-df0b-4333-8aa9-0cd3e5c975b9 | 0 | public Set keySet() {
return this.map.keySet();
} |
8bb1e16b-97c3-45a6-aa65-6329676d380d | 9 | public void handleEvents(List<PrioritizableStageDriver> drivers, List<StageProcessTimingEvent> events) {
if (events.isEmpty()) {
return;
}
Map<Stage, Tuple> timings = new HashMap<Stage, Tuple>();
long total = 0;
for (StageProcessTimingEvent ev : events) {
... |
20bf1e46-e94b-4436-8e5d-63e9f83300a2 | 3 | public String toStringAsciiArt(int maxLen) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < maxLen; i++) {
if ((i >= start) && (i <= end)) sb.append('-');
else sb.append(' ');
}
return sb.toString();
} |
1fea604e-dae7-43b9-a20f-d3c7876e0fc5 | 4 | public static Map<String, Object> getHasMany(Object obj) throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
for (Field field : obj.getClass().getDeclaredFields()) {
Class<?> fieldType = field.getType();
String fieldName = field.getName();
Annotation[] annotations = field.getDecla... |
ebd1c608-6fd9-4423-b976-388f02775bdc | 9 | public boolean isValidSudoku(char[][] board) {
for (int i = 0; i < 9; i++) {
boolean[] pos1 = new boolean[board.length];
boolean[] pos2 = new boolean[board.length];
for (int j = 0; j < 9; j++) {
char c1 = board[i][j];
char c2 = board[j][i];
... |
6ecdba96-84aa-4b48-921a-d4c569ac789a | 6 | @SuppressWarnings("unchecked")
public static <T extends Number> T getNeutralMulElem(Class<T> type) {
switch (type.getSimpleName()) {
case "Double":
return (T) (new Double(1.0));
case "Float":
return (T) (new Float(1.0));
case "Byte":
return (T) (new Byte((byte) 1));
case "Short":
return... |
51d8cd03-f884-4995-a9f6-ee4c83ca4b35 | 7 | public void testPresent6() {
try {
TreeNode tree = new TreeNode("root", 2);
tree.branch[0] = mkChain(new String[]{ "label1", "label2" });
tree.branch[1] = mkChain(new String[]{ "label3", "label4" });
TreeNode result = contains(tree, new TreeNode("label4"));
... |
4af382dd-0687-49a5-9316-b4b12b88bad1 | 5 | public void stateChanged(ChangeEvent e) {
if(imageMat != null){
int oldIdx = viewTabs.getSelectedIndex();
viewTabs.removeAll();
viewTabs.addTab("Output", null, outputViewPanel, null);
viewTabs.addTab("Overlay", null, overlayViewPanel, null);
Mat localMat = imageMat.clone();
Mat overlayMat = new Mat... |
e3bfe386-50a1-4923-8378-0203b3602024 | 1 | private static ByteBuf toByteBuf(String wiresharkCopy) {
ByteBuf bb = Unpooled.buffer();
char[] charArray = wiresharkCopy.toCharArray();
for (int i = 0; i < charArray.length; i += 2) {
char one = charArray[i];
char two = charArray[i + 1];
bb.writeByte(Byte.parseByte("" + one + two, 16));
}
return b... |
5d9b0f77-8852-4375-a815-0e4a69a8fe92 | 3 | public String readThing() {
// skip whitespace
// System.out.println("PAParser: whitespace: \"");
while (PDFFile.isWhiteSpace(data[loc])) {
// System.out.print (new String(data, loc, 1));
loc++;
}
// System.out.print("\": thing: ")... |
670cca66-bf4c-4c97-b53c-30fbecb245b7 | 7 | static void assignBands(float rnd, int[][] pal, int split, int cur) {
float hue, sat;
int place = (256 / split) * cur;
for (int i = 0; i < 256; i += split) {
if (i <= 60) {
hue = (float) (i) / 420.0f;
sat = (i / 60.0f) * 0.2f + 0.8f;
} else if (i > 60 && i <= 120) {
hue = (float) (i) / 500.0f;
... |
ace448ec-0856-4936-b623-706a1f6b27b7 | 1 | private void indent(Node node, StringBuffer buf) {
for (int i = 0, limit = node.getDepth(); i < limit; i++) {
buf.append("\t");
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.