method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
e8661589-b5a6-40d7-9d05-f236d363ecef | 6 | public void testApp() {
// Create a map object
TS3Map map = new TS3Map();
// Test the parseMapEntry() method
Map.Entry<String, List<String>> entry = null;
entry = map.parseMapEntry("name=value");
assertEquals(entry.getKey(), "name");
assertEquals(entry.getValue(... |
f590ce0f-9eea-46a8-8a92-a597e80231ab | 5 | private void setAutoSizeDimension() {
if (!autoSize) {
return;
}
if (image != null) {
if (image.getHeight(null) == 0 || getHeight() == 0) {
return;
}
if ((getWidth() / getHeight()) == (image.getWidth(null) / (image.getHeight(null)))... |
46b69630-90c0-44b0-b9eb-552027abaee7 | 5 | public boolean kopt(Kswap2 kswap, int[] rightCuts, int i, int length,int k,int index, boolean first){
if(k==0){
// System.out.println("doing k swap on: "+Arrays.toString(rightCuts));
return kswap.startFindBestSolution(rightCuts);
}
int limit=length;
boolean improved=false;
for(int iters=0; iters<limit;... |
b2371be9-e4b8-43a6-8c39-5ae3899fac5d | 8 | public void moveLeft() {
setDirection(-90);
for (TetrisBug tb : blocks){
tb.setDirection(-90);
}
if (rotationPos==0){
if (canMove() && blocks.get(1).canMove()) {
blocks.get(1).move();
move();
blocks.get(0).move();
blocks.get(2).move();
}
}
if (rotationPos == 1){
if (bloc... |
af205a05-6a44-495f-bd48-b5a3b96df549 | 5 | private void rotateObject(PolygonObject toRotate, float x, float y) {
int yRotate = 10;
// maus koordinatensystem transformieren fuer rotation
// sprich: verschiebe nach unten rechts
x = x + 0.5f;
y = y + 0.5f;
if (toRotate != null) {
// x-Rotation bewusst k... |
45a2687c-d4fe-4a07-9437-a7417504818f | 9 | private Data[] executeCommandsOnNodes(int commandType, final Command[] commands) throws InterruptedException{
final int maxCounterMsg;
if(commandType == Command.INSERT_TABLE){
maxCounterMsg = 2;
}else{
maxCounterMsg = numberOfNodes;
}
final CountDownLatch latch = new CountDownLatch(maxCounterMsg);
fin... |
cd9e3624-068d-48f9-9b6a-972a0229b9e5 | 6 | public SeasonCreatePanel() {
// ------instantiations-------
lblWelcomeText = new JLabel("Welcome to SurvivorPool!");
lblInfoText = new JLabel(
"Fill out the fields below to create a new season.");
lblWeeks = new JLabel("Weeks:");
lblContestants = new JLabel("Contestants:");
lblTribe1 = new JLabel("Trib... |
101544d4-a878-4a4b-868e-e2499b401a23 | 5 | private void delete(int row) {
if (!MyFactory.getResourceService().hasRight(MyFactory.getCurrentUser(), Resource.CONSUMPTION_W)) {
return;
}
Consumption selectedRow = result == null ? null : result.get(row);
if (selectedRow != null) {
if (JOptionPane.showConfirmDi... |
1bc25873-bf20-4758-8479-5ae45918b216 | 1 | public synchronized boolean remover(int i)
{
try
{
new AreaFormacaoDAO().remover(list.get(i));
list = new AreaFormacaoDAO().listar("");
preencherTabela();
}
catch (Exception e)
{
return false;
}
return true;
} |
9fefb378-74f4-4dce-856a-b9689487e8d9 | 1 | public void addTelefone(Telefone t){
if(!telefones.contains(t)){
this.telefones.add(t);
}
} |
72468e51-76f8-4d1f-bddb-32bab28a41f5 | 1 | private String executeCommand(String commandAsStr) {
String response;
try {
response = client.sendRequestToServer(commandAsStr);
} catch (HttpClientException e) {
response = e.getMessage();
}
return response;
} |
181087c4-4ace-45a9-9eac-7baef14693b4 | 7 | public static final boolean addClass(final CMObjectType type, final CMObject O)
{
final Object set=getClassSet(type);
if(set==null)
return false;
CMClass.lastUpdateTime=System.currentTimeMillis();
if(set instanceof List)
{
((List)set).add(O);
if(set instanceof XVector)
((XVector)set).sort();
}... |
8ac47ed5-00a0-4786-95d1-470abea74252 | 3 | public void remover(int codigo) throws ProdutoException {
Produto prod = null;
if(codigo < 0)
throw new ProdutoException("CÛdigo inv·lido. Valor informado È menor que 0.");
try {
prod = buscarProduto(codigo);
} catch (ProdutoException pe) {
throw pe;
}
if(prod != null)
produtos.remove(prod);
... |
d2c1f3c4-0734-4305-bec2-fbbe02e5b8a3 | 4 | public boolean isFirstCharZero(String s)
{
if (s.length() < 1)
{
return false;
}
else
{
// 12:(00) is een uitzondering bij het detecteren van leading zero's
if (s.length() > 1 && s.charAt(0) == '0' && s.charAt(1) != '0')
{
return true;
}
return false;... |
04d6d3b0-6f97-4f76-bee2-4b2609bce0da | 5 | private String adapter(String key) {
String aRetourner="";
for(int i=0;i<key.length();i++) {
if(key.charAt(i)>=65 && key.charAt(i)<=90) {
aRetourner+=key.charAt(i);
}
if(key.charAt(i)>=97 && key.charAt(i)<=122) {
aRetourner+=(char)(key.charAt(i)-32);
}
}
return aRetourner;
} |
07eb3c9f-da07-4a9d-b4f0-9ebf83eb5389 | 8 | public void right()
{
if (mState != jumping && mState != beginJump && mState != ducking && mState != hardLanding)
{
facing = right;
mState = running;
if (heroxSpeed < 0)
heroxSpeed = .5f;
else if (heroxSpeed < 4)
heroxSpeed += .5f;
}
else if (mState == hardLanding)
heroxSpeed *= .9;
... |
9bbfebe9-4444-43f1-98f7-577e5e6f4cdb | 2 | private boolean checkFront(int x, int y, int z){
int dx = x + 1;
if(dx > CHUNK_WIDTH - 1){
return false;
}else if(chunk[dx][y][z] != 0){
return true;
}else{
return false;
}
} |
fd2450f0-0752-445d-8766-d88c53259a14 | 2 | @Override
public void removeAttribute(String key) {
if (attributes != null) {
if (key == null) {
key = "";
}
this.attributes.remove(key);
this.isReadOnly.remove(key);
}
} |
8598b0c9-5fc1-4dd0-a7ab-54b7344a7980 | 1 | public double AverageScore()
{
double sum = 0;
for (QuizResult qr: quizResults)
{
sum += qr.PercentScore();
}
double avg = sum / quizResults.size();
return avg;
} |
8b9a0ed1-5a25-47c9-aaa2-c7cfc5681e5b | 6 | private void outputExcel(int orderChoice){
FileOutput fout = new FileOutput(this.outputFilename);
fout.println(title[0]);
fout.println((this.nItems));
fout.println(this.nPersons);
for(int i=0; i<this.nItems; i++){
fout.printtab(this.itemNames[i]);
}
f... |
f6244dee-5c2c-4faa-9cf7-9b65c44fa3a1 | 1 | public void calcBonusUnite() {
// Calcul des gains d'unités si pouvoir spécial
int bonusUnite = this.bonusUnite() + (hasPower() ? this.pouvoir.bonusUnite() : 0);
bonusUnite = Math.min(this.nbUniteMax - this.nbUnite, bonusUnite);
this.nbUnite += bonusUnite;
this.nbUniteEnMain += bonusUnite;
} |
1cb57911-39a1-4693-81fc-379f6edcc53d | 1 | *
* @return <tt>true</tt> iff the query is true in the knowledge base
*
* @throws IOException if a data communication error occurs
* @throws CycApiException if the api request results in a cyc server error
*/
public boolean isQueryTrue_Cached(CycList query,
CycObject mt)
throws IOEx... |
6e754b7d-bdd0-40c0-9b37-bba260f8dee6 | 5 | public void setShutdownmenuButtonPosition(Position position) {
if (position == null) {
this.buttonShutdownmenu_Position = UIPositionInits.SHDMENU_BTN.getPosition();
setShutdownframeBorderlayout(false);
} else {
if (!position.equals(Position.LEFT) && !position.equals(... |
a9aee2bd-6001-457c-9866-7ce13bb4fa08 | 8 | private void FindNodes() {
if (current.loc.x-1>=0&&unit.PathCheck(current.loc.x-1, current.loc.y)) {
AddNode(current.loc.x-1,current.loc.y);
}
if (current.loc.y-1>=0&&unit.PathCheck(current.loc.x, current.loc.y-1)) {
AddNode(current.loc.x,current.loc.y-1);
}
if (current.loc.x+1<Game.map.width&&unit.Path... |
d668a112-cb43-485a-b6bd-b78646280aed | 0 | private boolean areTriesLeft() {
return gpm.getMaxTries() >= grid.getIntellingentMovementHistory()
.size();
} |
ced76869-b5ae-4371-946c-6391c6586cda | 3 | private void btnUploadSkinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUploadSkinActionPerformed
if (fcSkin.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
File skinFile = fcSkin.getSelectedFile();
if (skinFile.exists() && skinFile.canRead()) {
... |
1adf4cab-e298-42dc-b82d-e53e917e2531 | 9 | public void generatePath(Vector2 bestStartPoint)
{
Segment2D prev = null;
if (layer.skirt != null)
{
Polygon poly = layer.skirt.getLargestPolygon();
if (poly != null)
{
prev = poly.closestTo(bestStartPoint);
layer.pathStart = prev;
prev = poly.cutPoly(prev);
}
}
for (int i = 0; i < l... |
27179795-e218-4099-93f8-efa5e831f0d2 | 0 | public SpecifiedActionListener(GUI gui, String text, boolean leaveZero) {
this.gui = gui;
this.text = text;
this.leaveZero = leaveZero;
} |
5b5ed771-5a76-4bd3-a2a2-7a0fa2bb0549 | 3 | @Action(name = "hcomponent.handler.onclick.invoke", args = { "undefined" })
public void onClickInvoke(Updates updates, String[] args, String param) {
HComponent<?> html = (HComponent<?>) Session.getCurrent().get(
"_hcomponent.object." + param);
if (html.getOnClickListener() != null)
Session.getCurrent()
... |
0e2c81fd-383e-40b4-83e1-e1b35fb4b088 | 8 | public void testBinaryCycAccess16() {
System.out.println("\n**** testBinaryCycAccess 16 ****");
CycAccess cycAccess = null;
try {
try {
if (connectionMode == LOCAL_CYC_CONNECTION) {
cycAccess = new CycAccess(testHostName, testBasePort);
} else if (connectionMode == SOAP_CYC_... |
7875fdad-f0e0-42c3-ae0b-b487a5fff840 | 2 | private void copyBack(int[][] origin, int iStart, int iEnd, int jStart, int jEnd, int[][] subMatrix) {
for (int i = iStart; i < iEnd; ++i)
for (int j = jStart; j < jEnd; ++j)
origin[i][j] = subMatrix[i-iStart][j-jStart];
} |
88a85e40-ba49-41ae-a0e7-b2404d6236af | 4 | @Test
public void test_mult_skalar() {
int a = 2;
int b = 3;
int skalar = -4;
Matrix m1 = new MatrixArrayList(a, b);
Matrix m2 = new MatrixArrayList(a, b);
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++)
m1.insert(i, j, (double) (2 * i - j));
}
for (int i = 1; i <= a; i++) {
for... |
6f43ca06-c7c8-4f65-b010-ec6c432a4ca7 | 5 | private void createHdr() {
hdrData = new float[width * height * 3];
double[] relevances = new double[width * height];
int color;
double red, green, blue;
boolean isPixelSet;
for (int i = 0; i < width * height; i++) {
isPixelSet = false;
for (MyIma... |
bd8cb92f-23ac-4a50-a783-e7598018567b | 7 | public int getDirectionFacing(){
if( controller.getY() == 1 && !isOnGround ){
facingDown = true;
} else if( controller.getY() == 1 ) {
this.currentPosition.y--;
this.oldPosition.y--;
} else {
facingDown = false;
}
if (controller.getX() < 0 && directionFacing != -1){
directionFacing = -1;
ret... |
a1f364bc-8841-476f-a35c-3098246a828d | 5 | public void load() {
String line, lineBeforeComment;
String[] tokens;
try {
BufferedReader fin = new BufferedReader(new FileReader(fileName));
try {
while ((line = fin.readLine()) != null) {
tokens = line.split("#");
if (tokens.length > 0) {
lineBeforeComment = tokens[0];
tokens... |
b4998d3a-5b34-4b9f-a540-530018528caf | 0 | public static void main(String[] args) {
String mango = "mango";
String s = "abc" + mango + "def" + 47;
// StringBuilder sb = new StringBuilder();
// sb.append("abc");
// sb.append(mango);
// sb.append("def");
// sb.append(47);
// s = sb.toString();
System.out.println(s);
} |
c2364cde-a610-433c-adc2-005266af1416 | 3 | private static void printGridletList(GridletList list, String name,
boolean detail)
{
int size = list.size();
Gridlet gridlet = null;
String indent = " ";
System.out.println();
System.out.println("============= OUTPUT for " + name ... |
3e9d026c-96cf-496c-8b6f-9dc23b0291dd | 9 | public Map<Integer, Double> getRankedTagList(int userID, int resID) {
Map<Integer, Double> resultMap = new LinkedHashMap<Integer, Double>();
if (this.userMaps != null && userID < this.userMaps.size()) {
Map<Integer, Double> userMap = this.userMaps.get(userID);
Map<Integer, Double> recMap = this.tagRecencies.g... |
4220bed9-81a2-482a-8e65-8d88e2b5e80e | 8 | public void clearEmptyLines(Set<Entry<String, List<String>>> entrySet) {
for (Entry<String, List<String>> entry : finalFiles.entrySet()) {
ArrayList<String> tempArray = new ArrayList<>();
tempArray.addAll(entry.getValue());
for (ListIterator<String> itr = tempArray.listIterator(); itr.hasNext(); ) {
... |
43dea56f-bd6e-44b6-9792-d496e1ebfbcf | 6 | public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if (!plugin.hasPerm(sender, "tp", false)) {
sender.sendMessage(ChatColor.YELLOW
+ "You do not have permission to use /" + label);
return true;
}
if (args.length == 0) {
plugin.getServer().broadcastMess... |
1eb98231-1436-4198-81e1-ce265c19422d | 4 | @Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
setUser((User) session.get("User"));
Date date = new Date();
System.out.println("--------------------------------------------------" + existrate);... |
2cdaeb77-f99d-4174-9afc-34a7ae120a80 | 8 | static Field getStaticField(Class<?> c,String key) throws DetectRightException {
if (c == null) return null;
if (Functions.isEmpty(key)) return null;
Field f;
try {
f = c.getDeclaredField(key);
return f;
} catch (NoSuchFieldException e) {
CheckPoint.checkPoint("Get Field 2" + key + " " + c.toString(... |
417814b0-04f8-4c89-931e-adc7808cb4c0 | 7 | @Override
public boolean execute(CommandSender sender, String[] args) {
if(!(sender instanceof Player)) {
return true;
}
String username = sender.getName();
String name = args[0];
Group group = groupManager.getGroupByName(name);
if(group == null) {
sender.sendMessage("Group doesn't exist");
... |
ee9d4e81-816e-4550-aa9e-f8a348a9fe31 | 7 | private void findMiddle(String s) {
ArrayList<Integer> operations = new ArrayList<Integer>();
// compile the index of each operator
for(int i = 0; i < s.length(); i++) {
if( s.charAt(i) == OR || s.charAt(i) == AND || s.charAt(i) == IMPLY) {
operations.add(i);
}
}
// if there is only one operat... |
043e8639-0a98-41dd-9b7b-f21e669b853e | 4 | public Stability getLackingStabilityForType(DiscType discType){
LOGGER.log(Level.INFO, "Determining lacking stability rating for disc type " + discType);
Bag tDiscs = getDiscsByType(discType);
if (tDiscs.size() == 0) { return Stability.STABLE; }
float stablePct = (float)(tDiscs.getDiscsWithStability(Stabi... |
6953a4b0-1036-4fc0-bcc2-84236abfb4b2 | 9 | public Vector apply(Vector b, Vector x) {
if (!(b instanceof DenseVector) || !(x instanceof DenseVector))
throw new IllegalArgumentException("Vectors must be a DenseVectors");
int[] rowptr = F.getRowPointers();
int[] colind = F.getColumnIndices();
double[] data = F.getData()... |
a2246d79-34f1-4b8e-869b-10826e6147b4 | 8 | private boolean isAlreadyExecuted() throws DomainToolsException{
boolean res = false;
if(format.equals(DTConstants.JSON) && !responseJSON.isEmpty()
|| format.equals(DTConstants.HTML) && !responseHTML.isEmpty()
|| format.equals(DTConstants.XML) && !responseXML.isEmpty()
|| format.equals(DTConstants.OBJEC... |
20d94262-f1e1-4dc6-b0ef-874c4758c519 | 1 | public void visitAttribute(final Attribute attr) {
checkEndMethod();
if (attr == null) {
throw new IllegalArgumentException(
"Invalid attribute (must not be null)");
}
mv.visitAttribute(attr);
} |
21d4093e-9a4e-4a78-9968-f7ccca4d278f | 3 | /*package*/ static void init() {
defaultProperty = new Properties();
defaultProperty.setProperty("weibo4j.debug", "true");
// defaultProperty.setProperty("weibo4j.source", Weibo.CONSUMER_KEY);
//defaultProperty.setProperty("weibo4j.clientVersion","");
defaultProperty.setProperty("... |
9e65e5f1-4724-42f5-9091-16e63823d567 | 2 | public Polynomial monic() throws Exception {
if (coeff.length == 0) return this; // 0
if (head() == 1L) return this; // already monic
return mul(PF.inv(head()));
} |
1fd786c9-a894-45ec-9dd1-abb2e11a03ad | 8 | @Override
protected void initiate()
{
// Create a menu to add all of the input fields into
menu = new TMenu(0, 0, Main.canvasWidth / 4, Main.canvasHeight, TMenu.VERTICAL);
menu.setBorderSize(5);
add(menu);
// Simulation parameters
depthNumberField = new TNumberField(0, 0, 125, 25, 4); // l... |
50a4a101-8853-4540-8040-74c2085ddc93 | 4 | public static void main(String Args[]) {
int i = 0;
long l = 0;
for (i = 0; i < perfectarray.length; i++) {
// l = i * i;
// if (issquaredigitsquare(l)) {
array[perfectarray[i]] = true;
// System.out.println(perfectarray[i]);
// System.out.print(",");
// }
}
Scanner sr = new Scanner(Syste... |
cab54bb9-2827-41f0-aece-b21116f1a330 | 3 | public static String getStackTrace(Exception ex) {
if (ex == null) {
return "";
}
Object [] traces = ex.getStackTrace();
if (traces == null) {
return "";
}
String s = "";
for (Object trace : traces) {
s += " " + trace.toString() + "\r\n";
}
return s + "\r\n";
} |
bd7c1ec8-b698-4560-bfa8-a48a625db2c5 | 2 | public static boolean isBetween(int value, int lowLimit, int highLimit) {
boolean between = false;
if (value >= lowLimit && value < highLimit) {
between = true;
}
return between;
} |
6ff09fe5-67f5-4ab1-abf0-5af499a3e0d4 | 1 | public void writeCorpusToFile(String fileName) throws IOException {
BufferedWriter out = new BufferedWriter(new FileWriter(new File(fileName)));
out.write("<?xml version='1.0' encoding='UTF-8'?>");
out.write("\n<corpus corpusname=\"tagged-corpus\">");
out.write("\n\t<head>");
out.write("\n\t</head>");
out.w... |
0aa89be3-3b1a-41d6-b60d-554bc3d3ff1a | 5 | private void pickRandomQuote(MessageEvent<PircBotX> event) {
try {
if (!file.exists()) {
System.out.println(file.createNewFile());
}
FileReader fw = new FileReader(file);
BufferedReader reader = new BufferedReader(fw);
String line;
Random random = ... |
5fffdbd8-5b44-468b-8b3e-c337f733996f | 7 | private boolean isBlocking(float _x, float _y, float xa, float ya)
{
int x = (int) (_x / 16);
int y = (int) (_y / 16);
if (x == (int) (this.x / 16) && y == (int) (this.y / 16)) return false;
boolean blocking = world.level.isBlocking(x, y, xa, ya);
byte block = world.level.g... |
14aa66b5-43ea-4c2c-b846-a7e678c4a1e5 | 7 | public void tableChanged(TableModelEvent e)
{
boolean dirty = !isSorted(); // Dirty bit to see if we should resort
if (!dirty) {
if (e.getType() == TableModelEvent.UPDATE) {
if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
// Table structure changed. Not supported for now!
throw new UnsupportedOper... |
7c595c0b-755a-4442-a7e2-11a2a87227d2 | 8 | @Override
public final void run() {
if (shutdown) {
CTT.debug("Attempting to shutdown game " + getGameId() + " again");
plugin.getServer().getScheduler().cancelTask(taskID);
return;
}
signTracker++;
if (signTracker == 2) {
signTracker =... |
7f6321b4-a250-4871-8a44-f4db601c060b | 2 | private void initialize() {
int padding = 5;
joinChatPressed = false;
agent = new MenuAgent(this);
double ratio = (1.0+Math.sqrt(5.0))/2.0;
Dimension screenDims = Toolkit.getDefaultToolkit().getScreenSize();
joinAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
... |
a280e72a-2211-4995-adad-51b048c2125d | 1 | final int countIgnoredTests(final Xpp3Dom results) {
final AtomicInteger ignored = new AtomicInteger();
new ForAllTestCases(results) {
@Override
void apply(Xpp3Dom each) {
final String result = each.getChild("result").getValue();
ignored.addAndGet(... |
c58c73cd-cc3d-4596-a52f-5387d3580820 | 2 | @Override
public boolean equals(Object obj) {
if (obj instanceof Vector) {
Vector v = (Vector) obj;
return x == v.x && y == v.y;
}
return false;
} |
569c1f62-f71c-4547-bad4-a4346f425a8f | 1 | @EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
private void onVehicleLeave(VehicleExitEvent event)
{
if(mResetTicksLived)
event.getVehicle().setTicksLived(0);
} |
a9a38c01-515d-4c82-bff9-f21cd47c8f83 | 7 | boolean performAndOrShortcut(Node a, Node b) {
if (b.getInEdges().size() != 1) return false;
if (b.block.getChildCount() > 0) {
// Node b is not a mere conditional.
return false;
}
ConditionalEdge aToC;
ConditionalEdge bToC;
bool... |
3a22e539-1f56-4a99-b3ae-96592932266f | 1 | public void addAssociation(Association a)
{
if(!associationsSet.contains(a))
{
associationsList.add(a);
associationsSet.add(a);
}
} |
8d9edebe-f8db-4584-96cf-73ca50c89d84 | 3 | public void setValor(PValor node)
{
if(this._valor_ != null)
{
this._valor_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
... |
94bae2f7-ab1e-40d0-b9fb-beb3c01ccedf | 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://down... |
324af607-9c59-4ba9-8892-2ce58ec4142c | 3 | public static void sort(int[] array) {
printArray(array);
int index = 0;
int tmp = array[0];
int j;
for (int i = 0; i < array.length - 1; i++) {
index = 0;
tmp = array[0];
for (j = 1; j < array.length - i; j++) {
if(tmp < array[j]) {
index = j;
tmp = arr... |
bb12f049-1700-44f5-a603-7cf1c6e93811 | 8 | public JSONObject executeBasic() throws CloudflareError {
try {
HttpPost post = new HttpPost(
CloudflareAccess.CF_API_LINK);
post.setEntity(new UrlEncodedFormEntity(post_values));
HttpResponse response = api.getClient().execute(post);
Buffered... |
6c258990-9717-469f-8774-98c8ea00185d | 3 | public void save() {
SortedMap<String,String> sortedKeys = new TreeMap<String,String>(keys);
try {
BufferedWriter output = new BufferedWriter(new FileWriter(fileName));
try {
for (String key : sortedKeys.keySet())
output.write(key.toLowerCase() + "=" + sortedKeys.get(key) + newLine);
} catch (IOEx... |
9239735e-49ad-460d-bed1-069e16698dca | 2 | public long getLong(String key) throws JSONException {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).longValue()
: Long.parseLong((String) object);
} catch (Exception e) {
throw new JSONException("JSONObject["... |
8defdef1-95af-41d3-881c-f9eb43db80a5 | 1 | public void newProduct() {
try {
Database db = dbconnect();
String query = "INSERT INTO product (name, description) VALUES "
+ "(?,?)";
db.prepare(query);
db.bind_param(1, this.name);
db.bind_param(2, this.description);
d... |
45506a2e-a5dc-4177-9f77-54d10a61a519 | 5 | */
private boolean isInstDefault() {
if (instCheck.size() == 0) {
return false;
}
for (Iterator j=instCheck.keySet().iterator(); j.hasNext(); ) {
String key = (String)j.next();
if ( isDefaultInst(key) ) { // デフォルト装置種別の場合
if ( !((JCheckBox)instCheck.get(key)).isSelected() ) {
return... |
bb96a7de-dc7e-4045-95b6-0febab14861e | 1 | public ArrayList<GradeItem> gradeItems(ResultSet rs) throws Exception {
DBConnector db = new DBConnector();
ArrayList<GradeItem> data = new ArrayList<>();
while (rs.next()) {
data.add(new GradeItem(db.getGradeItem(rs.getInt("gradeitemid"))));
}
return data;
} |
b78452f0-3466-4614-bc27-ec70dc971eda | 2 | public static Utilisateur selectById(int id) throws SQLException {
String query = null;
Utilisateur util = new Utilisateur();
ResultSet resultat;
try {
query = "SELECT * from UTILISATEUR where ID_UTILISATEUR=? ";
PreparedStatement pStatement = ConnectionBDD.get... |
f50fd98f-3be3-4d50-9953-4f30f15fc15f | 6 | @Override
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
Point imageOrigin = getImageLoc();
if(p != null && bufImage != null){
Point imagePixel = new Point(p);
imagePixel.x -= imageOrigin.x;
imagePixel.y -= imageOrigin.y;
if(imagePixel.x >= bufImage.getWidth() ||
imagePixe... |
b4e7125b-8d88-4fbd-be96-a762c757c937 | 8 | public static PostingsList andMerge(PostingsList posting1,
PostingsList posting2) {
PostingsList merged = new PostingsList();
if (posting1 != null && posting2 != null && posting1.size() > 0
&& posting2.size() > 0) {
Node p1 = posting1.head;
Node p2 = posting2.head;
while (p1 != null && p2 != null... |
0e84dc39-0608-4314-9315-e2987c86d572 | 4 | public boolean collides(int x, int y){ //CHECKS IF PASSED X Y COORDS COLLIDE WITH THE BLOCK
if(x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height){
return true;
}
return false;
} |
f8524188-4212-4680-b7f2-8c5d3affd595 | 5 | static void analyze(Object obj) {
Class clazz = obj.getClass();
String name = clazz.getName();
System.out.println(name);
Constructor[] constructors = clazz.getConstructors();
for (Constructor c : constructors) {
System.out.println("Constructor name: " + c.getName());
}
Field[] fields = clazz.getF... |
cd8da66a-d7e9-4277-a993-b7d49b1b6aa2 | 9 | private void processTextFile(File file) {
BufferedReader is = null;
PrintWriter pw = null;
TextModes modes = new TextModes();
try {
pw = new PrintWriter(file.getAbsolutePath().replace(REMOVE_FROM_PATH, ""));
is = new BufferedReader(new FileReader(file));
String aline;
List<String> lines = new ArrayL... |
e3a1ba32-4e8f-4429-9bfe-dc36d6c90726 | 5 | public String getResult(){
String display = new String();
int n = 0;
display = "";
if(this.valorCliente>0){
this.valorTroco = this.valorCliente;
if(this.valorTroco>=50){
n = (int)(this.valorTroco/50);
this.valorTroco-= n*50;
}//END IF
display += n+" ";
n = 0;
if(this.valorTroco>=10){
... |
cf980c51-9895-4e35-932d-5c676f2c77a8 | 4 | public static void delete(File src) throws IOException {
if (!src.exists()) return;
if (!src.isDirectory()) {
src.delete();
return;
}
for (File f : src.listFiles()) {
if (f.isDirectory()) delete(f);
f.delete();
}
} |
ec831b38-dfa9-4441-96c1-401cd631fe13 | 7 | public double olbStart() {
sortResources();
sortClass();
calculateWeight();
System.out.println(iCPUMaxNum);
dmMinminCost = new double[iSite][iCPUMaxNum];
dmMinminTime = new double[iSite][iCPUMaxNum];
double[] daMinminTimeBySite = new double[iSite];
// find the current cheapest site for the acitvities.... |
b025cedf-4309-40f0-86da-f3edfdb4cb2c | 9 | public static List<MeasureSite> findAllMeasureSite() {
List<MeasureSite> measureSiteList = new ArrayList<MeasureSite>();
MeasureSite measureSite = null;
ResultSet rs = null;
Statement stmt = null;
Connection conn = null;
try {
// new oracle.jdbc.driver.OracleDriver();
// jdbc.url=jdbc\:oracle\:thin\... |
0cfa7db7-1f19-44e0-9e92-6375358d1a1d | 3 | private void checkmappos() {
if (cam == null)
return;
Coord sz = this.sz;
SlenHud slen = ui.slenhud;
if (slen != null)
sz = sz.add(0, -slen.foldheight());
Gob player = glob.oc.getgob(playergob);
if (player != null)
cam.setpos(this, player, sz);
} |
b18bd98e-3670-4b73-a7c5-e3b86ea1fb71 | 3 | public final void generateFiles(boolean internal) {
// internal is true if called by onEnable and False if called by command
if (internal && !generationFinished) {
// 5 * 20 = 5 seconds (20 ticks per second)
scheduler.scheduleSyncDelayedTask(this, new PermissionTask(this), 5 * 20L);
} else if (!internal) {
... |
da6cf275-734e-49aa-8991-82e797c87b97 | 9 | private boolean replaceEvents(String key, Faction.FactionChangeEvent event, boolean strict)
{
final Faction.FactionChangeEvent[] events=changes.get(key);
if(events==null)
return false;
final Faction.FactionChangeEvent[] nevents=new Faction.FactionChangeEvent[events.length-1];
int ne1=0;
boolean done=false... |
05b07465-3c88-4dea-aebc-6ba3830cadb3 | 9 | public void run()
{
try
{
SocketChannel socketChannel = SocketChannel.open();
socketChannel.socket().setReceiveBufferSize( m_socketBufferSize );
StreamDefragger streamDefragger = new StreamDefragger(4)
{
... |
4d065e7e-603e-457d-b1bd-6d065e821e2c | 1 | public static void assertNotNull(Object value, String errorMessage)
throws BeanstreamApiException {
// could use StringUtils.assertNotNull();
if (value == null) {
// TODO - do we need to supply category and code ids here?
BeanstreamResponse response = BeanstreamRespon... |
14dd3e68-d9b2-41be-a8eb-3aa7991b1324 | 8 | public SplashScreen()
{
setTitle("Board Games");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Set up the menu
setJMenuBar(menuBar);
menuBar.add(fileMenu); fileMenu.add(exit);
menuBar.add(helpMenu); helpMenu.add(about); helpMenu.add(... |
b337a581-bbb3-4547-adfe-ffaff62d9cf2 | 0 | @Override
public void applyCurrentToApplication() {
// Apply any prefs to the app that won't be looked up directly from the preferences.
} |
7edf534c-8992-4c01-bc04-fbdfc2e07c51 | 2 | private String join(String[] array, String separator) {
if (array.length == 0) {
return "";
}
String ret = "";
for (int i = 0; i < array.length; i++) {
ret += array[i] + separator;
}
return ret.substring(0, ret.length() - separator.length());
} |
80bea09a-48af-41e7-a838-d2d96487d4da | 4 | public static JsonNode merge(JsonNode mainNode, JsonNode updateNode) {
Iterator<String> fieldNames = updateNode.fieldNames();
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
JsonNode jsonNode = mainNode.get(fieldName);
// if field doesn't exist ... |
699eec85-a6d2-46f5-8914-c834348dfaa0 | 4 | public JButton getButton(int buttonType) {
for (int a = 0; a < getComponentCount(); a++) {
if (getComponent(a) instanceof JButton) {
JButton button = (JButton) getComponent(a);
Object value = button.getClientProperty(PROPERTY_OPTION);
int intValue = -1... |
0a43d140-89f6-4470-895e-d5698f2b4917 | 2 | public abstractPage(){
super(new BorderLayout());
if ( lang.equals("en"))
{
//static Button
appLang = new JButton("Arabic");
//welcomePage
//--------Labels--------
appNameLabel = new JLabel("Parking Permit Kiosk");
appInfoLabel = new JLabel("This application issues parking permits for ... |
cdab8583-42e4-4807-9d43-f0f344066c98 | 2 | private static int[] portRangeToArray(int portMin, int portMax) {
if (portMin > portMax) {
int tmp = portMin;
portMin = portMax;
portMax = tmp;
}
int[] ports = new int[portMax - portMin + 1];
for (int i = 0; i < ports.length; i++)
ports[i] = portMin + i;
return ports;
} |
ef5c11ca-dc01-430d-acaf-02f60f9cc8f9 | 0 | public void setBytes(byte[] bytes) {
this.bytes = bytes;
} |
50e91f5b-a39a-44b0-a56a-3f9335200249 | 9 | @Override
public String getStat(String code)
{
if(CMLib.coffeeMaker().getGenMobCodeNum(code)>=0)
return CMLib.coffeeMaker().getGenMobStat(this,code);
switch(getCodeNum(code))
{
case 0: return ""+getWhatIsSoldMask();
case 1: return prejudiceFactors();
case 2: return bankChain();
case 3: return ""+getC... |
b0eeb7a6-8860-4b3d-9458-4d1ceef9f2e3 | 3 | public boolean isDead() {
if (age > esperancevie)
return true;
else if (age <= 5 && (loterie.nextInt(25) + 1) == 1)
return true;
else
return false;
} |
cdd590e5-68a1-47bc-90fd-982963a32a90 | 9 | private boolean r_mark_suffix_with_optional_n_consonant() {
int v_1;
int v_2;
int v_3;
int v_4;
int v_5;
int v_6;
int v_7;
// (, line 132
// or, line 134
lab0: do {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.