method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
ae46927a-b002-4f22-ab0a-5bb4c938dd95 | 4 | public void guardarSQLite(){
Connection con = null;
PreparedStatement state = null;
try{
Class.forName("org.sqlite.JDBC");
String dir = System.getProperty("user.dir");
System.out.println(dir);
con = DriverManager.getConnection("jdbc:sqlite:"+dir+"/... |
05c165ba-dc6d-4772-84a7-356d1d9a40de | 7 | public void mergeUnhandledException(TypeBinding newException){
if (this.extendedExceptions == null){
this.extendedExceptions = new ArrayList(5);
for (int i = 0; i < this.handledExceptions.length; i++){
this.extendedExceptions.add(this.handledExceptions[i]);
}
}
boolean isRedundant = false;
for(int i = thi... |
dcfb07f7-95be-48ae-85f5-fd8bd883e081 | 5 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Ticket ticket = (Ticket) o;
if (id != ticket.id) return false;
if (Double.compare(ticket.price, price) != 0) return false;
return true... |
32b076f5-d5f7-46a7-ac78-0b0e8702bc35 | 0 | public void redo(){
myKeeper.redo();
} |
d22aac6b-b7a2-4dc8-87f1-2236340e9655 | 9 | @Override
public ParserResult specialCheckAndGetParserResult(ParserResult result,
SyntaxAnalyser analyser) throws GrammarCheckException {
Map<String, String> dimensionLevelInfo = result.getDimensionLevelInfo();
boolean conditionIsOk = dimensionLevelInfo.size() >= 3;
int nullValueNumber = 0;
for (Iterator<St... |
84209662-3a51-4604-8015-d8d17d2f1789 | 5 | String fileSizeStr(long s) {
if (s < K) return String.format("%dbytes", s);
if (s < M) return String.format("%.1fKb", (1.0 * s / K));
if (s < G) return String.format("%.1fMb", (1.0 * s / M));
if (s < T) return String.format("%.1fGb", (1.0 * s / G));
if (s < P) return String.format("%.1fTb", (1.0 * s / T));
... |
00e5ee3e-f014-4b4a-a73c-267c62eb1201 | 9 | private String getLoginUserIP(){
HttpServletRequest req=(HttpServletRequest)ServletActionContext.getRequest();
String lastLoginIP = req.getHeader("x-forwarded-for");
if(lastLoginIP == null || lastLoginIP.length() == 0
|| "unknown".equalsIgnoreCase(lastLoginIP)) {
lastLoginIP = req.getHeader("Proxy-Cl... |
7e3ca204-7edb-4247-b495-0ea30f728bcb | 7 | public EditButtonsListener(final MenuItem menuItem) throws IllegalParametrs {
this.menuItem = menuItem;
switch (menuItem) {
case ADD:
listener = new AddButtonActionListener();
break;
case DELETE:
listener = new DeleteButtonActionListener();
break;
case FIND:
listener = new FindButtonAct... |
84ce5a8f-6e01-4179-a187-324a6f98a78a | 0 | private void initGroupCreation() {
driver.findElement(By.name("new")).click();
} |
bcd9a2e3-d262-4427-a2ba-e9a6d7f16003 | 3 | public static boolean isHappy(int n) {
Map<Integer, Boolean> traverseMap = new HashMap<Integer, Boolean>();
int res = n;
while (true) {
res = assistIsHappy(res);
if (1 == res) return true;
if (traverseMap.containsKey(res)) return false;
traverseMap.put(res, true);
}
} |
1e243976-85f4-4d6a-8db0-82833c195bfa | 8 | private boolean isLegalNameChar(char ch) {
return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z'))
|| ((ch >= '0') && (ch <= '9')) || (ch == '.') || (ch == '_')
|| (ch == '$');
} |
2eff715e-62a3-4e92-b881-bfc990330819 | 8 | private void powrotDoOknaGlownego()
{
widokOpisTworcow.setVisible(false);
if(oknoMacierzyste.equals("OknoGlowne"))
widokOpisTworcow.widokGlowny.setVisible(true);
if(oknoMacierzyste.equals("OknoDolacz"))
widokOpisTworcow.widokGlowny.widokDolacz.setVisible(true);
if(oknoMacierzyste.equals("OknoUtworz"))
... |
c615567f-7945-4ccc-807f-e939828a181f | 5 | public static int findRowByDate(Date date, int dateColumn, CSTable table) {
String type = table.getColumnInfo(dateColumn).get(KEY_TYPE);
if ((type == null) || !type.equalsIgnoreCase(VAL_DATE)) {
throw new IllegalArgumentException();
}
DateFormat fmt = lookupDateFormat(table,... |
d3637997-a8f5-4b5e-8af2-a4d40c7a3784 | 9 | public void keyPressed(KeyEvent e) {
// Packet sent for any type of key event. So create the packet first
Packet event = null;
// Create event packet according to key event
// If the user pressed Q, invoke the cleanup code and quit.
if((e.getKeyChar() == 'q') || (e.getKeyChar() == 'Q')) {
event = new Pac... |
c8a6f3cb-59f4-4e4c-bb8c-22163166ffaa | 8 | private boolean moveTowards(int tx, int ty) {
if(x < tx && move(x+1, y)) return true;
if(x > tx && move(x-1, y)) return true;
if(y < ty && move(x, y+1)) return true;
if(y > ty && move(x, y-1)) return true;
return false;
} |
64d1f92b-eff8-4756-8adc-a2c672ce22ef | 6 | public void multiplyPay(int multiplier) {
if(multiplier == 1)
return;
this.win *= multiplier;
for(WinResult winResult : this.nonReelWinResults) {
winResult.Win *= multiplier;
}
for(ReelGridEvalResult reelGridEvalResult : this.reelGridEvalResults) {
... |
07574d9b-b5c3-46f5-98c3-f75d9cdfe3d8 | 1 | public static Config getInstance() {
if (instance == null) {
new Config();
}
return instance;
} |
aa5e8495-e34b-4580-934b-b85ac73ae679 | 8 | protected void ShowMainScreen(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// set the encoding, otherwise database is encoded wrongly
request.setCharacterEncoding("UTF-8");
// so, 2 ways to be here - there is session with our data (then it was
// post),
... |
0f019da9-021f-44e8-b70d-e97a4cc24731 | 8 | public static void displayOpponentPlayerExpeditions(Player player) {
List<String> lines = new ArrayList<String>();
int rowCount = 0;
List<List<String>> cardsStrings = new ArrayList<List<String>>();
for (ExpeditionCardStack expeditionCardStack : player.getExpeditions()) {
List<String> expeditionStrings = bui... |
4c143fdf-517b-42bc-9d5b-359ccb6d89f7 | 8 | Point2D randomGoal(Game game, Point2D pt){
Point2D candidatePt = pt;
Tile fTile = game.getMap().getTileAt(pt);
Rectangle2D fRect = fTile.getArea();
double fwidth = fRect.getWidth();
double fheight = fRect.getHeight();
int n = 50;
... |
d01d0fde-5e43-4ac4-b657-ccef411d7ba5 | 6 | private void makeFire() {
final Tile playerTile = ctx.players.local().tile();
if (ctx.objects.select().at(playerTile).select(ObjectDefinition.name(ctx, "Fire")).isEmpty()) {
if (ctx.inventory.itemOnItem(TINDERBOX, LOGS)) {
Condition.wait(new Callable<Boolean>() {
@Override
public Boolean call() thr... |
3199bb03-cd81-480a-b28c-75fc196598bc | 4 | public String Add(BigInteger a)
{
String output = "";
ArrayList<Integer> lawl2 = new ArrayList<Integer>();
ArrayList<Integer> second = a.getNum(); //Returns the BigInteger objects ArrayList
int z = 0;
for(int i=0; i < input.length(); i++)
{
if((second.get(i) + this.lawl.get(i) + z)... |
f7caba66-d85d-4b25-8b0f-eae98253396d | 2 | void parseNotationDecl() throws java.lang.Exception
{
String nname, ids[];
requireWhitespace();
nname = readNmtoken(true);
requireWhitespace();
// Read the external identifiers.
ids = readExternalIds(true);
if (ids[0] == null && ids[1] == null) {
... |
188bcdf5-9165-4f73-a905-ca6b914e9beb | 5 | public void abrir() throws Exception {
if(id.length() > 0 && id != "0"){
long cod = Long.parseLong(id);
if(produto == null || (produto != null && produto.getId() != cod ) )
setProduto(ejb.Open(cod));
}
} |
4b5a7105-6872-4c79-aa4c-c1597fd02c6a | 9 | public void initTransient() {
if (blocks == null) {
throw new RuntimeException("The level is corrupt!");
} else {
listeners.clear();
blockers = new int[width * length];
Arrays.fill(blockers, height);
calcLightDepths(0, 0, width, length);
... |
78861cd0-ec8d-47e6-bb10-e6944bcd36ea | 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... |
496aa0e8-cc6b-4a34-bdf3-15ab1c89676d | 8 | public void setLook(int i){
switch(i){
case 0: this.look = 0; /*look.N; */ break;
case 1: this.look = 1; /*look.NE; */ break;
case 2: this.look = 2; /*look.E; */ break;
case 3: this.look = 3; /*look.SE; */ break;
case 4: this.look = 4; /*look.S; */ break;
case 5: this.look = 5; /*look.SW; */ break... |
5279e35b-0273-4ff3-b89f-1a5fd698b179 | 7 | @Override
public boolean execute(WorldChannels plugin, CommandSender sender,
Command command, String label, String[] args) {
final Map<Flag, String> info = new EnumMap<Flag, String>(Flag.class);
info.put(Flag.TAG, WorldChannels.TAG);
if(!(sender instanceof Player)) {
... |
33b53408-47f0-430d-b530-9cb1c0ede038 | 5 | DisguiseSound(Sound... sounds) {
for (int i = 0; i < sounds.length; i++) {
Sound s = sounds[i];
if (i == 0)
disguiseSounds.put(SoundType.HURT, s);
else if (i == 1)
disguiseSounds.put(SoundType.STEP, s);
else if (i == 2)
... |
20867193-e95e-4383-9995-30fcc32fdbd3 | 7 | public boolean validMove(int dir) {
boolean valid = true;
int[][] key = screen[row][col].key();
if (col+dir < 0 || col+dir >= NUM_COLS || dead[row][col+dir] == true)
valid = false;
for (int i=0; i<3; i++) {
int r = row+key[i][0];
int c = col+key[i][1];
if (c+dir < 0 || c+dir >= NUM_COLS || dea... |
099c1b70-9153-404b-9acf-36a5039e6eff | 2 | public void setPassengerCurCount(int passengerCount)
throws CarriageException {
if ((passengerCount >= 0) && (passengerCount <= this.passengerMaxCount)) {
this.passengerCurCount = passengerCount;
} else {
throw new CarriageException(
"Current passenger count is out of range [0,"
+ this.passenge... |
e13060b8-12ca-40ee-b67a-0f6810603450 | 3 | private static ArrayList<Integer> obtenerTiempos(String etiqueta, Element elemento) {
ArrayList<Integer> t = null;
/*Desgloza los tiempos en funcion de la etiqueda deseada*/
NodeList e = elemento.getElementsByTagName(etiqueta);
int n = e.getLength();
if (e.getLength() >... |
54748209-6c34-46b6-824e-c303a93877f6 | 9 | public String getMessage() {
if (!specialConstructor) {
return super.getMessage();
}
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSeq... |
017a8351-e015-4eb6-b933-7c82e3286036 | 1 | @Test
public void nodeTests(){
Node db = null;
try{
ConfigParser cp = ConfigParser.getParser("resources/config.xml");
cp.getElementAt("wookie", 0);
db = (Node)cp.getElementAt("databases", 0);
}
catch(Exception e){
assertTrue(false);
}
Connection con = ConnectionFactory.createConnection(db);
a... |
1f2c177b-ee67-442c-b645-5ad5b5c92e27 | 5 | public String getDefaultName() {
ClassInfo type;
if (clazz != null)
type = clazz;
else if (ifaces.length > 0)
type = ifaces[0];
else
type = ClassInfo.javaLangObject;
String name = type.getName();
int dot = Math.max(name.lastIndexOf('.'), name.lastIndexOf('$'));
if (dot >= 0)
name = name.substr... |
35065adf-687e-4e75-8eb4-0e6895be169f | 6 | @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemPickup(PlayerPickupItemEvent event)
{
// CAUTION:This event fires, BEFORE the picked up item is added to the inventory!
// therefore, delay all checks for 1 tick because "itemInHand()" is needed for checks
... |
fca92df4-1746-4ea4-a9fe-b920e1da7844 | 0 | protected User()
{
super(User.class.getSimpleName());
} |
d95d296c-9466-47da-b2f0-13580d4b46c6 | 2 | public void Draw(Graphics2D g2d) {
//*******************************************
//text coordinates
g2d.setColor(Color.white);
g2d.drawString("Car coordinates: " + x + " : " + y, 5, 15);
g2d.drawString("Frame size, height " + Framework.frameHeight + ", width " + Framework.fram... |
ebd19a0a-94d5-4f64-8fe5-e245bbdd32a7 | 5 | private void stopButtonAction() {
text.append(String.format("Stopping current action.%s", newline));
// Remember the state before stopping
State state = currentState;
// Set to initial
this.setStateInitial();
//remove buttons
if (!results.isEmpty())
{
... |
4d6d306b-b76c-438d-89df-be5db60fe606 | 0 | public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
} |
d231ea7e-b247-4872-a4dc-1896bae3361f | 9 | private void refreshClipboardList() {
Transferable[] copiedItems = CopyPasteManager.getInstance().getAllContents();
int amountItems = UtilsClipboard.getAmountStringItemsInTransferables(copiedItems);
String[] itemsUnique = null;
boolean hasClipboardContent= UtilsClipboard... |
d4037e21-f991-4bdd-9c75-6221d602501c | 2 | @Override
public void execute() {
Player receiver = getReceiver();
for (String playerName : players) {
Ban ban = new Ban(playerName, until, reason);
TimeBanBanEvent event;
if (receiver != null) {
event = new TimeBanBanEvent(receiver, ban);
... |
18b180eb-0944-402a-8825-94aa5ffac83c | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
MOB target=mob;
if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB))
target=(MOB)givenTarget;
if(target.fetchEffect(this.ID())!=null)
{
mob.tell(target,null,null,L("<S-YOUPOSS> ca... |
11e51637-738a-41a8-980a-4f8791fc59e0 | 7 | public void unpack(String filename1)
{
String filename = filename1;
File srcFile = new File(filename);
String zipPath = filename.substring(0, filename.length()-4);
File temp = new File(zipPath);
temp.mkdir();
ZipFile zipFile = null;
try {
zipFile = new ZipFile(srcFile);
Enumeration<? extends ... |
d8cee225-adad-4009-a307-ef63a5bb7620 | 7 | private boolean checkIfStuck(){
// bottom of the board
if(myPieceLocation.y == 0){
return true;
}
// check if crashed into another piece
Point[] points = getPoints(myPieceLocation, myPiece, myOrientation);
for(int i = 0; i < points.length; i++){
Point p = points[i];
if(p.y - 1 > 0 && p.y - 1 < ge... |
8c445ea8-3228-4c7a-94fe-7a0198305219 | 4 | public static void goToManageMenu() {
alphabetize();
System.out.println("\nEmployee List:");
for (Prototype p : employeeList) {
System.out
.println(employeeList.indexOf(p) + 1 + ") " + p.getName());
}
System.out
.print("\n~Management Menu~\nA) Remove Employee\nB) Edit Employee\nC) View Employee In... |
f0725f3c-1f68-4096-83d4-170f902083dc | 7 | public void switchDoors(Gameboard gameboard)
{
Field[][] fields = gameboard.getFields();
for(int i = 0; i < fields.length; i++)
{
for(int j = 0; j < fields[i].length; j++)
{
if(fields[i][j].getType() == 2 && Math.random() < GlobalGameboard.doorSwitchFrequency)
{
if(fields[i][j].isDoorOpen()... |
4bc67270-75b1-4a14-8ac0-106ccfc2e577 | 8 | public void parse(String sentence, ParserReceiver receiver, Console console) throws EvaluationException {
String normalized = sentence.trim().toLowerCase();
// Check if sentence is a known magic phrase
String magicPhrase = vocabulary.getMagicPhrases().get(normalized);
if (magicPhrase != null) {
receiver.m... |
c1e2007d-2cf9-4aab-ba59-6bd99be9b02f | 5 | private static Object evaluate(final Object problem, final String expression)
throws SecurityException, NoSuchMethodException,
IllegalArgumentException, IllegalAccessException,
InvocationTargetException
{
final StringTokenizer tok = new StringTokenizer(expression, ".");
Object result = problem;
if (to... |
e5b5b472-ba81-469c-b109-c541157c8aad | 5 | private void buyButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (road == -1 && settlement == -1) { return; }
Request toSend = new Request();
toSend.setRequest(road == -1 ? 7 : 8);
toSend.setHexagonSelected(hexagon);
if (road == -1) { toSend.setOnSpotSelected(settlement); }
else ... |
3ff7b7fa-0e7b-4465-8850-ae0f03520408 | 5 | private void write(){
//Writing to OutputStream
try {
try {
transferUsePermit.acquire();
} catch (InterruptedException e){ } //never thrown
if (transfer==null)
transfer=new NullTransfer();
//To ensure memory space and that the objects are properly serialised
oos.reset();
... |
fa486d63-230c-4bfc-a671-e9df755d49ec | 8 | private void generateStereogram() {
try {
if (this.dottedRadioButton.isSelected()) {
if (batchMode) {
//todo
} else {
BufferedImage depthMap = null;
if (this.textRadioButton.isSelected()) {
... |
3591db0b-bf88-4cbc-bc3a-e63d4edf1104 | 0 | public JLabel getjLabelNumeroRapport() {
return jLabelNumeroRapport;
} |
874902c3-b3d5-4b17-94af-fa576f1270d5 | 9 | protected static PreparedStatement prepareStatement(String query, Object... args) throws SQLException {
String[] splitedQuery = (query + " ").split("\\?");
int count = splitedQuery.length - 1;
String resultQuery = "";
List<Object> resultArgs = new ArrayList<Object>();
if (count !... |
9152ec42-5d2e-43bf-b856-8061a3f3b886 | 0 | public String getLabel() {
return label;
} |
e0049c73-b484-4159-8bec-b9e59784f55d | 5 | private void occurrencesCharacter(char ... c) {
MyIterator<String> forward = list.getForwardIterator();
int[] counts = new int[c.length];
while (forward.hasMoreElements()) {
String temp = (String)forward.nextElement();
for (int i = 0; i < temp.length(); i++)
for (int j = 0; j < c.length; j++) {
... |
946c317e-7d9a-4ee8-91ff-3bee2cee9bf5 | 3 | public static String readDodgyXML(String filename) throws IOException
{
InputStream in = new FileInputStream(new File(filename));
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String line = br.readLine();
// Ignore first line and replace it with th... |
47d99c44-7b5e-48ab-89e4-6eb72ddaf752 | 1 | public Member findById(java.lang.Integer id) {
log.debug("getting Member instance with id: " + id);
try {
Member instance = (Member) getSession().get(
"com.oj.hibernate.daoNdo.Member", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
} |
4b9df246-d164-4e8f-8d83-d02a407a9ec2 | 4 | public static void main(String[] args) {
try (InputStreamReader isr = new FileReader(System.getProperty("user.dir") + "/file/tmp");
BufferedReader br = new BufferedReader(isr)) {
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.... |
29206484-f0ca-45b9-a969-e3254e5e7fab | 8 | public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
... |
776ee5dd-ca20-424e-8f7a-438e0012ea37 | 7 | private boolean ValidPetNameChars(String inputStr,int HardCodedLen)
{
for(int i=0;i<HardCodedLen;i++)
{
if(i==0)
{
if(inputStr.charAt(0) == ' ')
{
return false;
}
}
if((inputStr.charAt... |
3adbd9ce-566c-4aa8-a940-755fae3e1d40 | 1 | public GlobalParams withLocalParams(Collection<ParamsType> params) {
GlobalParams p = copy();
for (ParamsType t: params) {
p.put(t.name, t.value);
}
return p;
} |
850f5511-5385-4a21-99f1-0281d93788ae | 2 | public static IntNode listSearch(IntNode head, int target)
{
IntNode cursor;
for (cursor = head; cursor != null; cursor = cursor.link)
if (target == cursor.data)
return cursor;
return null;
} |
3c9c6830-6cc2-4f67-a71b-f2693a7bca01 | 6 | protected void getNodeTexts(TreeMap<String, LinkedList<ParseTopiaryNode>> map, boolean includeNamedNodes) {
// System.out.format("names.size()=%d\n",names.size());
if ( (text!=null) && !text.isEmpty() ) {
if (names.size() == 0 || includeNamedNodes ) {
LinkedList<ParseTopiaryNode> ll = map.get(text);
... |
95c6e1c6-b905-483c-bcc5-e89a50cd76c5 | 5 | @Override
public void run() {
if (isConnected && ossl != null) {
bdl = new BroadcastDiscoveryListener();
bdl.start();
onServerStart();
} else {
System.err.println("Could not launch onStartServerListener... null or not connected");
}
... |
84da5cca-9c89-410b-8274-33d85ff86dac | 6 | private synchronized static void startBackgroundThread () {
if (backgroundThread == null) {
backgroundThreadMayRun = true;
backgroundThread = new Thread(asyncThreadGroup, "AnalyticsBackgroundThread") {
@Override
public void run () {
Log... |
ee0357f8-2aa3-4353-8b8a-decbb4c86862 | 0 | public boolean isChoking() {
return this.choking;
} |
aa046abe-1a8b-4840-9cbf-ea4795bb6e88 | 5 | private void processWalksFromSource(int source, ArrayList<Walk> walksFromSource) {
// Now sort by target
Collections.sort(walksFromSource, new Comparator<Walk>() {
@Override
public int compare(Walk walk1, Walk walk2) {
int dest1 = walk1.getDestination();
... |
cd3ffab8-db03-42c6-a292-54fc64c320e6 | 5 | public void update() {
if (hasGameStarted()) {
if (keyListener.isUp()) {
sessionImpl.update(-1);
} else if (keyListener.isDown()) {
sessionImpl.update(1);
} else {
sessionImpl.update(0);
}
} else if (!hasGame... |
2e4ccca1-b485-4329-8f77-a1b396bd16be | 0 | public AutomatonEnvironment(Automaton automaton) {
super(automaton);
Listener listener = new Listener();
automaton.addStateListener(listener);
automaton.addTransitionListener(listener);
automaton.addNoteListener(listener);
initUndoKeeper();
} |
7fdf13fa-f677-4ae6-81bb-f23a5839a7b6 | 9 | final void paintBranchCircular( final PhylogenyNode p,
final PhylogenyNode c,
final Graphics2D g,
final boolean radial_labels,
final boolean to_pdf,
... |
2fb1494f-e339-4bed-9d64-de0ad4d84e0e | 1 | public int getLEShort() { // method437
offset += 2;
int v = ((payload[offset - 1] & 0xff) << 8) + (payload[offset - 2] & 0xff);
if (v > 32767) {
v -= 0x10000;
}
return v;
} |
1b77c024-9a8d-4e65-bce4-9a1f37d163f0 | 6 | private boolean interestedInBitfield(byte[] bfield)
{
if (amountLeft == 0)
{
return false;
}
for (int byteIndex = 0; byteIndex < bitfield.length; byteIndex++)
{
for (int bitIndex = 0; bitIndex < 8; bitIndex++)
{
try
{
if (!Util.isBitSet(this.bitfield[byteIndex], bitIndex)
&& Util.... |
b47b59e8-9c0a-4be7-9b61-1f6a90bae93b | 4 | public int getTableId(Block block) {
Set<Integer> tilesKeys = tilesLocations.keySet();
for(Integer key : tilesKeys) {
SerializableLocation blockLocation = new SerializableLocation(block.getLocation());
if(tilesLocations.get(key).contains(blockLocation))
return key;
} Set<Integer> spinnersKeys = spinners... |
eba9a6ba-aa9c-45af-9639-13eed2268deb | 7 | @Override
public void mouseDragged(MouseEvent e) {
if (this.grabbing) {
Rectangle r = this.getRegionBounds();
int flags = 0;
double pre = this.position;
int left = e.getX() + this.grabOffset;
this.position = left / (double) (r.width - this.grabSize) * (this.valueRange[1] - this.valueRange[0]);
if ... |
a1c54e24-994f-452d-9f03-9ea9b82c5c9e | 7 | public SFormat newSFormat(JType t, String colName)
//public SFormat newSFormat(JType t, boolean editable)
{
// Try by name
if (colName != null) {
Object o = makerMap.get(colName);
if (o != null) return getSFormatObj(o, t);
}
// Index on general class of the JType,
// or on its underlying Java Class (for Java... |
7286a769-d438-472d-9503-05188e0bd7c4 | 5 | protected Object initialInput(Component component, String title) {
if(title.equals("")) title = "Input";
if(getObject() instanceof TuringMachine){
// Do the multitape stuff.
TuringMachine tm = (TuringMachine) getObject();
int tapes = tm.tapes();
if(title.equals("Expe... |
c5e0a93c-1755-4d55-9c69-406a5ed8cea8 | 9 | public void check(int x, int y, int [] loc, float startmag)
{
int r = 10;
float [][] SSD = new float[size][size];
int N = size/4;
for (int l = -size/2; l <= size/2; l++)
for (int k = -size/2; k <= size/2; k++)
SSD[l+size/2][k+size/2] = w[l+size/2][k+size/2];
IJ.write("Check minima at "+x+","... |
c22e539f-9a9b-4212-8875-04f291515226 | 9 | public static void main(String[] args) {
// TODO Auto-generated method stub
int mat[][]={{1,2,3},{4,5,6},{7,8,0}};
boolean row[]=new boolean[mat.length];
boolean col[]=new boolean[mat[0].length];
for(int i=0;i<mat.length;i++)
{
for(int j=0;j<mat[0].length;j++)
{
if(mat[i][j]==0)
{
... |
f224da06-54c4-4552-8022-ebd054d6ef47 | 1 | @Test
public void testEquals() {
try {
System.out.println("equals");
Port port = new Port();
Ship instance = new Ship(port, "Test", 12, 23);
Ship newInstance = new Ship(port, "Test", 12, 23);
boolean expResult = true;
boolean result = i... |
dfc20bc2-7980-4465-8bc6-39b9a07d560a | 3 | private FieldIdentifier findField(String name, String typeSig) {
for (Iterator i = fieldIdents.iterator(); i.hasNext();) {
FieldIdentifier ident = (FieldIdentifier) i.next();
if (ident.getName().equals(name) && ident.getType().equals(typeSig))
return ident;
}
return null;
} |
5a2b7cda-13ef-46fa-b0cb-f146e97c9cf5 | 2 | public static void insert (int [ ] values, int pos, int newInt) {
if (pos<0 || pos>=values.length) {
return;
}
// your code goes here
} |
510b16b7-dc0e-483d-99aa-9b0fba6abbee | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Palette other = (Palette) obj;
if (!Arrays.equals(data, other.data))
return false;
return true;
} |
390bd4a1-f927-4ff5-a549-e4dae17c0523 | 1 | static public ReciboCertificado instancia() {
if (UnicaInstancia == null) {
UnicaInstancia = new ReciboCertificado();
}
return UnicaInstancia;
} |
68b84880-9dc2-46d3-8e31-5e92e990353c | 4 | public int maxProfit(int[] prices) {
if (prices == null || prices.length <= 1)
return 0;
int max = 0;
for (int i = 0; i < prices.length - 1; ++i) {
if (prices[i + 1] > prices[i]) {
max += prices[i + 1] - prices[i];
}
}
return max;
} |
762b3c5c-68ab-427f-bd71-be8a98f89999 | 1 | private static void loopCallBack() {
Iterator<Entry<Long,UserNotificationBuffer>> it = monitors.entrySet().iterator();
while(it.hasNext()) {
Entry<Long,UserNotificationBuffer> pair = it.next();
UserNotificationBuffer notification = pair.getValue();
notification.performSchedule();
}
} |
f62640f1-4c33-4d7a-8f5a-d22a10880952 | 1 | private static String normalize(String wiki) {
pattern = Pattern.compile("(\\[\\[[^\\|]*\\|)([^\\]]*)(\\]\\])", Pattern.UNICODE_CASE);
matcher = pattern.matcher(wiki);
while (matcher.find()) {
wiki = wiki.replaceFirst("(\\[\\[[^\\|]*\\|)([^\\]]*)(\\]\\])", matcher.group(2));
... |
62ae03fb-f100-4622-9af3-c1f2bfdc93d5 | 9 | private static boolean stack_boolean(CallFrame frame, int i)
{
Object x = frame.stack[i];
if (x == Boolean.TRUE) {
return true;
} else if (x == Boolean.FALSE) {
return false;
} else if (x == UniqueTag.DOUBLE_MARK) {
double d = frame.sDbl[i];
... |
f6f0085f-bbf9-445e-9119-dffca5ffce44 | 7 | private static Class getAttributeTypeClass(int attributeType, String typeStr) {
Class type = RadiusAttribute.class;
if (typeStr.equalsIgnoreCase("string"))
type = StringAttribute.class;
else if (typeStr.equalsIgnoreCase("octets"))
type = RadiusAttribute.class;
// DAVI allow integer8 and integer16
//else... |
85160641-4ce0-487e-98ad-aa3823b9672b | 6 | public ArgumentReader resolveReader(Class<?> type)
{
ArgumentReader reader = getReader(type);
if (reader == null)
{
for (Class<?> next : readers.keys())
{
if (type.isAssignableFrom(next))
{
reader = readers.get(next)... |
1c662d92-45d5-4f55-ae46-99fe116ac86b | 6 | final Class318_Sub4 method2386(int i, AbstractToolkit var_ha) {
anInt10159++;
AnimatableToolkit class64 = ((Class318_Sub1_Sub5_Sub2) this).aClass235_10155
.method1668(false, true, -127, 2048, var_ha);
if (class64 == null)
return null;
Class101 class101 = var_ha.method3705();
class101.method894((((Cla... |
ae1af979-fb94-439d-99c7-1658e662d72f | 3 | private HashSet<Integer> getForbiddenColors(Value n) {
HashSet<Value> edges = adjacencyList.get(n);
HashSet<Integer> rval = new HashSet<Integer>();
for(Value v : edges) {
Integer c = v.getColor();
if(c != null && c != -1) {
rval.add(c);
}
... |
8175dde8-1f2e-4b7f-aa98-736c2870aa0e | 3 | protected boolean inBounds(int i, int j, BufferedImage completePic) {
return (i > 0 && j > 0 && i < completePic.getWidth() && j < completePic
.getHeight());
} |
f5011cd9-8275-41d6-97c9-8bf5477ec61f | 1 | public static void changeUserLastLogDate (User user) {
try {
Connection conn = DriverManager.getConnection(Utils.DB_URL);
PreparedStatement prS = conn.prepareStatement("update user set date_lastlog = ? where name = '" + user.getName() + "'");
prS.setString(1, Utils.getTodaysD... |
85cb7929-7495-4206-a6d7-d1e298885523 | 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... |
64fb0afc-6847-4bdf-aa00-4d3f97a2aaee | 0 | public void setjButtonPrevious(JButton jButtonPrevious) {
this.jButtonPrevious = jButtonPrevious;
} |
fc549ae7-e1bc-42e1-a37d-fe5ee917a52e | 1 | private final void insertOnline(Entry<K,V> e) {
if (onl[e.getH()].size()<this.w) {
onl[e.getH()].add(e);
onlsize++;
}
else { cam.put(e.getK(), e); }
} |
f8614d54-ea45-4d7f-9898-af2616ace9ee | 3 | public Texture loadTexture(String paramFileName, boolean paramFlipped, boolean paramUseRes)
{
String fileLoc;
try
{
if (paramUseRes)
{
fileLoc = "resources/" + paramFileName;
}
else
{
fileLoc = paramFile... |
abe2bb87-9d17-4bb8-b23d-efd8c0a1768d | 3 | public int getStatusDuration(TileStatus.Type type) {
if (!this.hasStatus(type)) { // Check if the tile even has the status at all.
return 0; // If not, then that status has 0 effectively 0 duration.
} else {
// Loop through all the status the tile does have.
for (TileStatus status : this.statuses) {
//... |
b02ed05f-e13a-407e-9c90-20a026affb8c | 5 | public static Map<String, List<Integer>> readCSV(String fileName) {
Map<String, List<Integer>> disp = new HashMap<String, List<Integer>>();
File file = null;
FileReader fr = null;
BufferedReader br = null;
try {
file = new File(fileName);
fr = new FileRead... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.