method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
ea0c9c28-b564-46da-8f22-bfd49d4f40f5 | 1 | @EventHandler(priority = EventPriority.LOWEST)
public void onRemoteConsoleEvent(RemoteServerCommandEvent event) {
try {
plugin.getDataManager().apply(plugin.getDataManager().getRcon(), event.getSender(), null);
} catch (DataLoadFailedException ex) {
plugin.getLogger().log(Lev... |
79a429d5-13c0-4ae1-a508-bdbe9af2c99d | 4 | private static <AnyType extends Comparable<? super AnyType>>
AnyType median3( AnyType [ ] a, int left, int right )
{
int center = ( left + right ) / 2;
if( a[ center ].compareTo( a[ left ] ) < 0 )
swapReferences( a, left, center );
if( a[ right ].compareTo( a[ left ] ) < 0 )
... |
7cd0196a-a160-4cff-ae52-9d1e73bf9a86 | 8 | @Override
public void doStep() {
final ProcessBuilder n = new ProcessBuilder();
final List<String> meta = new ArrayList<String>();
meta.add(ConfigManager.FFMPEG.getAbsolutePath());
meta.add("-i");
meta.add(entry.getDownloadTempFile().getAbsolutePath());
meta.add("-af");
meta.add("silencedetect=n=-50dB:d... |
c2313ed6-445b-4253-ae00-78db0f52cd98 | 3 | @Override
public boolean equals(Object o)
{
if (o == null || !(o instanceof Symbol))
{
return false;
}
Symbol obj = (Symbol) o;
if (!obj.getSymbol().equals(this.getSymbol()))
{
return false;
}
return true;
} |
ab84ac7c-7ef8-4adf-8ca4-9ae6e04dabaa | 3 | @Override
public void atacar(){
for(int i = 0; i < ejercito.size(); i++){
int refPosX = ejercito.get(i).refLabel.getLocation().x;
int refPosY = ejercito.get(i).refLabel.getLocation().y;
Point pos = super.refPosToMatrizPos(refPosX, refPosY);
... |
e722a4ac-f59a-4e8b-86dd-5d3c4d5f2d7e | 3 | private void fixColDown() {
moveToCeiling();
turnRight();
while (frontIsClear()) {
if (noBeepersPresent()) {
putBeeper();
}
move();
}
if (noBeepersPresent()) {
putBeeper();
}
turnLeft();
} |
e852fe12-d640-4950-ac45-3b64181ad48d | 0 | public int getHunger() {return hunger;} |
fd42cd67-bad9-4f9c-b23f-55dc37b68d7c | 5 | public int cdl3StarsInSouthLookback( )
{
return ((( ((( (this.candleSettings[CandleSettingType.ShadowVeryShort.ordinal()].avgPeriod) ) > ( (this.candleSettings[CandleSettingType.ShadowLong.ordinal()].avgPeriod) )) ? ( (this.candleSettings[CandleSettingType.ShadowVeryShort.ordinal()].avgPeriod) ) : ( (this.cand... |
a884fc00-a037-4f80-ab2e-a9a4e9ec5a57 | 5 | @Path("/admin/profiles.json")
@Produces(MediaType.APPLICATION_JSON)
@DELETE
public String deleteProfiles(
@Context HttpServletRequest request,
@Context HttpServletResponse response,
@QueryParam("json") String json ) {
if( !checkHostInfo(request.getRemoteHost(),
AdminProperties.getHttp_allowed()) ) ... |
54fc088d-0ca8-4bce-9b21-54827b13b578 | 4 | public void gameLoop() {
this.window.setVisible(true);
this.window.setCursorVisible(false);
this.musicStore.stopMidi("attack");
this.musicStore.playMidi("intro");
while(this.exit == false) {
while(this.eventQueue.hasNext()) {
this.eventQueue.handle();
}
this.window.draw(this... |
2668dd7d-606a-476a-9df0-f0950298fcc8 | 6 | private void merge( int start, int mid, int end)
{
int i = start;
int j = mid + 1;
int k = start;
while(i <= mid && j <= end)
{
if(number[i] < number[j])
{
temp[k] = number[i];
k++;
i++;
}
else
{
temp[k] = number[j];
k++;
j++;
}
}
while(i <= mid)
{
tem... |
78e57d18-f3b1-4a30-a741-c4e8d683b8df | 3 | public void rulesDelete(String objectName) {
String objectPath;
Folder ruleFolder;
objectPath = "/TranslateRules/" + objectName;
try {
ruleFolder = (Folder) session.getObjectByPath(objectPath);
ItemIterable<CmisObject> children = ruleFolder.getChildren();
... |
ef4b79d7-76af-4faf-926d-d77e096e6ddd | 5 | private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
... |
ec2a8da0-0b21-4ff8-9199-7f68fa991e1b | 4 | public void setComando(List<?> list)
{
for(PComando e : this._comando_)
{
e.parent(null);
}
this._comando_.clear();
for(Object obj_e : list)
{
PComando e = (PComando) obj_e;
if(e.parent() != null)
{
e.pa... |
871c1d2f-b599-447e-8d3c-fabf5ac9b44f | 5 | @Override
public void extract() throws XMLStreamException, FileNotFoundException
{
FileInfo simc = this.bfis.get(Parser.Types.SIMC.toString());
this.factory = XMLInputFactory.newInstance();
this.readerRaw = factory.createXMLStreamReader(new BufferedInputStream(new FileInputStream(... |
0c657644-7d2c-4c56-83ae-f8dcd1120ebc | 3 | public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException
{
background.draw(0,0);
for (int a = 0; a < 5; a++)
{
g.drawString("" + colBombs[a],180 + a * 100,105);
g.drawString("" + rowBombs[a], 80, 210 + a * 100);
g.drawString("" + colTotal[a], 195 + a * 100, 80);
g... |
7e294606-7a4c-4c71-9f58-709b75abe6ab | 1 | public void makePurchase(int amount) {
if (amount > getAvailableCredit()) {
throw new IllegalArgumentException("Amount of the purchase exceeds the available credit");
}
this.balance = this.balance + amount;
} |
139bd8b4-4035-426d-a63a-b6fa50384560 | 5 | public static String removeFormatting(String line) {
int length = line.length();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < length; i++) {
char ch = line.charAt(i);
if (ch == '\u000f' || ch == '\u0002' || ... |
779851d9-d340-47f5-89ab-8cd313245476 | 9 | public int evaluateBoard(Board b) {
Board.Player winner= b.hasConnectFour();
if (winner == null) {
// Store in sum the value of board b.
int sum= 0;
List<Board.Player[]> locs= b.winLocations();
for (Board.Player[] loc : locs) {
for (Board.... |
74cf050d-26a3-4bd5-a7d2-c9e229563016 | 3 | private Saveable getTarget() {
Saveable saveable = getTarget(Saveable.class);
if (saveable != null) {
for (String extension : saveable.getAllowedExtensions()) {
if (mExtension.equals(extension)) {
return saveable;
}
}
}
return null;
} |
abcfcd37-8577-4ccc-ab86-85970dd2be9c | 3 | public void initGame(ViewPlayer player1, ViewPlayer player2, int timeRemaining) {
if(!myThread.isPaused ()){
synchronized(myThread){
myThread.pause ();
}
}
if ( player1.isHuman () ) {
p1 = new Human (player1.getPlayerName (), WHITE, timeRemaining);
}
else {
p1 = ... |
51e07499-ae6b-4a00-b114-03b865f42f8f | 0 | public void setAmountPaid(double amountPaid) {
this.amountPaid = amountPaid;
} |
d59770fc-2170-412f-8062-f9d69472b106 | 1 | public List<String> getKeys() {
List<String> keysArray = new ArrayList<String>();
for(int i = 0; i < size; i++) {
keysArray.addAll(map[i].getKeys());
}
Collections.sort(keysArray);
return keysArray;
} |
0627fb73-d3b5-4497-a140-2d4e94092fc4 | 8 | public Map<String, String> queryInfo(String idNo) {
if(idNo == null || idNo.length() < 1) {
return null;
}
this.identityNo = idNo;
Map<String, String> result = new HashMap<String, String>();
String query = buildQueryString();
String url = buildConnectionStri... |
fc4b8851-478b-4a00-8425-25e103c08656 | 6 | @Override
public void removeEdgesBetween(N from, N to) {
if(containsNode(from) && containsNode(to)) {
for(WeightedEdge<N, W> edge : edgesFrom(from)) {
if(edge.to.equals(to)) {
nodes.get(from).remove(edge);
}
}
for(WeightedEdge<N, W> edge : edgesFrom(to)) {
if(edge.to.equals(from)) {
... |
e896525e-b1d0-4677-b836-5ee71f10854d | 3 | public void setThis(TThis node)
{
if(this._this_ != null)
{
this._this_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}... |
0240d391-36fb-4354-bd17-30b2d92814f8 | 3 | public String toStringHtml(int width, int maxHeight) {
StringBuffer sb = new StringBuffer();
sb.append("<table border=0>\n\t</tr>\n");
for (int pos = 0; pos < pwm.size(); pos++) {
// Sequence conservation
double seqConserv = seqConserv(pos);
// Calculate all base sizes and sort by size
ArrayList<Base... |
f788692c-5607-45b3-bfb9-63dbf7b03a35 | 8 | public int getSelection()
{
if(selectionOvalY == 3)
return 1;
else if(selectionOvalY == 27)
return 2;
else if(selectionOvalY == 51)
return 3;
else if(selectionOvalY == 75)
return 4;
else if(selectionOvalY == 99)
return 5;
else if(selectionOvalY == 123)
return 6;
else if(se... |
7013533d-23e0-4589-9651-aa593a9bbf28 | 1 | public int attackSpecial(Character opponent){
int damage;
System.out.println(_name+" makes an obscure " + lore[(int)(Math.random()*lore.length)]+ " reference!\n Ouch that one hurt!");
damage = reference(opponent);
if ( damage < 0 )
damage = 0;
opponent.lowerHP( damage );
return damage;} |
8054853e-1f01-4f0b-bc47-ae57c03f0978 | 1 | public void testEqualsAtEL() {
System.out.println("\n*** testEqualsAtEL ***");
try {
CycFormulaSentence sentence = getCyc().makeCycSentence("(#$likesAsFriend ?X ?Y)");
assertTrue(sentence.equalsAtEL(getCyc().makeCycSentence("(#$likesAsFriend ?Z ?Y)")));
CycFormulaSentence sentence2 = getCyc().... |
82b20962-0e74-47fb-af17-dbe0c19eba99 | 4 | int getRandomData(double r, double[] weights) {
double sum;
if (r <= weights[0]) {
return 0;
}
sum = 0;
for (int s = 1; s < weights.length; s++) {
if (r > sum && r <= sum + weights[s]) {
return s;
}
sum += weights[s];
}
return weights.length-1;
} |
672e02e5-2037-4724-b954-d3160acdd918 | 2 | public void testCycVariable() {
System.out.println("\n*** testCycVariable ***");
CycVariable cycVariable1 = VAR_X;
assertNotNull(cycVariable1);
assertEquals("?X", cycVariable1.toString());
assertEquals("?X", cycVariable1.cyclify());
assertEquals("'?X", cycVariable1.stringApiValue());
CycVari... |
b4c93917-c0be-4e34-b06e-cf67ee808193 | 8 | private void populateView(DefaultMutableTreeNode root) {
//root.removeAllChildren();
//while (root.getChildCount() > 0) {
//treeModel.removeNodeFromParent((MutableTreeNode)root.getChildAt(0));
//}
System.out.println("Computing selection range");
SampleLog filter = SampleFilter.filter(log, selectionStart, s... |
73903d15-20dc-47de-9718-d9e2d86a76f8 | 2 | public int getSortSequence(TreeColumn column) {
int size = mSortData.size();
for (int i = 0; i < size; i++) {
if (mSortData.get(i).mColumn == column) {
return i;
}
}
return -1;
} |
992953d6-fcd1-4bb7-b019-1ccec2c1c81a | 0 | public void setEstadoMovimiento(String estadoMovimiento) {
this.estadoMovimiento = estadoMovimiento;
} |
9723304c-40a1-4c17-8cfe-601679a1c800 | 6 | @EventHandler
public void CaveSpiderRegeneration(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.getCaveSpiderConfig().getDouble("C... |
b422a91e-82af-4d53-93c2-6e12bd387a92 | 9 | protected static void nnbr(KDNode kd, HPoint target, HRect hr, double max_dist_sqd, int lev, int K,
NearestNeighborList nnl) {
// 1. if kd is empty then set dist-sqd to infinity and exit.
if (kd == null) {
return;
}
// 2. s := split field of kd
int s = l... |
74cd8dfa-b782-4488-9d79-173a90bf586b | 3 | private void close() throws PersistenceException {
try {
if(this.connection != null &&
!this.connection.isClosed()) {
ConnectionProvider.getInstance().closeConnection();
this.connection = null;
}
} catch (SQLException sqlException) ... |
66ac3553-c0bb-46bb-83a5-bab87a720659 | 0 | private void printScore() {
timer.stop();
_timer = new Timer(300, this);
_timer.start();
ballMovement = false;
} |
1acbf747-4d22-46fc-a922-84c20ff6deb2 | 8 | public int play() {
for (int i = 0; i < ROW * COL; i++) {
Player p = (i % 2 == 0) ? p1 : p2;
char stone = p.getStone();
try {
// TODO 10秒でタイムアウトする。(スレッド?)
char[][] tmpBoard = new char[ROW][COL];
for (int k = 0; k < ROW; k++)
tmpBoard[k] = Arrays.copyOf(board[k], board[k].length);
in... |
5a28e28e-6982-4632-9431-90b7252e448d | 7 | public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine().trim());
int[] inputs = new int[N];
long[] candies = new long[N];
for (int i = 0; i < N; i++)
inputs[i] = Integer.parseInt(br.readLine... |
a22a313f-359b-4d01-8f03-9d8e1001e943 | 6 | @Override
public BinaryNodePS<T> addRightSubtree(Node<T> parent, BinaryTree<T> st) {
if (!(parent instanceof BinaryNodePS) || !(st instanceof BinaryTreePS)) {
throw new DifferentNodeTypesException();
} else if (isSafe() && !contains(parent)) {
throw new NodeNotFoundException();
}
BinaryNodePS<T> bn = (Bi... |
2e6a7c71-6f90-4ba4-96d0-5a7c8513bfe5 | 6 | public static void main(String argv[]) {
if (argv.length == 0) {
System.out.println("Usage : java EUGScanner <inputfile>");
}
else {
for (int i = 0; i < argv.length; i++) {
EUGScanner scanner = null;
try {
scanner = new EUGScanner( new java.io.FileReader(argv[i]) );
... |
2e9757bd-9470-43f3-b34f-655c30c1d6f2 | 1 | public void insertBack(CacheableNode cacheableNode) {
if (cacheableNode.previousNode != null) {
cacheableNode.unlinkSub();
}
cacheableNode.previousNode = head.previousNode;
cacheableNode.nextNode = head;
cacheableNode.previousNode.nextNode = cacheableNode;
cacheableNode.nextNode.previousNode = cacheableN... |
eca96e19-2b1d-4a7c-b642-e9f401f47444 | 3 | private boolean jj_3R_86() {
if (jj_3R_64()) return true;
Token xsp;
while (true) {
xsp = jj_scanpos;
if (jj_3_44()) { jj_scanpos = xsp; break; }
}
return false;
} |
d10bae4b-24a2-4688-803d-592082f1aaef | 8 | public QuestStatus status(IClientContext ctx) {
QuestStatus status = QuestStatus.NOT_STARTED;
if (configId != null) {
//System.out.println(configId.length);
for (int i = 0; i < configId.length; i++) {
int id = configId[i];
int value = ctx.varpbits.varpbit(id);
if (value == configEndValue[i]) {
... |
60ad79b6-a429-4609-bf1f-3f7e35039d2f | 2 | public boolean generateBarChart() {
int A1 = m_attributeDropdownBar1.getSelectedIndex();
int A2 = m_attributeDropdownBar2.getSelectedIndex();
String header = m_barHeader.getText();
String caption = m_Caption.getText();
String author = m_Author.getText();
String capt... |
054693d2-d924-41b4-9cec-072ef00bfb7b | 5 | void printInfo() {
System.out.print("You are in room " + String.valueOf(myIndex) +". Exits:");
for (int i = 1; i <= WumpusMap.N_DIRECTIONS; i++) {
WumpusRoom room = roomInDirection(i);
if (room != null) {
System.out.print(" " + WumpusMap.directionName(i));
}
}
System.out.println();
for (... |
362dd05f-5905-4b17-aaaa-b59b83443cd7 | 4 | private void setTableSize() {
if (!initialized) {
return;
}
setRowHeight(hight);
TableColumnModel columnModel = getColumnModel();
for (int i = 0; i < columnModel.getColumnCount(); i++) {
TableColumn column = columnModel.getColumn(i);
int preferredWidth = (int) getTableHeader().getDefaultRen... |
5c5e8478-52ba-44a7-947d-31d5cb0361c2 | 1 | public Boolean getValue(String word) {
if ( word == null )
return null;
logger.info("Searching InMemory datastore for [{}]", word);
Boolean isPalindrome = values.get(word);
return isPalindrome;
} |
2403216d-19c2-4284-bee2-8d34ebf118c9 | 2 | private void drawOldTutorial(Graphics g, Dimension size) {
int yCoord = 50;
g.setColor(Color.getHSBColor(172, 0, 75));
g.fillRect(0, 0, size.width, size.height);
g.setColor(Color.BLACK);
Font original = g.getFont();
g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 24));
String welcomeMessage = "Welcome to Y... |
71bd5662-d995-4727-9d7e-4b3edeca65f6 | 0 | public ResourceId(int packageId, int typeId, int itemIndex) {
this.packageId = packageId;
this.typeId = typeId;
this.itemIndex = itemIndex;
} |
c39d92be-3d39-4d96-b519-d8f2f0342377 | 8 | public static void main(String[] args) throws BadStateMachineSpecification, InvalidEventException, InterruptedException {
ConcurrentStateMachine<PerformanceEnum>[] concurrentFSM = new ConcurrentStateMachine[FSMS];
CountDownLatch latch = new CountDownLatch(FSMS);
TestThread[] testThreads = new... |
e2a8a7e4-f136-42d0-862a-1ca1c6505788 | 0 | @Basic
@Column(name = "reorder_level")
public int getReorderLevel() {
return reorderLevel;
} |
80072fdc-7b5c-4c06-9737-44ac846edb2e | 8 | public static void multAdd( RowD1Matrix64F A , D1Matrix64F B , D1Matrix64F C )
{
if( C.numCols != 1 ) {
throw new MatrixDimensionException("C is not a column vector");
} else if( C.numRows != A.numRows ) {
throw new MatrixDimensionException("C is not the expected length");
... |
0da75d39-fe23-4dbf-bc35-847023e662da | 9 | public int bitrate(int i){
if(i>=links)return(-1);
if(!seekable && i!=0)return(bitrate(0));
if(i<0){
long bits=0;
for(int j=0;j<links;j++){
bits+=(offsets[j+1]-dataoffsets[j])*8;
}
return((int)Math.rint(bits/time_total(-1)));
}
else{
if(seekable){
// return the actual... |
70ff346f-d477-4a95-a561-286fc5151a6c | 3 | public boolean isApplicable(PageInfo page) {
boolean acceptable = true;
acceptable &= params.acceptableURLs == null ||
params.acceptableURLs.matcher(page.getURL().toString()).find();
if (page.getContent() != null) {
acceptable &= params.acceptableContent == nu... |
17174197-693f-4d09-bb89-9448d424f718 | 9 | public int compare(String season1, int year1, String season2, int year2) {
if (year1 < year2) {
return -1;
} else if (year1 > year2) {
return 1;
} else if (year1 == year2) {
if (season1 == null || season2 == null) {
return 0;
} else... |
6f5b8e65-21cf-4e0c-ab4b-090328049b33 | 7 | private boolean endsWithPossessive(int pos) {
return (stemEnglishPossessive &&
pos > 2 &&
text[pos - 2] == '\'' &&
(text[pos - 1] == 's' || text[pos - 1] == 'S') &&
isAlpha(charType(text[pos - 3])) &&
(pos == endBounds || isSubwordDelim(charType(text[pos])... |
d7719d18-020c-4a23-b322-231ab92f6b04 | 2 | @Override
public boolean activate() {
if(Tabs.getCurrent() != Tabs.INVENTORY && hasSpinTicket()) {
return false;
}
return hasSpinTicket();
} |
10394db5-d889-4d17-a121-6fd1013c1318 | 6 | public static boolean twoPairs(Hand hand) {
hand.sortByValue();
if(
(hand.getCard(0).getValue() == hand.getCard(1).getValue()) &&
((hand.getCard(2).getValue() == hand.getCard(3).getValue())
) || (
(hand.getCard(0).getValue() == hand.getCard(1).getValue()) &&
((hand.getCard(3).getValue() == hand... |
8e46d6e8-d375-4599-82eb-8c981e0ca4e1 | 8 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Pair<?, ?> other = (Pair<?, ?>) obj;
if (!Objects.equals(this.var1, other.var1)) {
return fal... |
98d5e158-44fa-4661-8180-f4a37de3e726 | 4 | public static void main(String[] args) throws Exception{
DocumentBuilderFactory domFactory = DocumentBuilderFactory
.newInstance();
domFactory.setNamespaceAware(true); // never forget this!
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc=null;
try {
doc = builder.parse("C:\\U... |
4534d3dd-7e2e-42b9-ae5c-49e03d724313 | 9 | public boolean execute(Action a) throws IOException {
QState state;
boolean rc=false;
if(a instanceof LostConnection) {
_session.terminate();
rc=true;
} else if(a instanceof SuspendServiceAck) {
_log.debug("Sending ACK for Suspend Service Request");
_session.send(new SuspendServiceAck());
_ses... |
86f63416-e01e-4c99-b429-df9b511042ee | 4 | void radb5(int ido, int l1, final double cc[], double ch[],
final double wtable[], int offset)
{
final double tr11=0.309016994374947D;
final double ti11=0.951056516295154D;
final double tr12=-0.809016994374947D;
final double ti12=0.587785252292473D;
... |
71a601a1-ead1-47bb-964e-95337a9e21b3 | 9 | public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[63];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 53; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
i... |
3f4194ff-c953-45f9-9439-440f3e9ef829 | 7 | public ColorCafe calcDestColor (ColorCafe sourceColor, ColorCafe backgroundColor,
double lightValue)
{
double sourceRed = (double)sourceColor.red / 255.0;
double sourceGreen = (double)sourceColor.green / 255.0;
double sourceBlue = (double)sourceColor.blue / 255.0;
double source... |
2a3c946c-e207-49dd-a0f6-63c4e9d88855 | 9 | public String strStr(String haystack, String needle) {
int head = 0;
int pHaystack = 0;
int pNeedle = 0;
while(true){
while(pHaystack < haystack.length() && pNeedle < needle.length() &&
haystack.charAt(pHaystack) != needle.charAt(pNeedle)){
... |
f0e2203b-fc21-4e1a-b56e-59e615a21a90 | 3 | public static byte[] fetchClass(String host, int port,
String directory, String classname)
throws IOException
{
byte[] b;
URLConnection con = fetchClass0(host, port,
directory + classname.replace('.', '/') + ".class");
int size = co... |
a5909a03-b026-40c7-88c4-030b257ed3e8 | 4 | public boolean authenticate(String userName)
{
boolean success = false;
SendHandler sendHandler = new SendHandler(this);
Message msg = new Message();
if (userName.contains(",")) {
return success;
}
msg.setType("login");
msg.setSender(userName);
msg.setMessage(userName);
try {
sendHandler.sen... |
85e046d4-10e7-4d9e-a61f-13251156b7d8 | 1 | public void newEmployee() {
Database db = dbconnect();
try {
String query = "INSERT INTO employee (firstName, lastName, "
+ "username, password, bIsTroubleshooter) "
+ "VALUES (?,?,?,?,?)";
db.prepare(query);
... |
2fa59ce6-cb92-49a7-a7f6-484efebe99cf | 5 | @Override
public void preform(int source) {
switch(source) {
case(0): //Disconnecting
if(host) {
try {
Server.server.close();
} catch (IOException e) {
e.printStackTrace();
}
}
closeGui(this); break;
case(1): Rocket.getRocket().network.manager.sendStartgame();
break;
... |
17f7bfb9-150f-4cfb-aa58-3122fb521a66 | 1 | private void paintBackgroundAndStuff(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
if(status <= 2) {
g.setColor(Color.WHITE);
g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 200));
g.drawString(stringShownYAMG.toString(), 190, 200);
g.setFont(new Fo... |
4ad76c83-3704-474c-82e3-cb8ee5de7935 | 7 | public List<RadialBond> getBonds() {
if (model == null)
return null;
if (model.bonds == null || model.bonds.isEmpty())
return null;
List<RadialBond> list = null;
RadialBond rBond = null;
synchronized (model.bonds.getSynchronizationLock()) {
for (Iterator it = model.bonds.iterator(); it.hasNext();) {
... |
25a0146e-a992-4d04-9813-75a167df02a2 | 3 | public static boolean saveStudent(Student stu)
{
StudentDAO studentDao = new StudentDAO();
Session sessObj = studentDao.getSession();
Transaction tx =null;
boolean flag = false;
try
{
tx = sessObj.beginTransaction();
studentDao.save(stu);
tx.commit();
flag=true;
}
catch(RuntimeException re)... |
19638efb-195a-4776-bf9b-13e42418b42d | 9 | public static long getLetCount(File file) throws FileNotFoundException {
// This variables stores the number of letters.
long numOfLets = 0;
// This scans the document.
BufferedReader reader = null;
// Initializes the reader.
reader = new BufferedReader(new FileReader(file));
// A temporary variable to st... |
86daccdb-155d-41a2-9f94-47c9d243701f | 1 | private void itmMnu_DepartamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itmMnu_DepartamentoActionPerformed
if (usuarioLogado.getTipo().equals("Diretor")) {
GestaoDepartamentoForm gestaoDepartamentoForm = null;
gestaoDepartamentoForm = new GestaoDepartamentoFor... |
05f66868-b7b1-412b-aa7b-89e57f846849 | 8 | private void checkInput(int delta) {
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
magnitude += delta / 1000.0f;
if (magnitude > 0.9f) {
magnitude = 0.9f;
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
magnitude -= delta / 1000.0f;
if (magnitude < 0.1f) {
magnitude = 0.1f;
}
}
if (Key... |
7e72fc56-ada1-43a7-ad3b-bb8c994615f1 | 9 | protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
System.out.println("HProjet Post");
// recherche du projet à modifier, par son Id. si pas d'Id, on est en creation de projet
Projet updatedProjet = new Projet();
if ((request.getParamete... |
f08fd2a8-4576-4cfe-8137-1fb08d152428 | 4 | private void buildItemElements(Node node, StringBuffer buf, String line_ending) {
Iterator it = node.getAttributeKeys();
StringBuffer readOnlyAtts = new StringBuffer();
if (it != null) {
while (it.hasNext()) {
String key = (String) it.next();
Object value = node.getAttribute(key);
//if (isR... |
aa443523-c084-4d01-af4e-5b96343a1bf8 | 9 | int[] neighbours(int i,int j)
{
int cnt=0;
int n[]=new int[4];
if(i!=0)
{
if(!cells[i-1][j].visited) n[cnt++]=0;
}
if(j!=94)
{
if(!cells[i][j+1].visited) n[cnt++]=1;
}
if(i!=44)
{
if(!cells[i+1][j].vi... |
d7ac0407-9680-409e-be7e-95602aa1f57c | 2 | public void setConstants(double cognitiveConstant, double socialConstant, double K){
assert(socialConstant + cognitiveConstant >= 4 && K >= 0 && K <= 1);
this.socialConstant = socialConstant;
this.K = K;
this.cognitiveConstant = cognitiveConstant;
} |
56a39fd3-52af-4dec-b188-1434726004cd | 6 | @Override
public ArrayList<Task> findAllDone(Boolean done) {
ArrayList taskList = new ArrayList();
try {
connection = getConnection();
ptmt = connection.prepareStatement(QUERY_SELECT + "WHERE done=?;");
ptmt.setBoolean(1, done);
resultSet = ptmt.execut... |
236cc921-2aa9-42a2-bc0f-1d0116bfb460 | 7 | private void compare152And68APEBS(PrintWriter outFile)
{
boolean noExceptions = true;
// outFile.printf("%s enter compare152And68APEBS%n", TAG);
// outFile.flush();
outFile.printf("%n********** ********** ********** ");
outFile.printf("********** ********** **********%n%n");
outFile.printf("Li... |
feaa9380-6d9d-484e-ac94-5cbe739f1808 | 1 | public boolean isEmpty(){
return (root == null)? true : false;
} |
5c5995fd-b86b-485a-acc5-b628b29b36bc | 5 | public final FEMFormatter putArray(final Iterable<? extends FEMValue> array) throws NullPointerException, IllegalArgumentException {
final Iterator<? extends FEMValue> iter = array.iterator();
if (iter.hasNext()) {
FEMValue item = iter.next();
if (iter.hasNext()) {
this.putIndent().put("[").putBreakInc().... |
36853415-09dc-4f19-857a-4bb08a4d0cea | 2 | public String getDefaultLayerName() {
String prefix = "Layer ";
int highestLayerNb = 0;
for (CPLayer l : layers) {
if (l.name.matches("^" + prefix + "[0-9]+$")) {
highestLayerNb = Math.max(highestLayerNb, Integer.parseInt(l.name.substring(prefix.length())));
}
}
return prefix + (highestLayerNb + 1);... |
8e66fe2c-f559-44f0-a3e6-717b66ec5ed7 | 5 | @SuppressWarnings("unchecked")
@Override
public VariableValue getValidValue(VariableValue value) {
if (value == null)
return min;
if (!(value instanceof Comparable<?>))
return min;
if (((Comparable<VariableValue>)min).compareTo(value) > 0)
return min;
if (((Comparable<VariableValue>)max).compareTo(va... |
50e0d53a-2e78-4a8a-94c4-f970f3e5ed62 | 9 | private void updateScreen() {
bufferStrat = getBufferStrategy();
graphics = null;
try {
graphics = bufferStrat.getDrawGraphics();
Graphics2D graphics2D = (Graphics2D) graphics;
RenderingHints renderHints = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);... |
42b4956b-ef0a-4cb3-8744-eabf0ce7f3fe | 7 | @Override
public void mouseClicked(MouseEvent event) {
CentralSystem centralSystem = CentralSystem.getCentralSystem();
JToggleButton sourceJTB = new JToggleButton();
JButton sourceJB = new JButton();
ButtonsJP buttonsJP = connectionWindowController.getConnectionWindow().getButtonsJP();
if(event.getSource(... |
f3316789-8e05-4d57-992e-00bf304d629d | 9 | public void drawGUI(Graphics g) {
if (locations != null) {
/*g.setColor(new Color(0, 0, 255, 100));
for (Location[] colomn : locations)
for (Location l : colomn)
if (l.getRoom() != null)
g.fillRect(l.getPoint().x * 27 + 3,
l.getPoint().y * 27 + 3, 24, 24);*/
g.setColor(new Color(0, 25... |
015c8c60-815c-40f5-a90e-c898980cfc61 | 6 | public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Run format: app <GridSimConfigFileName> <GridSimOutputFileName>");
System.exit(-1);
}
if (args[0].equals("--test")) {
createTestConfig(args[1]);
System.exit(0);
... |
da2923f7-41e8-4656-9683-a1b10a50fb4e | 3 | public static void main(String[] args) {
// Check if this PC is already configured
if (ConfigManager.configExists()) {
// Get instance of ConfigManager which will read from file
ConfigManager cm = new ConfigManager();
// Run correct class based on current role.
if (cm.getRole() == ConfigManager.ROLE_CL... |
7c9eac37-4b0b-4ca9-be8c-9c2511e97c44 | 2 | @Override
public void startElement(String arg0, String arg1, String arg2,
Attributes arg3) throws SAXException {
System.out.println("开始解析元素 " + arg2);
if (arg3 != null) {
for (int i = 0; i < arg3.getLength(); i++) {
// getQName()是获取属性名称,
System.out.print(arg3.getQName(i) + "=\"" + arg3.getValue(... |
9af0b82d-a81e-472e-84d5-30e2f5e8f57c | 7 | public void paint(Graphics g) {
g.setColor(Color.white);
g.fillRect(LEFT_BORDER, TOP_BORDER, cols*SQUARE_SIZE, rows*SQUARE_SIZE);
g.setColor(Color.blue);
g.drawRect(LEFT_BORDER, TOP_BORDER, cols*SQUARE_SIZE, rows*SQUARE_SIZE);
//set the color for drawing circles
g.setColor(C... |
52c57309-2f56-4d78-940b-7218baa7bd8b | 5 | @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("(" + i + "," + j +") ");
switch (direction) {
case Board.NORTH: sb.append("North"); break;
case Board.EAST: sb.append("East"); break;
case Board.WEST: sb.append("West"); break;
case Board.SOUTH: sb.append("Sou... |
bdf18067-9d29-4c23-8763-2521bbaa57cf | 4 | private void executePromotion(Position pos) {
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
Piece gonnaTransPiece = Board.chessBoard.get(pos);
Color color = gonnaTransPiece.color;
System.out.println("어떤 piece로 바꾸시겠습니까? 1.퀸 2.룩 3.비숍 4.나이트" );
switch(sc.nextInt()){
case 1 :
... |
c4d1b06f-34eb-453c-b800-17652905ea35 | 3 | @Override
protected void afterEnteredFocus(FocusChangeDirection direction) {
if(items.isEmpty())
return;
if(direction == FocusChangeDirection.DOWN)
selectedIndex = 0;
else if(direction == FocusChangeDirection.UP)
selectedIndex = items.size() - 1;
... |
8f5cbe58-42f5-400d-bd1f-a55a07d00dd1 | 5 | public void setDateTimeZone(Object dtz) throws JspTagException {
if (dtz == null || dtz instanceof String
&& ((String) dtz).length() == 0) {
this.dateTimeZone = null;
} else if (dtz instanceof DateTimeZone) {
this.dateTimeZone = (DateTimeZone) dtz;
} else ... |
9c25ed22-dad4-4533-ae9f-b09ea3f3a298 | 5 | public ControlsFrame(String title, final MotionScreen attatched) {
super(title);
this.attatched = attatched;
ActionListener typeChanged = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String type = ((JRadioButton)arg0.getSource()).getText();
if (type.equals(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.