method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
52ac43e5-dc67-4cbe-b861-ebdcaa2e1f8c | 3 | public void sql_lookup() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Statement s = GUI.con.createStatement();
s.executeQuery ("SELECT * FROM groups");
ResultSet rs = s.getResultSet();
boolean found = false... |
4ecfa84e-66bc-4419-894d-9eb3ead68df9 | 1 | @Override
public void reduce(Text key, Iterator<Text> values,
OutputCollector<Text, Text> output, Reporter arg3) throws IOException {
int sumImpressions = 0;
int sumClicks = 0;
int sumConversions = 0;
String []countLineArr = null;
Text countLine = null;
while(values.hasNext()){
countLine = values... |
4d553075-eab1-4f24-ae41-8c44c542c0b5 | 3 | public void setAsset(String as, int a){
if ("Pork Bellies".equals(as)){
pb = a;
}
else if ("Frozen Orange Juice Concentrate".equals(as)){
oj = a;
}
else if ("Soybeans".equals(as)){
sb = a;
}else throw new Error("No such asset");
} |
f6050c88-0a18-402a-9a7d-b6adc2441c8a | 9 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
if (!checkIfLogged(request)) {
this.getServletContext().getRequestDispatcher(PathsMap.getInstance().getJspPath("login")).forward(request, response);
... |
e7ad5705-91c0-47ea-8db8-1cb2d4342875 | 8 | private static String getValTemplate(int i){
switch (i) {
case LITERAL:
return "?1";
case POINTER:
return "[?1]";
case atA_plusLiteral:
return "[A + ?1]";
case atB_plusLiteral:
return "[B + ?1]";
case atC_plusLiteral:
return "[C + ?1]";
case atX_plusLiteral:
return "[X + ?1]";
case atY... |
c511a6ba-9289-4dd6-8725-7deab7a24e48 | 9 | @Override
public void run() {
try{
Socket socket=new Socket("localhost",1890);
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
... |
a839a678-573f-494c-8e99-e38fa9629575 | 1 | public static void exchange(int[] array,int i,int j){ //exchange 2 elements array[i] and array[j]; i and j is the index of the array.
if(j!=i){
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
} |
f28a1060-1ce1-41da-8ff1-b6cb43aa6bc1 | 4 | @Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
Position other = (Position) obj;
return this.x == other.x && this.y == other.y;
} |
c35f140a-6ef6-4907-881c-e072a383c7f1 | 1 | public static int checksum(ByteBuffer data, int offset, int length) {
data.order(ByteOrder.LITTLE_ENDIAN);
short sum = 0;
for (int i = offset; i < offset + length; i += 2) {
sum += data.getShort(i);
}
return ((~sum + 1) & 0xffff);
} |
9642bad6-54c9-43cb-a128-a0713b4b7280 | 0 | public static void main(String[] args) {
Integer i=new MaxProductOfWordLength().toInt("abc");
System.out.println(i.toBinaryString(i));
} |
da81c1ee-09ba-4737-b785-dea7c74a30e5 | 8 | private List<List<String>> huntForTokens(String text) {
// OVO BI TREBALO ISKORISTITI.Broj riječi u rečenici
// int numberOfTokens = 0;
int numberTokenCount = 0;
int wordTokenCount = 0;
List<String> wordTokens;
List<String> numberTokens;
StringTokenizer tokenizer = new StringTokenizer(text,
". * ! ... |
0b0fd38b-f5ca-4b16-96fd-6fd95aadfb8f | 6 | @Override
public String toString() {
String string = "\n\t\t\tCPU:";
for (HardwareAlternative alt : cpuAlternatives)
string += "\n\t\t\t\t" + alt.toString();
string += "\n\t\t\tHDD:";
for (HardwareAlternative alt : hddAlternatives)
string += "\n\t\t\t\t" + alt.toString();
string += "\n\t\t\tMemory:";
... |
aa4915c9-c314-4cdb-834a-8d37d5e94f21 | 9 | public static int validateInstallFromStationTransaction(Player player, Station station, String componentName) {
int result = -1;
CargoHoldComponent stationHold = station.getShip().getCargoHold().get();
CargoHoldComponent playerHold = player.getShip().getCargoHold().get();
if (stationHold... |
12fa940d-86fd-4582-91ec-d0983d9b8a97 | 7 | public static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... |
e4afadf1-5bd7-4f2d-9471-fb9c24730b36 | 7 | public boolean ajouterPointDeLivraison(Noeud noeudALivrer, int idClient, Livraison livraisonAvant) throws HorsPlageException {
// Recherche de la plage horaire de precedent
PlageHoraire plageInsertion = null;
int maxId = 0;
for (PlageHoraire plage : this.getPlagesHoraire()) {
... |
78afe05d-160c-4d6e-b9de-a8f5c376637a | 7 | public void listen()
{
String s;
while ((s = in.readLine()) != null)
{
if (s.equals("/accept"))
{
try
{
System.out.println("Client making new audio chat socket on port: "+(socket.getPort()+1));
if (... |
a8e178cc-6276-46a4-881a-7e8074d7f13c | 5 | private void calcImage() {
image = new BufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.TRANSLUCENT);
Graphics2D graphics2d = image.createGraphics();
RoundRectangle2D rectangle2d = new RoundRectangle2D.Double(0, 0, DEFAULT_WIDTH-1, DEFAULT_HEIGHT-1 ,13 ,13);
graphics2d.setColor(new Color(0xdddeee));
... |
d8c70dc3-08ee-4b5b-8a06-e124445c42a7 | 9 | private void process(File aFile) {
if(aFile.isFile()){
String name = aFile.getName();
if (name.substring(name.length()-4).equals("java")){
try {
if (!name.equals("Command.java") && !name.equals("CommandFactory.java")){
String pack = aFile.getPath().replaceAll("\\\\", ".");
pack = pack.subst... |
909363ea-c14a-427d-af88-45481d88f829 | 7 | public void draw(Graphics2D g,float interpol) {
if (isPaused)
interpol = 0F;
g.setColor(Color.BLACK);
g.fillRect(0, 0, screenDims.width, screenDims.height);
Vector offset = calcMapScreenOffset(interpol);
drawBackgroundPattern(g,interpol,offset);
for (Mob m : dots) {
if (isWithinScreen(m))
... |
b11ae391-b1cf-482c-9d13-9e786cf8053f | 5 | public void performOpenCommand()
{
// Show jFileChooser
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Timeflecks Database Files", "db");
fileChooser.setFileFilter(filter);
int returnVal = fileChooser.showOpenDialog(menu);
if (returnVal ==... |
a710c0ed-e17f-4bec-96ba-3dccb2bea704 | 4 | private String readSection(Document document, String firstLine, BufferedReader reader, HasSubSection parent) throws IOException {
int currentlvl = getLvl(firstLine);
Section section = new SectionImp(new TitleImp(firstLine.substring(currentlvl)), parent);
String line;
while((line = reader.readLine())!=null && !l... |
3ecc16e2-008a-451d-b51f-681cb305adc4 | 3 | public String expression(){
String word;
switch(randomFunc){
case 0:
word = "sin(" + nextNode.expression()+ ")" ;
break;
case 1:
word = "cos(" + nextNode.expression()+ ")" ;
break;
c... |
1f539e97-5480-45f6-994f-3ee22ace30f9 | 6 | public void createMiniMap(Graphics2D g) {
g.setColor(new Color(200,200,200,75));
g.fillRect(Constants.FRAME_WIDTH - MINIMAP_WIDTH, Constants.FRAME_HEIGHT - MINIMAP_HEIGHT, MINIMAP_WIDTH, MINIMAP_HEIGHT);
g.setColor(new Color(200,200,200,200));
g.drawRect(Constants.FRAME_WIDTH - MINIMAP_W... |
c3ea6520-e20b-4507-a141-737acb2ae5c3 | 1 | public void updateUser(User user){
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
String url = "jdbc:derby:" + DBName;
Connection connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement();
DateFormat dtfLastLogin = new SimpleDateFormat("yyyy-MM-dd ... |
a952fb15-cdca-4869-a9b3-e91b259c2b45 | 7 | public void writeCSS(){
File file = new File("genfile.html");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
System.err.println("Unable to create file");
}
}
FileWriter fw = null;
try {
fw = new FileWriter(file.getAbsoluteFile());
} catch (IOException e) {
... |
b885f2dc-d864-4dec-b2d3-ca4cd22131a7 | 6 | private void vaccineHealthyPopulation() {
int vaccines;
HumanInformation humanInformation;
//Calculate the number of healthy humans to vaccine
vaccines = Math.min(this.healthyCount, this.configuration.getResources().getVaccination().getVaccinatedPerVaccinationKit());
... |
f5459ada-0d11-4e90-ad59-a689f8fe2d12 | 0 | public static void setHeight(int height) {
h = height; // h = basic dimension: height (distance between two adj centresr aka size)
r = h / 2; // r = radius of inscribed circle
s = (int) (h / 1.73205); // s = (h/2)/cos(30)= (h/2) / (sqrt(3)/2) = h / sqrt(3)
t = (int) (r / 1.73205); // t =... |
2b28e9ac-539e-430f-9f96-38bcf564dbf9 | 6 | public void run() {
while(!this.shutdown || !this.queuedMessages.isEmpty()) {
final List<byte[]> queuedMessagesCopy;
synchronized(this.queuedMessages) {
queuedMessagesCopy = new LinkedList<byte[]>(this.queuedMessages);
this.queuedMessages.clear();
}
if (queuedMessagesCopy != null) {
while(!q... |
a899ec0b-fc29-4fd2-95d2-c8e8e9571b9c | 2 | @Override
public void mouseDragged(MouseEvent evt) {
Point p;
if (evt.getSource().equals(slider)) {
p = new Point (truncX(slider.getLocation().x + (evt.getX() - startPointX)), 3);
Date d = xToDate ((int)p.getX());
Calendar c = Calendar.getInstance();
c.setTime(d);
if (c.get(Calendar.MINUTE) % 15 ==... |
08fa3fa9-5191-4d9e-9cdc-62f76d6e588f | 7 | private static int resolveTimeUnit(String unit) {
if (unit.equalsIgnoreCase("second")) {
return RrdGraphConstants.SECOND;
}
else if (unit.equalsIgnoreCase("minute")) {
return RrdGraphConstants.MINUTE;
}
else if (unit.equalsIgnoreCase("hour")) {
... |
2da7f8d1-0d52-4a52-a40a-68bb21ac618b | 6 | protected static int base36toInt(byte abyte) {
if ((abyte >= 48) && (abyte <= 57)) {
return abyte - 48;
}
if ((abyte >= 97) && (abyte <= 122)) {
return abyte - 97 + 10;
}
if ((abyte >= 65) && (abyte <= 70)) {
return abyte - 65 + 10;
}
... |
023041f0-588c-4842-a627-465bad82c05a | 6 | public synchronized void gridletPause(int gridletId, int userId, boolean ack)
{
boolean status = false;
// Find in EXEC List first
int found = gridletInExecList_.indexOf(gridletId, userId);
if (found >= 0)
{
// updates all the Gridlets first before pausing
... |
73db8cdf-7009-4c33-8358-3340202b4898 | 3 | private void createList() {
assayContainer = new JPanel(new FlowLayout(FlowLayout.LEFT));
assayContainer.setOpaque(false);
errorMessageWriter = new ErrorMessageWriter();
errorReports.add(0, createSummaryReport());
for (ISAFileErrorReport errorReport : errorReports) {
... |
126355aa-1aba-4ff8-bb7d-7e1e07e6b3bc | 7 | public static void makeCompactGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeCompactGrid must use SpringLayout... |
04c0e789-9a9c-4f84-af57-f2a807f2231e | 0 | public PdbReaderWriter ()
{
// subclasses can place flavor-specific init stuff here
// if (Outliner.DEBUG) System.out.println("\tStan_Debug:\tPdbReaderWriter:constructor");
} // end constructor |
7822b3f4-e9a9-4b5e-aba6-992dc822aca3 | 3 | private Node find(T value, Node node) {
while (node != null) {
if (value.compareTo((T) node.data) < 0) {
node = node.left;
} else if (value.compareTo((T) node.data) > 0) {
node = node.right;
} else {
return node;
}
}
return null; // No match
} |
015b9543-4c61-4f4d-bd8e-0c8e6c562a60 | 8 | public static String toTable(ArrayList<ArrayList<String>> array, boolean header){
//===================== Local Data ======================//
final int COL_DIVIDE_WIDTH = 8;
StringBuilder msg = new StringBuilder();
//create array to hold column formatting information
... |
845f9294-feab-4fb0-ae2a-0ef4a7e7e392 | 7 | public byte markTokensImpl(byte token, Segment line, int lineIndex)
{
if(line.count == 0)
return Token.NULL;
switch(line.array[line.offset])
{
case '+': case '>':
addToken(line.count,Token.KEYWORD1);
break;
case '-': case '<':
addToken(line.count,Token.KEYWORD2);
break;
case '@': case '*':
... |
2f9d9584-9427-4b93-af96-7bf1d33c774c | 4 | public JPanel buildDateTimePanel(Date value)
{
JPanel datePanel = new JPanel();
_dateChooser = new JDateChooser();
_dateChooser.setPreferredSize(new Dimension(143, 20));
if (value != null)
_dateChooser.setDate(value);
for (Component comp : _dateChooser.getCompone... |
4233df6a-55b5-46a4-adef-a8acfe215a1d | 6 | public static Hand findDuplicateTypeHand(Set<Card> cardSet) { // quads, trips, pairs, or high cards
CardSetStats stats = new CardSetStats(cardSet);
// quads?
if (stats.quadsRank != null) {
List<Rank> remainingCards = stats.getRemainingHighCards(stats.quadsRank);
return Hand.FourOfAKind(stats.qua... |
58f95cfc-cc88-4ddc-a9e9-f9478087e946 | 7 | public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(!DONE_IMPORTING)
{
if(frames%2==0)
g.setColor(Color.BLACK);
else
g.setColor(Color.WHITE);
g.fillRect(0,0,getWidth(),getHeight());
return;
}
if (!jsb.getValueIsAdjusting() && !duder)
jsb.setValue(Integer.MAX_VALUE);
... |
4ae3e5bc-713d-4763-8a7c-8980e69d643f | 3 | private void leaveGame() {
int result = JOptionPane.showConfirmDialog(
this,
"Are you sure you want to leave a game?",
"Exit Application",
JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
try {
... |
d0e7f3d1-610c-490d-af6e-56457ced1997 | 6 | public static String numberToString(Number number) throws JSONException {
if (number == null) {
throw new JSONException("Null pointer");
}
testValidity(number);
// Shave off trailing zeros and decimal point, if possible.
String string = number.toString();
if (string... |
45c9db6f-3be3-4b7a-9da5-89422fb1cbf4 | 8 | @Override
public boolean convert(String filename, ArrayList<ConvertOption> options) {
try {
int toolindex = 0;
File f = new File(filename);
String nLine = String.format("%n");
FileWriter writer = new FileWriter(f);
writer.write("PA;" + nLine);
String id = "";
int x = 0;
int y = 0;
for (int... |
36596ae3-fc29-43e8-bfaa-31cc47c637bf | 6 | public void move(Direction direction) throws PlayerCannotMoveException {
if (canMove(direction)) {
switch (direction) {
case NORTH:
positionLine--;
break;
case SOUTH:
positionLine++;
break;
case WEST:
positionColumn--;
break;
case EAST:
positionColumn++;
break;
}
i... |
3de80665-10e6-48a3-bea9-510cd6b2ce79 | 4 | public Face getDirectionToStart(){
if(start.getNorth()!=null){
return Face.SOUTHERN;
}else if(start.getWest()!=null){
return Face.EASTERN;
}else if(start.getSouth()!=null){
return Face.NORTHERN;
}else if(start.getEast()!=null){
return Face.WESTERN;
}
return null;
} |
519f1dae-8bb0-46e3-b81f-94dd5784623f | 3 | public Track getTrack(int trackNumber)
{
Track ret = new Track();
// Search all the tracks
boolean found = false;
Iterator<Track> tIt = tracks.iterator();
while (tIt.hasNext() && !found)
{
Track currTrack = tIt.next();
if (currTrack.getTrackNumber() == trackNumb... |
7ffd0573-c910-4025-9706-422bfac2a5e8 | 5 | public Boolean wipeTable(String table) {
try {
if (!core.checkTable(table)) {
core.writeError("Error at Wipe Table: table, " + table + ", does not exist", true);
return false;
}
Connection connection = getConnection();
Statement statement = connection.createStatement();
String query = "DE... |
7a931b9a-c790-4ad1-aaa9-a49f75f5ffa1 | 0 | public Student(String name) {
super(name);
} |
274d2364-e3c6-4bee-9f83-cab9723ec417 | 7 | public static void normalizeButtons(JButton[] buttons) {
int maxWidth = 0;
int maxHeight = 0;
for (int a = 0; a < buttons.length; a++) {
buttons[a].setPreferredSize(null);
Dimension d = buttons[a].getPreferredSize();
Number n = (Number) buttons[a].getClientPro... |
dbf99e25-76c8-44e7-bcc9-7a5dbed9a00b | 9 | public void keyPressed(KeyEvent e) {
switch ( e.getKeyCode() ) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_A:
gc.keys[0] = true;
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_D:
gc.keys[1] = true;
bre... |
002913b3-11c1-4d53-bd17-0cd90bb6e2d9 | 3 | protected synchronized Message handleMessage(Message msg) throws IOException, InterruptedException {
if (msg instanceof HelloMessage) {
hello = (HelloMessage)msg;
status = CONNECTING;
// This is kind of annoying, we have to create fields for every variable we want to present ... |
e4c78801-f0bd-4286-a193-ca8ce3238b2d | 7 | public void loadCurrentResource() {
if (Page.isApplet()) {
URL url = null;
try {
url = new URL(resourceAddress);
}
catch (MalformedURLException mue) {
mue.printStackTrace();
if (!FileUtilities.isRemote(resourceAddress)) {
try {
url = new File(resourceAddress).toURI().toURL();
}... |
4ee6d3dc-1b18-41c9-aa10-a7ac52a9d595 | 0 | public void setDccInetAddress(InetAddress dccInetAddress) {
_dccInetAddress = dccInetAddress;
} |
63dd2c1f-6512-439e-8264-4aa52e8848bf | 4 | public static void renameSkin(String filename, String newName) {
if ((newName != null) && !newName.equals("") && !filename.equals(newName)) {
Path skinPath;
if (!filename.endsWith(Constants.SKINFILE_SUFFIX)) {
skinPath = Constants.PROGRAM_SKINS_PATH.resolve(filename + Con... |
5ba8e184-679b-486e-bdd0-4b90ec6b5ee6 | 3 | public void union(int p, int q) {
if (!connected(p, q)) {
int pValue = id[p];
// replace id values same as p's into the value of q
for(int i = 0; i < this.id.length; i++) {
if (id[i] == pValue) {
id[i] = id[q];
}
}
}
} |
ffb5cbe7-d272-4387-843b-bde5abfc7fda | 0 | public static void changeFocusToTextArea(OutlinerCellRendererImpl textArea, JoeTree tree, OutlineLayoutManager layout) {
Node currentNode = textArea.node;
int index = textArea.getText().length();
tree.setCursorPosition(index);
tree.getDocument().setPreferredCaretPosition(index);
tree.setComponentFocus(O... |
d9ea4114-9094-41fb-bb50-b4fd4a4fa064 | 7 | @Override
public HandshakeState acceptHandshakeAsClient( ClientHandshake request, ServerHandshake response ) {
if( failed ) {
return HandshakeState.NOT_MATCHED;
}
try {
if( !response.getFieldValue( "Sec-WebSocket-Origin" ).equals( request.getFieldValue( "Origin" ) ) || !basicAccept( response ) ) {
ret... |
05ef01db-e815-4493-949a-908a2bcb8412 | 7 | public List<String> getUserId(int userId, int uprofile) {
String queryLISTMSISDN = "";
List<String> userIdList = new ArrayList();
if (uprofile == 3) {
queryLISTMSISDN = "select uemail from user;";
} else {
queryLISTMSISDN = "SELECT uemail from user where ownerid=... |
34a14c9e-1392-4f52-898c-15b18ac9726d | 1 | @Override
public void fireEvent(UIEvent e) {
super.fireEvent(e);
if(e instanceof KeybindEvent) {
processKeybindEvent((KeybindEvent) e);
}
} |
c6259d65-b9ca-450a-ac9a-d47dfa3b8d53 | 2 | public void draw(Graphics2D g) {
for (Particle p : particles) {
if (p.active) {
//Color color = new Color(9, 9, 9, p.life * 250);
g.setColor(p.color);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, p.life*20));
g.fillRect(p.x, p.y, 20, 20);
g.setComposite(AlphaComposite.getI... |
460edf03-55d6-48a0-888d-a260da05d728 | 0 | public BigInteger getKeyLength() {
return keyLength;
} |
f1a4badc-81a2-4b26-9c7b-68a3eda37340 | 5 | protected Element createFollowPath(List<String> path) {
if (path != null && path.size() > 0) {
Element cur = root.getRootElement();
Element next = null;
if (cur == null) {
cur = root.addElement(path.get(0));
}
for (int i=1; i<path.size(); i++) {
next = cur.element... |
a4ac199f-698d-4ec7-ab77-fda1816101fa | 3 | public String versionID( ArrayList<Group> groups )
{
StringBuilder sb = new StringBuilder();
Group g = null;
sb.append( shortName );
if ( group != 0 )
{
int index = group-1;
g = groups.get( index );
}
else
sb.insert(0,"/");
... |
0f230ce1-c1bf-4dec-bda8-a9c7887420a8 | 6 | @EventHandler
public void PlayerWaterBreathing(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.getPlayerConfig().getDouble("Player.... |
2af61aad-2555-4397-9e34-5a94f65f219a | 5 | protected void debugOutput(int topK, String filePrefix) {
File parentTopicFolder = new File(filePrefix + "parentTopicAssignment");
File childTopicFolder = new File(filePrefix + "childTopicAssignment");
if (!parentTopicFolder.exists()) {
System.out.println("creating directory" + parentTopicFolder);
parentTo... |
875795de-706c-4b32-b3b5-13d650a0049b | 0 | public boolean connected(int p, int q) {
return id[p] == id[q];
} |
d0b38157-21c7-4289-9df7-429d6368d76d | 2 | public void changePin(Pin new_pin) {
pin = new_pin;
if (pin != null) {
if (pin.seriesName == "Scrapper") {
isScrapper = true;
} else {
isScrapper = false;
}
}
fadeEffect = new FadeEffect(pin.image, 32, ... |
2b81890b-c43a-4b27-a2b8-502acfa3a60e | 3 | @Override
public void processEntity(Entity entity) {
// Get the entity's currently spatial
Spatial parentSpatialComponent = entity.getComponent(Spatial.class, true);
// Get all of the child entities and update their position relative
// to the 'parent' entity
Children childrenComponent = entity.getComponent(... |
fc272d14-ee15-4498-915a-4cc77971dc4f | 3 | private void doAction(Action actionToDo) {
try {
if (!objectTron.isFinished())
objectTron.activePlayerDoAction(actionToDo);
} catch (IllegalArgumentException | InvalidActionException e) {
System.out.println(objectTron.getActivePlayer().getPosition()
.toString());
showError(e.getClass().getSimpleNa... |
a1842bbf-7941-4a0e-b98b-d1aac62703a5 | 8 | @SuppressWarnings("unchecked")
public static void readFromFile() {
ObjectInputStream inputStream = null;
ArrayList<TaskModel> obj = new ArrayList<TaskModel>();
try {
inputStream = new ObjectInputStream(new FileInputStream("AllTask.ser"));
obj = null;
while((obj = (ArrayList<TaskModel>)inputStream.r... |
6562c9d2-ae4c-4dcc-8091-3ff90be90050 | 5 | public static void handleEvent(int eventId)
{
if(eventId == 1)
{
//TODO: referring to Main is not ideal
//System.out.println("mainMenu has focus? " + Main.mainMenu.isFocusOwner());
//Main.mainMenu.transferFocus();
//Main.mainMenu.setFocusable(false);
//Main.levelSelectorMenu.requestFocusInWindow(... |
d2bdad0b-727e-4ad4-9c1f-fab9b7f1e7b5 | 6 | public static boolean accept(Program program, TokenReader reader)
{
boolean result = false;
if (reader.lookahead(0).code() == Token.DATA_TYPE_NAME
&& reader.lookahead(1).code() == Token.IDENTIFIER
&& reader.lookahead(2).code() == Token.OPEN_PAREN)
{
... |
4f6ddcfe-b7b0-4a8e-baec-a873ab26ef9c | 0 | public void clear() {
this.rules.clear();
} |
40b17e35-a893-4511-9c49-827b4c648c6d | 1 | protected String decodePercent(String str) {
String decoded = null;
try {
decoded = URLDecoder.decode(str, "UTF8");
} catch (UnsupportedEncodingException ignored) {
}
return decoded;
} |
61cc0c33-b93a-4864-85a2-aed60aa0fff6 | 3 | public Indicator(Registry r, IndicatorManager im, int x, int y, String in, String t, Color c, boolean showLong) {
registry = r;
indicatorManager = im;
mapX = x;
mapY = y;
imageName = in;
text = t;
textColor = c;
startX = mapX;
startY = mapY;
... |
c0e325bb-33af-438f-a039-2e0c5dec2831 | 1 | public static List<Image> imageListCreator(Image... imgs) {
List<Image> images = new ArrayList<Image>();
for(Image image : imgs) {
images.add(image);
}
return images;
} |
0320f8b1-3b30-4f28-a144-9bf341e42cb2 | 1 | public void WheelDown()
{
switch(Main.Screen)
{
case "inGame":
objectPanel.wheelDown();
break;
}
} |
2b5238ec-d7a9-4387-b37c-028c08d52dd1 | 3 | public void add(Item item) {
// First check through the array
// to see if there are any free
// (null) slots
for(int i = 0; i < items.length; i++) {
if(items[i] == null) {
items[i] = item;
return;
}
}
// Otherwise, expand the array by
// 1 to accommodate the new item
// (and add the new ... |
9576a6e9-ff4c-4cbe-9123-d2af2c1c4b1c | 0 | public boolean isBlockTransition() {
return blockTransition;
} |
a5a7751e-b73d-42d7-ab31-a8335ba2bac3 | 5 | public Wave16(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 250; i++){
if(i % 5 == 0)
add(m.buildMob(MobID.SPEAROW));
else if(i % 4 == 0)
add(m.buildMob(MobID.DROWZEE));
else if(i % 3 == 0)
add(m.buildMob(MobID.PIDGEY));
else if(i % 2 == 0)
add(m.buildMob(MobID.SANDS... |
1c6d1173-8bce-4994-9916-1fe2a3838756 | 7 | public void open() {
Display display = Display.getDefault();
createContents();
serialEvent(SerialState.Disconnected);
shell.getDisplay().addFilter(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event arg0) {
if( ( (arg0.stateMask&SWT.CTRL) == SWT.CTRL) && arg0.keyCode == 'f' ... |
965f67aa-389c-4d4d-b1fa-88e8bd701ee8 | 4 | public int left(int graus) {
if (graus < 340) { //limite de elevação 270º
if (graus < 10) {
left = "!00" + graus + "L*";
System.out.println("LEFT = " + left);
arduino.enviaDados(left);
} else if (graus >= 10 && graus < 100) {
... |
d91c08e8-2b8a-49a1-809a-ce4794164e58 | 7 | private Optional<Plan> degradeConflict(Conflict conflict) {
List<List<Step>> newOrderedSteps = removeStepFromList(conflict.getStep(), orderedSteps);
int leftIndex = getStepIndex(conflict.getRelationship().getRelationship().getLeft(), newOrderedSteps).get();
int rightIndex = getStepIndex(conflic... |
ade0edd8-53f6-43dc-a845-5b46dd9ff56a | 1 | public static void main(String args[]){
try{
System.out.printf("45%2$b%4$+04d",978,654,321,111);
System.out.printf("\n %b",978);
System.out.println();
new TestException().method();
}catch(Exception e){
System.out.println("Fell down in the catch block");
}
} |
af6670f3-b1cc-4b62-8bff-645927c061a8 | 2 | @Override
public void playMonopolyCard(IPresenter presenter, ResourceType resource) {
MoveResponse response=presenter.getProxy().playMonopolyCard(presenter.getPlayerInfo().getIndex(), resource, presenter.getCookie());
if(response != null && response.isSuccessful()) {
presenter.updateServerModel(response.getG... |
df3a9813-61ed-472a-822f-05e78fce93fa | 2 | public void draw(Graphics2D g,float interpol) {
g.setFont(new Font(Font.SANS_SERIF,Font.PLAIN,textSize));
if (position == null)
initializePosition(g);
if (isButton) {
g.setColor(Color.BLACK);
g.fillRect((int)position.x, (int)position.y, (int)(dims.width), (int)(dims.height));
g.setColor(borderColor);
... |
48f2b4ea-a93d-405e-a55d-8d665e3e4375 | 8 | @Override
public void paint(Graphics g) {
Rectangle clipArea = g.getClipBounds();
if (clipArea == null) {
clipArea = getBounds();
clipArea.x = clipArea.y = 0;
}
if (clipArea.isEmpty()) {
// we are done - the picture is OK
return;
... |
47dd0556-b806-40e0-8e94-0f4693aec521 | 4 | public void newKeyEvent(KeyEvent e){
if(e.getKeyCode() == KeyEvent.VK_ENTER){
if(getStatus()){
setStatus(false);
addMsg();
}
else{
setStatus(true);
}
}
if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE){
backspace();
}
if(getStatus()){
nextChar(e.getKeyChar());
}
} |
1ebbdcc8-728c-488c-a1d9-ed0ccafd06d2 | 4 | private static void loadRecursively(File dir) {
if(dir.isDirectory()) {
for(File child : dir.listFiles()) {
loadRecursively(child);
}
} else {
if(dir.getName().endsWith(".py")) {
try {
interpreter.execfile(new FileInputStream(dir));
System.out.println("Loaded " + dir.getAbsolutePath());
... |
b9231edc-9a27-4648-b5d8-024851a62913 | 3 | public void switchHand() {
int index;
for (Hand hand : hands) {
if (hand.isActive()) {
hand.setActive(false);
index = hands.indexOf(hand);
if (index == numberOfHands() - 1) {
Hand next = hands.get(0);
ne... |
eb5cbe15-8471-48fd-ad83-0e468286cbb9 | 9 | public int exec() throws IOException {
int exitValue = 0;
List<String> argl = new ArrayList<String>();
argl.add(executable.toString());
for (Object a : args) {
if (a != null) {
if (a.getClass() == String.class) {
argl.add(a.toString());
... |
9c08fe65-d387-46db-adec-f4a3e4be8fac | 2 | @Override
public void mouseReleased(MouseEvent e) {
if(e.getButton() == 1)left = false;
if(e.getButton() == 3)right = false;
} |
0e9b873e-6e26-4a8a-8352-fedc33a02388 | 0 | public void setDescLangKey(String descLangKey) {
this.descLangKey = descLangKey;
} |
3ac4fe94-9376-4b96-9d32-1187314bd777 | 4 | public void jumpChecker(Checker marked) {
//Find piece to jump.
for (int i = 0; i < pieces.size(); i++) {
if (pieces.get(i).getX() == marked.getX() &&
pieces.get(i).getY() == marked.getY() &&
!pieces.get(i).sameColor(marked)) {
pieces.remove(i);
return;
}
}
//Board is invalid.
va... |
dafe010d-f2c8-4670-aa2e-db5a2b9070f3 | 5 | public void addLauncherToPanel(final String id) {
JButton launcher = new JButton(id, new ImageIcon(
LaunchersPanel.class.getResource(LAUNCHER_IMAGE_PATH)));
launcher.setVerticalTextPosition(SwingConstants.BOTTOM);
launcher.setHorizontalTextPosition(SwingConstants.CENTER);
launcher.setPreferredSize(new Dimens... |
df930487-04c0-406b-97d9-bb1b6371bbe6 | 9 | public void renderTopFace(Block par1Block, double par2, double par4, double par6, int par8)
{
Tessellator tessellator = Tessellator.instance;
if (overrideBlockTexture >= 0)
{
par8 = overrideBlockTexture;
}
int i = (par8 & 0xf) << 4;
int j = par8 & 0xf0;
... |
5965d106-bee9-4eed-87fd-1c5be5e541dc | 8 | public void run()
{
buffer = (BufferedImage)createImage(Consts.FRAMESIZEX,Consts.FRAMESIZEY);
while(true)
{
rita();
try
{
Thread.sleep((int)(1000/Consts.FPS));
}
catch(InterruptedException e)
{
... |
74e5f04d-184e-4762-8680-579d489ddc98 | 5 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
config = plugin.getConfig();
if (args.length == 0){
if (sender instanceof Player) {
Player player = (Player) sender;
if (commandLabel.equalsIgnoreCase("chillpill")) {
if (sender.hasPermission("darkcomma... |
4df1637a-8082-481d-b2d2-acccc5f5182e | 5 | public boolean enableBillTypesMonitor()
{
if (FLAG_ENABLE_BILL_TYPES)
{
if (this.poll(true))
{
if (this.deviceAnswerSTATE.equals("Unit Disabled")) // купюрник отключился после принятия купюры, включаем снова
{
// убиваем пот... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.