method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
13262067-093d-4c24-8b50-9acb4eb479ae | 5 | @Override
public void paintComponent(Graphics g) {
if ( image == null ) {
super.paintComponent(g);
return;
}
Dimension size = getSize();
int iw = image.getWidth();
int ih = image.getHeight();
if ( iw > size.width ) {
ih *= (double)size.width/iw;
iw = size.width;
}
if ( ih > size.heigh... |
536dcd33-d13c-439a-a93e-378fd064aaee | 2 | public static Connection getConn(){
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/struts", "root", "root");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(... |
0252098b-ce82-479f-a23d-13464ae85bc2 | 6 | static List<List<Card>> checkPairs(List<Card> cards) {
boolean skipIter;
Card temp;
List<Card> bottomSet;
List<Card> currentSet;
List<Card> topSet;
List<List<Card>> sets;
temp = cards.get(0);
skipIter = true;
bottomSet = new ArrayList<>();... |
24e6a092-22df-42ca-b47e-63746b6e67bc | 0 | public void pushMinusOperator(){
((Vector)operatorStack).add(0, new MinusOperator());
} |
2e9c1ec5-af45-46f9-8bae-359240b0026e | 8 | public static double computeThreshold(ArrayList<Double> class1, ArrayList<Double> class2)
{
double threshold = 0;
Collections.sort(class1);
Collections.sort(class2);
// Choose c1 as the most left-located class and c2 as the most right-located
ArrayList<Double> c1, c2;
if (class1.get(0) < class2.get(0)) {
... |
9be332b4-af0d-4f95-86d0-395930ef00fd | 6 | public void use(){
// use skill by type
// add effects & element
if(Game.PLAYER.reduceMana(requiredMana)){
switch(type){
case PROJECTILE: projectileAttack();
break;
case LASER: laserAttack();
break;
case IMPACT: impactAttack();
break;
case AURA: auraAttack();
break;
}
}
delta++;
... |
55318e62-befa-4391-b044-1404b2ecb874 | 5 | private void ValidateMapSize(int height, int width) {
boolean change = false;
int newwidth = Game.map.width;
int newheight = Game.map.height;
if (height >= Game.map.minsize && height <= Game.map.maxsize) {newwidth = width;change = true;}
if (width >= Game.map.minsize && width <= Game.map.maxsize) {newheight =... |
204df744-0064-4174-ad86-1ba7e5bcaa7f | 9 | public boolean isDiagonal(int p1Index, int p2Index) {
Point p1 = points.get(p1Index);
Point p2 = points.get(p2Index);
boolean result;
/*
* Neighborhood test.
*/
Point ccwNeighbor = points.get((p1Index + 1) % points.size());
Point cwNeighbor = points.get((p1Index + points.size() - 1) % points.size());
... |
e9c0cfb8-1922-4995-9910-3561fd1f12cf | 2 | public void renderElement(Graphics2D g2d)
{
if(this.Enable)
{
BufferedImage DrawTexture = new BufferedImage(Texture.getWidth(), Texture.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D ImgG2d = DrawTexture.createGraphics();
ImgG2d.rotate(Rotation, DrawTexture... |
a47cb629-da9f-42fe-97a9-2e2e53733099 | 5 | public String[] queryColumn(String table, String columnName, int n) {
String[] resultColumn = null;
try {
String stm = null;
stm = "select " + columnName + " from " + table;
con = DriverManager.getConnection(url, user, password);
pst = con.prepareStatement(stm);
rs = pst.executeQuery();
resultCol... |
3e984bbd-8d10-479c-b2eb-265e483a0b0c | 2 | private void getWordsAmountForSections () {
try {
connection = DriverManager.getConnection(Utils.DB_URL);
statement = connection.createStatement();
for (Integer id : sectionIdList) {
resultSet = statement.executeQuery("SELECT COUNT(*) AS count FROM word WHERE ... |
ab006060-b926-4672-bb57-38514fc29c73 | 3 | public boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
... |
e0c55e99-c493-4993-8df0-c2bd5a4a486e | 6 | public void run() {
if (!parent.getConfigu().getBool(
Config.Option.DisableEditDupeProtection)) {
for (@SuppressWarnings("rawtypes")
Map.Entry e : parent.map.entrySet()) {
@SuppressWarnings("rawtypes")
Iterator i = ((CBlock) e.getValue()).getBlocks();
while (i.hasNext()) {
Block b = Util
... |
0f104214-0182-470f-bb3d-589f6aee1644 | 8 | private List<Cell> neighbors(Cell [][] cells, Cell cell) {
List<Cell> neighbors = new ArrayList<Cell>();
if (cell.getxCoordinate() + 1 < Config.X_AMOUNT_CELLS
&& cells[cell.getxCoordinate() + 1][cell.getyCoordinate()].getBall() == null) {
neighbors.add(cells[cell.getxCoordinate() + 1][cell.getyCo... |
d869c2c8-6be9-494f-ad6f-e9ff4a3c8a3f | 6 | @Override
public void update() {
if (InputHandler.instance.keyIsDown(KeyEvent.VK_ESCAPE) && (StateHandler.instance.getCurrentState() == State.PLAYING) && (waitTimer.getRemaining() == 0)) {
StateHandler.instance.setCurrentState(State.IN_GAME_MENU);
showing = true;
waitTimer.reset();
} else if (InputHandler... |
9cca709a-2511-4f53-9621-3e80e21fd344 | 7 | private void readMapITP() throws Exception {
try {
FileReader fr = new FileReader(mapFilenameITP);
BufferedReader br = new BufferedReader(fr);
String str = br.readLine();
while (str != null) {
int as1;
int as2;
try {
as1 = Integer.parseInt(str.substring(0, str.indexOf("\t")));
st... |
57be0953-81dc-4417-b2c4-a9bd8f9b3e53 | 4 | public static <A> Equal<Option<A>> optionEqual(final Equal<A> ea) {
return equal(o1 -> o2 -> o1.isNone() && o2.isNone() ||
o1.isSome() && o2.isSome() && ea.f.f(o1.some()).f(o2.some()));
} |
a311208e-4160-468b-b916-2ed437ae4e69 | 5 | public void heapIncKey(int indeksi, int arvo) {
if (indeksi >= 0 && indeksi < keko.size()) {
if (arvo > keko.get(indeksi)) {
keko.set(indeksi, arvo);
}
while (indeksi > 0 && keko.get(parent(indeksi)) < arvo) {
int apuluku = keko.get(parent(inde... |
7a261610-fa3c-4ff7-ac9b-5d1021ccda89 | 2 | public static int numberOfInversionsB(List<Element> a) {
int counter = 0;
for (int i = 0; i < a.size() - 1; i++) {
if (a.get(i).getValue() > a.get(i + 1).getValue()) {
counter++;
}
}
return counter;
} |
8e60f26c-b1f3-463e-be2e-53264f9182ae | 4 | public Map<String, String> getMapOfFieldsNames() {
try {
if (verifyMappingModel()) {
logger.debug("Start searching field assignment for "
+ srcClass.getSimpleName());
Field[] srcfields = getFieldsFromSourceClass();
for (Field srcField : srcfields) {
String sourceFieldName = srcField.getName... |
47c7f285-06e7-420f-8f5e-8440870e2700 | 5 | public void ensureSkeleton() {
if (skeleton != null) return;
List<Integer> sids = new ArrayList<Integer>();
if (sid != -1) {
sids.add(sid);
}
for (Integer stsid : soundtracks.keySet()) {
if (stsid != -1) {
sids.add(stsid);
}
... |
9a93f6e3-ee93-46b0-b888-30c61800d3af | 0 | @Basic
@Column(name = "PCA_PRECIO_VENTA")
public Integer getPcaPrecioVenta() {
return pcaPrecioVenta;
} |
f0035bbb-f631-40fc-bf47-9666e9c4bac6 | 2 | public Complex getPropagationConstant(){
if(this.distributedResistance==0.0D && this.distributedConductance==0.0D){
this.generalPropagationConstant = new Complex(0.0D, this.omega * Math.sqrt(this.distributedInductance * this.distributedCapacitance));
}
else{
this.generalP... |
54061f20-e391-484d-ad3b-4e33d8e8a84a | 4 | public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Usage: java MD md-algorithm filename");
System.exit(0);
}
try {
// MessageDigest-Objekt erstellen (Algorithmus z.B. SHA-1 oder MD5)
MessageDigest md = MessageDigest... |
9c4ba5ed-22ad-47ed-8b25-374b00974609 | 2 | public boolean exists(Place searchedPlace) {
for (Place place : places) {
if (place.getNumber() == searchedPlace.getNumber()) {
return true;
}
}
return false;
} |
566d24c8-2fd9-4abb-bf15-0cecfb1d794f | 6 | public static String generateLine(String lastWord, int desiredLetterCount) {
if(lyricMap == null) {
throw new NullPointerException("You forgot to set RCLineGenerator's lyric map");
}
String result = lastWord;
while(lyricMap.hasPreviousWord(lastWord)) {
String newWord = lyricMap.getRandomPreviousWor... |
7e283f61-284f-4e57-a074-4fe757b8bfb4 | 3 | public JSONWriter object() throws JSONException {
if (this.mode == 'i') {
this.mode = 'o';
}
if (this.mode == 'o' || this.mode == 'a') {
this.append("{");
this.push(new JSONObject());
this.comma = false;
return this;
}
t... |
4efdef26-2249-457b-bc09-8dda072262c5 | 7 | public Object getData(int pos) {
if (pos == 1){
return this.data1;
}
if (pos == 2){
return this.data2;
}
if (pos == 3){
return this.data3;
}
if (pos == 4){
return this.data... |
e2630727-121a-4aca-9a63-37986addc0c5 | 4 | private static void printDiamondDetails (int indent, DeviceDescriptor info)
{
Device dev = info.getDevice ();
if (info.getProductId () != 0x0001) {
indentLine (indent, "That's not a Rio 500 ...");
return;
}
Rio500 rio = null;
try {
indentLine (indent, "Rio 500 Status: ");
indent += 2;
... |
4a58e0fc-3763-43fb-9064-cf0960bace02 | 3 | private void sendAck(COMMAND cmd, boolean success) {
try {
COMMAND msgCmd = (success ? cmd : COMMAND.BLANK);
Message msg = new Message(true, msgCmd, 1, "", new byte[1][0]);
objectToClient.writeObject(msg);
objectToClient.flush();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception... |
80b483eb-98da-40cf-b240-04bb26d18f84 | 9 | public static List<String> frequentWords(String input, int count){
HashMap<String,Integer> wordHash = new HashMap<String,Integer>(); //Stores the words with their frequency count
ArrayList<String> list[]; //Array of list of words with their frequency count as index
ArrayList<String> result = new ArrayList<String>... |
87dffd86-a0b8-442c-bca7-855bb162dd7d | 2 | private Element findFirstChildByTag(Element element, String name){
Node current = element.getFirstChild();
while(null != current){
if(name.equals(current.getNodeName()))
return (Element)current;
current = current.getNextSibling();
}
return null... |
209f7be4-c8e0-4c7e-8ef8-cbb0cea84996 | 1 | public void endMatch(Player victor) {
inProgress = false;
if (victor == null) {
System.out.println("A draw has occurred.");
} else {
System.out.println(victor.getTheme().toString()+" is victorious.");
}
cancelCurrentAction();
panel.endMatch();
board.repaint();
//TODO: Display victory on the match ... |
08820130-65da-48b6-92b9-fb13d06a311c | 7 | @Override
public boolean equals( Object b ) {
if (!(b instanceof gridArrayClass)){
return false;
}
if ( grid.length != ((gridArrayClass)b).grid.length ){
return false;
}
for (int k = 0; k < grid.length; k++ ){
if ( grid[k].length != ((gridArrayClass)b).grid[k].length ){
... |
a6814c6b-6f69-4e79-9eff-8c5575d74e65 | 0 | public void installUI(JComponent c) {
super.installUI(c);
tip = (JToolTip) c;
rendererPane = new CellRendererPane();
c.add(rendererPane);
} |
016dce4e-0dae-4820-bc9f-ea5fcdd26458 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TipoMoto other = (TipoMoto) obj;
if (this.id != other.id) {
return false;
}
i... |
5c4359b6-3b81-467d-9ad9-d91d21c92a5f | 8 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(sender instanceof ConsoleCommandSender) {
sender.sendMessage("§cThis can only be run in game!");
return true;
}
Player p = (Player) sender;
if(args.length== 0)
return false;
if(args[0].equa... |
ed8d5d98-4491-4534-96de-43903ca0c6c0 | 9 | static protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos... |
1987c5f2-c2f2-4040-826a-23b1ae77e03c | 6 | private void summariseDemand(Base base) {
shortages.removeAllItems() ;
surpluses.removeAllItems() ;
final World world = base.world ;
final Tile t = world.tileAt(0, 0) ;
for (Object o : world.presences.matchesNear(SupplyDepot.class, t, -1)) {
final SupplyDepot venue = (SupplyDepot) o ... |
704dec83-8598-4f8d-a13a-d28a2aea36c1 | 7 | private static double incbcf(double a, double b, double x) throws ArithmeticException {
double xk, pk, pkm1, pkm2, qk, qkm1, qkm2;
double k1, k2, k3, k4, k5, k6, k7, k8;
double r, t, ans, thresh;
int n;
double big = 4.503599627370496e15;
double biginv = 2.22044604925031308085e-16;
k1 = a;
k2 = a + b;
... |
fa7f5f70-6c22-405d-8600-bdbfef508fd2 | 5 | private void checkAccess(){
boolean tested=true;
if(!(gamePath.equals("") | gamePath==null)){
File f = new File(gamePath); //Check if we have read and write access
if(!f.canWrite() & !f.canRead()) {
tested=false; //if no access
con.log("Severe","Failed to write and read");
}
}
try {
FileW... |
5a529ca3-5488-4594-856a-60f529baca5f | 7 | public void copyLanguageFiles() {
File langFolder = new File(plugin.getDataFolder() + "/lang/");
if (!langFolder.exists())
langFolder.mkdirs();
try {
JarFile jarFile = new JarFile(plugin.getClass()
.getProtectionDomain().getCodeSource().getLocation()
.toURI().getPath());
for (Enumeration<JarE... |
fc98e28f-5b28-4734-9cfc-47368b95dbc4 | 8 | public boolean setCellData(String sheetName,String colName,int rowNum, String data){
try{
fis = new FileInputStream(path);
workbook = new XSSFWorkbook(fis);
if(rowNum<=0)
return false;
int index = workbook.getSheetIndex(sheetName);
int colNum=-1;
if(index==-1)
return false;
sheet = work... |
86a0eeb9-f764-4c3d-b255-78438f0d42d8 | 7 | private void drawOneColumn(Graphics2D g2d, Column column, Rectangle bounds) {
Shape oldClip = g2d.getClip();
Color divColor = getDividerColor();
int last = getLastRowToDisplay();
int y = bounds.y;
int maxY = bounds.y + bounds.height;
if (mHeaderPanel != null) {
bounds.height = mHeaderPanel.getHeight();
... |
aa31d514-2584-497e-8d4f-10df1c836d50 | 4 | public void open(Display display) {
Shell shell = new Shell(display);
shell.setText("Drag and Drop Example");
shell.setLayout(new FillLayout());
itemImage = new Image (display, DNDExample.class.getResourceAsStream("openFolder.gif"));
ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROL... |
110a6792-cd78-4cd2-8b00-dabbfe846259 | 7 | public Class<?>[] genericsTypes(Class<?> superClazz) {
Type type = getGenericSupertype(clazz, superClazz);
List<Class<?>> types = new LinkedList<Class<?>>();
if (type instanceof ParameterizedType) {
Type[] paramTypes = ((ParameterizedType) type).getActualTypeArguments();
types.addAll(evalTypesAsClasses(pa... |
12bbee0d-5983-462f-baec-c51de0ce3f41 | 7 | private static ProcessWrapper[] topologicallyOrder( ProcessWrapper[] processes ) throws ProcessException
{
while( !isTopologicallyOrdered( processes ) )
{
List<ProcessWrapper> sorted = new LinkedList<ProcessWrapper>();
sorted.add( processes[ 0 ] );
for( int i = 1; i < processes.length;... |
f65c1780-b4df-4bab-a6b0-2277cab8a859 | 9 | @Override
public void run() {
List<UIEvent> lastEvents = Model.getModel().getInteractionStack().getLastEvents(2);
if (lastEvents.get(0).getEventType() != EventType.MOUSE_BUTTON_UP
|| lastEvents.get(0).getButton() != 1
|| lastEvents.get(1).getEventType() != EventType.MOUSE_BUTTON_DOWN
|| Model.getModel(... |
5bbed149-7222-4761-b7cd-5bf81c485340 | 5 | private void show() {
if (!UIUtilities.inModalState()) {
if (mWindow != null) {
if (mWindow.isDisplayable() && mWindow.isVisible()) {
mWindow.toFront();
return;
}
}
JPanel aboutPanel = App.createAboutPanel();
if (aboutPanel != null) {
mWindow = new AppWindow(getTitle());
mWindow.... |
3e2bf8c8-c9cb-451b-a1f8-768f27685e44 | 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... |
e8272f20-2e0c-415f-ad55-b0c5c0500bad | 1 | public synchronized void keyTyped(KeyEvent e) {
if (e.getKeyChar() <= currentKeys.length) {
letter = e.getKeyChar();
}
} |
1e1bb1bc-e055-40ea-af1c-83a4cca8d68e | 9 | public static Move[] generateMoves(int nMoves) {
Move[] moves = new Move[nMoves];
for (int i = 0; i < nMoves; i++) {
Move m = new Move("Move #" + i);
moves[i] = m;
}
for (Move m0 : moves) {
for (Move m1 : moves) {
if (m0 == m1 || m0.beats(m1) || m1.beats(m0))
continue;
if (RPSGame.rand.nex... |
995d389a-863b-4865-8f19-b63278033414 | 5 | public ArrayList<Residue> calcPMOI(ArrayList<Residue> residueList) {
newResArray = new ArrayList<Residue>();
int bc = 0;
int newC = 0;
boolean nt, ct;
for (int i = 0; i < residueList.size(); ++i) {
// get relevant info for residue construction
ArrayList<Atom> atomList = residueList.get(i).getAtomList... |
9b9bc460-1955-4a3c-8653-c39491e472a6 | 8 | @Override
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset == null) {
return null;
}
if ... |
a692ca20-f6bc-462c-9531-27b6177c31b0 | 2 | public String loadHelpContents(String target) {
String contents = "";
try {
BufferedReader fin = new BufferedReader(new FileReader(("src/resources/help" + target + ".txt")));
String line;
while ((line = fin.readLine()) != null) {
contents += line + "\n";
}
} catch (IOException e) {
System.out.p... |
09778c75-0a80-42c9-a724-43cabdac5364 | 8 | protected void addFrameVetoListener() {
addVetoableChangeListener(new VetoableChangeListener() {
@Override
public void vetoableChange(PropertyChangeEvent evt)
throws PropertyVetoException {
if (evt.getPropertyName().equals(
JInternalFrame.IS_SELECTED_PROPERTY)
&& evt.getNewValue().equals(B... |
bf9ceba0-5a2d-45b5-b1fd-be08341d2d14 | 3 | @Override
public List<TroubleTicket> getTroubleTicketsByName(String callerName)
{
try
{
// Build select query
String selectQuery = "SELECT * FROM troubletickets";
if (callerName.length() > 0)
{
selectQuery += " WHERE callerName = '" + callerName + "'";
}
// Select all trouble ticket... |
39264c7f-605f-44f3-aca8-b950edb57b05 | 7 | public void run()
{
try
{
GuiConnecting.setNetClientHandler(connectingGui, new NetClientHandler(GuiConnecting.func_74256_a(connectingGui), ip, port));
if (GuiConnecting.func_74257_b(connectingGui))
{
return;
}
GuiConnectin... |
6a573583-d9f3-411e-9966-8061d3b7a8b0 | 5 | public void writeInformation(Description d, int categoryID, HUD UI) {
d.append("Is: ") ;
super.describeStatus(d) ;
d.append("\n\nCondition: ") ;
final Batch <String> healthDesc = health.conditionsDesc() ;
for (String desc : healthDesc) {
d.append("\n "+desc) ;
}
final Batch <Cond... |
93dd0e3e-8811-4764-b4a7-4348642aaf18 | 5 | public TreeMap<Integer, Integer> colorieur(TreeMap<Integer, Integer> couleur, TreeMap<Integer, TreeSet<Integer>> couleurPossible )
{
if(couleurPossible.isEmpty())
{
return couleur;
}
else
{
Entry<Integer, TreeSet<Integer>> entry = couleurPossible.firstEntry();
TreeSet<Integer> tree = entry.getValue... |
c638145a-1507-402d-823e-0ce5aa381980 | 3 | public static void main(String [] args){
System.out.println("Enter value of n:");
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
for(int i=1;i<=n;i++){
for(int j=1;j<=n+(i-1);j++)
System.out.print(" ");
for(int k=n;k>=i;k--){
System.out.print(" "+ k);
}
Sy... |
f0fbfc42-11fd-44c9-891e-10b5cab36600 | 1 | public void movePlayerXPositive(int PlayerID)
{
if(checkNoPlayerBoundsCollisionPositive(PlayerID) == true) players.get(PlayerID).moveBatPositve();
} |
81ba689b-6dd7-41a6-a867-d6989721405e | 5 | void addHistoryItem(Choice choiceHistory, String historyFile, String newItem) {
boolean alreadyInHistory = false;
try {
String line = new String();
BufferedReader history = new BufferedReader(new FileReader(historyFile));
while ((line = history.readLine()) != null) {
if (line.equals(... |
76fa87a6-ef72-45eb-a143-dc3ce1c0bb26 | 8 | @Override
public Object evaluate(ArrayList<Context1> pila) throws Exception {
System.out.println("estoy evaluando");
if (e.evaluate(pila) instanceof Double) {
valor = (Double) e.evaluate(pila);
} else {
System.out.println("In the increment the object is not double");
}
int i;
for (i = pila.size() - ... |
dc5a8456-ef84-44be-9c2e-44bc690015cd | 0 | public String getContract() {
return contract;
} |
aed1d24e-0718-42eb-91d4-544e0c0feb8b | 4 | private BufferedReader makeRequest() {
URL request;
String authtext = "";
if(!mUser.equalsIgnoreCase("") && !mPass.equalsIgnoreCase("")) // If the user provided both username and password, include them.
authtext = mUser + ":" + mPass + "@";
URL url;
try { // Check that the URL is ok and form the request... |
5cae79f4-7a1d-4319-b012-271722a3bcd0 | 5 | private DijkstraAlgorithm getPathFinder() {
List<Vertex> vertices = new ArrayList<Vertex>();
List<Edge> edges = new ArrayList<Edge>();
this.vertexArray = new Vertex[16];
for(Entry<Byte,TreeSet<Byte>> neighbour : networkTreeMap.entrySet()) {
String id = neighbour.getKey().toString();
Vertex v = new V... |
1f0f9312-2bcb-444e-9eb2-a836695d62df | 2 | public static String formatJSON(String s) {
try {
return new JSONObject(s).toString(4);
} catch (JSONException e) {
try {
return new JSONArray(s).toString(4);
} catch (JSONException e2) {
return s;
}
}
} |
29a36390-e641-4be1-8335-ae4b06107ff8 | 4 | public Location towards(Location other) {
if(x < other.x) {
return new Location(x+1, y);
} else if(x > other.x) {
return new Location(x-1, y);
} else if(y < other.y) {
return new Location(x, y+1);
} else if(y > other.y) {
return new Location(x, y-1);
} else {
return new Location(x, y);
}
} |
516bb95c-1477-4ff7-811a-91b71bb8b882 | 0 | public void setNewTranslation(String newTranslation){
this.newTranslation.setText(newTranslation);
} |
8479840a-c364-4af8-92ea-762f20d65d60 | 9 | private int readHexDigit() throws PDFParseException {
// read until we hit a non-whitespace character or the
// end of the stream
while (buf.remaining() > 0) {
int c = (int) buf.get();
// see if we found a useful character
if (!PDFFile.isWhiteSpac... |
b03f0044-6d00-4942-a286-d04c646f0b80 | 9 | private void mainFrame() throws DALException {
mf = new JFrame("Top Pharma");
mf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mf.setSize(802, 640);
if (currentUser.getmedArbId() == 0) {
JOptionPane.showMessageDialog(mf, "Velkommen Til MedCo Synthetics\n"
+ "Click ok for at logge ind", "Opstart" ... |
2b4ede18-07ee-4924-b8c8-ac1741b98d1e | 3 | public Player(int x, int y){
this.x = x;
this.y = y;
centerCamera();
baseStats.setIntelligence(15);
baseStats.setStrength(10);
baseStats.setWisdom(10);
baseStats.setVitality(12);
baseStats.setpDef(10);
baseStats.setmDef(8);
recalculateStats();
// TODO remove these testcases
// START TE... |
0b451d3a-2373-4641-a4c6-d0d6e2690585 | 2 | public Node insertChg(Node node, int value)
{
if(node==null)
return new Node(value);
else
{
if(node.right==null)
{
System.out.println("Rnull-"+node.value);
node.right = insertChg(node.right,value);
}
else
{
System.out.println("!Rnull-"+node.value);
n... |
764dede8-d13f-4a7a-b5a1-1af5e57528a2 | 9 | protected void loadInputProperties() {
if (VERBOSE)
System.out.println("Loading '" + getInputFilename() + "'...");
m_InputProperties = new Properties();
try {
File f = new File(getInputFilename());
if (getExplicitPropsFile() && f.exists())
m_InputProperties.load(new FileInputStrea... |
ce9a69a8-69a8-4978-998c-44a0c64d54e2 | 5 | public static boolean isReservedColon(String candidate) {
int START_STATE = 0;
int TERMINAL_STATE = 1;
char next;
if (candidate.length()!=1){
return false;
}
int state = START_STATE;
for (int i = 0; i < candidate.length(); i++)
... |
548e5605-3c6e-40bd-9353-4102db09be35 | 1 | public void testNullInputGivesCorrectErrorMessage() throws MalformedParenthesisException, InvalidOperandException, MalformedTokenException, MalformedDecimalException {
String badExpressionString = null;
try {
Expression badExpression = new Expression(badExpressionString);
fail("Expression not thrown!... |
a67eadf0-1ff5-4499-ad32-134c69288c12 | 7 | private static String[] safeSplit(String cmdString)
{
//This will be converted into an array and returned in the end
ArrayList<String> parts = new ArrayList<String>();
StringBuilder partBuilder = new StringBuilder();
char[] chars = cmdString.toCharArray();
boolean goingThroughVariant = false;
for(... |
8f0613d1-1537-4d27-bbe1-ea59bd26bb23 | 0 | public String toString() {
return "q_" + Integer.toString(getID()) + " at ("
+ Integer.toString(getPoint().x) + ","
+ Integer.toString(getPoint().y) + ")" + " label: "
+ getLabel();
} |
ab9fc272-e473-44ce-8d2a-620d85806b03 | 1 | private BencodeInteger getIntegerValue(String stringValue) throws InvalidFormatException {
try {
Integer result = Integer.valueOf(stringValue);
return new BencodeInteger(result);
} catch (NumberFormatException e) {
throw new InvalidFormatException();
}
} |
185d110d-2d61-47f7-aea4-734faa07d192 | 6 | public String toJSONString()
{
StringBuilder sb = new StringBuilder();
sb.append("{");
//boolean rowWithNesting = hasNestedTable();
if ( isHidden() )
sb.append("\"class\":\"hidden\"," );
//else if ( rowWithNesting )
// sb.append(" class=\"nested\"" );
... |
acddd769-093e-46c9-9738-45ab5afc1ded | 5 | public void render(GameContainer gc, StateBasedGame sbg, Graphics g){
if(!isGameOver){
if(!isPause){
//draw the bounds of the object
g.draw(boundsArea);
g.setColor(Color.orange);
g.fill(boundsArea);
for(int i = 0; i < groundTiles.size(... |
769cd07d-0788-4adc-8e45-26c41f75c0b5 | 0 | public InputManager(){
t = new Timer();
t.schedule(Base.in, 0, 1000 / 60);
} |
fefbfec9-4542-4cf7-a60b-d58fc46e7e0a | 7 | private void handleActionComplete(MqttToken token)
throws MqttException {
final String methodName = "handleActionComplete";
synchronized (token) {
// @TRACE 705=callback and notify for key={0}
log.fine(className, methodName, "705", new Object[] { token.internalTok.getKey() });
// Unblock any waiters... |
db0046f7-9c53-41cd-a7e4-57d2b2baee08 | 6 | private void removeAxisPairMetricObjects(List<Integer> currentAxisList) {
for(AxisPairMetrics am: metricsList){
int axis1 = am.getDimension1();
int axis2 = am.getDimension2();
for(int index=0; index<currentAxisList.size()-1; index++)
{
if((currentAxisList.get(index)== axis1 && currentAxisList.get(... |
8ffca40a-7268-45d6-914c-b17d5a2859d2 | 1 | private void selectionAboutToChange() {
if (mOwner != null) {
mOwner.selectionAboutToChange();
}
} |
206a0ecd-9a6e-4944-b1a1-80c92633662c | 4 | public void set(int i, int j, GameObjectModel go) {
if(i > -1 && j > -1 && i < m_height && j < m_width){
m_board[i * m_width + j] = go;
}
} |
b7c90198-3a0e-4e5e-a658-a25ac42f2b1d | 8 | private void updateBoundryCheck (T p) {
if ((p.getX () - p.r < 0 && p.v.dx < 0)
|| (p.getX () + p.r > width && p.v.dx > 0)) {
p.v.dx = -p.v.dx;
updateNextPosition (p);
}
//v = p.v;
if ((p.getY () - p.r < 0 && p.v.dy < 0)
|| (p.getY () + p.r > height && p.v.dy > 0)) {
p.v.dy = -p.v.dy;
updateN... |
8b97df9c-227b-4080-a5a5-8b5fcd51c5c1 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final ChangeOfState other = (ChangeOfState) obj;
if (listOfValues == null) {
... |
558ba464-ec98-43f0-b4dd-0ad3cede6e2b | 7 | public Symbol debug_parse()
throws java.lang.Exception
{
/* the current action code */
int act;
/* the Symbol/stack element returned by a reduce */
Symbol lhs_sym = null;
/* information about production being reduced with */
short handle_size, lhs_sym_num;
/* set up ... |
1596bbd7-5b56-4acc-9888-5525d479160d | 0 | private Battlefield() {
heroTurn = new LinkedList<BattleHeroSlots>(); // no turn at first
monsterTurn = new LinkedList<MonsterSlots>(); // no turn for monster at first
} |
370c46e6-2a64-4a50-96bc-66c8f5ccd864 | 4 | public void showAllBombs(Tile[][] tempField) {
int x, y;
for(x=0; x<10; x++) {
for(y=0; y<10; y++) {
if(tempField[x][y].checkForBomb()) {
try {
Image icon = ImageIO.read(getClass().getResource("bomb.gif"));
tempField[x][y].setIcon(new ImageIcon(icon));
} catch (IOException ex) { }
... |
10a28663-cc6f-467a-b13e-657492947f34 | 0 | public Configuration[] getInitialConfigurations(String input)
{
Configuration[] configs = new Configuration[1];
configs[0] = new MealyConfiguration(myAutomaton.getInitialState(), null, input,
input, ((MooreMachine)myAutomaton).getOutput(myAutomaton.getInitialState()));
retu... |
d8a75881-a44c-47ed-a969-c766d2de2eb6 | 8 | public int longestValidParentheses_3(String s) { // solution where indices are stored in the stack
if(s == null || s.length() == 0) return 0;
Stack<Integer> stk = new Stack<Integer>();
int res = 0;
for(int i = 0; i < s.length(); ++i){
char c = s.charAt(i);
if(c == '(') stk.push(i);
else if(c == ')'){
... |
cf116dc3-96af-4ac6-b146-c6112a17c59a | 0 | public static void main(String[] args) {
Visitor ceo = new VisitorCEO();
Visitor a = new VisitorA();
Visitor b = new VisitorB();
Element pa = new PartA();
Element pb = new PartB();
ObjectStructure os = new ObjectStructure();
os.addVisitor(pa);
os.addVisitor(pb);
os.accapt(ceo);
os.accapt(a);
os.a... |
193f28cb-5a34-4d16-a9dd-a5629b3f44d0 | 1 | public void update() {
//Log.print("Actor hp: "+characterSheet.getHP());
if (characterSheet.isDead()) {
flagDelete = true;
}
} |
2c604117-2be7-49a9-ac20-4133556ed300 | 4 | @Override
public void processEntity(Entity entity) {
Spatial spatialComponent = entity.getComponent(Spatial.class, true);
/**
* It is assumed, as everywhere (unless explicitly stated) that top left
* is 0,0. We check if either the center x location of the entity is
* within the camera's boundaries, and if... |
f0ea9ac4-c54f-4151-831e-65a7e49cb3f9 | 8 | public void setObject(Object obj) {
if(obj != null && obj instanceof BancaExaminadora){
this.banca = (BancaExaminadora)obj;
this.lblTituloValor.setText(
(banca.getDissertacao() != null ? banca.getDissertacao().getTitulo() : ""));
if(ba... |
4377b683-b666-4a1a-be1b-e53b5ade2407 | 1 | private Object toValueI(String name, int[] vals) {
Object orig = parameter.get(name);
if (orig.toString().indexOf('{') > -1) {
// this is an array (hopefully 1dim)
return Conversions.convert(vals, String.class);
} else {
return Integer.... |
66107d7a-f559-43d5-ad75-55fc84dbb684 | 4 | public static void escribirFichero(Cliente x){
float aux_cuenta_corriente=0, aux_cuenta_ahorro=0, aux_penalizacion=0;
try{
if(x.getCunetacorriente()==null){
aux_cuenta_corriente=-1;
}else{
aux_cuenta_corriente=x.getCunetacorriente().consultarSaldo();
}
if(x.getCunetaahorro()==null){
aux_cuenta_ahor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.