method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
be509018-7ccf-4b83-acd8-76044d4159c3 | 0 | public Integer getIdObservacion() {
return idObservacion;
} |
a7f9b0a9-ff10-48b8-bde0-bf86c81ee727 | 3 | public String printAST()
{
StringBuilder ret = new StringBuilder();
switch(rhs.size()){
case 1:
if(rhs.get(0) instanceof DeclList){
ret.append(((DeclList)rhs.get(0)).printAST());
}else{
ret.append(((FuncList)rhs.get(0)).printAST());
}
break;
case 2:
ret.append(((DeclList)rhs.get(0)).prin... |
5a0b2c74-ae42-49fc-8c4b-e13afacba16d | 1 | @Override
public Item next() {
if (!hasNext())
throw new java.util.NoSuchElementException();
Item x = current.item;
current = current.next;
return x;
} |
7f845fdc-bd85-4c56-95ce-64c739f31b09 | 5 | @SuppressWarnings("unchecked")
private Collection<Object[]> getParameterArrays4_3() throws Exception {
Object[][] methodCalls = new Object[][]{new Object[]{"getTestClass"}};
Class<?> cl = invokeMethodChain(this, methodCalls);
Method[] methods = cl.getMethods();
Method parametersMeth... |
36c81d65-fef4-4efa-b37b-d17942bd0b64 | 4 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
if (plugin.config.BLOCK_WATER_DESTROY_LIST.contains(event.getBlockClicked().getType())){
event.setCancelled(true);
} else if (plugin.frozenPlayers.conta... |
89f96d59-7ee1-4178-97c0-5abc8f179226 | 7 | public static String clean(String s) {
String ns = "";
for (int i=0;i<s.length();i++) {
char c = s.charAt(i);
if (c>=47&&c<=57 || c==45 || c==43 || c==42 || c==95) {
ns += c;
}
}
return ns;
} |
e1ab5126-0e9e-4f97-8a0e-5afb050c58ab | 2 | public double getDouble(String key) throws JSONException {
Object object = this.get(key);
try {
return object instanceof Number
? ((Number)object).doubleValue()
: Double.parseDouble((String)object);
} catch (Exception e) {
throw new JSONExc... |
f9755582-ee45-4b6c-98d6-193d59553773 | 1 | public String toString(){
return color ? "o":"x";
} |
807f87aa-fad0-4651-8b76-abeb0967ed33 | 9 | void updateFramebufferSize() {
// Useful shortcuts.
int fbWidth = rfb.framebufferWidth;
int fbHeight = rfb.framebufferHeight;
// Calculate scaling factor for auto scaling.
if (maxWidth > 0 && maxHeight > 0) {
int f1 = maxWidth * 100 / fbWidth;
int f2 = maxHeight * 100 / fbHeight;
scalingFactor = Ma... |
5e1e8395-d50b-4244-adf3-9509a91043b3 | 2 | @Override
public boolean equals(Object o) {
if ( !this.getClass().equals(o.getClass()) ) {
return false;
}
Key other = (Key)o;
if ( this.key == other.key ) {
return true;
} else {
return false;
... |
712c45ed-f7ad-440c-9ae8-cdde27b6f672 | 5 | public SubjectVo detail(int no) throws Throwable {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
con = dataSource.getConnection();
stmt = con.prepareStatement(
"select SNO, TITLE, DEST from SE_SUBJS"
+ " where SNO=?");
stmt.setInt(1, no);
rs = stmt.exec... |
21cad1ca-e2bf-43ff-8316-0d4f904239ff | 1 | private String getDeleteVerified( String variable ) {
StringBuilder sb = new StringBuilder();
if ( variable.equalsIgnoreCase( table.getDomName() ) ) {
sb.append( "\n" + TAB + TAB + TAB + "readRecord = " + toJavaCase( variable ) + "Dao.read( ");
sb.append( param + " );\n" );
... |
795dd548-5402-44b0-a968-dc6d4949405f | 8 | public static void main(String[] args) {
RockPaperScissors myRPSgame = new RockPaperScissors();
String choice;
boolean keepOnPlaying=false;
if(args.length==0){
keepOnPlaying=true;
System.out.println("Play a game? Choose an option:");
}
Scanner in = new Scanner(System.in);
do{
choice="";
if(ar... |
d983b4c7-6423-49ae-9f28-9a81ac6dfeb4 | 9 | private List<Mapper> estimateMappers() {
List<Mapper> newMapperList = new ArrayList<Mapper>();
if(isSplitSizeChanged || isMapperConfChanged) {
MapperEstimator mapperEstimator = new MapperEstimator(finishedConf, newConf);
//split size is changed
if(isSplitSizeChanged) {
List<Long> splitsSi... |
0d327b28-1e27-4562-bdc3-a38be6a7751b | 2 | private TreeNodePageWrapper getNodeOfPage (TreeNodePageWrapper parentNode, AbstractPage page) {
TreeNodePageWrapper childNode = null;
for (@SuppressWarnings("unchecked")
Enumeration<TreeNodePageWrapper> children = parentNode.children(); children.hasMoreElements();) {
childNode = children.nextElement();
if (... |
3eb97f53-9715-4832-8585-639516bdaa4c | 1 | private void writeComment() {
if ( comment == null ) {
sb.append( "" );
}
else
sb.append( comment );
} |
3273442c-2dfb-450d-bb06-808d86b204df | 1 | @Test
public void validateBudgetObjectAndThrowExceptionIfNull() {
try {
calculateBudgetBreakdown.calculateBreakdown(null, budgetBreakdown);
fail("Budget Object Is Null.");
} catch(Exception e) {
assertEquals("Budget is null.", e.getMessage());
}
} |
8afed8dc-da1c-4e58-81de-13f8e5176b42 | 2 | @Override
public Iterable<Key> keys()
{
LinkedList<Key> list = new LinkedList<Key>();
for (int i = 0; i < M; i++)
if (keys[i] != null)
list.add(keys[i]);
return list;
} |
5eec5044-6cce-45a1-bbdd-a1b2141627aa | 6 | @Override
public void use(Mob source, World world) {
int dir = source.dir;
Vector2i pos = Vector2d.toVector2i(source.getPos());
Vector2i targeted;
//TODO: fix this shit.
if (dir == Mob.dirUp) {
targeted = new Vector2i(pos.getX() >> 4, (pos.getY() >> 4) - 1);
... |
6834d7bf-9831-4fe9-9adc-da3496bc47dd | 3 | private static boolean deleteDirectory(File path)
{
if (path.exists())
{
File[] files = path.listFiles();
for (int i = 0; i < files.length; i++)
if (files[i].isDirectory())
deleteDirectory(files[i]);
else
... |
c274f536-98e1-41a3-9fa2-a9f2be65602a | 5 | @Override
public Buildable create(Object name, Object value) {
if (name.equals("forecast_end")) {
Date d = Conversions.convert(value, Date.class);
fc_end = new GregorianCalendar();
fc_end.setTime(d);
} else if (name.equals("forecast_days")) {
fc = (Int... |
96784bf6-b26e-440b-bef4-72315ba26877 | 8 | static int FMInitTable() {
int s, t;
double rate;
int i, j;
double pom;
/* allocate total level table plus+minus section */
TL_TABLE = new int[2 * TL_MAX];
/* make total level table */
for (t = 0; t < TL_MAX; t++) {
if (t >= PG_CUT_OFF) {
... |
a946c711-0609-463c-b589-c5928ff506f6 | 5 | public void stopOpenCmsProcess(String targetDirectory) {
// Check to see if a process is specified in the pid.txt file
this.getLogger().info(
"Checking to see if OpenCms Process is currently running");
try {
String currentlyRunningPid = this.readPidFromFile(targetDirectory);
if (!StringUtils.isEmpty(... |
7b1e1cf7-dc3b-4247-9653-86e218e04c6a | 8 | private StringBuilder constructOutputsInit()
{
StringBuilder outputsInit = new StringBuilder();
HashSet<String> outputVars = new HashSet<String>();
outputsInit.append("\t/* Initialize output variables*/\n");
for(int i = 0; i < states.length; i++)
for(int j = 0; j < states[i].length; j++)
{
S... |
222f0829-5730-424f-be12-f0dfacd883cd | 3 | public void moveMatchedFiles(){
File folderToMove = new File(folderForTheRestOfRaw);
for(String name:filesNamesFromFolderWithJPG){
if(fileAndItsNameinRawFolder.containsKey(name)){
try {
Files.move(fileAndItsNameinRawFolder.get(name).toPath(),
folderToMove.toPath().resolve(fileAndItsNameinRawFolde... |
34a66732-14f7-4208-bc56-7e21bf3d5084 | 3 | private void collectSaveables(Component component, List<Saveable> saveables) {
if (component instanceof Container) {
Container container = (Container) component;
int count = container.getComponentCount();
for (int i = 0; i < count; i++) {
collectSaveables(container.getComponent(i), saveables);
}
}
... |
3c4a374d-bbc4-4260-92c5-fac7f8e78968 | 4 | public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int score = Integer.parseInt(in.next());
if (score > 85) {
System.out.println("A");
} else if (score > 75) {
System.out.println("B");
} else if (score > 65) {
System.out.println("C");
} else if (score > 55) {
System.out.println("D"... |
4ce167c0-5575-4b9f-b552-aaa09ea14dab | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Computer))
return false;
Computer other = (Computer) obj;
if (model == null) {
if (other.model != null)
return false;
} else if (!model.equals(other.model))
ret... |
7c27ec6b-34d4-40fb-9aa3-4686e270d052 | 6 | public Texture(String fileName) {
try {
BufferedImage image = ImageIO.read(new File(TEXTURE_FOLDER + fileName));
int[] flippedPixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth());
int[] pixels = new int[flippedPixels.length];
// Flip the image vertically
for(i... |
627ff26e-f518-478d-b12d-746be272e3ab | 6 | public static int toggleDoor(){
int i, j, k;
int count = 0;
boolean s2, s;
Map<Integer, Boolean> map = new HashMap<Integer, Boolean>();
s = true;
for (k = 1; k <= 100; k++){
map.put(k, s); //save all NO. of doors and status in map
}
for (i = 2; i <= 100; i++){
for (j... |
186dbd66-f3f9-4a25-baad-942854c520d7 | 6 | public void writeCellWithComputationsToFilesForVisualization(
String fullFileName,
int maxMeas,
int minMeas,
int mcc,
int net,
int area,
long cellid,
int n,
double d,
double r) {
List<OpenCellIdCell> cells = parseCells(fullFileName, maxMeas, minMeas, r);
for(OpenCellIdCell cell : ... |
48954d67-b3e6-472e-962f-717e54f5f39e | 9 | public static double[] getOptimalParams(int day,XYSeriesCollection dataset, String fileName, int lineNumber,double[] Prices) throws FileNotFoundException, IOException
{
double[] answer=new double[2];
int testStartDay=day-20;
double tempResult=0;
for(int longPeriod=10;longPeriod<80;l... |
27d32dd1-6aa2-4fa6-a353-7d2b35f78cd8 | 4 | public static void main(String args[]) {
try {
MulticastSocket ms = new MulticastSocket();
ms.setTimeToLive(1);
InetAddress ia = InetAddress.getByName("experiment.mcast.net");
while (true) {
int ch;
String s = new String();
do {
ch = System.in.read();
if (ch != '\n') {
s = s + ... |
90867659-f21a-4b46-98b8-baa40b06d641 | 1 | @Override
public void removeClientDisconnectListener(DisconnectOnServerListener listener) {
if (clientDisconnectListenerList != null) {
clientDisconnectListenerList.remove(DisconnectOnServerListener.class, listener);
}
} |
9aba9259-e457-4f71-bb10-8a6454ffce2b | 3 | public Direction getFacing() {
return (isMoving() || isCancelingMove() || isRecoveringFromCanceledMove() ? moveDirection : facingDirection);
} |
ec10e475-4c06-49f7-a80c-50cee66dde96 | 4 | public int getXSquares() {
boolean test = false;
if (test || m_test) {
System.out.println("GameBoardGraphics :: getXSquares() BEGIN");
}
if (test || m_test) {
System.out.println("GameBoardGraphics :: getXSquares() END");
}
return X_SQUARES;
} |
deaf23e4-d510-4567-ad21-434dd6885538 | 5 | public boolean mapActionPath(Request request){
String actionPath = getActionpathListenPattern();
String regExpActionPath = actionPath;
String requestPath = request.getPath();
List<String> varNames = new ArrayList<String>();
List<String> varValue = new ArrayLis... |
b98c2131-a513-44ee-a7de-deef8cd9bb07 | 4 | public PointGame getDownNeighbor() {
int x0 = x;
int y0 = y;
while (y0 < MAXY) {
// check if x=3 and y=2, we cannot go down.
if (x0==3 && y0==2) {
break;
}
y0++;
if (Board.validPoints.contains(new PointGame(x0,y0))) {
return new PointGame(x0,y0);
}
}
return null;
} |
79bc2f1b-64b6-4563-8426-93dd6eaad71a | 6 | public void engineSetSeed(byte[] seed) {
// compute the total number of random bytes required to setup adaptee
int materialLength = 0;
materialLength += 16; // key material size
materialLength++; // index size
byte[] material = new byte[materialLength];
// use as much as possible by... |
741e13b7-854f-49ec-a15f-4e625cf6286f | 0 | public int getNumberOfImages()
{
return numberOfImages;
} |
c0ac9c2b-ab6b-4338-bfd0-93941b3d3398 | 9 | private int update() {
int n = getWritableFieldsCount();
String fields = "";
String separator = "";
Object[] valuesObj = new Object[n];
int i =0;
String clause = "";
String delimiter = "";
for(BeanTableMapping mapping: tableFields)
... |
f0f8682a-e467-4e01-821f-db248f315355 | 2 | public static boolean deleteSystem(String name) {
if(listSystems.containsKey(name)) {
System system = listSystems.get(name);
if(system.getUnits().isEmpty()) {
listSystems.remove(name);
return true;
}
... |
de12c8c8-95ca-4d98-8516-fd8f539126c5 | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
boolean success=proficienc... |
f54d7631-44f8-4f24-a277-d7c98f27c4e7 | 5 | public static boolean checkMenuKeys(String keys)
{
for(byte j=0;j<ControlKeys.getKeys();++j)
{
if((keys.charAt(j) == '1' && !ControlKeys.isKeyPressed(j)) || (keys.charAt(j) == '0' && ControlKeys.isKeyPressed(j)))
return false;
}
return true;
} |
4eee4958-4115-4642-95c5-2c62c665f866 | 3 | public void push(int action, IIntervalsTimeDomain domain) {
switch (action) {
case ADD:
actionStack.add(new AddAction(domain));
break;
case REMOVE:
actionStack.add(new RemoveAction(domain));
break;
case MASK:
... |
1fe83132-74f0-43aa-a925-3cc4ece9d5d6 | 4 | private static String replace(String original, String find, String replace) {
if (original == null) return original;
if (find == null) return original;
if (replace == null) replace = "";
int found = original.indexOf(find);
while (found != -1) {
original = original... |
8080b00f-8636-444c-8d9b-7cde0683c292 | 6 | @Override
public boolean equals( Object other )
{
if ( other instanceof Table )
{
Table t = (Table)other;
if ( t.versions.equals(versions)&&t.rows.size()==rows.size() )
{
for ( int i=0;i<rows.size();i++ )
{
R... |
8da074a2-50f7-4ca1-8c6c-ca9ba755ce48 | 8 | @Override
public void actionPerformed(ActionEvent e) {
JMenuItem it = (JMenuItem) e.getSource();
if (it.getText().equals("Quitter")) {
System.exit(0);
} else {
if (it.getText().equals("Pause") && _players != null) {
for (int i = 0; i < _players.length;... |
081a7e0e-a328-4c26-9073-6d69e5391d3c | 6 | private void move(int x, int y) {
if(!selected) {
selectedColumn += x;
selectedRow += y;
selectedColumn = getColumnPosition(selectedColumn);
Column column = getColumn(selectedColumn);
selectedRow = column.getRowPosition(selectedRow);
} else {
Column column = getColumn(selectedColumn);
if(co... |
be9c0d02-94a9-485c-a2bf-acc8d88d16e9 | 8 | @Override
/**
* When attribute changed we need to change our LSDB and neighborList and
* and send to everyone a new LSP to keep them up to date.
*/
public void attrChanged(Interface iface, String attr) {
if (attr.equals("metric")) {
for (Entry<IPAddress, LinkState> ls : neighb... |
237431ff-e861-4611-9470-e809a9a6b376 | 1 | public void cycle(long n) {
for (long i = 1; i <= n; i++){
result = result * i;
}
System.out.println(result);
//return result;
} |
f34c090b-65f3-4f83-b5c8-2f111fcbdf0d | 8 | public static boolean createTradingStrategy(String name, String username,
ArrayList<String> ruleList) {
initialise();
UserAccount user = UserAccountController.returnAccount(username);
// Check rules are all valid
boolean validStrategy = validStrategy(name, ruleList);
// Check ts name is unique
boolea... |
8f9b6aff-ac57-4f6d-9e7d-0e36590b35e2 | 6 | public PongWindow() {
super();
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception ex) {
ex.printStackTrace();
}
this.width = 800;
this.height = 600;
if (ISMAXIMIZED) {
Dimension ... |
bb842b08-22f6-4c09-a323-21321222e03b | 2 | private static int biggestLength(ArrayList<String> string) {
int biggerLength = string.get(0).length();
for(int i = 1; i < string.size(); i++) {
if(string.get(i).length() > biggerLength) {
biggerLength = string.get(i).length();
}
}
return biggerLength;
} |
8e0471eb-59e3-4a18-8029-9e93090dba53 | 3 | private boolean isPositionOutOfFrame(LifePosition lifePosition) {
return lifePosition.getPosition()[0] < 0 || lifePosition.getPosition()[1] < 0
|| lifePosition.getPosition()[0] >(frame.height()-1) || lifePosition.getPosition()[1] > (frame.width()-1);
} |
2fa69bd8-b1b5-4490-b10a-1166de57cf1f | 1 | public int hashCode() {
return (username != null ? username.hashCode() : 0);
} |
12120af5-17db-4d3d-8629-edd4085aed98 | 6 | @Override
public void run()
{
while (this.active)
{
try
{
if (players.isEmpty())
{
Thread.sleep(50L);
}
else
{
MapObjectPlayer p = players.pop();
... |
fc89c0b9-9e61-4bad-a047-109ae2a7c221 | 9 | public Object execute(List<Object> args) {
if (args.isEmpty()) {
throw new IllegalStateException("at least one argument expected in function EQUALS");
}
else if (args.size() == 1) {
return true;
}
else {
Object prev = args.get(0);
... |
19d6e10d-bb73-48ee-b124-82734f2a5976 | 5 | @Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (!(obj instanceof Version))
{
return false;
}
Versi... |
20025e89-bef4-4a7e-a095-be11311afc88 | 5 | public CheckResultMessage check16(int day) {
int r1 = get(33, 5);
int c1 = get(34, 5);
int r2 = get(36, 5);
int c2 = get(37, 5);
BigDecimal b = new BigDecimal(0);
if (checkVersion(file).equals("2003")) {
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
b = getValue(r2 +... |
5bdf3101-4d33-45b4-9cf1-6b9ce0b8ac09 | 8 | public static void DoTurn(PlanetWars pw) {
// long endingTime = System.currentTimeMillis() + 5;
int testIndex = 0;
Planet source = null;
Planet dest = null;
MyNode root = new MyNode(new SimulatedPlanetWars(pw));
ArrayList<MyNode> beam = new ArrayList<MyNode>(3);
beam.add(root);
// for (MyNode node : r... |
39efce97-7d8e-4cfd-848d-026e2844af8b | 9 | @Override
public void run() {
//Thread.setPriority(4);
try {
BufferedReader in = new BufferedReader( new InputStreamReader( client.getInputStream() ));
String message = "";
while (message != null) {
message = in.readLine().trim();
//first we check for known commands, if nothing ma... |
cd0c149e-348e-45f3-9e2b-7fdcb4b65b0e | 5 | private int ret10BitCode (int in,boolean errorBitsAllowed) {
int a,b,dif,errorMax;
// Make copy of what is going into the error corrector
unCorrectedInput=in;
if (errorBitsAllowed==true) errorMax=1;
else errorMax=0;
for (a=0;a<VALIDWORDS.length;a++){
dif=0;
for (b=0;b<BITVALUES.length;b++) {
if ((... |
21985138-b59d-4eea-ba0c-2458bd14a307 | 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 SpringLayo... |
036b951c-19b9-4515-8734-50520f8df3be | 0 | protected void setI(int i)
{
tempI = i;
} |
4ddbc10a-ca13-46b6-9edc-1b269259e10a | 9 | public void testSimpleToken() throws Exception {
XmlPullParser xpp = factory.newPullParser();
assertEquals(true, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES));
// check setInput semantics
assertEquals(XmlPullParser.START_DOCUMENT, xpp.getEventType());
try {
... |
1dd9f107-6b40-4bb0-8ac5-1733914c25b5 | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final People other = (People) obj;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {... |
99c033bc-51da-4bb9-9ab8-9c8ba315a738 | 7 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// Retrieving the form POST data
//int account_number = Integer.parseInt(request.getParameter("account_number"));
//int total_purchaseCost= Integer.pars... |
82694714-d058-4f96-a59f-f03918d00761 | 2 | public void endOfTime() {
Iterator it = timeOut.keySet().iterator();
while(it.hasNext()) {
String nick = (String) it.next();
if(this.getDiffDate(nick) / 1000 >= timeToDeco) {
this.connectHandler.disconnect(nick);
timeOut.remove(nick);
}... |
08047f58-0d09-4a54-930c-4b2fb3b71d73 | 9 | private static DataSet[][][] aggregateTraces(String[] nodeClasses,
String[] approaches, String[] metrics) {
DataSet[][][] allData = new DataSet[nodeClasses.length][approaches.length][metrics.length];
for(int i = 0; i < nodeClasses.length; i++) {
// VirtuaTraces
... |
896c013e-d2d5-4775-9eda-c1ae968a32e0 | 4 | public static void arc(double x, double y, double r, double angle1, double angle2) {
if (r < 0) throw new RuntimeException("arc radius can't be negative");
while (angle2 < angle1) angle2 += 360;
double xs = scaleX(x);
double ys = scaleY(y);
double ws = factorX(2*r);
doubl... |
21a30859-d35a-4614-a1ee-2c185d046daf | 8 | private void process () {
IndexFile ixfl = null;
try {
File srcf = new File(srcPath);
if (!srcf.exists()) {
System.out.println ("File " + srcPath + " does not exist.");
return;
}
else if (srcf.isDirectory()) {
... |
c31f8adf-85ed-4003-9bfd-5ae6e945447d | 1 | private static final void loadImage(InputStream in, int length, String name, List<StdImage> images) throws IOException {
byte[] data = new byte[length];
StreamUtils.readFully(in, data);
StdImage img = StdImage.loadImage(data);
if (img != null) {
track(name, img);
images.add(img);
}
} |
1edb890a-a0b1-4d6c-9179-a673d793d27c | 4 | public boolean commit() throws LoginException {
if (succeeded == false) {
return false;
} else {
// add a Principal (authenticated identity)
// to the Subject
// assume the user we authenticated is the SamplePrincipal
userPrincipal = new SamplePrincipal(username);
if (!subject.getPrincipals().con... |
83f640cf-866b-4517-b9ea-d134573aeebf | 7 | public void writeWorld()
{
voted = false;
try {
// System.out.println("World sent s");
ByteBuffer toSend = ByteBuffer.allocate(9600004);
//out.write(Server.ENTIREWORLD);
//out.flush();
toSend.putInt(handle.earth.ground.w);
toSend... |
15e4a74e-b285-420f-8d82-89bede09d677 | 4 | public void startRun(int numSteps)
{
if (numSteps == 0)
{
this.numSteps = 1;
infinite = true;
}
else
{
this.numSteps += numSteps;
}
try{
if (!threadRun && Thread.currentThread().isAlive())
{
new Thread(this).start();
}
}
... |
1a2079f1-f1e8-4429-9a89-f1458d1c5548 | 4 | public boolean checkProjectileToShipCollisions(Projectile p, Ship s){
if(p.getPos().getX()>(s.getPos().getX()-(s.getSize().getWidth()/2)))
if(p.getPos().getX()<(s.getPos().getX()+(s.getSize().getWidth()/2)))
if(p.getPos().getY()>(s.getPos().getY()-(s.getSize().getHeight()/2)))
if(p.getP... |
97eeee45-adfa-4848-b164-2492902d137a | 1 | public static synchronized ResponseParserFactory getInstance() {
if (instance == null) {
instance = new ResponseParserFactory();
}
return instance;
} |
90fcbcc5-23e9-4955-b86e-5b4eae623187 | 4 | public void fillDeclarables(Collection used) {
if (usedAnalyzers != null)
used.addAll(usedAnalyzers);
if (innerAnalyzers != null) {
Enumeration enum_ = innerAnalyzers.elements();
while (enum_.hasMoreElements()) {
ClassAnalyzer classAna = (ClassAnalyzer) enum_.nextElement();
if (classAna.getParent()... |
28d6b278-735a-44c4-b19d-b00b2538bd7b | 6 | private double medianOfFive(ArrayList<double[]> puntos, int axis, int start){
if(puntos.get(start)[axis]>puntos.get(start+1)[axis])
swap(puntos, start,start+1);
if(puntos.get(start+2)[axis]>puntos.get(start+3)[axis])
swap(puntos,start+2,start+3);
//dejar en indice 0 el menor de los 4 (no es mediana)
... |
52f4b39a-2504-4611-bcee-a2ab5e1f285b | 6 | public String performSubtraction(String tal1, String tal2)
{
StringBuilder sBuilder = new StringBuilder();
int lenght = tal1.length();
tal2 = matchLenght(lenght, tal2);
int carry = 0;
int i = 0;
if(tal2.length() > lenght)
{
lenght = tal2.length();
tal1 = matchLenght(lenght, tal1);
}
// Rever... |
e3ff8176-68d4-40b4-aea7-78701259c46f | 8 | private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
... |
14c50a72-8607-423e-b812-174f44a54199 | 4 | public double calcBuildingArea(double length, double width) {
if (length < 7 || length > 20) { // length value not within the accepted range?
return 0;
}
if (width < 5 || width > 15) { // width value not within the accepted range?
return 0;
}
double ar... |
ceafdbc1-d042-4cae-bae3-526f94106c3e | 4 | private void initDirNames(File cfgFile) {
GenericObject cfg = EUGFileIO.load(cfgFile);
String mainDir = "";
String modDir = "";
if (cfg != null) {
mainDir = cfg.getString("maindir");
modDir = cfg.getString("moddir");
}
if(mainDir.equals("")) {
... |
22574971-ef18-410a-8534-0089de2043d7 | 7 | public Move findbest(Game g) throws GameException {
try {
boolean max;
int bestVal;
// if first player, then find the max value
// otherwise find the min value
if (g.whoseTurn() == Game.FIRST_PLAYER) {
max = true;
bestVal = Integer.MIN_VALUE; // running max, starts at bottom
} else {
ma... |
32890c4e-4783-46ab-b6c9-d112f226a361 | 8 | @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==this.b1)//write
{
l=new ArrayList<Exp>();
TextIO te=new TextIO();
te.readFile();
t1.setText(te.text);
for( String x : te.stringToArray()){
Exp ex=new Exp(x);
l.add(ex);
}
}
if(e.getSource()==this.b5)... |
5bf726fd-7ea0-4478-a7a2-cae449ffe5e4 | 6 | public void train(List<DataEntry<double[], Integer>> data_set){
int m = data_set.size();
for(DataEntry<double[], Integer> entry:data_set){
phi[entry.label] += 1;
for(int i=0;i<N;i++){
mean[entry.label][i] += entry.data_vec[i];
}
}
for(int i=0;i<K;i++){
for(int j=0;j<N;j++){
mean[i][j] /= phi... |
bfe3f38f-df51-489d-a876-7c3f64352099 | 6 | private void knightTopRightPossibleMove(Piece piece, Position position)
{
int x1 = position.getPositionX();
int y1 = position.getPositionY();
if((x1 >= 0 && y1 >= 0) && (x1 <= 5 && y1 <= 6))
{
if(board.getChessBoardSquare(x1+2, y1+1).getPiece().getPieceType() != board.getBlankPiece().getPieceType())
{... |
708159a3-adc0-459b-9d70-6383d90c2521 | 8 | public boolean wearingHeldMetal(Environmental affected)
{
if(affected instanceof MOB)
{
final MOB M=(MOB)affected;
for(int i=0;i<M.numItems();i++)
{
final Item I=M.getItem(i);
if((I!=null)
&&(I.container()==null)
&&(CMLib.flags().isMetal(I))
&&(!I.amWearingAt(Wearable.IN_INVENTORY))
... |
8231b63d-76a9-4b2e-bc66-321475ad3bd9 | 3 | public String getResult_HTML(){
if(endtime==null) evaluateBenchmark();
String s ="";
//if(totaltime==0) return "0ms ???";
if(sections.size()==0) return "keine sections angegeben";
else {
s="<html><table style='width:330px;' cellspacing='2' cellpadding='0'><tr><th>section name</th><th>ms</th><th>%</th>... |
83a17332-3eef-46ee-8677-47647062689c | 5 | public void setMerges(Merge merge, MapperCounters counters) {
long inputRecsInPreviousMerges = 0;
long outputRecsInPreviousMerges = 0;
List<MergeInfo> list = merge.getMergeInfoList();
MergeInfo info = null;
for(int i = 0; i < list.size(); i++) {
info = list.get(i);
merges.add(new MergeAction(info));
... |
2fa2e787-4d29-48d4-82f6-6ec4790744aa | 8 | public static String getLongestCommonSubsequence(String str1, String str2)
{
int[][] sol = new int[str1.length()+1][str2.length()+1];
int max = -1;
for(int i = 1; i < str1.length() + 1; i++)
{
for(int j = 1; j < str2.length() + 1; j++)
{
if(str1.charAt(i-1) == str2.charAt(j-1))
{
sol[i][j] =... |
bed430a0-f5b3-4ef1-836d-cab49e284f9a | 1 | public Pie getPie() {
if (pb.isBaked()) {
return pb.getPie();
} else {
BuilderClient.addOutput("error - your pie is not ready yet");
return null;
}
} |
35a7dd78-5db7-445b-91a6-4a5acb4de5bd | 4 | @Override
protected void handleMessage(String message) {
String[] parsed = message.split(":");
if(parsed[0].equals("collision")) {
if(parsed[1].equals(Projectile.ENT_NAME)) {
if(parsed[2].equals("no")) {
this.health--;
SpaceInvaders... |
a868b1d6-33b6-4eac-ab03-7be52f66fbf4 | 6 | private void setupCloseBehaviour(final Stage primaryStage) {
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
if (StateMachine.isSongModified()
|| StateMachine.isArrModified()) {
... |
a44b2e28-5fb5-410d-a378-484577341651 | 0 | public String getDate_depreciated_by() {
return date_depreciated_by;
} |
cc53afb8-28fc-48e5-8aaf-4896d149c34e | 4 | public ArrayList<String> getModuletitles() {
try{
openDatabase();
}catch(Exception e){}
String query = "SELECT name FROM t8005t2 .modules";
ArrayList<String> modules = new ArrayList<String>();
try {
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) ... |
8b6161b6-f440-4742-9a13-8b7b8a697776 | 9 | @Test
public void testUpdateEditorsPick() {
Integer testISBN = 800;
Set<StockBook> books = new HashSet<StockBook>();
books.add(new ImmutableStockBook(testISBN, "Book Name", "Book Author",
(float) 100, 1, 0, 0, 0, false));
try {
storeManager.addBooks(books);
} catch (BookStoreException e) {
e.print... |
77ef5189-fb17-4a95-a0be-c00f6bccf7e8 | 2 | private void initReportWriter() {
// Create an output factory
final XMLOutputFactory xmlof = XMLOutputFactory.newInstance();
// Create an XML stream writer
final File reportFile = new File(getOutputDirectory(), "report.xml");
try {
reportWriter = xmlof.createXMLStreamWriter(new FileWriter(reportFile));
... |
6052d5c1-231f-49e9-8279-6bf941a451a3 | 7 | public boolean sameStops(RoutePath b) {
boolean same = true;
ListIterator aLi = mStops.listIterator();
ListIterator bLi = b.getStops().listIterator();
while (aLi.hasNext() && bLi.hasNext()) {
Stop aS = (Stop) aLi.next();
Stop bS = (Stop) bLi.next();
System.out.println(aS.getID() + " -> " + bS.getID()... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.